From 523de7d435b184a2ca9c2e627b8ed2a6baf35874 Mon Sep 17 00:00:00 2001 From: garrytan Date: Mon, 2 Nov 2026 18:01:24 +0000 Subject: [PATCH] fix(receipt): inline triple backticks open no fence, and nothing after an unclosed fence is skipped (GST-984 review) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- .../gst-983-984-prose-exception-fences.md | 4 ++-- docs/ship-policy.md | 5 +++-- lib/ship-receipt-prose.ts | 18 +++++++++++------- test/ship-receipt-prose.test.ts | 8 ++++++++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/changelog.d/gst-983-984-prose-exception-fences.md b/changelog.d/gst-983-984-prose-exception-fences.md index b82b80289..6e4e2dbfa 100644 --- a/changelog.d/gst-983-984-prose-exception-fences.md +++ b/changelog.d/gst-983-984-prose-exception-fences.md @@ -2,7 +2,7 @@ ### Fixed - **`lib/ship-receipt-prose.ts`:** the line that matches the receipt's own docs exception exactly is skipped, like the Review-loop exception line. The same words anywhere else, or a line for a different exception, are still checked. -- **`lib/ship-receipt-prose.ts`:** a closed code fence (backticks or tildes, closed by a run of its own character at least as long as the opener) is skipped. Counts outside the fence are still checked, and a fence that never closes stays prose, so an unclosed opener cannot hide the claims after it. +- **`lib/ship-receipt-prose.ts`:** a closed code fence (backticks or tildes, closed by a run of its own character at least as long as the opener) is skipped. Counts outside the fence are still checked. A line that starts with inline code like ```` ```npm test``` ```` opens no fence, and a fence that never closes stays prose along with the rest of the body, so an unclosed opener cannot hide the claims after it. ### Tests -- `test/ship-receipt-prose.test.ts`: the docs exception line passes `--check-prose` beside a matching `70 skip` claim; the #142 fenced evidence passes while a wrong count outside the fence still fails; an unclosed fence stays prose. On main all three cases failed. +- `test/ship-receipt-prose.test.ts`: the docs exception line passes `--check-prose` beside a matching `70 skip` claim; the #142 fenced evidence passes while a wrong count outside the fence still fails; an unclosed fence stays prose; inline triple backticks and a shorter fence inside an unclosed one hide no claim. On main the first three cases failed. diff --git a/docs/ship-policy.md b/docs/ship-policy.md index 00d638cab..adabb6867 100644 --- a/docs/ship-policy.md +++ b/docs/ship-policy.md @@ -1234,8 +1234,9 @@ and 2 skip detector" is not a `2 skip` claim. Only a line that matches the rendered line exactly is skipped; the same words inside a longer line are still checked. A closed code fence is skipped too (GST-984): pasted test output ("113 pass, 0 fail") and quoted code are evidence, not this PR's counters, so -put a count you mean as a claim outside the fence. A fence that never closes -stays prose. Data PRs (evals, +put a count you mean as a claim outside the fence. A line like ```` ```npm test``` ran ```` +opens no fence, and a fence that never closes stays prose, along with the rest +of the body. Data PRs (evals, measurements, sweeps) run it before READY so the body's numbers are the run's. diff --git a/lib/ship-receipt-prose.ts b/lib/ship-receipt-prose.ts index f0acc6ba9..ddf53c4b2 100644 --- a/lib/ship-receipt-prose.ts +++ b/lib/ship-receipt-prose.ts @@ -35,18 +35,22 @@ const fenceClose = (fence: string) => new RegExp(`^ {0,3}${fence[0] === '`' ? '` /** * The body without its closed code fences (GST-984): pasted test output (`113 pass, 0 fail`) and quoted code * (`the first 35 failing`) are evidence, not this PR's counters. The fence rules are withoutApprovalsBlocks' (a fence - * closes only on a run of its own character at least as long as the opener with nothing after it). A fence that never - * closes stays prose, so an unclosed opener cannot hide the claims after it. A marker line takes each fence's place so - * the text on either side never joins into a claim. + * closes only on a run of its own character at least as long as the opener with nothing after it). A backtick run with + * another backtick later on its line (```npm test``` inline code) opens no fence, as in CommonMark. A fence that never + * closes stays prose, and so does the rest of the body, so an unclosed opener cannot hide the claims after it or let a + * shorter fence inside it hide them. A marker line takes each fence's place so the text on either side never joins + * into a claim. */ function withoutFences(body: string): string { const lines = body.split(/(?<=\n)/); const out: string[] = []; for (let i = 0; i < lines.length; i++) { - const open = FENCE_OPEN.exec(lines[i]!.replace(/\r?\n$/, '')); - const close = open ? fenceClose(open[1]!) : undefined; - const end = close ? lines.findIndex((l, j) => j > i && close.test(l.replace(/\r?\n$/, ''))) : -1; - if (end < 0) { out.push(lines[i]!); continue; } + const line = lines[i]!.replace(/\r?\n$/, ''); + const open = FENCE_OPEN.exec(line); + if (!open || (open[1]![0] === '`' && line.slice(open[0].length).includes('`'))) { out.push(lines[i]!); continue; } + const close = fenceClose(open[1]!); + const end = lines.findIndex((l, j) => j > i && close.test(l.replace(/\r?\n$/, ''))); + if (end < 0) return out.join('') + lines.slice(i).join(''); out.push('(code fence)\n'); i = end; } diff --git a/test/ship-receipt-prose.test.ts b/test/ship-receipt-prose.test.ts index e9235a15b..f088ead4b 100644 --- a/test/ship-receipt-prose.test.ts +++ b/test/ship-receipt-prose.test.ts @@ -183,6 +183,14 @@ describe('code fences are not prose (GST-984, gstack-evals #142)', () => { expect(checkReceiptProse(lanes, 'Intro\n```text\n113 pass\n').mismatches).toEqual([{ field: 'gate.unit.pass', prose: 113, receipt: 1181 }]); expect(checkReceiptProse(lanes, 'Shipped 3\n```\nx\n```\npass rates are below.\n')).toEqual({ checked: 0, mismatches: [] }); }); + + // Value: protects=a line that only looks like a fence opener, or a shorter fence inside an unclosed one, cannot hide a + // claim GitHub shows as prose; fails_when=either shape skips the "113 pass" after it; seam=lib/ship-receipt-prose.ts checkReceiptProse + test('inline triple backticks open no fence, and nothing after an unclosed fence is skipped', () => { + const wrong = [{ field: 'gate.unit.pass', prose: 113, receipt: 1181 }]; + expect(checkReceiptProse(lanes, '```npm test``` ran.\nUnit: 113 pass.\n\n```text\nlog\n```\n').mismatches).toEqual(wrong); + expect(checkReceiptProse(lanes, '````\n```\nUnit: 113 pass.\n```\n').mismatches).toEqual(wrong); + }); }); describe('gstack-ship-receipt read --check-prose', () => {