Lines 8-48javascript
9 * #915: Format the classifier-reason block for injection into both
10 * `appendEvidenceBlock` and `renderFailureAlert`. Returns an empty array when
11 * `reason` is absent or empty. Single-line reasons render inline as one line
12 * (`**Reason**: <safeReason>`); multi-line reasons render as `**Reason**:`,
13 * blank line, fenced ```text``` block. Backticks are ZWSP-escaped (matching
14 * the outputTail idiom). Multi-line body is capped at 1 KiB by
15 * `Buffer.byteLength`; on truncation, `…` is appended before the closing fence.
17 * The returned lines are inserted between the header lines (`**Exit**` for
18 * stage comment, summary line for failure alert) and the blank line preceding
19 * the `<details>` wrapper — both callers already emit that blank. See
20 * contracts/failure-reason-block.md §Rendering normalization.
22function formatReasonBlock(reason) {
26 // ZWSP after every backtick — mirror the outputTail sanitization idiom
27 // already used at appendEvidenceBlock (~:200) and renderFailureAlert (~:334).
28 const safeReason = reason.replace(/`/g, '`');
CriticalTrojan Source Unicode
Source contains bidi control or invisible Unicode characters associated with Trojan Source attacks.
dist/worker/stage-comment-manager.jsView on unpkg · L28 29 const isMultiLine = safeReason.includes('\n');
31 return [`**Reason**: ${safeReason}`];
33 // Multi-line: cap body at 1 KiB (bytes) with a `…` marker on truncate.
34 const bytes = Buffer.byteLength(safeReason, 'utf8');
35 if (bytes > REASON_MULTILINE_BYTE_CAP) {
36 const buf = Buffer.from(safeReason, 'utf8');
37 const sliced = buf.subarray(0, REASON_MULTILINE_BYTE_CAP).toString('utf8');
38 return ['**Reason**:', '', '```text', sliced, '…', '```'];
40 return ['**Reason**:', '', '```text', safeReason, '```'];
43 * Stage display titles with emoji prefixes
46 specification: '\u{1F4CB} Specification',
47 planning: '\u{1F4D0} Planning',
48 implementation: '\u{1F528} Implementation',