From d9d4f349651cd28e1155d7be09e13c59f89e012c Mon Sep 17 00:00:00 2001 From: garrytan Date: Thu, 8 Oct 2026 08:31:25 +0000 Subject: [PATCH] =?UTF-8?q?fix(outside-review):=20read=20a=20trailing=20'?= =?UTF-8?q?=E2=80=94=20Medium.'=20or=20'(High)'=20severity=20on=20a=20find?= =?UTF-8?q?ing=20line,=20the=20shape=20Codex=20now=20writes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/outside-review-result.ts | 5 ++++- test/outside-review-severity.test.ts | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/outside-review-result.ts b/lib/outside-review-result.ts index 530474bf8..446a4e745 100644 --- a/lib/outside-review-result.ts +++ b/lib/outside-review-result.ts @@ -116,7 +116,8 @@ function execution(input: OutsideReviewInput): OutsideReviewClassification['exec * Severity words count as findings only in label position, never inside prose * ("high-level", "a low-risk change", "no critical findings"): `Severity: High` * or `Priority: high`, a leading `High:` / `High —` / `[High]` (after an - * optional heading, bullet or number), a bold `**High**`, or a table cell. + * optional heading, bullet or number), a bold `**High**`, a table cell, or a + * trailing `… — Medium.` / `… (High)` at the end of a finding line. * Critical and high block like P0/P1; medium and low are advisory like P2/P3. */ const SEVERITY_WORDS: Record = { critical: 'P0', high: 'P1', medium: 'P2', low: 'P3' }; @@ -126,6 +127,8 @@ const SEVERITY_LABELS = [ new RegExp(`^[\\t ]*(?:>[\\t ]*)?(?:#{1,6}[\\t ]+|[-+*][\\t ]+|\\(?\\d{1,3}[.)][\\t ]+)?(?:\\*\\*|__)?\\[?${WORD}\\]?(?:\\*\\*|__)?[\\t ]*(?::|\u2014|\u2013|-[\\t ]|\\]|\\(|\\*\\*[\\t ]*(?:\u2014|\u2013|-[\\t ]))`, 'gim'), new RegExp(`(?:\\*\\*|__)\\[?${WORD}\\]?:?(?:\\*\\*|__)`, 'gi'), new RegExp(`\\|[\\t ]*(?:\\*\\*)?${WORD}(?:\\*\\*)?[\\t ]*(?=\\|)`, 'gi'), + new RegExp(`[\\t ](?:\u2014|\u2013|-)[\\t ]+(?:\\*\\*|__)?${WORD}(?:\\*\\*|__)?[\\t ]*[.;]?[\\t ]*$`, 'gim'), + new RegExp(`\\((?:severity:[\\t ]*)?${WORD}\\)[\\t ]*[.;]?[\\t ]*$`, 'gim'), ]; function severityWords(text: string): Severity[] { return SEVERITY_LABELS.flatMap(re => [...text.matchAll(re)].map(m => SEVERITY_WORDS[m[1]!.toLowerCase()]!)); diff --git a/test/outside-review-severity.test.ts b/test/outside-review-severity.test.ts index 82f6c2b0d..c707ea657 100644 --- a/test/outside-review-severity.test.ts +++ b/test/outside-review-severity.test.ts @@ -49,6 +49,9 @@ describe('severity words count as findings in label position', () => { ['| 1 | high | cap ignored |', 'P1', 'findings'], ['Low: rename the helper.', 'P3', 'clean'], ['Medium: the docs lag.\nLow: a typo.', 'P2', 'clean'], + ['1. The guard trusts the payload without a flush check — High.', 'P1', 'findings'], + ['2. The docs lag the new flag – Medium.', 'P2', 'clean'], + ['- The retry loop never stops (high)', 'P1', 'findings'], ]; for (const [text, highest, verdict] of cases) { const r = classifyOutsideReview({ text: `${text}\n${REC}`, gate: 'review' }); @@ -60,7 +63,8 @@ describe('severity words count as findings in label position', () => { const r = classifyOutsideReview({ text: read('prose-negative.txt'), gate: 'review' }); expect([r.verdict, r.findings.highest]).toEqual(['clean', null]); for (const text of ['A high-level plan.', 'Highly consistent.', 'This is low-risk.', 'A medium-term follow-up.', - 'There are no critical findings.', 'High availability: kept.', 'The high number of retries is fine.', 'Lower the limit.']) { + 'There are no critical findings.', 'High availability: kept.', 'The high number of retries is fine.', 'Lower the limit.', + 'Latency stays low.', 'The cost is high-ish - acceptable.', 'Keep the trade-off low.']) { expect({ text, highest: classifyOutsideReview({ text: `${text}\nNo issues found.\n${REC}`, gate: 'review' }).findings.highest }) .toEqual({ text, highest: null }); }