From 9238e6a4231e897c1666bff08a88837a5e12fbe9 Mon Sep 17 00:00:00 2001 From: James Wiesebron Date: Mon, 24 Aug 2026 16:50:00 -0700 Subject: [PATCH 1/3] [agent/pra7-comment-verdict] review: a COMMENT middle verdict when medium findings post and nothing blocks --- .changeset/pra7-comment-verdict.md | 7 ++ workflows/review/lib/cache-record.ts | 6 +- .../lib/dispatch-gate-hardening.test.ts | 15 +++++ workflows/review/lib/dispatch-gate.ts | 15 +++-- workflows/review/lib/render-comment.test.ts | 12 ++++ workflows/review/lib/render-comment.ts | 23 +++++-- workflows/review/lib/rereview-mode.test.ts | 7 ++ workflows/review/lib/rereview-mode.ts | 6 +- .../lib/submission-blocking-medium.test.ts | 58 ++++++++++++++++- workflows/review/lib/submission.ts | 22 +++++-- workflows/review/lib/verdict.test.ts | 65 +++++++++++++++++++ workflows/review/lib/verdict.ts | 47 ++++++++++++-- workflows/review/review.md | 30 +++++---- 13 files changed, 271 insertions(+), 42 deletions(-) create mode 100644 .changeset/pra7-comment-verdict.md diff --git a/.changeset/pra7-comment-verdict.md b/.changeset/pra7-comment-verdict.md new file mode 100644 index 00000000..50438870 --- /dev/null +++ b/.changeset/pra7-comment-verdict.md @@ -0,0 +1,7 @@ +--- +"review": minor +--- + +The COMMENT middle verdict: a run that finds medium-importance findings and nothing blocking now submits a COMMENT review instead of an approval. The verdict stays mechanical (lib/verdict.ts): REQUEST_CHANGES iff a posted claim carries a blocking label (plus the existing floors), COMMENT iff nothing blocks and the post-veto medium count is nonzero (collapsed mediums count too: the verdict follows what the run found, not which surface showed it, the same invariant that keeps a 21st blocking claim blocking), APPROVE otherwise. COMMENT outranks HOLD_FOR_HUMAN deliberately: the hold exists to stop the automation approving what its core passes never checked, and a COMMENT approves nothing while carrying actionable findings, so a missing core pass is disclosed in the note lines rather than held on. A vetoed medium demotes nothing. The stamp and cache-record machinery accept the new verdict (a COMMENT run still records its fingerprint, so re-review depth planning is unaffected), the conformance gate's no-blocking-inline rule covers COMMENT the same as APPROVE, and the frontmatter's allowed-events gains COMMENT (consumers inherit it at bump time; the gh-aw engine passes the event through to GitHub's review API). + +Expected output-shape effect: no change to inline comment count or body sizes; the review event changes from APPROVE to COMMENT exactly when the medium count is nonzero, and the body head reads "Commented — medium-importance findings posted; nothing blocks." instead of the approval line. Authors keep a clean green approval only when the run found nothing worth fixing before merge. diff --git a/workflows/review/lib/cache-record.ts b/workflows/review/lib/cache-record.ts index 3808bfd5..f7ff03e7 100644 --- a/workflows/review/lib/cache-record.ts +++ b/workflows/review/lib/cache-record.ts @@ -381,7 +381,11 @@ export const runCacheRecordCli = ( } return dropRisksPatternsKey(fs, "hold"); } - if (plan.event !== "APPROVE" && plan.event !== "REQUEST_CHANGES") { + if ( + plan.event !== "APPROVE" && + plan.event !== "COMMENT" && + plan.event !== "REQUEST_CHANGES" + ) { return refuse("the staged plan carries no submittable event"); } diff --git a/workflows/review/lib/dispatch-gate-hardening.test.ts b/workflows/review/lib/dispatch-gate-hardening.test.ts index 40211e88..bce789df 100644 --- a/workflows/review/lib/dispatch-gate-hardening.test.ts +++ b/workflows/review/lib/dispatch-gate-hardening.test.ts @@ -350,6 +350,21 @@ describe("verdict and resolution chokepoints (slice 3)", () => { expect(result.violations.map((v) => v.code)).toEqual([ "approve-with-blocking-comment", ]); + // The COMMENT verdict is checked the same way: it exists for the + // medium-and-below population, never for blocking findings. + const comment = evaluate({ + ...conforming(), + items: [ + commentItem(2, "**issue (blocking):** guard removed"), + submitItem( + "COMMENT", + "Commented — medium-importance findings posted; nothing blocks.", + ), + ], + }); + expect(comment.violations.map((v) => v.code)).toEqual([ + "approve-with-blocking-comment", + ]); // The same comment under REQUEST_CHANGES is the conforming shape. const rc = evaluate({ ...conforming(), diff --git a/workflows/review/lib/dispatch-gate.ts b/workflows/review/lib/dispatch-gate.ts index 87330c9c..987e4e5d 100644 --- a/workflows/review/lib/dispatch-gate.ts +++ b/workflows/review/lib/dispatch-gate.ts @@ -399,12 +399,13 @@ export const evaluateDispatchConformance = ( } } - // Rule 4: an APPROVE cannot carry a blocking inline comment (Step 4 is a - // mechanical function of the labels: a surviving validated blocking - // finding means REQUEST_CHANGES at every depth). The inverse direction is - // legitimate (a REQUEST_CHANGES may ride entirely on kept prior threads), - // so only the APPROVE direction is enforced. - if (verdictEvent === "APPROVE") { + // Rule 4: neither an APPROVE nor a COMMENT can carry a blocking inline + // comment (Step 4 is a mechanical function of the labels: a surviving + // validated blocking finding means REQUEST_CHANGES at every depth; the + // COMMENT verdict exists only for the medium-and-below population). The + // inverse direction is legitimate (a REQUEST_CHANGES may ride entirely + // on kept prior threads), so only the non-blocking verdicts are checked. + if (verdictEvent === "APPROVE" || verdictEvent === "COMMENT") { for (const item of input.items) { if (item.type !== COMMENT_TYPE || typeof item.body !== "string") { continue; @@ -415,7 +416,7 @@ export const evaluateDispatchConformance = ( code: "approve-with-blocking-comment", dimension: "verdict", detail: - `APPROVE queued alongside an inline comment labeled "${label}" ` + + `${verdictEvent} queued alongside an inline comment labeled "${label}" ` + `(a surviving blocking finding mechanically requires REQUEST_CHANGES)`, }); break; diff --git a/workflows/review/lib/render-comment.test.ts b/workflows/review/lib/render-comment.test.ts index 99c1a4c5..58f6d64c 100644 --- a/workflows/review/lib/render-comment.test.ts +++ b/workflows/review/lib/render-comment.test.ts @@ -388,3 +388,15 @@ describe("renderReviewBody — one non-empty line per verdict (+ notes)", () => `); }); }); + +describe("renderReviewBody — the COMMENT verdict", () => { + it("always carries the middle verdict's head", () => { + const body = renderReviewBody({ + event: "COMMENT", + hasInlineComments: true, + }); + expect(body).toContain( + "Commented — medium-importance findings posted; nothing blocks.", + ); + }); +}); diff --git a/workflows/review/lib/render-comment.ts b/workflows/review/lib/render-comment.ts index 9b23737b..7edb7d1f 100644 --- a/workflows/review/lib/render-comment.ts +++ b/workflows/review/lib/render-comment.ts @@ -22,17 +22,24 @@ import type {Anchor, Finding, Lens} from "./finding-schema"; /** * The review-outcome vocabulary. `APPROVE` / `REQUEST_CHANGES` are #194's - * mechanical events; `HOLD_FOR_HUMAN` is the third outcome (missing-core - * dimension gate + policy-named conflicts). It is not a GitHub review event — - * `review.md` only allows `[APPROVE, REQUEST_CHANGES]` — so the orchestrator - * surfaces a hold by pulling in a human rather than auto-submitting an approval. + * mechanical events. `COMMENT` is the middle verdict (PRA-7): the run found + * medium-importance findings and nothing blocking, so it neither vouches for + * the change nor demands another round; it IS a GitHub review event, and the + * findings post exactly as they would on an approval. `HOLD_FOR_HUMAN` is + * the coverage outcome (missing-core dimension gate + policy-named + * conflicts); it is NOT a GitHub review event, so the orchestrator surfaces + * a hold by pulling in a human rather than auto-submitting anything. * * Defined here (the rendering module) rather than in `verdict.ts` so the import * graph has a single direction (`verdict.ts` -> `render-comment.ts`) with no * cycle: rendering is the lower-level presentation vocabulary, verdict is the * policy computed on top of it. */ -export type VerdictEvent = "APPROVE" | "REQUEST_CHANGES" | "HOLD_FOR_HUMAN"; +export type VerdictEvent = + | "APPROVE" + | "COMMENT" + | "REQUEST_CHANGES" + | "HOLD_FOR_HUMAN"; /** * The Conventional-Comment labels that drive REQUEST_CHANGES under #194's @@ -324,6 +331,12 @@ export const renderReviewBody = (input: ReviewBodyInput): string => { // make the event non-empty: the pointer line is unconditional. head = "Changes requested — see inline comments."; break; + case "COMMENT": + // The middle verdict never has an empty body either: the head is + // what tells an author this is deliberately not an approval. + head = + "Commented — medium-importance findings posted; nothing blocks."; + break; case "HOLD_FOR_HUMAN": head = HOLD_HEAD; break; diff --git a/workflows/review/lib/rereview-mode.test.ts b/workflows/review/lib/rereview-mode.test.ts index 72608eb4..1cc1ded1 100644 --- a/workflows/review/lib/rereview-mode.test.ts +++ b/workflows/review/lib/rereview-mode.test.ts @@ -601,6 +601,13 @@ describe("stampFromCacheMemory", () => { }); }); + it("accepts a COMMENT verdict record (the PRA-7 middle verdict)", () => { + const stamp = stampFromCacheMemory( + JSON.parse(cacheRecord({verdict: "COMMENT"})), + ); + expect(stamp?.verdict).toBe("COMMENT"); + }); + it.each([ ["missing verdict", {verdict: undefined}], ["unknown verdict", {verdict: "COMMENTED"}], diff --git a/workflows/review/lib/rereview-mode.ts b/workflows/review/lib/rereview-mode.ts index 8284c06a..3e53783b 100644 --- a/workflows/review/lib/rereview-mode.ts +++ b/workflows/review/lib/rereview-mode.ts @@ -361,7 +361,11 @@ export const stampFromCacheMemory = (raw: unknown): ReReviewStamp | null => { reviewedHunks?: unknown; wasDraft?: unknown; }; - if (record.verdict !== "APPROVE" && record.verdict !== "REQUEST_CHANGES") { + if ( + record.verdict !== "APPROVE" && + record.verdict !== "COMMENT" && + record.verdict !== "REQUEST_CHANGES" + ) { return null; } if (typeof record.wasDraft !== "boolean") { diff --git a/workflows/review/lib/submission-blocking-medium.test.ts b/workflows/review/lib/submission-blocking-medium.test.ts index 338a2533..dff56928 100644 --- a/workflows/review/lib/submission-blocking-medium.test.ts +++ b/workflows/review/lib/submission-blocking-medium.test.ts @@ -96,7 +96,12 @@ describe("runSubmissionCli: re-review blocking-medium", () => { }), ); const plan = runSubmissionCli(fs); - expect(plan.event).toBe("APPROVE"); + // A posted medium demotes the would-be approval to the middle + // verdict (PRA-7): the run neither vouches nor demands a round. + expect(plan.event).toBe("COMMENT"); + expect(plan.body).toContain( + "Commented — medium-importance findings posted; nothing blocks.", + ); expect(plan.comments).toHaveLength(1); expect(plan.comments[0].line).toBe(2); expect(plan.body).toContain( @@ -283,3 +288,54 @@ describe("the veto's diff sources", () => { ); }); }); + +describe("the COMMENT verdict", () => { + it("a vetoed medium does not demote the approval", () => { + // Line 40 is outside the diff: the tier is stripped, the medium + // count is 0, and the verdict stays APPROVE. + const fs = makeFakeFs( + staged({ + depth: "scoped", + claims: [ + claim({id: "drifted", line: 40, importance: "medium"}), + ], + }), + ); + expect(runSubmissionCli(fs).event).toBe("APPROVE"); + }); + + it("a collapsed medium still demotes (the verdict follows what the run found)", () => { + // Strict blocking-only collapses the medium's surface, but the + // finding was verified and anchored: the verdict comments anyway, + // same invariant that keeps a collapsed blocking claim blocking. + const fs = makeFakeFs( + staged( + { + depth: "scoped", + claims: [claim({id: "medium", importance: "medium"})], + }, + {reReviewBlockingOnly: true}, + ), + ); + const plan = runSubmissionCli(fs); + expect(plan.comments).toHaveLength(0); + expect(plan.event).toBe("COMMENT"); + }); + + it("blocking still outranks medium", () => { + const fs = makeFakeFs( + staged({ + depth: "scoped", + claims: [ + claim({id: "medium", importance: "medium"}), + claim({ + id: "blocking", + line: 9, + label: "issue (blocking)", + }), + ], + }), + ); + expect(runSubmissionCli(fs).event).toBe("REQUEST_CHANGES"); + }); +}); diff --git a/workflows/review/lib/submission.ts b/workflows/review/lib/submission.ts index 4865b768..e6611c88 100644 --- a/workflows/review/lib/submission.ts +++ b/workflows/review/lib/submission.ts @@ -133,7 +133,7 @@ export type SubmissionPlan = { * HOLD_FOR_HUMAN, which submits NO review — the orchestrator posts * `body` as one standalone PR comment instead (Step 6's hold branch). */ - event: "APPROVE" | "REQUEST_CHANGES" | "HOLD_FOR_HUMAN"; + event: "APPROVE" | "COMMENT" | "REQUEST_CHANGES" | "HOLD_FOR_HUMAN"; /** * The full text to post verbatim: the review body (stamp included) for * a review event, or the hold comment (never stamped) for a hold. @@ -421,11 +421,10 @@ export const runSubmissionCli = ( // roster uses the tier at all is unobservable from posted output alone // (under-use looks exactly like the pre-tier surface), so every plan // records its post-veto medium count, zero included. - notes.push( - `medium-importance claims this run: ${ - vetoed.filter((claim) => claim.importance === "medium").length - }`, - ); + const mediumCount = vetoed.filter( + (claim) => claim.importance === "medium", + ).length; + notes.push(`medium-importance claims this run: ${mediumCount}`); // Stage the code-computed risks/patterns signature (trial suggestion b): // Step 7 compares THIS string against cache memory's `risksPatternsKey` @@ -581,6 +580,11 @@ export const runSubmissionCli = ( patternTriage: dimensionStatus(TRIAGE_DIMENSION), }, keptBlockingCount: keptBlockingFloor + suppressedBlocking, + // The middle verdict's signal (PRA-7): post-veto mediums, the same + // count the notes line records. Collapsed mediums count too; the + // verdict follows what the run FOUND, not which surface showed it + // (the same invariant that keeps a 21st blocking claim blocking). + mediumCount, }); // The depth note (Step 3), when the run reduced. @@ -874,7 +878,11 @@ export const runSubmissionCli = ( }); const event = - verdict.event === "REQUEST_CHANGES" ? "REQUEST_CHANGES" : "APPROVE"; + verdict.event === "REQUEST_CHANGES" + ? "REQUEST_CHANGES" + : verdict.event === "COMMENT" + ? "COMMENT" + : "APPROVE"; const head = renderReviewBody({ event, diff --git a/workflows/review/lib/verdict.test.ts b/workflows/review/lib/verdict.test.ts index 63c155e9..3454e909 100644 --- a/workflows/review/lib/verdict.test.ts +++ b/workflows/review/lib/verdict.test.ts @@ -297,3 +297,68 @@ describe("computeVerdict — purity", () => { expect(conflicts).toEqual([{policy: "p", detail: "d"}]); }); }); + +describe("the COMMENT verdict (the PRA-7 middle outcome)", () => { + const assessed = { + correctness: "assessed", + skillSeverity: "assessed", + patternTriage: "assessed", + } as const; + + it("mediums demote a would-be approval to COMMENT, with a reason", () => { + const verdict = computeVerdict({ + postedLabels: ["note (non-blocking)"], + dimensions: assessed, + mediumCount: 2, + }); + expect(verdict.event).toBe("COMMENT"); + expect(verdict.reasons).toContainEqual({ + code: "medium-importance", + count: 2, + }); + }); + + it("blocking outranks medium", () => { + expect( + computeVerdict({ + postedLabels: ["issue (blocking)"], + dimensions: assessed, + mediumCount: 1, + }).event, + ).toBe("REQUEST_CHANGES"); + }); + + it("a kept blocking thread outranks medium too", () => { + expect( + computeVerdict({ + postedLabels: [], + dimensions: assessed, + mediumCount: 1, + keptBlockingCount: 1, + }).event, + ).toBe("REQUEST_CHANGES"); + }); + + it("COMMENT outranks the hold: a comment approves nothing, so the missing core pass is disclosed, not held on", () => { + const verdict = computeVerdict({ + postedLabels: ["note (non-blocking)"], + dimensions: {...assessed, correctness: "unavailable"}, + mediumCount: 1, + }); + expect(verdict.event).toBe("COMMENT"); + expect(verdict.reasons).toContainEqual({ + code: "core-dimension-unavailable", + dimension: "correctness", + }); + }); + + it("zero mediums keeps the approval", () => { + expect( + computeVerdict({ + postedLabels: ["note (non-blocking)"], + dimensions: assessed, + mediumCount: 0, + }).event, + ).toBe("APPROVE"); + }); +}); diff --git a/workflows/review/lib/verdict.ts b/workflows/review/lib/verdict.ts index dd4dfc47..cbdf0fd8 100644 --- a/workflows/review/lib/verdict.ts +++ b/workflows/review/lib/verdict.ts @@ -2,9 +2,11 @@ * The computed review verdict. * * The verdict is a pure function of (1) the Conventional-Comment labels on the - * comments that will actually be posted, (2) which review dimensions were - * assessed this run, and (3) any policy-named conflicts a lens flagged. It emits - * one of three events with a machine-readable list of reasons. No prose is + * comments that will actually be posted, (2) the posted claims' medium tier + * (PRA-7: mediums demote a would-be approval to COMMENT), (3) which review + * dimensions were assessed this run, and (4) any policy-named conflicts a + * lens flagged. It emits one of four events with a machine-readable list of + * reasons. No prose is * synthesised here: reasons are structured records, not * sentences about the code. * @@ -86,7 +88,8 @@ export type VerdictReason = | {code: "core-dimension-unavailable"; dimension: CoreDimension} | {code: "pattern-triage-unavailable"} | {code: "policy-conflict"; policy: string; detail: string} - | {code: "kept-blocking-thread"; count: number}; + | {code: "kept-blocking-thread"; count: number} + | {code: "medium-importance"; count: number}; export type Verdict = { event: VerdictEvent; @@ -110,6 +113,15 @@ export type VerdictInput = { * never REQUEST_CHANGES regardless of this value. */ blockingThreshold?: number; + /** + * How many posted claims carry the medium importance tier (post-veto; + * the count the plan's notes record). Any nonzero value demotes a + * would-be APPROVE to COMMENT (PRA-7): a verified finding worth fixing + * before merge should not ride under an approval, and the middle + * verdict says so without demanding another round. Never affects + * REQUEST_CHANGES. Absent means zero. + */ + mediumCount?: number; /** * How many prior review threads with a blocking opening label the * reconciler KEPT this run (`rereview.json` `keptBlockingCount`). The @@ -145,7 +157,7 @@ export const DEFAULT_BLOCKING_THRESHOLD = 1; * input always yields the same verdict, which is what makes the determinism * boundary testable. * - * Precedence is REQUEST_CHANGES > HOLD_FOR_HUMAN > APPROVE: + * Precedence is REQUEST_CHANGES > COMMENT > HOLD_FOR_HUMAN > APPROVE: * * 1. If the blocking-label count meets the threshold -> REQUEST_CHANGES. A * blocking finding is actionable on its own: the author gets concrete @@ -153,10 +165,17 @@ export const DEFAULT_BLOCKING_THRESHOLD = 1; * after those changes retries the failed dimension anyway. Any missing * core dimension or policy conflict is still recorded in `reasons` (and * rendered into the body), so nothing is hidden. - * 2. Otherwise, if any core dimension is unavailable or any policy conflict + * 2. Otherwise, if any posted claim carries the medium tier -> COMMENT. + * The middle verdict outranks the hold deliberately: the hold exists + * to stop the automation APPROVING what its core passes never checked, + * and a COMMENT approves nothing, while the medium findings are + * actionable feedback the author can already use (a missing core + * dimension is still recorded in `reasons` and disclosed in the body's + * note lines). + * 3. Otherwise, if any core dimension is unavailable or any policy conflict * is present, the run must not resolve to an approval the automation * cannot stand behind -> HOLD_FOR_HUMAN. - * 3. Otherwise -> APPROVE. + * 4. Otherwise -> APPROVE. * * The hold therefore only ever replaces what would otherwise have been an * auto-approval; it never sits in front of feedback the author could already @@ -212,6 +231,12 @@ export const computeVerdict = (input: VerdictInput): Verdict => { // A run with zero blocking labels is never REQUEST_CHANGES (review.md // Step 4) — unless a prior review's blocking thread is still open, in // which case the earlier objection is the actionable feedback. + // (f) Medium-importance claims — the PRA-7 middle verdict's signal. + const mediumCount = input.mediumCount ?? 0; + if (mediumCount > 0) { + reasons.push({code: "medium-importance", count: mediumCount}); + } + if ( (blockingLabelCount > 0 && blockingLabelCount >= threshold) || keptBlocking > 0 @@ -219,6 +244,14 @@ export const computeVerdict = (input: VerdictInput): Verdict => { return {event: "REQUEST_CHANGES", reasons}; } + // The middle verdict: verified worth-fixing findings, nothing blocking. + // Ahead of the hold on purpose (see the precedence note above): a + // COMMENT approves nothing, so the hold's never-approve-unchecked + // premise is not violated, and the author gets the findings. + if (mediumCount > 0) { + return {event: "COMMENT", reasons}; + } + // The hold only ever replaces what would otherwise be an auto-approval. if (missingCore.length > 0 || policyConflicts.length > 0) { return {event: "HOLD_FOR_HUMAN", reasons}; diff --git a/workflows/review/review.md b/workflows/review/review.md index 803c9af6..643ee7c3 100644 --- a/workflows/review/review.md +++ b/workflows/review/review.md @@ -85,7 +85,7 @@ safe-outputs: side: "RIGHT" submit-pull-request-review: max: 1 - allowed-events: [APPROVE, REQUEST_CHANGES] + allowed-events: [APPROVE, COMMENT, REQUEST_CHANGES] footer: false # Resolve this workflow's own earlier review threads once their issue is addressed # (Step 7), instead of replying. Uses the bot token because the default GITHUB_TOKEN @@ -882,14 +882,18 @@ cd gh-aw-review-lib && npx -y tsx workflows/review/lib/submission.ts The verdict is computed by the plan CLI (Step 3), never by you: REQUEST_CHANGES iff a validated posted claim carries a blocking label, plus the reduced-depth -flip floor over kept blocking threads and the open-thread suppression floor — -all `lib/verdict.ts` / `lib/submission.ts` rules. A third outcome exists: -HOLD_FOR_HUMAN, when a core review pass (`correctness-reviewer` or -`skill-auditor`) produced no usable output this run and the run would -otherwise have auto-approved — the automation never approves a change its -core passes did not look at (a blocking finding still wins: it is actionable -on its own, so the verdict stays REQUEST_CHANGES and the gap is disclosed in -a note line). The plan's `event` IS the +flip floor over kept blocking threads and the open-thread suppression floor; +COMMENT when nothing blocks but at least one posted claim carries the medium +importance tier (a verified finding worth fixing before merge should not ride +under an approval, and the middle verdict says so without demanding another +round); APPROVE otherwise — all `lib/verdict.ts` / `lib/submission.ts` rules. +A fourth outcome exists: HOLD_FOR_HUMAN, when a core review pass +(`correctness-reviewer` or `skill-auditor`) produced no usable output this +run and the run would otherwise have auto-approved — the automation never +approves a change its core passes did not look at (a blocking finding still +wins, and a medium finding still comments: both are actionable on their own, +so the hold only ever replaces a would-be APPROVE and the gap is disclosed +in a note line). The plan's `event` IS the verdict; never recompute, second-guess, or override it. (The blocking-label vocabulary and the concrete-failing-scenario bar live in the sub-agent definitions and the shared lib.) @@ -935,8 +939,8 @@ review, posts inline comments, resolves threads, or drops the comment. ## Step 7: On Approval — Post Risk and Patterns as a PR Comment -**Only run this step when the verdict is APPROVE.** When requesting changes, skip -it entirely and post no comment. Also skip it entirely on a reduced re-review +**Only run this step when the verdict is APPROVE.** On REQUEST_CHANGES or +COMMENT, skip it entirely and post no comment. Also skip it entirely on a reduced re-review depth (`scoped`, `flip-gated`, `fast`; Step 3): the reduced run computed no triage or risk data to compare, so the existing comment stands and `risksPatternsKey` carries forward unchanged (Step 9). @@ -1137,8 +1141,8 @@ fully explained by a common pattern above: ## Step 8: On Approval — Request the Owning Teams as Reviewers -**Only run this step when the verdict is APPROVE.** Skip it entirely when -requesting changes. Also skip it entirely when `correctness-reviewer` did not run +**Only run this step when the verdict is APPROVE.** Skip it entirely on +REQUEST_CHANGES or COMMENT. Also skip it entirely when `correctness-reviewer` did not run this run (a `flip-gated` or `fast` re-review depth, Step 3): there are no fresh risk classifications to route on, and the anchoring full review already requested the owning teams. From 0d61b8445a0a0785669beaca78af50a763dd90b5 Mon Sep 17 00:00:00 2001 From: James Wiesebron Date: Mon, 24 Aug 2026 17:39:59 -0700 Subject: [PATCH 2/3] [agent/pra7-comment-verdict] review: address #384 feedback; the prompt stops denying the verdict, counters gain COMMENT --- .changeset/pra7-comment-verdict.md | 2 +- workflows/review/README.md | 18 ++-- workflows/review/eval/runner.ts | 8 ++ workflows/review/lib/cache-record.test.ts | 30 ++++++ workflows/review/lib/counters-report.test.ts | 2 +- workflows/review/lib/counters-report.ts | 10 +- workflows/review/lib/counters.ts | 2 + workflows/review/lib/dispatch-contracts.ts | 11 ++- .../lib/dispatch-gate-hardening.test.ts | 2 +- workflows/review/lib/dispatch-gate.ts | 9 +- workflows/review/lib/finding-schema.ts | 18 ++-- workflows/review/lib/render-comment.test.ts | 2 +- workflows/review/lib/render-comment.ts | 12 ++- .../lib/submission-blocking-medium.test.ts | 2 +- workflows/review/lib/verdict.ts | 9 +- workflows/review/review.md | 97 ++++++++++--------- 16 files changed, 150 insertions(+), 84 deletions(-) diff --git a/.changeset/pra7-comment-verdict.md b/.changeset/pra7-comment-verdict.md index 50438870..fa47e3b6 100644 --- a/.changeset/pra7-comment-verdict.md +++ b/.changeset/pra7-comment-verdict.md @@ -4,4 +4,4 @@ The COMMENT middle verdict: a run that finds medium-importance findings and nothing blocking now submits a COMMENT review instead of an approval. The verdict stays mechanical (lib/verdict.ts): REQUEST_CHANGES iff a posted claim carries a blocking label (plus the existing floors), COMMENT iff nothing blocks and the post-veto medium count is nonzero (collapsed mediums count too: the verdict follows what the run found, not which surface showed it, the same invariant that keeps a 21st blocking claim blocking), APPROVE otherwise. COMMENT outranks HOLD_FOR_HUMAN deliberately: the hold exists to stop the automation approving what its core passes never checked, and a COMMENT approves nothing while carrying actionable findings, so a missing core pass is disclosed in the note lines rather than held on. A vetoed medium demotes nothing. The stamp and cache-record machinery accept the new verdict (a COMMENT run still records its fingerprint, so re-review depth planning is unaffected), the conformance gate's no-blocking-inline rule covers COMMENT the same as APPROVE, and the frontmatter's allowed-events gains COMMENT (consumers inherit it at bump time; the gh-aw engine passes the event through to GitHub's review API). -Expected output-shape effect: no change to inline comment count or body sizes; the review event changes from APPROVE to COMMENT exactly when the medium count is nonzero, and the body head reads "Commented — medium-importance findings posted; nothing blocks." instead of the approval line. Authors keep a clean green approval only when the run found nothing worth fixing before merge. +Expected output-shape effect: no change to inline comment count or body sizes; the review event changes from APPROVE to COMMENT exactly when the medium count is nonzero, and the body head reads "Commented — medium-importance findings found; nothing blocks." instead of the approval line. Authors keep a clean green approval only when the run found nothing worth fixing before merge. diff --git a/workflows/review/README.md b/workflows/review/README.md index 7817523f..d79668f2 100644 --- a/workflows/review/README.md +++ b/workflows/review/README.md @@ -72,9 +72,12 @@ read-only **sub-agents** (it makes every GitHub and comment call itself): about a mechanism that predates the diff is confirmed only when the diff materially amplifies its consequence and the finding says so. -The workflow then posts the per-line Conventional Comments that survived validation, -submits an approve / request-changes review, and on approval posts the risk/patterns -summary and requests the owning teams. The config files below feed these sub-agents. +The workflow then posts the per-line Conventional Comments that survived validation +and submits an approve, comment, or request-changes review: changes are requested +iff a blocking finding survived, the run comments (without approving) when its +findings top out at the medium importance tier, and it approves only when it found +nothing worth fixing before merge. On approval it also posts the risk/patterns +summary; on approval or comment it requests the owning teams. The config files below feed these sub-agents. A mechanical gate and a budget guardrail sit between the reviewers and the PR. The **change-provenance gate** (enforced in code against the diff's parsed changed-line @@ -98,7 +101,7 @@ every safe output during the agent run and executes the queue from a separate verdict and findings against the staged `out/` sub-agent outputs (per re-review depth: the correctness pass wherever the depth dispatches one, the claim-validator whenever findings post, a disclosure note for every planned -shed, no blocking inline comment under an APPROVE, the reduced-depth flip veto +shed, no blocking inline comment under an APPROVE or COMMENT, the reduced-depth flip veto over kept blocking threads, and every queued thread resolution backed by the reconciler's decision) and, on violation, strips the posting items from the queue and fails the job. A run that skipped its own dispatch protocol (observed in production: @@ -614,8 +617,11 @@ posting inline, spending the non-blocking budget. Motivating case for preferring it over strict `blocking-only`: three 2026-08-24 approving re-reviews on this repo collapsed verified correctness findings behind a bare "Non-blocking observations (N)" count (#367's "the reply guard never fires" -among them). `blocking-only` stays available as the rollback dial if the -medium tier inflates on a consumer. At most one modifier per `re-review` +among them). `blocking-only` stays available as the rollback dial for the +inline surface if the medium tier inflates on a consumer; note it quiets the +posting surface only — the verdict follows the medium count regardless, so +sustained inflation is a calibration fix (reviewer prompts, validator +adjudication), not a ROUTING dial. At most one modifier per `re-review` line; a later line replaces an earlier one. The dial is a measured change, not a default change: it ships `full` diff --git a/workflows/review/eval/runner.ts b/workflows/review/eval/runner.ts index 8bb1b975..c165e614 100644 --- a/workflows/review/eval/runner.ts +++ b/workflows/review/eval/runner.ts @@ -465,6 +465,14 @@ export const runCase = ( dimensions: toDimensionReport(corpusCase.dimensions), policyConflicts: corpusCase.policyConflicts, keptBlockingCount, + // The PRA-7 middle-verdict signal, mirrored from submission.ts so + // the offline replica plans the same event the shipped path would + // submit. The harness has no changed-lines veto (fixtures are + // hand-anchored), so this is the pre-veto count; a fixture that + // wants a vetoed medium models it as advisory. + mediumCount: postedCandidates.filter( + (candidate) => candidate.finding.severity === "medium", + ).length, ...(options.blockingThreshold !== undefined ? {blockingThreshold: options.blockingThreshold} : {}), diff --git a/workflows/review/lib/cache-record.test.ts b/workflows/review/lib/cache-record.test.ts index 0fd50c9f..1453f634 100644 --- a/workflows/review/lib/cache-record.test.ts +++ b/workflows/review/lib/cache-record.test.ts @@ -202,6 +202,36 @@ describe("runCacheRecordCli", () => { }); }); + it("records a COMMENT verdict like any submittable event (the PRA-7 middle verdict)", () => { + const fs = makeFakeFs( + staged({ + [`${REVIEW}/submission-plan.json`]: JSON.stringify({ + event: "COMMENT", + comments: [{path: "a.ts", line: 2, body: "b"}], + }), + [QUEUE]: JSON.stringify({ + items: [ + { + type: "submit_pull_request_review", + event: "COMMENT", + }, + { + type: "create_pull_request_review_comment", + path: "a.ts", + }, + ], + }), + }), + ); + const result = runCacheRecordCli(fs, NOW); + expect(result.written).toBe(true); + const record = JSON.parse(fs.files[`${CACHE}/pr-41.json`]); + // A COMMENT run still records its fingerprint, so the next run's + // depth planning is unaffected. + expect(record.verdict).toBe("COMMENT"); + expect(record.reviewedHunks).toEqual(HUNKS); + }); + it("no-ops without a staged plan (the orchestrator's write stands)", () => { const fs = makeFakeFs(); const result = runCacheRecordCli(fs, NOW); diff --git a/workflows/review/lib/counters-report.test.ts b/workflows/review/lib/counters-report.test.ts index 4e6bf776..62c8c364 100644 --- a/workflows/review/lib/counters-report.test.ts +++ b/workflows/review/lib/counters-report.test.ts @@ -221,7 +221,7 @@ describe("renderCountersMarkdown", () => { ]); const markdown = renderCountersMarkdown(counters, 1); expect(markdown).toContain("Aggregated over **2** review runs"); - expect(markdown).toContain("| 1 | 0 | 1 |"); + expect(markdown).toContain("| 1 | 0 | 0 | 1 |"); expect(markdown).toContain("*1 run(s) submitted no review"); expect(markdown).toContain("| (unknown) | 2 | 1 | 50.0% |"); expect(markdown).toContain("$4.20 total"); diff --git a/workflows/review/lib/counters-report.ts b/workflows/review/lib/counters-report.ts index be78087a..8d733e37 100644 --- a/workflows/review/lib/counters-report.ts +++ b/workflows/review/lib/counters-report.ts @@ -110,7 +110,9 @@ export const synthesizeSummaryFromGhAw = ( } const event = entry["event"]; if ( - (event === "APPROVE" || event === "REQUEST_CHANGES") && + (event === "APPROVE" || + event === "COMMENT" || + event === "REQUEST_CHANGES") && summary["verdict"] !== "REQUEST_CHANGES" ) { summary["verdict"] = event; @@ -293,9 +295,9 @@ export const renderCountersMarkdown = ( "", "### Verdict mix", "", - "| APPROVE | REQUEST_CHANGES | HOLD_FOR_HUMAN* |", - "| --- | --- | --- |", - `| ${counters.verdictMix.APPROVE} | ${counters.verdictMix.REQUEST_CHANGES} | ${counters.verdictMix.HOLD_FOR_HUMAN} |`, + "| APPROVE | COMMENT | REQUEST_CHANGES | HOLD_FOR_HUMAN* |", + "| --- | --- | --- | --- |", + `| ${counters.verdictMix.APPROVE} | ${counters.verdictMix.COMMENT} | ${counters.verdictMix.REQUEST_CHANGES} | ${counters.verdictMix.HOLD_FOR_HUMAN} |`, "", `*${runsWithoutVerdict} run(s) submitted no review this window (e.g. the` + " redundant-approval skip) and count under the HOLD_FOR_HUMAN fallback.", diff --git a/workflows/review/lib/counters.ts b/workflows/review/lib/counters.ts index 46226f5f..416f53ca 100644 --- a/workflows/review/lib/counters.ts +++ b/workflows/review/lib/counters.ts @@ -162,6 +162,7 @@ export type RefusalFallbackCounter = { /** A fresh verdict histogram with every event key initialised to `0`. */ export const emptyVerdictMix = (): VerdictMix => ({ APPROVE: 0, + COMMENT: 0, REQUEST_CHANGES: 0, HOLD_FOR_HUMAN: 0, }); @@ -341,6 +342,7 @@ const asFiniteNumber = (value: unknown): number | undefined => const isVerdictEvent = (value: unknown): value is VerdictEvent => value === "APPROVE" || + value === "COMMENT" || value === "REQUEST_CHANGES" || value === "HOLD_FOR_HUMAN"; diff --git a/workflows/review/lib/dispatch-contracts.ts b/workflows/review/lib/dispatch-contracts.ts index f9fe8736..5f9fd416 100644 --- a/workflows/review/lib/dispatch-contracts.ts +++ b/workflows/review/lib/dispatch-contracts.ts @@ -683,11 +683,12 @@ export type Claim = { * The medium-importance tier (PRA-7): present (as `"medium"`) on a * claim whose finding carried `severity: "medium"` — a verified defect * or gap in code this PR adds, that a reasonable author would fix - * before merge, but that does not block. Absent means minor. Never a - * verdict input (the label carries blocking-ness); the posting surface - * (submission.ts) ranks medium claims ahead of minor ones for the - * non-blocking inline budget and posts them inline on `blocking-medium` - * re-reviews. The claim-validator adjudicates it (`corrected.importance` + * before merge, but that does not block. Absent means minor. It can + * never force REQUEST_CHANGES (the label carries blocking-ness); the + * posting surface (submission.ts) ranks medium claims ahead of minor + * ones for the non-blocking inline budget and posts them inline on + * `blocking-medium` re-reviews, and a nonzero post-veto medium count + * demotes a would-be APPROVE to COMMENT (verdict.ts). The claim-validator adjudicates it (`corrected.importance` * both directions), a `plausible` verification strips it (unconfirmed * fails the tier's "verified" test), and {@link applyMediumVeto} strips * it from any claim not anchored on a line this PR added. diff --git a/workflows/review/lib/dispatch-gate-hardening.test.ts b/workflows/review/lib/dispatch-gate-hardening.test.ts index bce789df..2768d5c9 100644 --- a/workflows/review/lib/dispatch-gate-hardening.test.ts +++ b/workflows/review/lib/dispatch-gate-hardening.test.ts @@ -358,7 +358,7 @@ describe("verdict and resolution chokepoints (slice 3)", () => { commentItem(2, "**issue (blocking):** guard removed"), submitItem( "COMMENT", - "Commented — medium-importance findings posted; nothing blocks.", + "Commented — medium-importance findings found; nothing blocks.", ), ], }); diff --git a/workflows/review/lib/dispatch-gate.ts b/workflows/review/lib/dispatch-gate.ts index 987e4e5d..f9fe2adb 100644 --- a/workflows/review/lib/dispatch-gate.ts +++ b/workflows/review/lib/dispatch-gate.ts @@ -426,10 +426,13 @@ export const evaluateDispatchConformance = ( // Rule 5: the re-review flip veto (Step 4, reduced depths only): at // flip-gated/fast depth, a prior REQUEST_CHANGES (read from the stamp, - // not the review state) may flip to APPROVE only when the code-rendered - // accountability result says every blocking thread was resolved. + // not the review state) may flip to APPROVE or COMMENT only when the + // code-rendered accountability result says every blocking thread was + // resolved (verdict.ts floors the verdict at REQUEST_CHANGES while a + // kept blocking thread exists, mediums or no mediums; this chokepoint + // mirrors that invariant for the no-plan case). if ( - verdictEvent === "APPROVE" && + (verdictEvent === "APPROVE" || verdictEvent === "COMMENT") && (depth === "flip-gated" || depth === "fast") ) { const bodyStamp = Array.isArray(input.priorReviews) diff --git a/workflows/review/lib/finding-schema.ts b/workflows/review/lib/finding-schema.ts index 9dd6c2d4..01b39846 100644 --- a/workflows/review/lib/finding-schema.ts +++ b/workflows/review/lib/finding-schema.ts @@ -77,14 +77,16 @@ export type Lens = typeof KNOWN_LENSES[number]; * * `medium` is the middle tier (PRA-7): a verified defect or gap in code this * PR adds, that a reasonable author would fix before merge, but that does - * not block. It is a POSTING-SURFACE tier, never a verdict input: a medium - * finding renders with the same non-blocking labels an advisory one does - * (`labelForFinding` treats them identically), so every label-keyed consumer - * (verdict, recap parser, dedup guards, flip gate) is untouched by - * construction. What medium buys is prominence: it ranks ahead of advisory - * findings for the non-blocking inline budget and posts inline on re-reviews - * under the ROUTING `blocking-medium` modifier, where advisory findings - * collapse. Motivating case: three 2026-08-24 approving re-reviews collapsed + * not block. It can never force REQUEST_CHANGES, and it mints no label: a + * medium finding renders with the same non-blocking labels an advisory one + * does (`labelForFinding` treats them identically), so every label-keyed + * consumer (recap parser, dedup guards, flip gate) is untouched by + * construction. What medium buys is prominence and honesty: it ranks ahead + * of advisory findings for the non-blocking inline budget, posts inline on + * re-reviews under the ROUTING `blocking-medium` modifier where advisory + * findings collapse, and demotes the run's verdict from APPROVE to COMMENT + * (verdict.ts reads the post-veto medium count directly, not through + * labels). Motivating case: three 2026-08-24 approving re-reviews collapsed * verified correctness findings behind a bare "Non-blocking observations * (N)" count (Khan/actions#367, #371, #366). * diff --git a/workflows/review/lib/render-comment.test.ts b/workflows/review/lib/render-comment.test.ts index 58f6d64c..45851951 100644 --- a/workflows/review/lib/render-comment.test.ts +++ b/workflows/review/lib/render-comment.test.ts @@ -396,7 +396,7 @@ describe("renderReviewBody — the COMMENT verdict", () => { hasInlineComments: true, }); expect(body).toContain( - "Commented — medium-importance findings posted; nothing blocks.", + "Commented — medium-importance findings found; nothing blocks.", ); }); }); diff --git a/workflows/review/lib/render-comment.ts b/workflows/review/lib/render-comment.ts index 7edb7d1f..ede6a987 100644 --- a/workflows/review/lib/render-comment.ts +++ b/workflows/review/lib/render-comment.ts @@ -137,10 +137,12 @@ const DOCUMENTATION_LENSES: ReadonlySet = new Set([ * - advisory + other lens -> `suggestion (non-blocking)` * * `medium` severity renders exactly as `advisory` does (the non-blocking - * rows above). That is the tier's design invariant, not an omission: medium - * is a posting-surface rank (which findings deserve the inline slots), and - * keeping it out of the label vocabulary is what leaves the verdict, the - * recap parser, dedup's blocking guards, and the flip gate untouched. + * rows above). That is the tier's design invariant, not an omission: + * keeping medium out of the label vocabulary is what leaves the label-keyed + * machinery (the recap parser, dedup's blocking guards, the flip gate) + * untouched. The verdict DOES read the tier, but directly (`verdict.ts` + * consumes the post-veto medium count and demotes a would-be APPROVE to + * COMMENT), never through labels. * * There is deliberately **no blocking documentation variant**. The * documentation reviewer is advisory-only (its definition permits it one @@ -335,7 +337,7 @@ export const renderReviewBody = (input: ReviewBodyInput): string => { // The middle verdict never has an empty body either: the head is // what tells an author this is deliberately not an approval. head = - "Commented — medium-importance findings posted; nothing blocks."; + "Commented — medium-importance findings found; nothing blocks."; break; case "HOLD_FOR_HUMAN": head = HOLD_HEAD; diff --git a/workflows/review/lib/submission-blocking-medium.test.ts b/workflows/review/lib/submission-blocking-medium.test.ts index dff56928..467a3fc3 100644 --- a/workflows/review/lib/submission-blocking-medium.test.ts +++ b/workflows/review/lib/submission-blocking-medium.test.ts @@ -100,7 +100,7 @@ describe("runSubmissionCli: re-review blocking-medium", () => { // verdict (PRA-7): the run neither vouches nor demands a round. expect(plan.event).toBe("COMMENT"); expect(plan.body).toContain( - "Commented — medium-importance findings posted; nothing blocks.", + "Commented — medium-importance findings found; nothing blocks.", ); expect(plan.comments).toHaveLength(1); expect(plan.comments[0].line).toBe(2); diff --git a/workflows/review/lib/verdict.ts b/workflows/review/lib/verdict.ts index cbdf0fd8..e41eb289 100644 --- a/workflows/review/lib/verdict.ts +++ b/workflows/review/lib/verdict.ts @@ -6,9 +6,8 @@ * (PRA-7: mediums demote a would-be approval to COMMENT), (3) which review * dimensions were assessed this run, and (4) any policy-named conflicts a * lens flagged. It emits one of four events with a machine-readable list of - * reasons. No prose is - * synthesised here: reasons are structured records, not - * sentences about the code. + * reasons. No prose is synthesised here: reasons are structured records, + * not sentences about the code. * * Relationship to #194: #194 already established the *mechanical label model* — * REQUEST_CHANGES iff at least one posted comment carries a blocking label, @@ -231,12 +230,14 @@ export const computeVerdict = (input: VerdictInput): Verdict => { // A run with zero blocking labels is never REQUEST_CHANGES (review.md // Step 4) — unless a prior review's blocking thread is still open, in // which case the earlier objection is the actionable feedback. - // (f) Medium-importance claims — the PRA-7 middle verdict's signal. + // (f) Medium-importance claims — the PRA-7 middle verdict's signal + // (post-veto count, from the caller). const mediumCount = input.mediumCount ?? 0; if (mediumCount > 0) { reasons.push({code: "medium-importance", count: mediumCount}); } + // Precedence: a blocking finding is actionable on its own, so it wins. if ( (blockingLabelCount > 0 && blockingLabelCount >= threshold) || keptBlocking > 0 diff --git a/workflows/review/review.md b/workflows/review/review.md index 643ee7c3..5e5e146f 100644 --- a/workflows/review/review.md +++ b/workflows/review/review.md @@ -1139,10 +1139,12 @@ fully explained by a common pattern above: risky file and no pattern and no NOTIFIED match), post nothing at all (see above) — do not write a placeholder, even if files were excluded. -## Step 8: On Approval — Request the Owning Teams as Reviewers +## Step 8: On Approval or Comment — Request the Owning Teams as Reviewers -**Only run this step when the verdict is APPROVE.** Skip it entirely on -REQUEST_CHANGES or COMMENT. Also skip it entirely when `correctness-reviewer` did not run +**Run this step when the verdict is APPROVE or COMMENT; skip it entirely on +REQUEST_CHANGES.** A COMMENT run routes the owning teams too, deliberately: it +found something worth a human's eyes and, unlike REQUEST_CHANGES, forces no +later run that would route them. Also skip it entirely when `correctness-reviewer` did not run this run (a `flip-gated` or `fast` re-review depth, Step 3): there are no fresh risk classifications to route on, and the anchoring full review already requested the owning teams. @@ -1337,10 +1339,11 @@ the diff's `NNN| ` prefix, never counted), `file` (with `path`), or `pr` (whole-PR, no path/line); `severity` is `blocking` for a genuine defect in your domain, `medium` for a verified non-blocking defect or gap in code this PR adds that a reasonable author would fix before merge, and `advisory` -otherwise (or as the matched skill declares). `medium` is prominence, not -severity: it never affects the verdict, and the claim-validator strips it from -any claim it cannot confirm, so mark it only where your evidence already makes -the case; +otherwise (or as the matched skill declares). `medium` can never force +REQUEST_CHANGES (it decides posting surface, and a run whose findings are at +most medium submits a COMMENT review instead of an approval), and the +claim-validator strips it from any claim it cannot confirm, so mark it only +where your evidence already makes the case; `confidence` is a number in [0,1]; `evidence_trace` has at least one non-empty entry; `failure_scenario` names the concrete failing scenario (specific inputs/state, then the wrong outcome) — it is the specific claim the @@ -1542,13 +1545,14 @@ Return ONLY this JSON object (no prose, no code fence): `importance: "medium"` is the optional middle tier: mark it only on a non-blocking finding that is a verified defect or gap in code this PR adds, one -a reasonable author would fix before merge. It is prominence, not severity: it -never affects the verdict; it decides which non-blocking findings post inline -rather than collapse, and it is what keeps a finding visible on re-reviews -under the `blocking-medium` dial. The claim-validator checks the marking and -strips any it cannot confirm, and code strips it from any finding not anchored -on a line this PR added, so an evidence-free medium costs the finding its -prominence and buys nothing. +a reasonable author would fix before merge. It can never force REQUEST_CHANGES; +what it does is decide which non-blocking findings post inline rather than +collapse, keep a finding visible on re-reviews under the `blocking-medium` +dial, and demote the run's verdict from APPROVE to COMMENT (the run posts its +findings without vouching for the change). The claim-validator checks the +marking and strips any it cannot confirm, and code strips it from any finding +not anchored on a changed line of this PR, so an evidence-free medium costs +the finding its prominence and buys nothing. `line` is a RIGHT-side (added/context) line number from the diff. Keep findings tight and high-signal; use a blocking label only for a defect CI would not catch. @@ -1690,13 +1694,14 @@ Return ONLY this JSON object (no prose, no code fence): `importance: "medium"` is the optional middle tier: mark it only on a non-blocking finding that is a verified defect or gap in code this PR adds, one -a reasonable author would fix before merge. It is prominence, not severity: it -never affects the verdict; it decides which non-blocking findings post inline -rather than collapse, and it is what keeps a finding visible on re-reviews -under the `blocking-medium` dial. The claim-validator checks the marking and -strips any it cannot confirm, and code strips it from any finding not anchored -on a line this PR added, so an evidence-free medium costs the finding its -prominence and buys nothing. +a reasonable author would fix before merge. It can never force REQUEST_CHANGES; +what it does is decide which non-blocking findings post inline rather than +collapse, keep a finding visible on re-reviews under the `blocking-medium` +dial, and demote the run's verdict from APPROVE to COMMENT (the run posts its +findings without vouching for the change). The claim-validator checks the +marking and strips any it cannot confirm, and code strips it from any finding +not anchored on a changed line of this PR, so an evidence-free medium costs +the finding its prominence and buys nothing. `line` is a RIGHT-side diff line. `failure_scenario` is required on every finding: the concrete consequence of the breach, stated specifically enough for the @@ -2082,8 +2087,9 @@ one a reasonable author would fix before merge. On a `confirmed` claim you may set `corrected.importance` in either direction: `"minor"` strips a marking whose evidence does not meet that bar, `"medium"` grants it to an unmarked claim whose evidence clearly does. This is not the never-raise rule's -territory: importance is prominence (which non-blocking findings post inline), -never severity, and it cannot affect the verdict. A `plausible` or `refuted` +territory: importance can never force REQUEST_CHANGES; it decides which +non-blocking findings post inline, and whether the run submits a COMMENT +review instead of an approval. A `plausible` or `refuted` claim needs no importance call from you; code strips the tier from every claim you verify as plausible or refute (a claim your output never mentions keeps whatever it arrived with, per the missing-output rule). @@ -2198,13 +2204,14 @@ Return ONLY this JSON object (no prose, no code fence): `importance: "medium"` is the optional middle tier: mark it only on a non-blocking finding that is a verified defect or gap in code this PR adds, one -a reasonable author would fix before merge. It is prominence, not severity: it -never affects the verdict; it decides which non-blocking findings post inline -rather than collapse, and it is what keeps a finding visible on re-reviews -under the `blocking-medium` dial. The claim-validator checks the marking and -strips any it cannot confirm, and code strips it from any finding not anchored -on a line this PR added, so an evidence-free medium costs the finding its -prominence and buys nothing. +a reasonable author would fix before merge. It can never force REQUEST_CHANGES; +what it does is decide which non-blocking findings post inline rather than +collapse, keep a finding visible on re-reviews under the `blocking-medium` +dial, and demote the run's verdict from APPROVE to COMMENT (the run posts its +findings without vouching for the change). The claim-validator checks the +marking and strips any it cannot confirm, and code strips it from any finding +not anchored on a changed line of this PR, so an evidence-free medium costs +the finding its prominence and buys nothing. Use a blocking label only for a whole-change defect that genuinely must be fixed before approval. `failure_scenario` is required on every finding: the concrete inputs/state @@ -2283,13 +2290,14 @@ Return ONLY this JSON object (no prose, no code fence): `importance: "medium"` is the optional middle tier: mark it only on a non-blocking finding that is a verified defect or gap in code this PR adds, one -a reasonable author would fix before merge. It is prominence, not severity: it -never affects the verdict; it decides which non-blocking findings post inline -rather than collapse, and it is what keeps a finding visible on re-reviews -under the `blocking-medium` dial. The claim-validator checks the marking and -strips any it cannot confirm, and code strips it from any finding not anchored -on a line this PR added, so an evidence-free medium costs the finding its -prominence and buys nothing. +a reasonable author would fix before merge. It can never force REQUEST_CHANGES; +what it does is decide which non-blocking findings post inline rather than +collapse, keep a finding visible on re-reviews under the `blocking-medium` +dial, and demote the run's verdict from APPROVE to COMMENT (the run posts its +findings without vouching for the change). The claim-validator checks the +marking and strips any it cannot confirm, and code strips it from any finding +not anchored on a changed line of this PR, so an evidence-free medium costs +the finding its prominence and buys nothing. Use a blocking label only when the change genuinely fails to deliver required, stated work. `failure_scenario` is required on every finding: the concrete gap and what a user or @@ -2358,13 +2366,14 @@ Return ONLY this JSON object (no prose, no code fence): `importance: "medium"` is the optional middle tier: mark it only on a non-blocking finding that is a verified defect or gap in code this PR adds, one -a reasonable author would fix before merge. It is prominence, not severity: it -never affects the verdict; it decides which non-blocking findings post inline -rather than collapse, and it is what keeps a finding visible on re-reviews -under the `blocking-medium` dial. The claim-validator checks the marking and -strips any it cannot confirm, and code strips it from any finding not anchored -on a line this PR added, so an evidence-free medium costs the finding its -prominence and buys nothing. +a reasonable author would fix before merge. It can never force REQUEST_CHANGES; +what it does is decide which non-blocking findings post inline rather than +collapse, keep a finding visible on re-reviews under the `blocking-medium` +dial, and demote the run's verdict from APPROVE to COMMENT (the run posts its +findings without vouching for the change). The claim-validator checks the +marking and strips any it cannot confirm, and code strips it from any finding +not anchored on a changed line of this PR, so an evidence-free medium costs +the finding its prominence and buys nothing. `failure_scenario` is required on every finding: name the untested path and the concrete regression that would slip through it unnoticed (the claim-validator From 26a1fcb438fc9e53ce8a48a1c1d226c089244323 Mon Sep 17 00:00:00 2001 From: James Wiesebron Date: Mon, 24 Aug 2026 22:43:40 -0700 Subject: [PATCH 3/3] [agent/pra7-comment-verdict] review: the hold outranks COMMENT again; a COMMENT never strands the bot's own prior block --- .changeset/pra7-comment-verdict.md | 2 +- workflows/review/README.md | 4 +- workflows/review/lib/counters-report.ts | 17 ++++++-- .../lib/dispatch-gate-hardening.test.ts | 16 ++++++++ .../lib/submission-blocking-medium.test.ts | 23 +++++++++++ workflows/review/lib/submission.ts | 20 +++++++++- workflows/review/lib/verdict.test.ts | 10 +++-- workflows/review/lib/verdict.ts | 40 +++++++++---------- workflows/review/review.md | 14 ++++--- 9 files changed, 108 insertions(+), 38 deletions(-) diff --git a/.changeset/pra7-comment-verdict.md b/.changeset/pra7-comment-verdict.md index fa47e3b6..301f5849 100644 --- a/.changeset/pra7-comment-verdict.md +++ b/.changeset/pra7-comment-verdict.md @@ -2,6 +2,6 @@ "review": minor --- -The COMMENT middle verdict: a run that finds medium-importance findings and nothing blocking now submits a COMMENT review instead of an approval. The verdict stays mechanical (lib/verdict.ts): REQUEST_CHANGES iff a posted claim carries a blocking label (plus the existing floors), COMMENT iff nothing blocks and the post-veto medium count is nonzero (collapsed mediums count too: the verdict follows what the run found, not which surface showed it, the same invariant that keeps a 21st blocking claim blocking), APPROVE otherwise. COMMENT outranks HOLD_FOR_HUMAN deliberately: the hold exists to stop the automation approving what its core passes never checked, and a COMMENT approves nothing while carrying actionable findings, so a missing core pass is disclosed in the note lines rather than held on. A vetoed medium demotes nothing. The stamp and cache-record machinery accept the new verdict (a COMMENT run still records its fingerprint, so re-review depth planning is unaffected), the conformance gate's no-blocking-inline rule covers COMMENT the same as APPROVE, and the frontmatter's allowed-events gains COMMENT (consumers inherit it at bump time; the gh-aw engine passes the event through to GitHub's review API). +The COMMENT middle verdict: a run that finds medium-importance findings and nothing blocking now submits a COMMENT review instead of an approval. The verdict stays mechanical (lib/verdict.ts): REQUEST_CHANGES iff a posted claim carries a blocking label (plus the existing floors), COMMENT iff nothing blocks and the post-veto medium count is nonzero (collapsed mediums count too: the verdict follows what the run found, not which surface showed it, the same invariant that keeps a 21st blocking claim blocking), APPROVE otherwise. HOLD_FOR_HUMAN outranks COMMENT: the hold's no-stamp/no-record effect is what forces the next run to review in full, and a COMMENT run writes both, so a partial assessment holds even when it found mediums (they fold into the hold comment as claim lines). One mechanical guard on GitHub's state model: a COMMENT that would leave this workflow's own prior REQUEST_CHANGES standing upgrades to APPROVE with a note, since GitHub only moves a reviewer's state on APPROVE or REQUEST_CHANGES and the author's fixes already earned the block's removal. A vetoed medium demotes nothing. The stamp and cache-record machinery accept the new verdict (a COMMENT run still records its fingerprint, so re-review depth planning is unaffected), the conformance gate's no-blocking-inline rule covers COMMENT the same as APPROVE, and the frontmatter's allowed-events gains COMMENT (consumers inherit it at bump time; the gh-aw engine passes the event through to GitHub's review API). Expected output-shape effect: no change to inline comment count or body sizes; the review event changes from APPROVE to COMMENT exactly when the medium count is nonzero, and the body head reads "Commented — medium-importance findings found; nothing blocks." instead of the approval line. Authors keep a clean green approval only when the run found nothing worth fixing before merge. diff --git a/workflows/review/README.md b/workflows/review/README.md index d79668f2..30931dd4 100644 --- a/workflows/review/README.md +++ b/workflows/review/README.md @@ -2,8 +2,8 @@ A [GitHub Agentic Workflow](https://github.github.com/gh-aw/) that reviews pull request changes for correctness, conventions, and risk on every push. It leaves -per-line Conventional Comments, and on approval posts a risk/patterns summary -comment and requests the owning teams as reviewers. +per-line Conventional Comments; on approval it posts a risk/patterns summary +comment, and on approval or comment it requests the owning teams as reviewers. The flow here is **generic**; everything repo-specific (risk file patterns, the best-practice skill catalog, the CI-tooling exclusions, and the reviewer team diff --git a/workflows/review/lib/counters-report.ts b/workflows/review/lib/counters-report.ts index 8d733e37..b7861280 100644 --- a/workflows/review/lib/counters-report.ts +++ b/workflows/review/lib/counters-report.ts @@ -109,11 +109,20 @@ export const synthesizeSummaryFromGhAw = ( continue; } const event = entry["event"]; + // If a malformed artifact carries several submissions, the + // stricter verdict wins, and strictness is now a three-value rank: + // REQUEST_CHANGES > COMMENT > APPROVE. + const rank: Record = { + APPROVE: 0, + COMMENT: 1, + REQUEST_CHANGES: 2, + }; if ( - (event === "APPROVE" || - event === "COMMENT" || - event === "REQUEST_CHANGES") && - summary["verdict"] !== "REQUEST_CHANGES" + typeof event === "string" && + event in rank && + (typeof summary["verdict"] !== "string" || + !(summary["verdict"] in rank) || + rank[event] > rank[summary["verdict"]]) ) { summary["verdict"] = event; } diff --git a/workflows/review/lib/dispatch-gate-hardening.test.ts b/workflows/review/lib/dispatch-gate-hardening.test.ts index 2768d5c9..e5aa7d1d 100644 --- a/workflows/review/lib/dispatch-gate-hardening.test.ts +++ b/workflows/review/lib/dispatch-gate-hardening.test.ts @@ -422,6 +422,22 @@ describe("verdict and resolution chokepoints (slice 3)", () => { rereviewAccounting: {keptBlockingCount: 2}, }); expect(full.conformant).toBe(true); + // A COMMENT flip is vetoed the same way: it cannot clear the prior + // REQUEST_CHANGES state, but the chokepoint mirrors verdict.ts's + // floor for the no-plan case regardless of the event flavor. + const commentFlip = evaluate({ + ...base, + items: [ + submitItem( + "COMMENT", + "Commented — medium-importance findings found; nothing blocks.", + ), + ], + rereviewAccounting: {keptBlockingCount: 2}, + }); + expect(commentFlip.violations.map((v) => v.code)).toEqual([ + "flip-vetoed-kept-blocking", + ]); }); it("vetoes the flip from a cache-memory stamp when posted bodies carry none (the production shape)", () => { diff --git a/workflows/review/lib/submission-blocking-medium.test.ts b/workflows/review/lib/submission-blocking-medium.test.ts index 467a3fc3..044d4244 100644 --- a/workflows/review/lib/submission-blocking-medium.test.ts +++ b/workflows/review/lib/submission-blocking-medium.test.ts @@ -339,3 +339,26 @@ describe("the COMMENT verdict", () => { expect(runSubmissionCli(fs).event).toBe("REQUEST_CHANGES"); }); }); + +describe("the COMMENT verdict's prior-state guard", () => { + it("upgrades COMMENT to APPROVE over a prior REQUEST_CHANGES stamp", () => { + // GitHub state only moves on APPROVE or REQUEST_CHANGES: a COMMENT + // would leave the bot's own prior block standing after the author + // fixed every blocking objection. + const files = staged({ + depth: "scoped", + claims: [claim({id: "medium", importance: "medium"})], + }); + files[`${REVIEW}/pr-context.json`] = JSON.stringify({number: 7}); + files[`/tmp/gh-aw/cache-memory/pr-7.json`] = JSON.stringify({ + verdict: "REQUEST_CHANGES", + wasDraft: false, + reviewedHunks: {"a.ts": ["h1"]}, + }); + const plan = runSubmissionCli(makeFakeFs(files)); + expect(plan.event).toBe("APPROVE"); + expect(plan.notes).toContainEqual( + "COMMENT verdict upgraded to APPROVE: a comment cannot clear the prior request-changes state, and every blocking objection is resolved", + ); + }); +}); diff --git a/workflows/review/lib/submission.ts b/workflows/review/lib/submission.ts index e6611c88..098131e8 100644 --- a/workflows/review/lib/submission.ts +++ b/workflows/review/lib/submission.ts @@ -877,10 +877,28 @@ export const runSubmissionCli = ( }; }); + // A COMMENT cannot clear this workflow's own prior REQUEST_CHANGES: + // GitHub derives a reviewer's state only from its latest APPROVE or + // REQUEST_CHANGES, and nothing here dismisses reviews. So when the + // prior stamped verdict is REQUEST_CHANGES and this run's blocking + // objections are all resolved (a COMMENT verdict implies exactly that: + // zero blocking labels AND zero kept blocking threads), the run + // approves instead, or the author stays blocked by a stale state their + // fixes already earned back. The mediums still post; the note line + // below says what happened. + const commentWouldStrandPriorRc = + verdict.event === "COMMENT" && + priorStamp !== null && + priorStamp.verdict === "REQUEST_CHANGES"; + if (commentWouldStrandPriorRc) { + notes.push( + "COMMENT verdict upgraded to APPROVE: a comment cannot clear the prior request-changes state, and every blocking objection is resolved", + ); + } const event = verdict.event === "REQUEST_CHANGES" ? "REQUEST_CHANGES" - : verdict.event === "COMMENT" + : verdict.event === "COMMENT" && !commentWouldStrandPriorRc ? "COMMENT" : "APPROVE"; diff --git a/workflows/review/lib/verdict.test.ts b/workflows/review/lib/verdict.test.ts index 3454e909..545580e6 100644 --- a/workflows/review/lib/verdict.test.ts +++ b/workflows/review/lib/verdict.test.ts @@ -339,16 +339,18 @@ describe("the COMMENT verdict (the PRA-7 middle outcome)", () => { ).toBe("REQUEST_CHANGES"); }); - it("COMMENT outranks the hold: a comment approves nothing, so the missing core pass is disclosed, not held on", () => { + it("the hold outranks COMMENT: a partial assessment must not write a fingerprint, whatever it found", () => { const verdict = computeVerdict({ postedLabels: ["note (non-blocking)"], dimensions: {...assessed, correctness: "unavailable"}, mediumCount: 1, }); - expect(verdict.event).toBe("COMMENT"); + expect(verdict.event).toBe("HOLD_FOR_HUMAN"); + // The medium findings are still recorded; the hold comment folds + // them as claim lines, so the author sees them anyway. expect(verdict.reasons).toContainEqual({ - code: "core-dimension-unavailable", - dimension: "correctness", + code: "medium-importance", + count: 1, }); }); diff --git a/workflows/review/lib/verdict.ts b/workflows/review/lib/verdict.ts index e41eb289..d1d5e1c6 100644 --- a/workflows/review/lib/verdict.ts +++ b/workflows/review/lib/verdict.ts @@ -156,7 +156,7 @@ export const DEFAULT_BLOCKING_THRESHOLD = 1; * input always yields the same verdict, which is what makes the determinism * boundary testable. * - * Precedence is REQUEST_CHANGES > COMMENT > HOLD_FOR_HUMAN > APPROVE: + * Precedence is REQUEST_CHANGES > HOLD_FOR_HUMAN > COMMENT > APPROVE: * * 1. If the blocking-label count meets the threshold -> REQUEST_CHANGES. A * blocking finding is actionable on its own: the author gets concrete @@ -164,21 +164,20 @@ export const DEFAULT_BLOCKING_THRESHOLD = 1; * after those changes retries the failed dimension anyway. Any missing * core dimension or policy conflict is still recorded in `reasons` (and * rendered into the body), so nothing is hidden. - * 2. Otherwise, if any posted claim carries the medium tier -> COMMENT. - * The middle verdict outranks the hold deliberately: the hold exists - * to stop the automation APPROVING what its core passes never checked, - * and a COMMENT approves nothing, while the medium findings are - * actionable feedback the author can already use (a missing core - * dimension is still recorded in `reasons` and disclosed in the body's - * note lines). - * 3. Otherwise, if any core dimension is unavailable or any policy conflict - * is present, the run must not resolve to an approval the automation - * cannot stand behind -> HOLD_FOR_HUMAN. + * 2. Otherwise, if any core dimension is unavailable or any policy conflict + * is present -> HOLD_FOR_HUMAN, mediums or no mediums. An earlier + * revision had COMMENT outrank the hold ("a COMMENT approves nothing"), + * which reasoned about the approval half only: the hold's OTHER effect + * is that no fingerprint stamp is written and the cache record is + * refused, so the next run reviews in full rather than anchoring a + * reduced re-review on a partial assessment. A COMMENT run writes both, + * so letting it win would trade that away; medium findings still reach + * the author as folded claim lines in the hold comment. + * 3. Otherwise, if any posted claim carries the medium tier -> COMMENT. * 4. Otherwise -> APPROVE. * * The hold therefore only ever replaces what would otherwise have been an - * auto-approval; it never sits in front of feedback the author could already - * act on. + * auto-approval or a comment; it never sits in front of blocking feedback. */ export const computeVerdict = (input: VerdictInput): Verdict => { const threshold = Math.max( @@ -245,18 +244,17 @@ export const computeVerdict = (input: VerdictInput): Verdict => { return {event: "REQUEST_CHANGES", reasons}; } + // The hold outranks the comment (see the precedence note above): its + // no-stamp/no-record effect is what forces the next run to review in + // full, and a COMMENT run would write both from a partial assessment. + if (missingCore.length > 0 || policyConflicts.length > 0) { + return {event: "HOLD_FOR_HUMAN", reasons}; + } + // The middle verdict: verified worth-fixing findings, nothing blocking. - // Ahead of the hold on purpose (see the precedence note above): a - // COMMENT approves nothing, so the hold's never-approve-unchecked - // premise is not violated, and the author gets the findings. if (mediumCount > 0) { return {event: "COMMENT", reasons}; } - // The hold only ever replaces what would otherwise be an auto-approval. - if (missingCore.length > 0 || policyConflicts.length > 0) { - return {event: "HOLD_FOR_HUMAN", reasons}; - } - return {event: "APPROVE", reasons}; }; diff --git a/workflows/review/review.md b/workflows/review/review.md index 5e5e146f..4af63c75 100644 --- a/workflows/review/review.md +++ b/workflows/review/review.md @@ -889,11 +889,15 @@ under an approval, and the middle verdict says so without demanding another round); APPROVE otherwise — all `lib/verdict.ts` / `lib/submission.ts` rules. A fourth outcome exists: HOLD_FOR_HUMAN, when a core review pass (`correctness-reviewer` or `skill-auditor`) produced no usable output this -run and the run would otherwise have auto-approved — the automation never -approves a change its core passes did not look at (a blocking finding still -wins, and a medium finding still comments: both are actionable on their own, -so the hold only ever replaces a would-be APPROVE and the gap is disclosed -in a note line). The plan's `event` IS the +run and the run would otherwise have auto-approved or commented — the +automation never approves a change its core passes did not look at, and it +never writes a fingerprint from a partial assessment either (a blocking +finding still wins: it is actionable on its own; medium findings fold into +the hold comment as claim lines). One more mechanical guard: a COMMENT that +would leave this workflow's own prior REQUEST_CHANGES standing upgrades to +APPROVE with a note, because GitHub only moves a reviewer's state on APPROVE +or REQUEST_CHANGES and a stale block the author's fixes already earned back +must not survive on a technicality. The plan's `event` IS the verdict; never recompute, second-guess, or override it. (The blocking-label vocabulary and the concrete-failing-scenario bar live in the sub-agent definitions and the shared lib.)