From 1ea9e6bf925011031d54b4533b025c33c2bfdd1e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 17:08:56 +0000 Subject: [PATCH 1/2] fix(pm): the contract-review record reader closes the last review's four nits A grade-carrying finding reads closed only when the state word ends the finding: no sentence after a closed bold title, and no body or wrapped title on the next line. FAIL now reads in a header row's verdict column, after an arrow or a struck word, with `was`, `is:` or an unspaced dash, after a mark in a cell, with key and value in one cell, and in any case in a heading tail. The fail-safe idiom (`fail-closed`, `fails closed`, `PASS, prior FAIL closed`) and a bare FAILED line no longer read FAIL. Claude-Session: https://claude.ai/code/session_01ADHkmQopcLwxooyvT2Kxvu Co-authored-by: Claude --- scripts/pm/check-governed-queue-guard.mjs | 7 +- scripts/pm/check-half-states.mjs | 107 +++++++++++++++++----- 2 files changed, 90 insertions(+), 24 deletions(-) diff --git a/scripts/pm/check-governed-queue-guard.mjs b/scripts/pm/check-governed-queue-guard.mjs index 15cc1be86f6..7bf5159664b 100644 --- a/scripts/pm/check-governed-queue-guard.mjs +++ b/scripts/pm/check-governed-queue-guard.mjs @@ -5651,8 +5651,11 @@ export async function selfTest() { // ⛔ S1 of review 6892305129: the state word must END the finding — a title that opens with `closed` or `none` names an OPEN finding. const titledOpen = await Promise.all(['S1 (should-fix): closed in part, still open for X', '- **S1 (should-fix) — closed in part; the table cell still clears.**', '**S2 (should-fix) — Closed PRs are still read as merged by the audit.**', '- **S2 (should-fix) — none of the three ablations ran on the committed head.**', 'S1 (should-fix) — closed on the prior head, reopened by this delta', '- should-fix: none of S1, S2 is fixed'].map((line) => graded([line]))); assert('⛔ #33604-r3-a-finding-whose-TITLE-opens-with-closed-or-none-stays-OPEN-and-REFUSES', titledOpen.every((r) => r.exitCode === EXIT_REFUSED_UNAPPROVED && /names 1 open must-fix\/should-fix finding/.test(renderGuardVerdict(r))), titledOpen.map((r) => r.entries[0].record.verdictReason ?? 'CLEARED').join(' | ')); - const stateEnds = await Promise.all(['S1 (should-fix): closed here.', '- **S1 (should-fix): closed.** Every knock names a key.', 'S1 (should-fix): closed;'].map((line) => graded([line]))); - assert('#33604-r3-CONTROL-closed-that-ends-the-finding-or-the-bold-title-CLEARS', stateEnds.every((r) => r.exitCode === EXIT_CLEAR), stateEnds.map((r) => r.entries[0].record.verdictReason).join(' | ')); + const stateEnds = await Promise.all(['S1 (should-fix): closed here.', 'S1 (should-fix): closed;'].map((line) => graded([line]))); + assert('#33604-r3-CONTROL-closed-that-ends-the-finding-CLEARS', stateEnds.every((r) => r.exitCode === EXIT_CLEAR), stateEnds.map((r) => r.entries[0].record.verdictReason).join(' | ')); + // ⛔ #33770 N1: a closed bold title with a sentence after it stays OPEN — the reader cannot weigh a body against its title. + const titleThenBody = await Promise.all(['- **S1 (should-fix): closed.** Every knock names a key.', '- **S1 (should-fix): closed.** Reopened by this delta.'].map((line) => graded([line]))); + assert('⛔ #33770-N1-a-closed-bold-title-with-a-body-after-it-stays-OPEN-and-REFUSES', titleThenBody.every((r) => r.exitCode === EXIT_REFUSED_UNAPPROVED && /names 1 open must-fix\/should-fix finding/.test(renderGuardVerdict(r))), titleThenBody.map((r) => r.entries[0].record.verdictReason ?? 'CLEARED').join(' | ')); const r3Fails = await Promise.all(['Verdict: FAILED', 'Verdict is FAIL', 'Verdict (delta): FAIL', '| FAIL | Verdict |', 'FAIL!', '## Contract review — PASS withdrawn, FAIL'].map((line) => graded([line]))); assert('⛔ #33604-r3-N2-FAILED-is-a-parenthetical-a-reversed-table-row-FAIL-bang-and-a-late-FAIL-in-a-heading-tail-REFUSE', r3Fails.every((r) => r.exitCode === EXIT_REFUSED_UNAPPROVED && /yet it also reads FAIL/.test(renderGuardVerdict(r))), r3Fails.map((r) => r.entries[0].record.verdictReason ?? 'CLEARED').join(' | ')); // ⛔ S2 of review 6891926185: every verdict-bearing FAIL form refuses, and an ambiguous negation fails closed. diff --git a/scripts/pm/check-half-states.mjs b/scripts/pm/check-half-states.mjs index ae1393b31c6..f06d125843f 100644 --- a/scripts/pm/check-half-states.mjs +++ b/scripts/pm/check-half-states.mjs @@ -12917,11 +12917,20 @@ export function contractReviewVerdictLines(body) { * in any heading's own tail (the patrol's inline dialect); a * `verdict` key in any case, under a heading mark, quote, list * bullet or emphasis, after up to two words (`Overall verdict:`), - * with a parenthetical (`Verdict (delta):`), with `:`, a dash, - * `=` or `is`, reading FAIL, FAILED or FAILS; a table row with a - * verdict cell and a FAIL cell in either order; a line that opens - * with a bare `FAIL` and nothing but a separator, a full stop or - * `!` after it. A record carrying one + * with a parenthetical (`Verdict (delta):`), with `:`, a dash + * (spaced on either side), `=`, `is` or `was` (a colon may follow + * those two), reading FAIL, FAILED or FAILS — first, after a + * struck word (`~~PASS~~ FAIL`), or after an arrow (`PASS → FAIL`); + * a table row with a verdict cell and a FAIL cell in either order, + * a cell holding the key and its value (`| Verdict: FAIL |`), or + * a FAIL cell under a header row's verdict column, the cell's word + * after any marks (`| ❌ FAIL |`); a line that opens with a bare + * `FAIL` and nothing but a separator, a full stop or `!` after it; + * any case of the word in a heading's tail. The fail-safe idiom + * is no verdict: `fail-closed`, `fails closed`, `failed closed` + * anywhere, and `FAIL closed` where it is not the key's value or + * the cell's word (`PASS, prior FAIL closed`); nor is a bare + * `FAILED` line (#33770 N4). A record carrying one * never clears beside its one PASS line: it contradicts itself; * findings the must-fix and should-fix grades (`contract-review.md`: a * must-fix is a FAIL, a should-fix earns a delta review of its @@ -12934,11 +12943,16 @@ export function contractReviewVerdictLines(body) { * closed a named finding whose line goes on to say * `closed` and nothing before it but punctuation, and * nothing after it but closing emphasis, `.`, `;` or - * `on this head` / `at this head` / `here` (a full stop - * ending the bold title may lead a new sentence): + * `on this head` / `at this head` / `here`, and whose + * finding ENDS there — the next line is blank, absent, + * a new block or a new finding, never its body: * `- **S1 (should-fix): closed.**` — a delta record * closing what an earlier one raised. `closed in part`, - * a title opening `Closed …` stay OPEN; + * a title opening `Closed …`, a closed title with a + * body after it on its line or under it, and a title + * wrapped after the word stay OPEN (#33770 N1, N2: a + * reader cannot weigh a body against its title; a + * finding closed with a body is closed by id alone); * none a named grade whose value is `none`, on the same * terms (`must-fix: none`; `none of …` stays OPEN); * cited a mention inside the citation of an earlier @@ -12961,17 +12975,46 @@ export function contractReviewVerdictLines(body) { * never read. Pure. */ const CONTRACT_REVIEW_LINE_LEAD = String.raw`^[ \t]*(?:#{1,6}[ \t]+)?(?:>[ \t]*)*(?:(?:[-*+]|\d+[.)])[ \t]+)?[*_]{0,3}[ \t]*`; -const CONTRACT_REVIEW_FAIL_KEYED = new RegExp(CONTRACT_REVIEW_LINE_LEAD + String.raw`(?:[A-Za-z-]+[ \t]+){0,2}verdict(?:[ \t]*\([^)]*\))?[ \t]*[*_]{0,3}[ \t]*(?:[::=]|[—–]|-(?=[ \t])|is(?=[ \t]))[ \t]*[*_` + '`' + String.raw`]{0,3}[ \t]*fail(?:ed|s)?\b`, 'i'); -// A table row with a verdict cell and a FAIL cell, in either order (the word may carry emphasis or a code mark). -const CONTRACT_REVIEW_FAIL_CELL = { test: (line) => /^[ \t]*\|/.test(line) && line.split('|').some((cell) => /\bverdict\b/i.test(cell)) && line.split('|').some((cell) => /^[ \t]*[*_`]{0,3}[ \t]*fail(?:ed|s)?\b/i.test(cell)) }; -const CONTRACT_REVIEW_FAIL_BARE = new RegExp(CONTRACT_REVIEW_LINE_LEAD + String.raw`FAIL(?:ED)?[*_]{0,3}[ \t]*(?:$|[—–·::|.。!!]|-[ \t])`); +// The verdict word where it is a VALUE (the key's, the cell's): FAIL, FAILED or FAILS, ⛔ never the fail-safe idiom +// `fail-closed` / `fails closed` / `failed closed` (#33770 N4). `FAIL closed` as a value still reads FAIL. +const CONTRACT_REVIEW_FAIL_WORD = String.raw`(?:fail(?:ed|s)\b(?![ \t-]+closed\b)|fail\b(?!-closed\b))`; +const CONTRACT_REVIEW_FAIL_KEYED = new RegExp(CONTRACT_REVIEW_LINE_LEAD + String.raw`(?:[A-Za-z-]+[ \t]+){0,2}verdict(?:[ \t]*\([^)]*\))?[ \t]*[*_]{0,3}[ \t]*(?:[::=]|[—–]|-(?=[ \t])|(?<=[ \t])-|(?:is|was)(?=[ \t::])[ \t]*[::]?)[ \t]*(?:[^\n]*?(?:→|->|⇒|⟶)[ \t]*)?(?:~~[^~\n]*~~[ \t]*)?[*_~` + '`' + String.raw`]{0,3}[ \t]*` + CONTRACT_REVIEW_FAIL_WORD, 'i'); +// A table cell whose word reads FAIL: after any marks (emphasis, a code mark, a symbol) and a struck word (#33770 N3). +const CONTRACT_REVIEW_FAIL_CELL_WORD = new RegExp(String.raw`^[ \t]*(?:~~[^~]*~~[ \t]*)?[^\p{L}\p{N}]*?` + CONTRACT_REVIEW_FAIL_WORD, 'iu'); +// A table row with a verdict cell and a FAIL cell, in either order, or one cell holding the key and its FAIL value. +const CONTRACT_REVIEW_FAIL_CELL = { test: (line) => /^[ \t]*\|/.test(line) && ((line.split('|').some((cell) => /\bverdict\b/i.test(cell)) && line.split('|').some((cell) => CONTRACT_REVIEW_FAIL_CELL_WORD.test(cell))) || line.split('|').some((cell) => CONTRACT_REVIEW_FAIL_KEYED.test(cell))) }; +// ⛔ A bare FAILED line is not a verdict (#33770 N4); a bare FAIL is. +const CONTRACT_REVIEW_FAIL_BARE = new RegExp(CONTRACT_REVIEW_LINE_LEAD + String.raw`FAIL[*_]{0,3}[ \t]*(?:$|[—–·::|.。!!]|-[ \t])`); +// The word in a heading's tail, any case (#33770 N3), once the fail-safe idiom is masked out (N4: `PASS, prior FAIL closed`). +const CONTRACT_REVIEW_FAIL_IDIOM = /\bfail(?:ed|s)?(?:-|[ \t]+)closed\b/gi; +const CONTRACT_REVIEW_FAIL_ANY = /\bfail(?:ed|s)?\b/i; const CONTRACT_REVIEW_GRADE = /\b(must|should)-fix(?:es)?\b/gi; const CONTRACT_REVIEW_GRADE_NAMED = new RegExp(CONTRACT_REVIEW_LINE_LEAD + String.raw`(?:([A-Z]{1,3}\d+)[*_]{0,3}[ \t]*([(\[][ \t]*|[—–:][ \t]*)?)?[*_]{0,3}(must|should)-fix\b`, 'i'); // ⛔ The state word must END the finding (review 6892305129): nothing but closing emphasis, a full stop or a -// semicolon may follow it, or the measured tails `on this head` / `at this head` / `here`; a full stop that -// closes the bold title may then be followed by a new sentence. `closed in part`, `Closed PRs are …` and -// `none of the three ablations ran` are titles, and the finding they name stays OPEN. -const CONTRACT_REVIEW_GRADE_NAMED_STATE = /^[^\S\n]*[*_::—–.,-]*[ \t]*[*_]{0,3}(closed|none)(?:[ \t]+(?:(?:on|at)[ \t]+this[ \t]+head|here))?(?:[*_]{0,3}[.;。]?[*_]{0,3}[ \t]*$|[.。](?:\*\*|__)[ \t]+\S)/i; +// semicolon may follow it, or the measured tails `on this head` / `at this head` / `here`. `closed in part`, +// `Closed PRs are …` and `none of the three ablations ran` are titles, and the finding they name stays OPEN. +// ⛔ Nor may a sentence follow a closed bold title (#33770 N1): `**S1 (…): closed.** Still open for X` takes +// the title back, and this reader cannot weigh a body against its title — a finding with a body closes by id. +const CONTRACT_REVIEW_GRADE_NAMED_STATE = /^[^\S\n]*[*_::—–.,-]*[ \t]*[*_]{0,3}(closed|none)(?:[ \t]+(?:(?:on|at)[ \t]+this[ \t]+head|here))?[*_]{0,3}[.;。]?[*_]{0,3}[ \t]*$/i; +// …and the finding must end on that line (#33770 N1, N2): a next line that is its body — indented under it, or +// a lazy continuation that opens no new block and no new finding — is the rest of a wrapped title or a body +// that may take the state back, so the finding stays OPEN. A blank line, a heading, a list item, a quote, a +// table row, a fence or a line led by a finding id (`S2: closed.`) ends it. Quote marks are stripped from both +// lines when the finding is quoted, so a quoted body is read the same way. +const CONTRACT_REVIEW_BLOCK_START = /^(?:#{1,6}[ \t]|[-*+][ \t]|\d+[.)][ \t]|>|\||```|~~~)/; +const CONTRACT_REVIEW_FINDING_ID_LEAD = new RegExp(CONTRACT_REVIEW_LINE_LEAD + String.raw`[A-Z]{1,3}\d+\b`); +function contractReviewFindingContinues(line, next) { + if (next === undefined) return false; + const quoted = /^[ \t]*>/.test(line); + const unquote = (s) => (quoted ? s.replace(/^[ \t]*(?:>[ \t]?)+/, '') : s); + const own = unquote(line); + const body = unquote(next); + if (quoted && !/^[ \t]*>/.test(next)) return /\S/.test(next) && !CONTRACT_REVIEW_BLOCK_START.test(next.trimStart()) && !CONTRACT_REVIEW_FINDING_ID_LEAD.test(next); + if (!/\S/.test(body)) return false; + const indent = (s) => /^[ \t]*/.exec(s)[0].replace(/\t/g, ' ').length; + if (indent(body) > indent(own)) return true; + return !CONTRACT_REVIEW_BLOCK_START.test(body.trimStart()) && !CONTRACT_REVIEW_FINDING_ID_LEAD.test(body); +} const CONTRACT_REVIEW_GRADE_NEGATED = /\b(?:no|nor|neither|zero|0)[ \t]+(?:(?:new|open|further|remaining|other|outstanding)[ \t]+)?(?:(?:must|should)-fix(?:es)?[ \t]*(?:(?:or|nor|\/)[ \t]*|(?:,|and)[ \t]*(?:no|nor)[ \t]+(?:(?:new|open|further|remaining|other|outstanding)[ \t]+)?))?$/i; const CONTRACT_REVIEW_RECORD_CITATION = /\(record[ \t]+\d{6,}\b[^()]*\)/gi; export function contractReviewRecordReading(body) { @@ -12982,14 +13025,26 @@ export function contractReviewRecordReading(body) { const open = []; const unreadable = []; const headingLine = new RegExp(CONTRACT_REVIEW_HEADING_MARKER.source); - for (const line of text.split(/\r?\n/)) { + const lines = text.split(/\r?\n/); + // The verdict column a table's HEADER row names, while that table lasts (#33770 N3); -1 when none. + let tableVerdictColumn = -1; + let inTable = false; + for (const [at, line] of lines.entries()) { // Every heading's own tail is read for an inline FAIL, not only the first one's (nit N3, review 6891926185). const heading = headingLine.exec(line); - // …and a caps FAIL anywhere in that tail, not only the first verdict word (`— PASS withdrawn, FAIL`, nit N2 of review 6892305129). - if (heading && (CONTRACT_REVIEW_VERDICT_INLINE.exec(line.slice(heading.index + heading[0].length))?.[1] === 'FAIL' || /\bFAIL(?:ED)?\b/.test(line.slice(heading.index + heading[0].length)))) failSpellings.push(line.trim()); + // …and the word in any case anywhere in that tail, not only the first verdict word (`— PASS withdrawn, FAIL`, + // nit N2 of review 6892305129; `— Fail`, #33770 N3), the fail-safe idiom aside (`PASS, prior FAIL closed`, N4). + const tail = heading ? line.slice(heading.index + heading[0].length) : ''; + if (heading && (CONTRACT_REVIEW_VERDICT_INLINE.exec(tail)?.[1] === 'FAIL' || CONTRACT_REVIEW_FAIL_ANY.test(tail.replace(CONTRACT_REVIEW_FAIL_IDIOM, '')))) failSpellings.push(line.trim()); + const row = /^[ \t]*\|/.test(line); + const cells = row ? line.split('|') : []; + let underVerdictColumn = false; + if (!row) [inTable, tableVerdictColumn] = [false, -1]; + else if (!inTable) [inTable, tableVerdictColumn] = [true, cells.findIndex((cell) => /\bverdict\b/i.test(cell))]; + else underVerdictColumn = tableVerdictColumn >= 0 && CONTRACT_REVIEW_FAIL_CELL_WORD.test(cells[tableVerdictColumn] ?? ''); const explicit = CONTRACT_REVIEW_VERDICT_EXPLICIT.exec(line); if (explicit) verdicts.push(explicit[1]); - else if (!heading && (CONTRACT_REVIEW_FAIL_KEYED.test(line) || CONTRACT_REVIEW_FAIL_CELL.test(line) || CONTRACT_REVIEW_FAIL_BARE.test(line))) failSpellings.push(line.trim()); + else if (!heading && (CONTRACT_REVIEW_FAIL_KEYED.test(line) || CONTRACT_REVIEW_FAIL_CELL.test(line) || underVerdictColumn || CONTRACT_REVIEW_FAIL_BARE.test(line))) failSpellings.push(line.trim()); const cited = [...line.matchAll(CONTRACT_REVIEW_RECORD_CITATION)].map((c) => [c.index, c.index + c[0].length]); const named = CONTRACT_REVIEW_GRADE_NAMED.exec(line); // The NAMED mention is the one the lead regex ended on; every other mention on the line is read on its own. @@ -13000,7 +13055,7 @@ export function contractReviewRecordReading(body) { // What follows the grade: past the bracket the finding opened with, then `closed` or `none` and only punctuation before it. let rest = line.slice(named[0].length); if (named[2] && /[(\[]/.test(named[2])) rest = rest.slice(rest.search(/[)\]]/) + 1 || rest.length); - const state = CONTRACT_REVIEW_GRADE_NAMED_STATE.exec(rest)?.[1]?.toLowerCase(); + const state = contractReviewFindingContinues(line, lines[at + 1]) ? undefined : CONTRACT_REVIEW_GRADE_NAMED_STATE.exec(rest)?.[1]?.toLowerCase(); if (state === undefined) open.push({ id: named[1] ?? null, grade: `${named[3].toLowerCase()}-fix`, line: line.trim() }); } else if (!CONTRACT_REVIEW_GRADE_NEGATED.test(line.slice(0, mention.index))) unreadable.push(line.trim()); } @@ -33060,8 +33115,16 @@ async function selfTest() { t43('#33604 S1 (review 6891926185): the measured delta preamble cites, a named finding whose line says closed is closed, `No new should-fix` denies', ['DELTA review from `42323f34` (record 6891274033: PASS, should-fix S3, nits N7 and N8) to this head.', '- **S1 (should-fix): closed.**', 'S1 (should-fix) — closed on this head', 'No new should-fix.', 'must-fix: none'].map(grades43).join(), '|0,|0,|0,|0,|0'); t43('#33604 S2 (review 6891926185): `No must-fix, should-fix S1 and S2 below.` is unreadable (a comma carries no denial); its own `no` after `and` does', [grades43('No must-fix, should-fix S1 and S2 below.'), grades43('No must-fix and no should-fix.')].join(), '|1,|0'); t43('#33604 S2 (review 6891926185): heading-led key, table cell, words before the key, a dash, a bare `FAIL.` and a second heading read FAIL', ['### VERDICT: FAIL', '## Verdict: FAIL', '| Verdict | FAIL |', 'Overall verdict: FAIL', 'Verdict — FAIL', 'FAIL.', '**FAIL.**', '## Contract review — FAIL', '| Verdict | PASS |'].map((l) => read43(l).failSpellings.length).join(), '1,1,1,1,1,1,1,1,0'); - t43('#33604 r3 (review 6892305129): the state word must end the finding — `closed in part`, `Closed PRs …`, `none of …` stay open; `closed here.`, a closed bold title then a sentence, `closed;` close', ['S1 (should-fix): closed in part, still open for X', '**S2 (should-fix) — Closed PRs are still read as merged.**', '- should-fix: none of S1, S2 is fixed', 'S1 (should-fix): closed here.', '- **S1 (should-fix): closed.** Every knock names a key.', 'S1 (should-fix): closed;'].map(grades43).join(), 'S1:should-fix|0,S2:should-fix|0,-:should-fix|0,|0,|0,|0'); + // #33770 N1 forces one cell of this row: a closed bold title with a sentence after it reads OPEN now (it was the r3 allowance). + t43('#33604 r3 (review 6892305129): the state word must end the finding — `closed in part`, `Closed PRs …`, `none of …` stay open; `closed here.` and `closed;` close; a closed bold title then a sentence stays open (#33770 N1)', ['S1 (should-fix): closed in part, still open for X', '**S2 (should-fix) — Closed PRs are still read as merged.**', '- should-fix: none of S1, S2 is fixed', 'S1 (should-fix): closed here.', '- **S1 (should-fix): closed.** Every knock names a key.', 'S1 (should-fix): closed;'].map(grades43).join(), 'S1:should-fix|0,S2:should-fix|0,-:should-fix|0,|0,S1:should-fix|0,|0'); t43('#33604 r3 N2: `Verdict: FAILED`, `Verdict is FAIL`, `Verdict (delta): FAIL`, `| FAIL | Verdict |`, `FAIL!` and a late FAIL in a heading tail read FAIL', ['Verdict: FAILED', 'Verdict is FAIL', 'Verdict (delta): FAIL', '| FAIL | Verdict |', 'FAIL!', '## Contract review — PASS withdrawn, FAIL', 'The verdict is PASS.'].map((l) => read43(l).failSpellings.length).join(), '1,1,1,1,1,1,0'); + // #33770 (review 6892689104, N1-N4 of PR #33736's last record): the closed allowance, the line-based finding, FAIL spellings, clean text. + t43('#33770 N1: a closed bold title taken back by its body stays OPEN — a sentence on its line (bold, `__`, a tab, an unpaired mark) or under it, plain, indented, quoted or a nested bullet', ['**S1 (should-fix) — closed.** Still open for the table cell', '- **S1 (should-fix): closed.** Reopened by this delta.', '__S1 (should-fix): closed.__ Still open', '**S1 (should-fix): closed.**\tStill open', 'S1 (should-fix): closed.** Still open', '- **S1 (should-fix): closed.**\n Still open for the table cell.', '**S1 (should-fix): closed.**\nStill open for the table cell.', '> **S1 (should-fix): closed.**\n> Still open.', '- **S1 (should-fix): closed.**\n - still open for X'].map(grades43).join(), Array(9).fill('S1:should-fix|0').join()); + t43('#33770 N2: a title wrapped right after the state word stays OPEN — bold and plain', ['- **S1 (should-fix) — closed\n in part, the table cell still clears.**', 'S1 (should-fix): closed\nin part, still open'].map(grades43).join(), 'S1:should-fix|0,S1:should-fix|0'); + t43('#33770 N1/N2 CONTROL: a closed finding that ENDS reads closed — before a blank line, a new bullet, a quoted bullet or a finding led by its id; `- should-fix: none`; a body under a finding closed by id alone', ['- **S1 (should-fix): closed.**', '- **S1 (should-fix): closed.**\n- **S2 (should-fix): closed.**', 'S1 (should-fix): closed here.\nS2: closed here.', '- **S1 (should-fix): closed.**\n\nNo must-fix.', '> - **S1 (should-fix): closed.**\n> - **S2 (should-fix): closed.**', '- should-fix: none', '- **S1: closed.** Every knock names a key.'].map(grades43).join(), Array(7).fill('|0').join()); + t43('#33770 N3: FAIL read in a header row\'s verdict column, after an arrow or a struck word, with `was`, `is:` or an unspaced dash, after a mark in a cell, key and value in one cell, title or lower case in a heading tail', ['| Tier | Verdict |\n|---|---|\n| at-tier | FAIL |', 'Verdict: PASS → FAIL', 'Verdict: PASS -> FAIL', 'Verdict: ~~PASS~~ FAIL', 'Verdict was FAIL', 'verdict is: FAIL', 'Verdict -FAIL', '| Verdict | ❌ FAIL |', '| Verdict | ✗ **FAIL** |', '| Verdict: FAIL |', '## Contract review — Fail', '## Contract review — fail'].map((l) => read43(l).failSpellings.length).join(), Array(12).fill('1').join()); + t43('#33770 N4: the fail-safe idiom and a bare FAILED line are not FAIL — `The verdict is fail-closed.`, a `fails closed` cell beside a verdict cell or under a verdict column, `PASS, prior FAIL closed` in a heading tail, `FAILED`', ['The verdict is fail-closed.', '| Verdict | fails closed |', '| Leg | Verdict |\n|---|---|\n| x | fails closed on error |', '## Contract review — PASS, prior FAIL closed', 'FAILED', '- Leg verdict: fail-closed reading holds.'].map((l) => read43(l).failSpellings.length).join(), '0,0,0,0,0,0'); + t43('#33770 N4 CONTROL: the idiom never excuses a verdict VALUE — `Verdict: FAIL closed`, a `FAIL closed` cell, a heading tail opening `FAIL closed` read FAIL; a PASS verdict column and `verdict-failure` do not', ['Verdict: FAIL closed', '| Verdict | FAIL closed |', '## Contract review — FAIL closed', '| Tier | Verdict |\n|---|---|\n| at-tier | PASS |', 'verdict-failure noted'].map((l) => read43(l).failSpellings.length).join(), '1,1,1,0,0'); t43('#33604 reading: no heading is no record (null); the template record reads one PASS, no FAIL, no grade', [contractReviewRecordReading('**VERDICT: PASS**'), JSON.stringify(contractReviewRecordReading(PASS43))].join(), ',{"verdicts":["PASS"],"failSpellings":[],"findings":{"open":[],"unreadable":[]}}'); t43('H43 verdict: latestContractReviewOnHead now carries the verdict beside id and sha', [latestContractReviewOnHead(rows43(ACCEPT43, PASS43), HEAD43)?.verdict, latestContractReviewOnHead(rows43(FAIL43), HEAD43)?.verdict, latestContractReviewOnHead(rows43(PASS43), '0123456789abcdef')].join(), 'PASS,FAIL,'); // The row and the probe, gated on the reading. From af85cdbeef1aa17fb1f95b318c3b7a96735dea56 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 17:43:26 +0000 Subject: [PATCH 2/2] fix(pm): the record reader reads past an explicit PASS and ends a finding at a grade-led line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An explicit `VERDICT: PASS` line is also read by the keyed reader, so `**VERDICT: PASS → FAIL**` is a FAIL spelling. A next line led by a grade with no id (`should-fix: none`) ends the finding above it. As a verdict value only the prose idiom is excused: `FAILED closed` and `FAILED - closed` read FAIL. Claude-Session: https://claude.ai/code/session_01ADHkmQopcLwxooyvT2Kxvu Co-authored-by: Claude --- scripts/pm/check-half-states.mjs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/pm/check-half-states.mjs b/scripts/pm/check-half-states.mjs index f06d125843f..43d9d99f45e 100644 --- a/scripts/pm/check-half-states.mjs +++ b/scripts/pm/check-half-states.mjs @@ -12976,8 +12976,9 @@ export function contractReviewVerdictLines(body) { */ const CONTRACT_REVIEW_LINE_LEAD = String.raw`^[ \t]*(?:#{1,6}[ \t]+)?(?:>[ \t]*)*(?:(?:[-*+]|\d+[.)])[ \t]+)?[*_]{0,3}[ \t]*`; // The verdict word where it is a VALUE (the key's, the cell's): FAIL, FAILED or FAILS, ⛔ never the fail-safe idiom -// `fail-closed` / `fails closed` / `failed closed` (#33770 N4). `FAIL closed` as a value still reads FAIL. -const CONTRACT_REVIEW_FAIL_WORD = String.raw`(?:fail(?:ed|s)\b(?![ \t-]+closed\b)|fail\b(?!-closed\b))`; +// spelled as prose spells it — hyphenated (`fail-closed`, `fails-closed`, `failed-closed`) or `fails closed` with one +// space (#33770 N4). Every other value reads FAIL: `FAIL closed`, `FAILED closed`, `FAILED - closed`. +const CONTRACT_REVIEW_FAIL_WORD = String.raw`(?:fails\b(?!-closed\b|[ \t]closed\b)|failed\b(?!-closed\b)|fail\b(?!-closed\b))`; const CONTRACT_REVIEW_FAIL_KEYED = new RegExp(CONTRACT_REVIEW_LINE_LEAD + String.raw`(?:[A-Za-z-]+[ \t]+){0,2}verdict(?:[ \t]*\([^)]*\))?[ \t]*[*_]{0,3}[ \t]*(?:[::=]|[—–]|-(?=[ \t])|(?<=[ \t])-|(?:is|was)(?=[ \t::])[ \t]*[::]?)[ \t]*(?:[^\n]*?(?:→|->|⇒|⟶)[ \t]*)?(?:~~[^~\n]*~~[ \t]*)?[*_~` + '`' + String.raw`]{0,3}[ \t]*` + CONTRACT_REVIEW_FAIL_WORD, 'i'); // A table cell whose word reads FAIL: after any marks (emphasis, a code mark, a symbol) and a struck word (#33770 N3). const CONTRACT_REVIEW_FAIL_CELL_WORD = new RegExp(String.raw`^[ \t]*(?:~~[^~]*~~[ \t]*)?[^\p{L}\p{N}]*?` + CONTRACT_REVIEW_FAIL_WORD, 'iu'); @@ -13009,11 +13010,13 @@ function contractReviewFindingContinues(line, next) { const unquote = (s) => (quoted ? s.replace(/^[ \t]*(?:>[ \t]?)+/, '') : s); const own = unquote(line); const body = unquote(next); - if (quoted && !/^[ \t]*>/.test(next)) return /\S/.test(next) && !CONTRACT_REVIEW_BLOCK_START.test(next.trimStart()) && !CONTRACT_REVIEW_FINDING_ID_LEAD.test(next); + // A line that opens a finding of its own — led by an id, or by a grade with no id (`should-fix: none`) — ends this one. + const opensFinding = (s) => CONTRACT_REVIEW_FINDING_ID_LEAD.test(s) || CONTRACT_REVIEW_GRADE_NAMED.test(s); + if (quoted && !/^[ \t]*>/.test(next)) return /\S/.test(next) && !CONTRACT_REVIEW_BLOCK_START.test(next.trimStart()) && !opensFinding(next); if (!/\S/.test(body)) return false; const indent = (s) => /^[ \t]*/.exec(s)[0].replace(/\t/g, ' ').length; if (indent(body) > indent(own)) return true; - return !CONTRACT_REVIEW_BLOCK_START.test(body.trimStart()) && !CONTRACT_REVIEW_FINDING_ID_LEAD.test(body); + return !CONTRACT_REVIEW_BLOCK_START.test(body.trimStart()) && !opensFinding(body); } const CONTRACT_REVIEW_GRADE_NEGATED = /\b(?:no|nor|neither|zero|0)[ \t]+(?:(?:new|open|further|remaining|other|outstanding)[ \t]+)?(?:(?:must|should)-fix(?:es)?[ \t]*(?:(?:or|nor|\/)[ \t]*|(?:,|and)[ \t]*(?:no|nor)[ \t]+(?:(?:new|open|further|remaining|other|outstanding)[ \t]+)?))?$/i; const CONTRACT_REVIEW_RECORD_CITATION = /\(record[ \t]+\d{6,}\b[^()]*\)/gi; @@ -13043,7 +13046,11 @@ export function contractReviewRecordReading(body) { else if (!inTable) [inTable, tableVerdictColumn] = [true, cells.findIndex((cell) => /\bverdict\b/i.test(cell))]; else underVerdictColumn = tableVerdictColumn >= 0 && CONTRACT_REVIEW_FAIL_CELL_WORD.test(cells[tableVerdictColumn] ?? ''); const explicit = CONTRACT_REVIEW_VERDICT_EXPLICIT.exec(line); - if (explicit) verdicts.push(explicit[1]); + if (explicit) { + verdicts.push(explicit[1]); + // The explicit reader stops at the first word, so `**VERDICT: PASS → FAIL**` is ALSO a FAIL spelling (#33770 r2 S1). + if (explicit[1] === 'PASS' && CONTRACT_REVIEW_FAIL_KEYED.test(line)) failSpellings.push(line.trim()); + } else if (!heading && (CONTRACT_REVIEW_FAIL_KEYED.test(line) || CONTRACT_REVIEW_FAIL_CELL.test(line) || underVerdictColumn || CONTRACT_REVIEW_FAIL_BARE.test(line))) failSpellings.push(line.trim()); const cited = [...line.matchAll(CONTRACT_REVIEW_RECORD_CITATION)].map((c) => [c.index, c.index + c[0].length]); const named = CONTRACT_REVIEW_GRADE_NAMED.exec(line); @@ -33125,6 +33132,10 @@ async function selfTest() { t43('#33770 N3: FAIL read in a header row\'s verdict column, after an arrow or a struck word, with `was`, `is:` or an unspaced dash, after a mark in a cell, key and value in one cell, title or lower case in a heading tail', ['| Tier | Verdict |\n|---|---|\n| at-tier | FAIL |', 'Verdict: PASS → FAIL', 'Verdict: PASS -> FAIL', 'Verdict: ~~PASS~~ FAIL', 'Verdict was FAIL', 'verdict is: FAIL', 'Verdict -FAIL', '| Verdict | ❌ FAIL |', '| Verdict | ✗ **FAIL** |', '| Verdict: FAIL |', '## Contract review — Fail', '## Contract review — fail'].map((l) => read43(l).failSpellings.length).join(), Array(12).fill('1').join()); t43('#33770 N4: the fail-safe idiom and a bare FAILED line are not FAIL — `The verdict is fail-closed.`, a `fails closed` cell beside a verdict cell or under a verdict column, `PASS, prior FAIL closed` in a heading tail, `FAILED`', ['The verdict is fail-closed.', '| Verdict | fails closed |', '| Leg | Verdict |\n|---|---|\n| x | fails closed on error |', '## Contract review — PASS, prior FAIL closed', 'FAILED', '- Leg verdict: fail-closed reading holds.'].map((l) => read43(l).failSpellings.length).join(), '0,0,0,0,0,0'); t43('#33770 N4 CONTROL: the idiom never excuses a verdict VALUE — `Verdict: FAIL closed`, a `FAIL closed` cell, a heading tail opening `FAIL closed` read FAIL; a PASS verdict column and `verdict-failure` do not', ['Verdict: FAIL closed', '| Verdict | FAIL closed |', '## Contract review — FAIL closed', '| Tier | Verdict |\n|---|---|\n| at-tier | PASS |', 'verdict-failure noted'].map((l) => read43(l).failSpellings.length).join(), '1,1,1,0,0'); + // #33770 round 2 (review 6898558527 of PR #34054): the template's own all-caps key, a grade-led next line, a FAILED value. + t43('#33770 r2 S1: the explicit all-caps line read past its first word — `**VERDICT: PASS → FAIL**`, the ASCII arrow, bare, quoted — states PASS AND a FAIL spelling; the plain PASS and FAIL lines stay one word each', ['**VERDICT: PASS → FAIL**', '**VERDICT: PASS -> FAIL**', 'VERDICT: PASS → FAIL', '> **VERDICT: PASS ⇒ FAIL**', '**VERDICT: PASS**', '**VERDICT: FAIL**'].map((l) => { const x = contractReviewRecordReading(PASS43.replace('**VERDICT: PASS**', l)); return `${x.verdicts.join('+')}|${x.failSpellings.length}`; }).join(), 'PASS|1,PASS|1,PASS|1,PASS|1,PASS|0,FAIL|0'); + t43('#33770 r2 S2: a next line led by a grade with no id ends the finding — `must-fix: none` over `should-fix: none`, bulleted or plain, and a closed finding over one; a body under `must-fix: none` keeps it open', ['must-fix: none\nshould-fix: none', '- must-fix: none\nshould-fix: none', 'S1 (should-fix): closed.\nshould-fix: none', 'must-fix: none\nstill open for X'].map(grades43).join(), '|0,|0,|0,-:must-fix|0'); + t43('#33770 r2 nit: as a VALUE only the prose idiom is excused — `FAILED - closed`, `FAILED closed`, `FAIL - closed` read FAIL; `fails closed`, `failed-closed` do not', ['Verdict: FAILED - closed', 'Verdict: FAILED closed', 'Verdict: FAIL - closed', 'Verdict: fails closed', 'Verdict: failed-closed'].map((l) => read43(l).failSpellings.length).join(), '1,1,1,0,0'); t43('#33604 reading: no heading is no record (null); the template record reads one PASS, no FAIL, no grade', [contractReviewRecordReading('**VERDICT: PASS**'), JSON.stringify(contractReviewRecordReading(PASS43))].join(), ',{"verdicts":["PASS"],"failSpellings":[],"findings":{"open":[],"unreadable":[]}}'); t43('H43 verdict: latestContractReviewOnHead now carries the verdict beside id and sha', [latestContractReviewOnHead(rows43(ACCEPT43, PASS43), HEAD43)?.verdict, latestContractReviewOnHead(rows43(FAIL43), HEAD43)?.verdict, latestContractReviewOnHead(rows43(PASS43), '0123456789abcdef')].join(), 'PASS,FAIL,'); // The row and the probe, gated on the reading.