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>
This commit is contained in:
garrytanandcapy-ai[bot] committed 2026-11-02 18:01:24 +00:00
1 parent b02b4f34c4
commit 523de7d435
4 files changed
+24 -11

No files matched your search

@@ -2,7 +2,7 @@
### Fixed ### 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`:** 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 ### 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.
+3 -2
View File
@@ -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 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 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 ("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 put a count you mean as a claim outside the fence. A line like ```` ```npm test``` ran ````
stays prose. Data PRs (evals, 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. measurements, sweeps) run it before READY so the body's numbers are the run's.
<a id="review-scope"></a> <a id="review-scope"></a>
+11 -7
View File
@@ -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 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 * (`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 only on a run of its own character at least as long as the opener with nothing after it). A backtick run with
* closes stays prose, so an unclosed opener cannot hide the claims after it. A marker line takes each fence's place so * another backtick later on its line (```npm test``` inline code) opens no fence, as in CommonMark. A fence that never
* the text on either side never joins into a claim. * 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 { function withoutFences(body: string): string {
const lines = body.split(/(?<=\n)/); const lines = body.split(/(?<=\n)/);
const out: string[] = []; const out: string[] = [];
for (let i = 0; i < lines.length; i++) { for (let i = 0; i < lines.length; i++) {
const open = FENCE_OPEN.exec(lines[i]!.replace(/\r?\n$/, '')); const line = lines[i]!.replace(/\r?\n$/, '');
const close = open ? fenceClose(open[1]!) : undefined; const open = FENCE_OPEN.exec(line);
const end = close ? lines.findIndex((l, j) => j > i && close.test(l.replace(/\r?\n$/, ''))) : -1; if (!open || (open[1]![0] === '`' && line.slice(open[0].length).includes('`'))) { out.push(lines[i]!); continue; }
if (end < 0) { 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'); out.push('(code fence)\n');
i = end; i = end;
} }
+8
View File
@@ -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, '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: [] }); 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', () => { describe('gstack-ship-receipt read --check-prose', () => {