chorus icon indicating copy to clipboard operation
chorus copied to clipboard

`verdictFromReviewerText` regex gaps cause false-positive APPROVED verdicts

Open brianmarr opened this issue 6 months ago • 0 comments

Summary

verdictFromReviewerText in src/daemon/runner/verdict.ts (dist: dist/daemon/runner/verdict.js) extracts an approve / request-changes / null verdict from each reviewer's English answer. The current regex set and tail-first matching strategy let real "request changes" reviews be classified as APPROVED. Observed in production with simple-review-style review_only chats where both reviewers wrote substantive rejections that ended with a conditional-approval kicker.

Code under discussion

const negatives = /\b(request changes|requesting changes|disagree|reject(?:ed|ing)?|blocker|(?:do not|don['’]?t) (?:approve|merge)|(?:cannot|can['’]?t) (?:approve|merge)|nack)\b/;
const positives = /\b(approve(?:d|s)?|lgtm|looks good to me|no concerns|ship it|ack)\b/;

const tail = stripped.slice(-400).toLowerCase();
if (negatives.test(tail)) return false;
if (positives.test(tail)) return true;
const whole = stripped.toLowerCase();
if (negatives.test(whole)) return false;
if (positives.test(whole)) return true;
return null;

Concrete leak cases

Each of the following reviewer outputs is currently classified APPROVED but is a real rejection:

  1. Third-person requests form. \brequest\b and \brequesting\b are covered; \brequests\b is not. So a reviewer ending with:

    "This change requests changes before merge. I'd approve a revised version."

    Tail-pass: negatives miss (no requests changes in the regex), positives match approve → returns true.

  2. Phrasings outside the negatives vocabulary combined with a positive token in the tail:

    "Several changes are needed before this can ship. I'll approve after the fixes are in."

    changes needed, needs work, not ready, changes required are not in negatives. Tail's approve → returns true.

  3. Tail-first beats body. When the rejection is in the body but the conclusion contains an approve(d|s) token:

    "Request changes. … [400+ chars of substantive critique] … Happy to approve once these are addressed."

    The Request changes line falls outside the last 400 chars; tail contains only approve → returns true. The whole-text fallback never runs because the tail already resolved.

Reproduce

  1. Run any review template (review_only shows it most clearly) where the reviewer prompt elicits substantive critique (e.g. xhigh-effort Claude or Codex reviewers).
  2. Reviewer writes a real rejection that ends with a phrase containing the bare word approve ("I'll approve once …", "would approve a revised version", etc.).
  3. Chat completes with verdict: 'approved' even though both reviewers requested changes.

Why it matters

wait_for_chat and get_chat_status return only {status, verdict, reviewerSummary}. The orchestrating agent gets a misleading top-line answer unless it ALSO reads each ~/.chorus/chats/<chatId>/round-<N>/reviewer-<lineage>/answer.md and re-evaluates. That defeats the point of automated verdict aggregation.

Suggested fixes (any of, in increasing order of invasiveness)

  1. Expand the negatives vocabulary. Cover the missing forms:

    • request(?:s|ed|ing)? changes
    • changes (?:are )?(?:needed|required|requested)
    • not (?:approved|ready|ok|merging)
    • needs (?:work|changes|fixes)
    • would (?:not |n't )approve
    • approve (?:after|once|when|conditional) → reframe conditional approvals as negative
  2. Weight negatives over positives globally, not just within the tail pass. A reviewer that writes ANY explicit rejection phrase ANYWHERE should not flip to APPROVED just because the conclusion has a polite "I'd approve once …" kicker.

  3. Ask reviewers for a structured verdict line. The reviewer prompt (prompt-builder.ts:288-290) already says "Do you approve? Answer: approve or request changes, end with: ## DONE" — could be tightened to require a single-line "VERDICT: approve" / "VERDICT: request_changes" on the line immediately before ## DONE, parsed deterministically. This eliminates the entire heuristic-regex problem at the cost of one extra line in the reviewer template.

(3) is the most robust; (1) is the smallest patch.

Related

Companion to #49 (also opened today): the iterate.onDisagreement: 'accept-doer' enum value is similarly exposed in the schema + cockpit UI but unimplemented in the runner.

brianmarr avatar May 17 '26 02:05 brianmarr