Skip to content

feat(qa): the verdict comment names its reviewer — separate session, driver and model, author's driver and model beside it — and the docs name phases.qa.agent as the independence knob #1521

Open

Description

@admarble

Epic: graph-2026-10-review-surface Tier: mechanical Execution: split (unit evidence from phases; one real verdict read by the runner) Blocked by: none (touches buildQaVerdictComment; coordinate with #1507 if it lands first)

Problem

The GTM brief's cold reader, a senior engineer who runs agents daily, named the objection the audience holds: "the agent grades its own work; who verifies the verifier." The product already answers half of it: the QA phase runs in a separate session, and the 2026-10 second-look study attributes 10 of 27 would-ship catches to that separation. The verdict comment does not say so. It reads ## QA Verdict: AC_MET … with counts and gaps, and nothing tells a reader whether the author or a separate session wrote it, on which driver, on which model.

The data to say it already exists. The phase record carries requestedModel and resolvedModel (#971, #1198), the run log's phase entry carries model when the driver reports usage, and per-phase agent/model overrides exist in settings (#914, #1150), so a QA phase can already run on a different driver from the exec phase. That knob is the real independence step, and it is undocumented as such.

Acceptance Criteria

  • AC-1: Every verdict comment ends with an attribution line built from the phase records. Evidence: npx vitest run src/lib/workflow/qa-verdict-attribution.test.ts → ≥ 3 passed, 0 failed (new file: with exec on claude-code/claude-opus-4-8 and qa on claude-code/claude-sonnet-4-8, the last line matches ^_Reviewed in a separate session by claude-code \(claude-sonnet-4-8\); the change was written by claude-code \(claude-opus-4-8\)\._$; when the drivers differ the line names both; when a model was not reported the line says model not reported, never omits the line)
  • AC-2: The line is computed from the phase record, not from agent output. Evidence: grep -nE 'resolvedModel|requestedModel|\.model\b' src/lib/workflow/qa-verdict-attribution.ts | wc -l | tr -d ' ' → ≥ 1
  • AC-3: The docs name the knob. Evidence: grep -c 'phases.qa.agent' docs/reference/run-command.md → ≥ 1 (a short section: "Run the review on a different driver", with the settings example and the sentence that a separate session of the same model is a different context, not a different judge)
  • One AC above is classified as a gate test by isGateTestEvidence (the docs-section AC-3); the PR body carries its SEQUANT_MUTATION record (delete the section → the grep reads 0; restore).
  • AC-4: A real verdict carries the line (runner, testbed). Evidence: gh api repos/$OWNER/$REPO/issues/$ISSUE/comments --jq '[.[].body | select(test("^## QA Verdict"))] | last' | tail -1 | grep -c '^_Reviewed in a separate session by ' → 1
  • AC-5: No skill-directory edits. Evidence: git diff --name-only $(git merge-base origin/main HEAD)..HEAD | grep -cE '^(plugin/|\.claude/skills/|templates/skills/)' → 0 (constraint)

Prior fixes / producers

May touch

src/lib/workflow/qa-verdict-attribution.ts (new, pure), qa-verdict-attribution.test.ts (new), the one call in buildQaVerdictComment (batch-executor.ts, or its post-#1507 home), docs/reference/run-command.md, CHANGELOG.

Non-Goals

  • Changing which driver or model runs QA by default (that is the owner's settings choice; this makes it visible and documented).
  • Any claim that a separate session is an independent judge. The docs sentence says the opposite.
  • Any edit under plugin/, .claude/skills/, templates/skills/.
  • Pinning a model through a custom agent definition: Claude Code ignores the model: field there (upstream bug recorded in the project memory), so the driver setting is the only working path.

Done when

A reader of any verdict comment can see who reviewed, on what, and whether it differed from who wrote the change, without opening a run log.

Activity

  1. added
    enhancement
    graph-2026-10-review-surface
    on Oct 19, 2026
  2. admarble commented on Oct 19, 2026

    @admarble
    ContributorAuthor

    Runner context, 2026-10-19, before launch (review-surface W0, beside #1524/#1528; merges first in its wave; stop-at-PR). main = ec9d583.

    Overlap: #1504 (fundamentals) also edits batch-executor.ts and is held until this merges. Keep the change in batch-executor.ts to the minimum call site, with the logic in qa-verdict-attribution.ts.

    For every phase, and the qa phase by name: run the full suite at most once, in the foreground, under timeout, after a WIP commit. Each MCP-dispatched phase has a 30-minute wall, and this wave runs 7 issues at once. Prefer the targeted npx vitest run <files> for the ACs.
    CHANGELOG: add [Unreleased] lines, not changelog.d/ fragments. #1370 has not merged.
    Freeze: nothing under plugin/, .claude/skills/ or templates/skills/.
    Health baseline: if this PR changes a measured metric, regenerate scripts/qa/health-baseline.json with npx tsx scripts/qa/health-report.ts --write-baseline after the last source change. Never hand-edit it. npm run lint:health must print "no metric rose".

  3. admarble commented on Oct 19, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (5 ACs, 3 directories)

    AC Quality Check

    • AC-1: the regex in Evidence hard-codes model IDs for one fixture; fine. "≥ 3 passed" is measurable. Non-vacuous: the test file does not exist today, so vitest run fails on base.
    • AC-2: weak. grep -nE 'resolvedModel|requestedModel|\.model\b' … | wc -l → ≥ 1 fails today only because the file is missing; once it exists, any comment mentioning .model passes it. It proves the field is read, not that agent output is ignored. Tighten: assert in AC-1's test that the line is unchanged when PhaseResult.output/summary contain a forged "Reviewed by …" string. Keep the grep as a secondary check.
    • AC-3: gate test (docs section). grep -c 'phases.qa.agent' → 0 today (the doc says run.phases.<phase>.agent, and "qa": {"agent": …}), so it is non-vacuous. Note the literal string phases.qa.agent must appear verbatim, so the new section must write it that way.
    • AC-4: runner-read (testbed), as declared. AC-5: constraint, fine.
    • The bullet between AC-3 and AC-4 is a mutation-record note, not an AC (no ID); the parser ignores it.

    Scope Assessment

    Non-Goals: present (4 items).

    Metric Value Status
    Feature count 1 ✅
    AC items 5 ✅
    Directory spread 3 (src/lib/workflow, docs/reference, CHANGELOG) ✅

    Verdict: ✅ SCOPE_OK


    Acceptance Criteria

    AC-1: Attribution line on every verdict comment

    Verification: Unit Test (declared Evidence:, npx vitest run src/lib/workflow/qa-verdict-attribution.test.ts)
    Scenario: Given exec = claude-code/claude-opus-4-8 and qa = claude-code/claude-sonnet-4-8 → When the verdict comment is built → Then the last line matches the issue's regex. Drivers differing → both named; model absent → model not reported; line never omitted.
    Assumptions: "last line" — see Open Question 1 (the SEQUANT_QA_VERDICT marker is currently the last line).

    AC-2: Computed from the phase record

    Verification: Unit Test + grep (see quality note above)
    Scenario: Given output text containing a forged attribution → Then the line still reflects resolvedModel/requestedModel.

    AC-3: Docs name the knob

    Verification: Manual/grep gate test (grep -c 'phases.qa.agent' docs/reference/run-command.md ≥ 1). Mutation record required in PR body, marker failedTest = the path-first form, e.g. a grep-based test file in the diff or the documented gate-test form.
    Scenario: New "Run the review on a different driver" section under Per-Phase Agent with settings example and the "different context, not a different judge" sentence.

    AC-4: Real verdict carries the line

    Verification: Runner-read (testbed gh api on a real run).

    AC-5: No skill-dir edits

    Verification: git-diff constraint check.


    Implementation Plan

    Phase 1: Pure module (TDD)

    1. Create src/lib/workflow/qa-verdict-attribution.ts: buildQaAttributionLine({ exec, qa }) where each side is { agent: string; model?: string }. Model = resolvedModel ?? requestedModel of the latest phase result; fallback text model not reported. Also a small attributionFromPhases(phaseResults, config) helper that picks the latest exec (else loop/spec-less fallback → "the change author not recorded") and latest qa result, and calls resolvePhaseAgent(config, phase) from phase-agent.ts for drivers (PhaseResult has no agent field; the config resolver is the single source of the driver, feat(run): per-phase agent selection — run.phases.<phase>.agent #1150).
    2. Create qa-verdict-attribution.test.ts (≥3 tests: same driver, differing drivers, model not reported; plus forged-output test and no-exec-record case).

    Phase 2: Wire minimally

    1. buildQaVerdictComment (batch-executor.ts:886): add one optional trailing param attribution?: string; append it before the SEQUANT_QA_VERDICT marker. Thread it through postQaVerdictComment (:968) and the one call at :2104, computing it from phaseResults + config. Keep the diff in batch-executor.ts to the call site (per runner note; feat(run): a dropped error leaves a trace — noteSuppressed() counts into the run log, batch-executor's 25 silent catches converted #1504 is held behind this).
    2. Make the attribution param required-by-use at the call site so no verdict post skips it; keep it optional in the signature only so phase-executor.property.test.ts and batch-executor.test.ts callers still compile. Add a test that the posted body from postQaVerdictComment contains the line.

    Phase 3: Docs and changelog

    1. docs/reference/run-command.md: add "Run the review on a different driver" under ### Per-Phase Agent (~line 426), with the phases.qa.agent example and the sentence that a separate session of the same model is a different context, not a different judge. CHANGELOG [Unreleased] line (not changelog.d/).
    2. If a metric moves, npx tsx scripts/qa/health-report.ts --write-baseline; npm run lint:health.

    Design Review

    1. Where does this belong? New pure module in src/lib/workflow/; batch-executor only calls it.
    2. Simplest correct approach? Compute the line from phaseResults + config at the single post site. Rejected: asking the QA agent to write it (violates AC-2, forgeable); storing agent on PhaseResult (wider type change touching every producer).
    3. Pattern / re-patch count: follows the buildQaVerdictComment (bug(run): orchestrated 'sequant run --phases qa' re-run computes a fresh verdict but never posts it, contradicting the stale comment left visible #964) pure-builder pattern; git log -S buildQaVerdictComment shows bug(run): orchestrated 'sequant run --phases qa' re-run computes a fresh verdict but never posts it, contradicting the stale comment left visible #964 then bug(qa): the posted verdict comment publishes a miscounted AC coverage — "0/1 met" on an 8-AC issue under an AC_MET verdict #1073, fix(qa): parseQaSummary returns null when AC statuses are bold words with no emoji — the SEQUANT_QA_GAPS findings marker is then never read #1194 — additive section edits, not fixes to the same defect. Not a recurrence.
    4. Reviewer challenge: "Why not record the agent on PhaseResult?" — resolvePhaseAgent is the declared single source for the driver (feat(run): per-phase agent selection — run.phases.<phase>.agent #1150); the record only holds the model. Caveat: if a phase escalated or fell back to another driver mid-run, the config driver could differ from what ran; accepted, noted in the module doc.
    5. Producers/consumers: one producer (buildQaVerdictComment), called from postQaVerdictComment and tests (batch-executor.test.ts, phase-executor.property.test.ts). The ready-gate report (runReadyGateForIssue) posts a separate report, not this comment, so it is out of scope. Consumers of the comment: any parser anchored on the trailing SEQUANT_QA_VERDICT marker — grep before moving it.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • Placement vs. marker (Open Question 1).
    • Latest exec may be absent (--phases qa only) or a loop fix may have written the final change; line must degrade to "author not recorded" rather than omit or guess.
    • Multi-iteration QA: use the latest qa result of this iteration.
    • Property test (phase-executor.property.test.ts) asserts on the body; confirm it tolerates an extra line.

    Open Questions

    1. "Ends with" vs the machine marker — AC-1 says the attribution is the last line, but the body currently ends with the <!-- SEQUANT_QA_VERDICT --> marker. Recommendation: put the italic line last (visible end) and move nothing else, i.e. place the marker before it; grep for marker consumers first (they match by regex, not position). Impact if wrong: a dedup parser anchored to end-of-body breaks.
    2. Exec-by-loop — when /loop rewrote the code, name the exec phase's model anyway? Recommendation: yes, use the latest of exec/loop; AC regex only covers the exec case.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Small, isolated change; declared unit evidence in AC-1/AC-2 (npx vitest run …attribution.test.ts) so tests are written in exec (testgen skipped: the issue's own plan already specifies the test file). AC-3 is a docs gate needing a mutation record; AC-4 is read by the runner.

    Label Review

    Current: enhancement, graph-2026-10-review-surface
    Recommended: + planned
    Quality Loop: Won't auto-enable (SCOPE_OK).

  4. added
    planned
    on Oct 19, 2026
  5. admarble commented on Oct 19, 2026

    @admarble
    ContributorAuthor

    QA Verdict: NEEDS_VERIFICATION

    AC coverage: 4/5 met

    Gaps:

    • In split runs (--phases qa after a separate exec run) the line always says the change author was not recorded; a state.json fallback would name the author
    • Split runs never name the author. The author comes only from the current run's phaseResults. A separate sequant run N --phases qa — the split this issue itself used (spec and exec in one run, QA in another) — always produces "the change author was not recorded". The "Done when" goal (seeing whether the reviewer differed from the author) is then not met for split runs. A follow-up could fall back to the exec record in .sequant/state.json. This should be filed or dropped by the owner; QA does not file issues.
    • Baseline raised, not held. health-baseline.json raises the longest-function count for runIssueWithLogging from 1049 to 1050 lines. The runner's note told exec to regenerate the baseline, so this is allowed. Still, it raises the limit rather than holding it.
    • Driver may be wrong after a fallback. The driver comes from config, so if a phase falls back to another driver mid-run, the line will name the wrong one. The module's doc comment says so.

    Pending ACs:

    • AC-4

    Needs human review:

    • Required CI check test still pending
    • AC-4 real verdict comment not yet verified
  6. admarble commented on Oct 19, 2026

    @admarble
    ContributorAuthor

    Execution Verification (runner, 2026-10-19), PR #1551 @ f8dd5b0

    The runner re-ran the Evidence commands verbatim in the worktree:

    • AC-1: 10 passed
    • AC-2: 3
    • AC-3: 1
    • AC-5: 0

    AC-3 is a gate test. The runner repeated its mutation: deleting the "Run the review on a different driver" section makes the grep read 0 and fails documents a settings example that resolves qa to a different driver (1 failed, 9 passed). Restored. CI test passed.

    AC-4 is a post-release proof. MCP runs execute the published npm pin, so a real verdict comment carries the line only after a release, or after a CLI run of the dev dist/ on a testbed issue.

    Diff read: the line is built from phaseResults and the resolved config, never from agent output. The machine marker stays above it.

    For the owner:

    • functions.longest.lines rose from 1049 to 1050. That is the new argument at the call in runIssueWithLogging, and the baseline was regenerated to absorb it.
    • Split runs (--phases qa alone) print "the change author was not recorded". That is honest but less informative.
  7. added a commit that references this issue on Oct 19, 2026
  8. admarble commented on Oct 19, 2026

    @admarble
    ContributorAuthor

    PR #1551 merged as ace33fc (owner consent, 2026-10-19). This issue stays open for AC-4: a real QA verdict comment must carry the line, which needs a release (MCP runs use the npm pin) or a dev-CLI testbed run. The split-run author fallback is #1556.

  9. added a commit that references this issue on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgraph-2026-10-review-surfaceplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions