Skip to content

bug(qa): parseQaVerdict records the first Verdict mention in the transcript, not the final heading — #1070 passed qa three times and was recorded AC_NOT_MET each time #1119

Closed

Description

@admarble

Symptom

parseQaVerdict (src/lib/workflow/phase-executor.ts, output.match(...)) returns the first Verdict: <token> in the whole qa transcript. A qa agent that quotes a verdict earlier in its output (in this case the ## QA Verdict: AC_NOT_MET comment format that #1070 makes the orchestrator post) is recorded with that quoted verdict, not with its own final ### Verdict: heading.

Evidence (guard-2026-09 wave 1, 2026-09-20)

Fix shape

Anchor on the last verdict-labelled line, or prefer a ###/**-labelled heading over a bare mention, and add the #1070 transcript tail as a fixture. Belongs with the parser property tests from #1095 (phase-executor.property.test.ts): "the verdict recorded is the one the transcript's final Verdict: heading names."

Acceptance criteria

  • AC-1: a transcript whose earlier text quotes QA Verdict: AC_NOT_MET and ends with ### Verdict: READY_FOR_MERGE parses as READY_FOR_MERGE — Verify: npx vitest run src/lib/workflow/phase-executor.test.ts -t "last verdict heading" → green. Mutation-verified per CLAUDE.md §Testing: restore the first-match regex → the case fails; restore.
  • AC-2: the bug(qa): a failing qa verdict (AC_NOT_MET) is never posted to the issue — posting is gated on phase success #1070 run-6ee4ad05 stdout tail is a committed fixture and parses READY_FOR_MERGE — Verify: same command, case run 6ee4ad05 fixture.
  • AC-3: npm run build && npm test green.

Activity

  1. added
    bug
    on Sep 20, 2026
  2. admarble commented on Sep 21, 2026

    @admarble
    ContributorAuthor

    Runner context — guard-2026-09 post-release launch, 2026-09-20. Base: origin/main at ad499b52 (2.17.0 released; the whole guard-2026-09 graph is on main; main rejects direct pushes — your PR is the only way in). These rules override the exec AND qa skills' defaults for this run:

    • No full npm test in the worktree — this applies to the qa phase too. Under concurrent phase agents that one call exceeds the 30-minute no-progress wall and the phase is killed (three wave-1 phases died this way). Verify each AC by its own command; run only the test files the ACs name. The runner runs the full suite once per PR from a clean shell and records it on the PR.
    • A named test file red before your change: the suite is now hermetic (bug(test): suite isn't hermetic against the SEQUANT_* env phases inject — exec sees red tests it didn't cause and opens no PR #1086), so a red file is real. Name the issue number and the base-vs-head result in the PR body.
    • Mutation marker (gate-test ACs): <!-- SEQUANT_MUTATION: {"ac":"AC-N","mutation":"<what you deleted>","failedTest":"<test file path> > <describe> > <case>"} --> in the PR body. failedTest MUST start with the test file path. Run parseMutationMarkers on your body before opening the PR. Commit before mutating.
    • 30-minute no-progress wall per phase. Commit a WIP checkpoint before any long command; every command foreground, with timeout.
    • Commits: single-line git commit -m "...", no Co-Authored-By. Push the branch and open the PR yourself (one wave-1 exec forgot). Never rebase or force-push after pushing. One AC per line in the PR body, ids AC-N only.
    • Stop at the PR. Do not merge.

    Issue-specific: Anchor on the LAST verdict-labelled heading (or prefer a ###/**-labelled heading over a bare mention), keep every existing parseQaVerdict case green, and commit the run-6ee4ad05 stdout tail as a fixture — it is in .sequant/logs/run-2026-09-20T15-09-08-6ee4ad05-*.json under issues[].phases[] | select(.phase=="qa") | .errorContext.stdoutTail (join with newlines). Property tests for the parsers live in src/lib/workflow/phase-executor.property.test.ts (#1095); add the invariant there or in phase-executor.test.ts. Do not touch parseQaSummary beyond what AC-1 needs.

  3. admarble commented on Sep 21, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (3 ACs, 1 directory)

    AC Quality Check

    All three ACs are measurable, one-line, and carry a Verify: command. Two warnings:

    • AC-2 does not discriminate as written. I replayed the committed-fixture candidate (errorContext.stdoutTail of run 6ee4ad05, 50 lines, 6.5 KB) through parseQaVerdict on main (ad499b52): it already returns READY_FOR_MERGE. The quoted ## QA Verdict: AC_NOT_MET is in the orchestrator's comment, earlier than the tail window, so the tail alone never contains it. A case that asserts only the tail would stay green with the first-match regex restored, which is exactly the tautology CLAUDE.md §Testing forbids. Plan handles this (see AC-2).
    • AC-3 conflicts with the runner context. AC-3 says npm run build && npm test; the runner comment says no full npm test in the worktree (30-min wall). Treated as: npm run build plus the named test files in the worktree; the runner runs the full suite once per PR. See Open Question 1.

    Scope Assessment

    Non-Goals: ⚠️ Not stated in the issue body. Inferred from the runner comment: do not touch parseQaSummary beyond what AC-1 needs; no change to the QA skill's output format; no change to buildQaVerdictComment.

    Metric Value Status
    Feature count 1 ✅
    AC items 3 ✅
    Directory spread 1 (src/lib/workflow/) ✅

    Verdict: ✅ SCOPE_OK


    Acceptance Criteria

    AC-1: transcript quoting QA Verdict: AC_NOT_MET and ending ### Verdict: READY_FOR_MERGE parses READY_FOR_MERGE

    Verification: Unit Test
    Scenario: Given output with an early ## QA Verdict: AC_NOT_MET line and a final ### Verdict: READY_FOR_MERGE heading → When parseQaVerdict(output) → Then READY_FOR_MERGE.
    Assumptions: Test name contains last verdict heading so -t "last verdict heading" selects it. Mutation: revert to the first-match output.match(...) → this case fails.

    AC-2: run 6ee4ad05 stdout tail is a committed fixture and parses READY_FOR_MERGE

    Verification: Unit Test
    Scenario: Given the fixture file, and the same fixture preceded by the line the orchestrator actually posts (## QA Verdict: AC_NOT_MET) → When parsed → Then READY_FOR_MERGE for both.
    Assumptions: Fixture is src/lib/workflow/__fixtures__/qa-stdout-tail-1070-run-6ee4ad05.txt, extracted with jq -r '…stdoutTail | join("\n")' from .sequant/logs/run-2026-09-20T15-09-08-6ee4ad05-*.json (.sequant/ rotates at 100 files, so copy it now). I scanned it for paths, emails, tokens: none. The discriminating case is the prefixed one, and it is what the mutation marker's failedTest must name. The bare-tail case is kept as a regression pin (green before and after; it is not the gate). Case title contains run 6ee4ad05 fixture.

    AC-3: npm run build && npm test green

    Verification: Integration Test (build + named files)
    Scenario: Given the change → When npm run build and npx vitest run src/lib/workflow/phase-executor.test.ts src/lib/workflow/phase-executor.property.test.ts src/commands/run.test.ts → Then green.
    Assumptions: Full npm test is run by the runner once per PR, not in this worktree (Open Question 1).


    Implementation Plan

    Phase 1: Parser (src/lib/workflow/phase-executor.ts:491-517)

    1. Replace output.match(re) with a scan over all matches, returning the last. Two tiers: (a) matches where Verdict is line-start-anchored heading/bold form (^\s*(#{2,4}\s*|\*\*)Verdict), take the last; (b) if none, the last match of the existing regex. Keeps the emoji/bold/plain tolerance and the negated-class ReDoS safety; no nested quantifiers added (use matchAll with the g flag on the existing pattern, do not re-derive the token group).
    2. Update the comment block above the regex to state the intent (final labelled verdict wins) and cite bug(qa): parseQaVerdict records the first Verdict mention in the transcript, not the final heading — #1070 passed qa three times and was recorded AC_NOT_MET each time #1119.

    Phase 2: Tests (parallel-safe with Phase 1 once the fixture is copied)

    1. Copy the fixture into src/lib/workflow/__fixtures__/ (see AC-2).
    2. phase-executor.test.ts describe("parseQaVerdict"): add last verdict heading (AC-1) and run 6ee4ad05 fixture (AC-2, bare + prefixed). Add cases for tier fallback: a lone ## QA Verdict: ✅ READY_FOR_MERGE (existing, must stay green), two bare mentions → last wins.
    3. phase-executor.property.test.ts (test(parsers): property-based and metamorphic tests with fast-check on ac-parser, parseQaSummary, and the marker parsers #1095): add the invariant "the recorded verdict is the one the final ### Verdict: heading names", with fast-check generating arbitrary preceding text containing quoted verdicts of any of the four values. Keep its FC_SEED handling.

    Phase 3: Gate evidence

    1. Commit first (git status --short | wc -l = 0), then mutate: restore the first-match regex, confirm the prefixed fixture case and last verdict heading fail, restore. Record <!-- SEQUANT_MUTATION: {"ac":"AC-1","mutation":"restored first-match output.match regex","failedTest":"src/lib/workflow/phase-executor.test.ts > parseQaVerdict > last verdict heading"} --> and the AC-2 equivalent in the PR body. failedTest must start with the file path. Run parseMutationMarkers on the body before opening the PR.

    Design Review

    1. Where does this logic belong? In parseQaVerdict itself. It is the only parser of the verdict token: repo-wide grep finds one regex (phase-executor.ts:509); ready-gate.ts and batch-executor.ts consume result.verdict, they do not re-parse.
    2. What's the simplest correct approach? Plain last-match (matchAll, take the final) is the minimum and satisfies both ACs. Recommended default adds the heading tier because a final-position mention can still be a quote (e.g. the agent's closing note "had the verdict been AC_NOT_MET…", present in the bug(qa): a failing qa verdict (AC_NOT_MET) is never posted to the issue — posting is gated on phase success #1070 tail; it does not match today only because a word sits between label and token). Rejected: parsing only the last N lines (the verdict heading is not guaranteed to be near the end, see the QA_DEFERRAL_MARKERS note about outputs with no labelled line at all).
    3. What existing pattern does this follow? The tail-window/literal-scan style of endedWithoutVerdict, and the parser property tests in test(parsers): property-based and metamorphic tests with fast-check on ac-parser, parseQaSummary, and the marker parsers #1095.
    4. What would a senior reviewer challenge? "Why two tiers, not just last?" Answer: a late quoted Verdict: X after the real heading. Counter-risk: a heading-anchored quote (### Verdict: AC_NOT_MET pasted from a prior comment) placed after the real one still loses; that is inherent, and the QA skill mandates the verdict as the final section. If the reviewer prefers the smaller change, dropping tier (a) is a 3-line delta and still passes every AC.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • Sibling scan: parseQaSummary has the same "first-of-many" exposure for its AC table but the runner comment forbids touching it beyond AC-1. Not widened; if wanted, file a follow-up.
    • Error-consequence: AC_NOT_MET is the only value that hard-fails the phase (phase-executor.ts:1066), so first-match errors produce false failures (as in bug(qa): a failing qa verdict (AC_NOT_MET) is never posted to the issue — posting is gated on phase success #1070) and never false passes; last-match shifts the risk to a quote after the real verdict. Tier (a) narrows that.
    • Existing cases: all parseQaVerdict cases in phase-executor.test.ts:53-155 must stay green; run.test.ts imports it through run-compat.ts.

    Open Questions

    1. AC-3 says npm test; runner context forbids it in the worktree. Recommendation: build + the three named files in the worktree, full suite by the runner, result recorded on the PR. Impact if wrong: qa marks AC-3 unmet or the phase hits the 30-min wall.
    2. One tier or two? Recommendation: two (last heading-form match, else last of any). Impact if wrong: minor; the simpler last-match variant passes all ACs.
    3. AC-2 wording. Recommendation: keep the AC, and treat the prefixed-fixture case as the gate. Impact if wrong: a bare-tail-only test is green on the unfixed code.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Single-function bug fix with bug label; targeted unit tests, so no testgen. No UI, no security surface. Worktree feature/1119-… already exists at origin/main ad499b52 with no commits.


    Label Review

    Current: bug
    Recommended: bug, planned
    Reason: Plan posted; no complexity labels warranted.
    Quality Loop: Won't auto-enable (SCOPE_OK, 1 directory).

  4. added
    planned
    on Sep 21, 2026
  5. added 3 commits that reference this issue on Sep 21, 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

    bugplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions