Skip to content

feat(run): every phase dispatch gets the needs-human Evidence block — exec ran the env-file command in the #1655 smoke #1688

Closed

Description

@admarble

Epic: graph-2026-11-simplify (found by the #1655 smoke) Tier: judgment Execution: split

Problem

D-8: Evidence that names an env file, a production CLI or a live URL goes to a person instead of being run. #1652 hands the qa dispatch a "do not run" block, and #1681 extends it to the ready gate's qa passes. The #1655 smoke (2026-11-16, main at 677e1bbde, notes-fixture #37) showed the qa agent obeying the block: it didn't run AC-2's npx tsx --env-file=.env.local scripts/smoke-check.ts and reported it PENDING. The exec agent ran that exact command in both of its attempts, as part of checking its own work. Only the sandbox and the missing file stopped it (node: .env.local: not found). E2c's 6 of 15 production-credential attempts came from phase agents generally, not only qa.

Prior fixes / producers

Acceptance Criteria

  • AC-1: For an issue with one needs-human AC, the spec, exec, qa and loop prompts each carry one block that names that AC and its command, and an issue with none gets no block. Evidence: npx vitest run src/lib/workflow/evidence-reach-dispatch.test.ts → ≥ 5 passed, 0 failed
  • AC-2: An issue with no state record is classified from its body, so sequant ready on an untracked issue still gets the block. Evidence: npx vitest run src/lib/workflow/evidence-reach-dispatch.test.ts -t "no state record" → ≥ 1 passed, 0 failed
  • AC-3: The classifier's tests still pass. The five assertions that pinned the per-site qa wrap move to the prompt seam in the new test file, and no caller wraps the config any more. Evidence: npx vitest run src/lib/evidence-reach.test.ts src/lib/workflow/evidence-reach-dispatch.test.ts → 0 failed, and grep -c 'withEvidenceReachContext(' src/lib/workflow/batch-executor.ts src/commands/ready.ts | awk -F: '{s+=$2} END{print s}' → 0 (constraint; amended 2026-11-16 with the owner's consent, option A in the spec comment)

May touch

src/lib/workflow/phase-executor.ts (prompt assembly), src/lib/workflow/batch-executor.ts, src/lib/workflow/ready-gate.ts, src/commands/ready.ts, src/lib/evidence-reach.ts (helpers only; P-9's rules are unchanged), the new test, CHANGELOG.

Non-Goals

Done when

No phase dispatch on any path is handed a needs-human Evidence command without the block, whether or not the issue has a state record. A re-run of the #1655 smoke shows no phase executing the env-file command.

Activity

  1. added
    graph-2026-11-simplify
    on Nov 16, 2026
  2. admarble commented on Nov 16, 2026

    @admarble
    ContributorAuthor

    Runner context, 2026-11-16

  3. admarble commented on Nov 16, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (3 ACs, 3 directories)

    AC Quality Check

    lintAcceptanceCriteria: all 3 pass. Each AC has an Evidence: clause (all resolve to unit_test). AC-1 and AC-2 point at evidence-reach-dispatch.test.ts, which doesn't exist on main, so they fail today and can only pass once the work is done. AC-3 passes today, which is expected for a constraint. vitest wasn't run in the main checkout (runner note: global setup rebuilds dist/).

    Scope Assessment

    Non-Goals: present (classifier rules #1682, skill text, hook blocking D-5).

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

    Verdict: ✅ SCOPE_OK

    ⚠️ Divergence: AC-3 conflicts with fixing the class (AC-1 / AC-2)

    The class fix (one site in executePhase, three per-site wraps removed) can't keep these existing assertions green, because they pin the old seam:

    1. batch-executor.evidence-reach.test.ts "puts the needs-human AC and its command in the qa config's promptContext". This asserts the block on the config passed to executePhaseWithRetry. Once the block is built inside executePhase, the config no longer carries it.
    2. ready-gate.evidence-reach.test.ts "--ready-gate … names the needs-human AC and its command". Same seam.
    3. ready-gate.evidence-reach.test.ts "sequant ready … names the needs-human AC and its command". Same seam.
    4. phase-executor.evidence-reach.test.ts "adds no block to a non-qa phase". This asserts the opposite of AC-1.
    5. ready-gate.evidence-reach.test.ts "gives an untracked issue no block and does not throw". It would still pass, because it checks the config, but its title says the opposite of AC-2.

    Owner decision needed. The recommended option is A.

    • A (recommended): fix the class. Amend AC-3 to: "The existing reach tests still pass, except the assertions that pin the per-site qa wrap (items 1–5 above). Those move to evidence-reach-dispatch.test.ts as prompt-level assertions." Result: one site and no wraps, which fits the simplify epic and the runner note ("prefer it to a fourth wrap").
    • B: keep AC-3 literal. Add the executePhase site, keep the three wraps, and make executePhase skip when promptContext already holds the block. All tests stay green with no edits. The cost is three redundant wraps plus a dedupe guard, which is four sites where there should be one. Item 5's title keeps contradicting the behaviour.

    Acceptance Criteria

    AC-1: spec/exec/qa/loop prompts each carry one block; no needs-human AC → no block

    Verification: Unit Test (dispatch-level).
    Scenario: Given a state record with AC-2 npx tsx --env-file=.env.local … → When executePhaseWithRetry runs each of spec, exec, qa and loop with dryRun: true (dry run returns the built prompt as output) → Then each prompt has exactly one sentinel block naming AC-2 and the command verbatim. With no needs-human AC, there is no block. That makes ≥ 5 cases.
    Assumptions: The loop's own promptContext (QA findings) and the block join into one sentinel block. This is the same join withEvidenceReachContext already does.

    AC-2: no state record → classified from the issue body

    Verification: Unit Test, -t "no state record".
    Scenario: Given getIssueState → null and fetchIssueBodySync → a body whose AC has an env-file Evidence → When a phase is dispatched → Then the prompt carries the block, and nothing is written to state.
    Assumptions: A failed body fetch yields no block (counted under noteSuppressed) and never throws.

    AC-3: existing reach tests pass (constraint)

    Verification: Unit Test. See the divergence above. As written, this holds only under option B.

    Implementation Plan (option A)

    Phase 1: Helpers (src/lib/evidence-reach.ts, helpers only)

    1. buildEvidenceReachContext(acs, phase = "qa"): qa keeps today's wording ("Report … as PENDING"). spec, exec and loop get: "Do not run them, including to check your own work. Leave them for a person and list them as unverified in your output." The default keeps evidence-reach.test.ts unchanged. P-9's rules are not touched.

    Phase 2: One site (src/lib/workflow/phase-executor.ts)

    1. Add resolveNeedsHumanAcs(issueNumber, deps). It reads the record through acRecordFor(issueNumber, getStateManager()). When that returns null (an untracked issue), it falls back to extractAcceptanceCriteria(fetchIssueBodySync(...)) without writing state, then needsHumanAcs(...). Errors become noteSuppressed plus an empty list.
    2. In executePhase, before getPhasePrompt, join the block for every phase into config.promptContext. Move withEvidenceReachContext here, generalised to all phases and taking the phase for wording, so there is one sentinel block per prompt. This covers the phase loop, --ready-gate, sequant ready, spec-only runs and the ready gate's loop pass, because every one of them dispatches through executePhaseWithRetry → executePhase.

    Phase 3: Remove the per-site wraps

    1. batch-executor.ts: drop the wrap in dispatchLoopPhase and in runReadyGateForIssue. Keep classifyIssueEvidence, which still feeds the per-AC reach in the run log and the summary (feat(qa): Evidence that names an env file, a production CLI or a live URL is handed to a person — classified in code, listed in the qa prompt as "do not run", recorded per AC in the run log, printed with its command in the run summary #1652). Keep withEvidenceReachContext as a re-export from batch-executor.ts, or update the one import in ready.ts.
    2. src/commands/ready.ts: drop the wrap and the acRecordFor block (lines ~351–371).

    Phase 4: Tests and changelog

    1. New src/lib/workflow/evidence-reach-dispatch.test.ts: the AC-1 cases (4 phases + none) and the AC-2 case "no state record". Rewrite items 1–5 above to the prompt seam.
    2. CHANGELOG entry. ⚠️ improve(release): changelog fragments instead of a shared [Unreleased] block — 121/192 main commits touch CHANGELOG.md #1351 (in flight) replaces ## [Unreleased] with changelog.d/ fragments. If it merges first, add a fragment instead.

    Design Review

    1. Where does this belong? In executePhase (phase-executor.ts): the one function that turns a config into a prompt for every dispatch path. No file outside "May touch" is needed (acRecordFor and getStateManager are imported, not changed).
    2. Simplest correct approach? Classify at the point the prompt is built. Rejected: a fourth wrap at the exec dispatch, which repeats the class. Also rejected: an ExecutionConfig.needsHuman field, which still needs every caller to fill it and touches types.ts (outside "May touch").
    3. Pattern and re-patch count: withEvidenceReachContext per-site wraps: 4d02df1 (feat(qa): Evidence that names an env file, a production CLI or a live URL is handed to a person — classified in code, listed in the qa prompt as "do not run", recorded per AC in the run log, printed with its command in the run summary #1652) and fd2a475 (feat(qa): the ready gate's qa passes get #1652's do-not-run block (--ready-gate and sequant ready) #1681). That is two prior fixes, so the rule is fix the class, don't add a third wrap. This is what drives the divergence on AC-3.
    4. What would a reviewer challenge? "One state read per phase dispatch, plus a gh call for untracked issues." The state read is cheap. The body fetch happens only when there is no record, which in practice means sequant ready on an untracked issue. A second challenge: "dry-run now calls gh." This is acceptable; the fetch failing yields no block.
    5. Producers and consumers of the block: producers today are dispatchLoopPhase, runReadyGateForIssue and ready.ts. After the change there is one producer, executePhase. Consumers: getPhasePrompt (the sentinel wrap) and /loop's sentinel detection (bug(loop): orchestrated Step 1A re-fetches QA findings from GitHub instead of trusting the promptContext already embedded in its own prompt #960). That detection is unaffected, since the block joins the same single sentinel. The run-log reach field (classifyIssueEvidence → recordAcStatuses, the summary) is a separate consumer of the classification and stays as it is.

    Feature Quality Planning

    Notable items:

    • The run-log reach field still comes from classifyIssueEvidence, which has no body fallback. An untracked issue under sequant run is rare because the run tracks the issue first. Out of scope; noting it here.
    • Prompt wording for spec, exec and loop must not tell those phases to "report PENDING". The test asserts per-phase wording.

    Open Questions

    1. A or B for AC-3? Recommendation: A. Impact if wrong: B leaves four sites and a test title that contradicts behaviour.
    2. Done-when smoke re-run (smoke(simplify): first real use — one detached run of a main build on two notes-fixture smoke issues, after #S-01 to #S-07 merge; the owner reads the report #1655): this is not an AC. Recommendation: run it manually after merge and record the result on smoke(simplify): first real use — one detached run of a main build on two notes-fixture smoke issues, after #S-01 to #S-07 merge; the owner reads the report #1655.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: The change is narrow, and the ACs already declare unit-test Evidence with named files. testgen would only stub a file exec writes anyway.

    Label Review

    Current: graph-2026-11-simplify. Recommended: add enhancement. Quality loop won't auto-enable (SCOPE_OK).

  4. added
    planned
    on Nov 16, 2026
  5. admarble commented on Nov 16, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 3/3 met

    Gaps:

    • The owner never chose A or B for AC-3; exec kept the three per-site wraps (B) against the spec's recommendation of A
    • dispatchNeedsHumanAcs is exported 'for testing only' but no test imports it
    • readyCommand grew to 199 lines and raised the health ratchet
    • The production (non-dry) dispatch path, with its gh fetch and state write, has no executePhase-level test
    • Three existing test titles now contradict the behaviour; they pass only because they check the config, not the prompt
    • The run-log reach field for an untracked issue under sequant run still has no body fallback; the item is neither filed nor dropped
    • The smoke(simplify): first real use — one detached run of a main build on two notes-fixture smoke issues, after #S-01 to #S-07 merge; the owner reads the report #1655 smoke re-run after merge is not done or tracked

    Reviewed in a separate session by claude-code (claude-opus-5-5); the change was written by claude-code (claude-opus-5-5).

  6. admarble commented on Nov 16, 2026

    @admarble
    ContributorAuthor

    Owner decision, 2026-11-16: option A. AC-3 is amended (see the issue body).

    The branch currently holds option B (PR #1690: 15943df8c and 1a0f70f0d). Rework it to the spec comment's option-A plan:

    • One site: executePhase (phase-executor.ts) joins the block for every phase, with per-phase wording. It classifies through the state record, and falls back to the issue body without writing state.
    • Remove the per-site wraps in dispatchLoopPhase, runReadyGateForIssue and src/commands/ready.ts, and remove the dedupe guard B added.
    • Move withEvidenceReachContext's definition out of batch-executor.ts. AC-3's grep counts withEvidenceReachContext( in batch-executor.ts and ready.ts, so a definition left there counts. A plain re-export has no ( and doesn't count.
    • Keep classifyIssueEvidence. It still feeds the run log's reach field and the summary.
    • Move the five wrap-seam assertions (spec items 1–5) into evidence-reach-dispatch.test.ts as prompt-level assertions. Delete or retitle the old ones so no test title contradicts the behaviour.
    • Keep the "no state record" case working on every path. ready.ts's helper can go if executePhase covers it.

    The spec's SPEC_DIVERGENCE didn't stop the first run because its marker had no timestamp (filed as #1691). Don't fix that here.

    Run vitest only in the worktree. vitest.global-setup.ts rebuilds dist/.

  7. added a commit that references this issue on Nov 16, 2026
  8. admarble commented on Nov 16, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 3/3 met

    Gaps:

    • AC registration from the issue body moves from first qa to first phase dispatch (spec) and is never refreshed, so ACs amended after spec stay stale in state.json and in the block; not in CHANGELOG
    • Deferred item has no terminal state (not filed or dropped)
    • Post-merge smoke re-run is not filed or tracked
    • Cached untracked-issue bodies never expire in a long-lived MCP server process
    • Required CI test check had not reported at review time

    Reviewed in a separate session by claude-code (claude-opus-5-5); the change was written by claude-code (claude-opus-5-5).

  9. added a commit that references this issue on Nov 16, 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

    graph-2026-11-simplifyplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions