Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/pra7-comment-verdict.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"review": minor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking, best-practice): Versioning: semver as the behavior contract for the review package. The README's Versioning section states the rule: "Semver is the behavior contract: a release that changes the reviewer's behavior bumps the major version, so a consumer pinned to review-v<major> can assume the fundamental behavior holds within a major." This changeset declares "review": minor for a change that alters the review event the workflow submits (APPROVE becomes COMMENT whenever the post-veto medium count is nonzero). I checked workflows/review/CHANGELOG.md: prior minors did carry behavior changes (v1.17.0's downvote adjudication, v1.19.0's adjudicated-corpus key drop), so minor is the house habit — but none of them changed the set of GitHub review events a consumer receives, which is the surface that sentence protects. Bump the major, or record in the changeset why a new submitted review event is within-major?

A sketch, not a committable replacement:

---
"review": major
---
review details found by skill-auditor

---

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.
22 changes: 14 additions & 8 deletions workflows/review/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Comment thread
khan-actions-bot marked this conversation as resolved.
Resolved

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
Expand All @@ -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:
Expand Down Expand Up @@ -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`
Expand Down
8 changes: 8 additions & 0 deletions workflows/review/eval/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): The eval harness's mediumCount mirror is never exercised. grep -rho 'severity": "[a-z]*' eval/corpus yields only advisory (23) and blocking (48), and grep -rn medium eval/ outside runner.ts hits only confidence prose in smoke.test.ts — so no fixture or synthetic case ever gives this filter a nonzero count. suite.test.ts's case builder already makes adding one cheap.

A sketch, not a committable replacement:

// suite.test.ts, alongside the existing verdict cases
it("a posted medium finding plans the COMMENT middle verdict", () => {
    const {result} = runOne(
        caseWith({
            findings: [{id: "m", severity: "medium" /* ...case fields */}],
            expected: {verdict: "COMMENT"},
        }),
    );
    expect(result.verdict.event).toBe("COMMENT");
    expect(result.plannedReview.event).toBe("COMMENT");
});
review details found by test-adequacy

(candidate) => candidate.finding.severity === "medium",
).length,
...(options.blockingThreshold !== undefined
? {blockingThreshold: options.blockingThreshold}
: {}),
Expand Down
30 changes: 30 additions & 0 deletions workflows/review/lib/cache-record.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion workflows/review/lib/cache-record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Comment thread
khan-actions-bot marked this conversation as resolved.
Resolved
plan.event !== "REQUEST_CHANGES"
) {
return refuse("the staged plan carries no submittable event");
}

Expand Down
2 changes: 1 addition & 1 deletion workflows/review/lib/counters-report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
21 changes: 16 additions & 5 deletions workflows/review/lib/counters-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +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<string, number> = {
APPROVE: 0,
COMMENT: 1,
REQUEST_CHANGES: 2,
};
if (
(event === "APPROVE" || 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;
}
Expand Down Expand Up @@ -293,9 +304,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.",
Expand Down
2 changes: 2 additions & 0 deletions workflows/review/lib/counters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down Expand Up @@ -341,6 +342,7 @@ const asFiniteNumber = (value: unknown): number | undefined =>

const isVerdictEvent = (value: unknown): value is VerdictEvent =>
value === "APPROVE" ||
value === "COMMENT" ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): No test drives a COMMENT run through the verdict histogram. grep -n COMMENT counters.test.ts counters-report.test.ts returns nothing: the only new assertion is the rendered table string | 1 | 0 | 0 | 1 |, which pins the COMMENT column at zero and never exercises the two predicates that would put a nonzero there. Since the PR description makes this histogram the day-one rollout instrument, it is worth one end-to-end case.

A sketch, not a committable replacement:

// counters.test.ts
it("tallies a COMMENT run under its own bucket, not the hold fallback", () => {
    const run = normalizeRunArtifacts({summary: {verdict: "COMMENT"}}, "r");
    expect(run.verdict).toBe("COMMENT");
    const counters = computeRunCounters([runOf({verdict: "COMMENT"})]);
    expect(counters.verdictMix.COMMENT).toBe(1);
    expect(counters.verdictMix.HOLD_FOR_HUMAN).toBe(0);
});

// counters-report.test.ts
it("derives a COMMENT verdict from the emitted submission", () => {
    const summary = synthesizeSummaryFromGhAw({
        safeOutputs:
            '{"type":"submit_pull_request_review","event":"COMMENT"}',
    });
    expect(summary["verdict"]).toBe("COMMENT");
});
review details found by test-adequacy

value === "REQUEST_CHANGES" ||
value === "HOLD_FOR_HUMAN";

Expand Down
11 changes: 6 additions & 5 deletions workflows/review/lib/dispatch-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
31 changes: 31 additions & 0 deletions workflows/review/lib/dispatch-gate-hardening.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 found; 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(),
Expand Down Expand Up @@ -407,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)", () => {
Expand Down
24 changes: 14 additions & 10 deletions workflows/review/lib/dispatch-gate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Comment thread
khan-actions-bot marked this conversation as resolved.
Resolved
for (const item of input.items) {
if (item.type !== COMMENT_TYPE || typeof item.body !== "string") {
continue;
Expand All @@ -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;
Expand All @@ -425,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") &&
Comment thread
khan-actions-bot marked this conversation as resolved.
Resolved
(depth === "flip-gated" || depth === "fast")
) {
const bodyStamp = Array.isArray(input.priorReviews)
Expand Down
18 changes: 10 additions & 8 deletions workflows/review/lib/finding-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*
Expand Down
12 changes: 12 additions & 0 deletions workflows/review/lib/render-comment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 found; nothing blocks.",
);
});
});
Loading
Loading