fix(outside-review): read a trailing '— Medium.' or '(High)' severity on a finding line, the shape Codex now writes

This commit is contained in:
garrytan committed 2026-10-08 08:31:25 +00:00
1 parent 2445fbcb93
commit d9d4f34965
2 files changed
+9 -2

No files matched your search

+4 -1
View File
@@ -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<string, Severity> = { 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()]!));
+5 -1
View File
@@ -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 });
}