fix(engine): prevent extractVerdict from matching verdict keywords in review body text
The body-scan fallback (includes("APPROVE") etc.) would misclassify verdicts
when the reviewer mentioned a keyword in context without it being the actual
verdict — e.g. "this does not yet merit APPROVE". Replaced with a
line-anchored regex that only matches "Verdict: X" lines, and expanded the
primary regex to also catch bold/italic formatted verdicts like **Verdict: APPROVE**.
UNAVAILABLE is now the honest fallback when no structured verdict is found,
triggering a retry rather than silently misclassifying.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -338,19 +338,21 @@ function buildReviewRequest(
|
||||
}
|
||||
|
||||
function extractVerdict(review: string): ReviewVerdict {
|
||||
// Look for "### Verdict: APPROVE" or similar patterns
|
||||
// Look for "### Verdict: APPROVE" or "**Verdict: REVISE**" or similar
|
||||
const verdictMatch = review.match(
|
||||
/###?\s*Verdict[:\s]*(APPROVE|REVISE|RETHINK)/i,
|
||||
/(?:###?\s*|[*_]{1,2})Verdict[:\s]*[*_]{0,2}\s*(APPROVE|REVISE|RETHINK)/i,
|
||||
);
|
||||
if (verdictMatch) {
|
||||
return verdictMatch[1].toUpperCase() as ReviewVerdict;
|
||||
}
|
||||
|
||||
// Fallback: look for the word anywhere in the text
|
||||
const upper = review.toUpperCase();
|
||||
if (upper.includes("RETHINK")) return "RETHINK";
|
||||
if (upper.includes("REVISE")) return "REVISE";
|
||||
if (upper.includes("APPROVE")) return "APPROVE";
|
||||
// Fallback: look for a standalone verdict line like "Verdict: APPROVE"
|
||||
const lineFallback = review.match(
|
||||
/^[>\s]*(?:verdict|decision)[:\s]+(APPROVE|REVISE|RETHINK)\b/im,
|
||||
);
|
||||
if (lineFallback) {
|
||||
return lineFallback[1].toUpperCase() as ReviewVerdict;
|
||||
}
|
||||
|
||||
return "UNAVAILABLE";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user