From 9bbb56688d1762f6169e65b7bce56e838ef47311 Mon Sep 17 00:00:00 2001 From: garrytan Date: Sat, 31 Oct 2026 10:36:05 +0000 Subject: [PATCH] fix(ship): a line naming a file:line or a table row always keeps a finding; "of which" stays inside a negated subject (fix-check) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- changelog.d/gsta-167-nonreview.md | 2 +- docs/review-policy.md | 5 +++-- lib/review-ledger.ts | 20 ++++++++++++-------- test/review-dispatch.test.ts | 8 ++++++-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/changelog.d/gsta-167-nonreview.md b/changelog.d/gsta-167-nonreview.md index a5a479858..b2f135546 100644 --- a/changelog.d/gsta-167-nonreview.md +++ b/changelog.d/gsta-167-nonreview.md @@ -3,6 +3,6 @@ ### Fixed - **`gstack-review-dispatch collect` needs the clean marker a reader's own brief asks for before it counts a reply with no findings.** That is `NO FINDINGS` alone on a line for the specialists, the batched specialist, the targeted reader, the Red Team and fix-check; the `Recommendation:` line for the outside voice; and either one for the native adversarial voice. A reply with no finding and no marker (a refusal, an empty reply, a reader that never got the diff) is recorded with `review: false`, prints `COLLECT_NOT_REVIEWED` and exits 1. Re-sending the brief and collecting a real review voids it, and the outside voice, whose failure never blocks, is collected with `--unavailable ''` and verifies as `UNAVAILABLE`, never as a review. A failure text that still holds findings is refused there and collected normally, so nothing is lost. - **`gstack-review-dispatch verify` reports that reader's brief `NOT_COLLECTED` and its output `NOT_REVIEWED`, so VERIFY reads dirty.** When the output file is still there and unchanged, verify checks the marker in it again, so a ledger written before this change is judged by the same rule. The GSTA-189 replay's combined ledger still verifies clean, with five `NO FINDINGS` specialists and one outside voice ending in `Recommendation:`. -- **A severity word used as a word is no longer a finding.** A fix-check reader on gstack-evals#94 closed with "Neither finding is CRITICAL.", `collect` stored that line as a CRITICAL finding, and `judge` would not let the lead drop it. Now a label that is negated ("not CRITICAL", "no High findings", "Neither finding is CRITICAL"), used as a yardstick ("below CRITICAL"), quoted or code-formatted in the middle of a sentence, or listed as vocabulary ("Critical|High") is skipped, and so is a closing "Overall:" or "Summary:" line after the findings unless it says `Blocks: yes`, names a file and line, or carries a label stronger than every finding before it. A label the line opens with, a `Severity:` field, a table cell, a quoted label at the end of its line like "(`FIXABLE`)" or "— `CRITICAL`", any label on a line naming a file and line that only a negated subject would cancel, and a label whose negation describes the defect ("Without auth this is CRITICAL", "None of the inputs are sanitized so this is CRITICAL") still count. +- **A severity word used as a word is no longer a finding.** A fix-check reader on gstack-evals#94 closed with "Neither finding is CRITICAL.", `collect` stored that line as a CRITICAL finding, and `judge` would not let the lead drop it. Now a label that is negated ("not CRITICAL", "no High findings", "Neither finding is CRITICAL"), used as a yardstick ("below CRITICAL"), quoted or code-formatted in the middle of a sentence, or listed as vocabulary ("Critical|High") is skipped, and so is a closing "Overall:" or "Summary:" line after the findings unless it says `Blocks: yes`, names a file and line, or carries a label stronger than every finding before it. A label the line opens with, a `Severity:` field, a table cell, a quoted label at the end of its line like "(`FIXABLE`)" or "— `CRITICAL`", and a label whose negation describes the defect ("Without auth this is CRITICAL", "None of the inputs are sanitized so this is CRITICAL") still count. A line that names a file and line, or a table row, always keeps a finding: when every label on it reads as a word, the strongest one still counts, so a tie costs a fold, never a lost finding. - **A paragraph finding keeps its detail bullets.** The GSTA-196 native adversarial voice wrote four findings, each with unlabeled bullets and then a `Severity:` line. Every bullet closed the open finding, so each `Severity:` line opened a new one: 4 findings collected as 8. They now collect as 4, each at the stronger of its two labels. Only an unnumbered bullet with no file and line of its own counts as detail; a numbered item is still its own finding. - **No blocker is lost.** Main's parser and this one were run over every recorded reader output: 25 raw outputs from the GSTA-189 and GSTA-196 replays and 2,172 finding records from arms C6, L6, A3668 (both suites), G1 and L. The 8 GSTA-196 lines merge into 4 findings, none at a weaker label. One INVESTIGATE finding, recorded in both arm G1 and arm L, loses a phantom CRITICAL ("no CRITICAL" inside its sentence), and another loses a phantom High ("resolves below High"). None of the 260 records matched to a judged blocker changes. diff --git a/docs/review-policy.md b/docs/review-policy.md index 1ddbeb07e..e17e682a3 100644 --- a/docs/review-policy.md +++ b/docs/review-policy.md @@ -479,9 +479,10 @@ ones, and the arm lost blockers. `bin/gstack-review-dispatch` closes both ends: opens a clause with its own subject, end the subject, so "None of the inputs are sanitized so this is CRITICAL" keeps its label), a yardstick ("below CRITICAL", "worse than High"; "up to" and "at most" are not yardsticks), quoted or code-formatted with words after it ("maps `FIXABLE` to `CRITICAL` in a comment"), or listed as vocabulary ("Critical|High"). A negation that describes the defect - ("Without auth this is CRITICAL") leaves the label standing, and a negated subject never cancels a label on a line naming a file:line; + ("Without auth this is CRITICAL") leaves the label standing; a label the line opens with, a quoted label at the end of its line ("— `CRITICAL`", "(`FIXABLE`)"), a label on a `Severity:` or - `Blocks:` field line and a table cell always count. A closing "Overall:", "Summary:", + `Blocks:` field line and a table cell always count. A line naming a file:line, or a table row, is finding-shaped: the word rules pick + its label but never leave it with none, so a tie goes to a phantom the lead must fix or fold, never to a lost finding. A closing "Overall:", "Summary:", "In summary" or "Verdict:" line after the findings starts none unless it carries `Blocks: yes`, a file:line, or a label stronger than every finding before it (GST-435). An unnumbered, unlabeled bullet with no file:line under a paragraph finding whose Severity or Blocks line has not come yet is that finding's detail, so the field line after it lands on the finding; a numbered item is its own finding. diff --git a/lib/review-ledger.ts b/lib/review-ledger.ts index 2690c82c1..4925ce39d 100644 --- a/lib/review-ledger.ts +++ b/lib/review-ledger.ts @@ -68,17 +68,16 @@ const OPENS = /^(?:[-*+>]\s+|\d+[.)]\s+|#{1,6}\s*)?[\s[(*_`"'“‘|]*$/; * ("below CRITICAL", "worse than High"), quoted or code-formatted inside a sentence, with words after it ("rated it 'High'; the fix * closes it", "maps `FIXABLE` to `CRITICAL` in a comment") or listed as vocabulary ("Critical|High"); bold or code marks between the * negation and the label change nothing. A negation that describes the defect ("Without auth this is CRITICAL", "None of the inputs - * are sanitized so this is CRITICAL") leaves the label standing, and a negated subject never cancels a label on a line naming a - * file:line. A quoted label at the end of its line or before only a file:line ("— `CRITICAL`", "(`FIXABLE`)"), on a Severity or Blocks - * field line or in a table row counts, and table cells are never vocabulary for each other. The clause runs back to the last - * sentence, colon, comma, dash, bracket or table bar. + * are sanitized so this is CRITICAL") leaves the label standing. A quoted label at the end of its line or before only a file:line ("— `CRITICAL`", "(`FIXABLE`)"), on a Severity or Blocks + * field line counts, and table cells are never vocabulary for each other. The clause runs back to the last sentence, colon, + * comma, dash, bracket or table bar. parseFindings never lets these rules empty a line naming a file:line or a table row. */ const NEGATOR = "not|no|never|nothing|without|zero|nor|isn't|aren't|wasn't|weren't|doesn't|don't|didn't|cannot|can't|won't"; const FILLER = '(?:a|an|any|rated|at|be|really|quite|even|rises?\\s+to|reach(?:es)?|counts?\\s+as)'; const MARKS = "[*_`\"'“‘]*"; const NEGATED = new RegExp(`\\b(?:${NEGATOR})\\s+(?:${FILLER}\\s+)*(?:${MARKS}(?:${LABELS})${MARKS}\\s*(?:or|nor|and|/)\\s*)*${MARKS}$`, 'i'); /** A new clause after a negated subject: a subordinating conjunction, or "and"/"or" that opens a clause with its own subject. */ -const CLAUSE_BREAK = '\\b(?:so|but|yet|because|since|while|whereas|although|though|if|when|which)\\b|\\b(?:and|or)\\s+(?:the|this|that|these|those|it|its|there|a|an|we|i|you|they)\\b'; +const CLAUSE_BREAK = '\\b(?:so|but|yet|because|since|while|whereas|although|though|if|when)\\b|(? = { '"': '"', "'": "'", '“': '”', '‘': '’', '`': '`' }; @@ -91,10 +90,10 @@ function aWord(t: string, at: number, len: number): boolean { const table = t.startsWith('|'); const quote = QUOTES[before.slice(-1)]; const mid = quote !== undefined && after.startsWith(quote) && /[A-Za-z]/.test(after.slice(1).replace(new RegExp(LOCUS.source, 'g'), '')); - if (mid && !table && !META.test(t)) return true; + if (mid && !META.test(t)) return true; if (!table && (VOCAB_AFTER.test(after) || VOCAB_BEFORE.test(before))) return true; const clause = ' ' + before.slice(Math.max(...['.', ';', ':', '!', '?', ',', '—', '–', '(', ')', '|'].map(c => before.lastIndexOf(c))) + 1); - return NEGATED.test(clause) || (!LOCUS.test(t) && NEGATED_SUBJECT.test(clause)) || YARDSTICK.test(clause); + return NEGATED.test(clause) || NEGATED_SUBJECT.test(clause) || YARDSTICK.test(clause); } /** * A closing summary line ("Overall: …", "In summary, …", "Verdict: …") after the findings restates them: it starts no finding unless @@ -129,7 +128,12 @@ export function parseFindings(reader: string, output: string): Array<{ label: st let gap = false; const role = reader.split('/')[0]; const named = (l: string) => (role === 'adversarial-native' && l.toUpperCase() === 'FIXABLE' ? 'CRITICAL' : l); - const strongest = (t: string) => [...t.matchAll(ALL_LABELS)].filter(m => !aWord(t, m.index!, m[1]!.length)).map(m => named(m[1]!)).reduce((a, b) => (a === undefined ? b : stronger(a, b)), undefined); + const strongest = (t: string) => { + const all = [...t.matchAll(ALL_LABELS)]; + const labels = all.filter(m => !aWord(t, m.index!, m[1]!.length)); + // A line naming a file:line or a table row is finding-shaped: the word rules may pick its label, never leave it with none. + return (labels.length || !(LOCUS.test(t) || t.startsWith('|') || /\s\|\s/.test(t)) ? labels : all).map(m => named(m[1]!)).reduce((a, b) => (a === undefined ? b : stronger(a, b)), undefined); + }; const push = (label: string, raw: string, fields: string[] = []): Finding => { const f = { label, raw, fields: new Set(fields), list: LIST_ITEM.test(raw) }; out.push(f); return f; }; for (const line of output.replace(/\r\n/g, '\n').split('\n')) { const t = line.trim(); diff --git a/test/review-dispatch.test.ts b/test/review-dispatch.test.ts index b0febcad4..7cdbbd92c 100644 --- a/test/review-dispatch.test.ts +++ b/test/review-dispatch.test.ts @@ -422,7 +422,7 @@ describe('gstack-review-dispatch sent, collect, judge and verify: nothing change "This doesn't rise to CRITICAL.", 'It cannot be CRITICAL.', 'Nothing here is CRITICAL.', 'This is not really CRITICAL.', 'I used the `CRITICAL` label for none of them.', 'This is not **CRITICAL**.', 'Neither finding is **High**.', 'There are no `CRITICAL` findings.', 'The race sits below `CRITICAL` on the floor.', 'No finding that I checked is CRITICAL.', 'None of the read and write paths are CRITICAL.', - 'No issues in auth or billing are High.']) + 'No issues in auth or billing are High.', 'Two nits in the docs, neither of which is CRITICAL.', 'Two nits, none of which is High.']) expect([word, parseFindings('outside-voice', word)]).toEqual([word, []]); expect(parseFindings('outside-voice', '1. **High**: retry loop never backs off (q.ts:78)\n\nOverall: one High finding, nothing CRITICAL.').map(f => f.label)).toEqual(['High']); expect(parseFindings('outside-voice', 'Severity: Low (not High)\n').map(f => f.label)).toEqual(['Low']); @@ -439,7 +439,11 @@ describe('gstack-review-dispatch sent, collect, judge and verify: nothing change ['|1|FIXABLE|High|race in queue.ts:78|', 'High'], ['| a.ts:3 | race | `High` |', 'High'], ['|a.ts:3|leak|`CRITICAL`|', 'CRITICAL'], ['| a.ts:3 | "CRITICAL" |', 'CRITICAL'], ['- Token leak in log.ts:3 — `CRITICAL`', 'CRITICAL'], ['1. Token leak (log.ts:3): `High`', 'High'], - ['Nothing checks the token which is CRITICAL (a.ts:3)', 'CRITICAL'], ['Neither path checks auth and auth is CRITICAL (a.ts:3)', 'CRITICAL'], ['**Token leak in log.ts:3**\nSeverity: `Critical`', 'Critical']]; + ['Nothing checks the token which is CRITICAL (a.ts:3)', 'CRITICAL'], + ['- Token leak in log.ts:3: `CRITICAL` — attacker reads every session token', 'CRITICAL'], ['1. Token leak (log.ts:3): `High`, reachable from any request', 'High'], + ['Token leak is `CRITICAL` at log.ts:3', 'CRITICAL'], ['a.ts:3 | `High` | race in queue', 'High'], ['| a.ts:3 | maps `FIXABLE` to `CRITICAL` in a comment | Low |', 'Low'], + // Merge-not-drop wins the tie: a line naming a file:line is finding-shaped, so the word rules pick its label but never leave it with none. + ['Nothing here is CRITICAL (checked auth.ts:9)', 'CRITICAL'], ['Neither path checks auth and auth is CRITICAL (a.ts:3)', 'CRITICAL'], ['**Token leak in log.ts:3**\nSeverity: `Critical`', 'Critical']]; for (const [line, label] of kept) expect([line, parseFindings('outside-voice', line).map(f => f.label)]).toEqual([line, [label]]); // Pre-landing review (#3677 Step 11): a summary-led line with a locus or Blocks: yes, or a stronger label than any finding so far, // still collects; a backticked native classification still collects as CRITICAL.