Skip to content

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

Closed

Description

@admarble

Epic: graph-2026-11-simplify Tier: judgment Execution: split Blocked by: #1648 (the qa dispatch site in batch-executor.ts and types.ts are edited by #1646 to #1648)

Problem

D-8: an Evidence line that names an env file, a production CLI or a live URL becomes a pending row with the command shown, run by a person (as #1630 proposes for CI). In E2c (15 sequant runs on a private mirror of a repo that reaches production, 2026-11-02 to 11-03), the phase agents tried to use production credentials in 6 of 15 runs because the issues' Evidence lines named --env-file=.env.local and live checks: npx tsx --env-file=.env.local scripts/dev/query.ts …, vercel env ls production, a read of the main checkout's .env.local. A sandbox and absent files stopped every attempt; nothing in sequant did (#1641). The qa skill's §6h runs each Evidence command as written, and the skill is frozen. Founding doc §4, P-8, P-9, OQ-3.

Decisions

ID Decision Rejected
E-1 classifyEvidenceReach(evidence: string) in a new src/lib/evidence-reach.ts returns { reach: "worktree" | "needs-human", reasons: ("env-file" | "production-cli" | "live-url")[] } by P-9's rules, applied to the backticked command(s) in the clause a configurable list
E-2 The qa dispatch builds a promptContext block listing each needs-human AC with its command and the instruction: do not run it; report the AC as PENDING with the command shown, for a person to run. It joins any existing context in the one sentinel block getPhasePrompt appends a second sentinel; a hook (D-5)
E-3 The run log's acs[] entry gains optional reach and reachReasons (I-2: additive, version: 1) a new top-level field
E-4 The run summary prints AC-N needs a person: <command> for each needs-human AC, whatever the QA output said trusting the QA output alone (OQ-3: whether the agent obeys is unverified)

Prior fixes / producers

Acceptance Criteria

  • AC-1: The classifier marks --env-file, a .env path, each listed production CLI and a non-local URL as needs-human, and leaves npx vitest run …, a localhost URL and a grep whose pattern contains https:// as worktree. Evidence: npx vitest run src/lib/evidence-reach.test.ts → ≥ 8 passed, 0 failed
  • AC-2: The qa prompt for an issue with one needs-human AC carries exactly one sentinel block naming that AC and its command verbatim, and an issue with none gets no reach block. Evidence: npx vitest run src/lib/workflow/phase-executor.evidence-reach.test.ts → ≥ 2 passed, 0 failed
  • AC-3: The run log records reach per AC and an old log without it validates. Evidence: npx vitest run src/lib/workflow/run-log-schema.test.ts -t "reach" → ≥ 2 passed, 0 failed
  • AC-4: The run summary prints one needs a person line per needs-human AC with its command. Evidence: npx vitest run src/commands/run-display.test.ts -t "needs a person" → ≥ 1 passed, 0 failed
  • 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)

The real-run half (does the agent obey; what verdict results) is #1655 (Execution: split, OQ-3, OQ-6).

May touch

src/lib/evidence-reach.ts and test (new), src/lib/workflow/batch-executor.ts (the qa dispatch's promptContext only), src/lib/workflow/phase-executor.ts (getPhasePrompt context join only) and phase-executor.evidence-reach.test.ts (new), src/lib/workflow/run-log-schema.ts, log-writer.ts, ac-status.ts (the acs[] entry only), src/commands/run-display.ts and test, docs/reference/run-command.md (one paragraph), CHANGELOG.

Non-Goals

Done when

Every qa dispatch tells the agent which Evidence lines are a person's to run, and the run log and summary name them, for every issue.

Activity

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

    @admarble
    ContributorAuthor

    Runner context, 2026-11-11: repo state since this issue was written

    #1646 to #1648 merged; main is at d1eb83be7.

  3. admarble commented on Nov 11, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (5 ACs, 4 directories)

    AC Quality Check

    • All 5 ACs are single-line and carry a command Evidence: clause. ✅
    • Vacuity check, run against main at d1eb83be7: evidence-reach.test.ts and phase-executor.evidence-reach.test.ts don't exist yet. -t "reach" matches nothing in run-log-schema.test.ts, and -t "needs a person" matches nothing in run-display.test.ts. So AC-1 to AC-4 all fail today. AC-5 is a constraint. None of them is vacuous.
    • ⚠️ AC-2 gates getPhasePrompt, not the dispatch. A test that passes a prebuilt context to getPhasePrompt stays green even if the qa dispatch in batch-executor.ts never passes the block. That missing link is exactly what this issue fixes, so derived AC-6 below closes the gap.
    • ⚠️ AC-1's grep case conflicts with P-9 as written. Under P-9, any non-local http(s) URL is needs-human, but AC-1 wants grep 'https://…' to stay worktree. The rule needs a first-word exception (see OQ-1).

    Scope Assessment

    Non-Goals: present. They cover §6h text, the verdict rules, buildQaVerdictComment, run.denyPaths, the README security section, and hook blocking.

    Metric Value Status
    Feature count 1 (one classifier with 3 consumers) ✅
    AC items 5 (+1 derived) ✅
    Directory spread 4 (src/lib, src/lib/workflow, src/commands, docs/reference) ✅

    Verdict: ✅ SCOPE_OK

    Blocker: #1648 is CLOSED (merged as #1674), so this issue is unblocked.

    Conflict risk: #1650 and #1651 (open worktrees) both edit docs/reference/run-command.md and CHANGELOG.md. Put the paragraph under ### Phase agent environment, which neither of them touches, and expect a CHANGELOG merge conflict. The #1351 worktree only touches skill directories, so it doesn't overlap.


    Acceptance Criteria

    AC-1: Classifier rules

    Verification: Unit Test (src/lib/evidence-reach.test.ts, ≥ 8 cases)
    Scenario: Given an Evidence clause → When classifyEvidenceReach(clause) runs → Then the result is needs-human with reasons for:

    • --env-file=.env.local
    • a .env / .env.production path
    • each of the 10 P-9 CLIs, including when invoked as npx vercel …
    • an https://api.example.com URL

    and worktree for:

    • npx vitest run …
    • curl http://localhost:3000
    • grep -c 'https://x' f

    Assumptions:

    • Only the backticked spans in the clause are classified. A prose-only clause (no backticks) is worktree, because qa doesn't run prose.
    • Expected-output spans such as `≥ 8 passed` classify as worktree without special handling.

    AC-2: qa prompt block

    Verification: Unit Test (phase-executor.evidence-reach.test.ts)
    Scenario:

    • Given one needs-human AC → When the qa prompt is built → Then exactly one SEQUANT_PROMPT_CONTEXT sentinel pair is present, and it contains AC-N and the command byte-for-byte.
    • Given none → Then there is no sentinel.

    AC-3: Run-log reach

    Verification: Unit Test (run-log-schema.test.ts -t "reach")
    Scenario:

    • An acs[] entry with reach: "needs-human", reachReasons: ["env-file"] validates.
    • A version: 1 log whose acs[] entries have no reach still validates.

    AC-4: Summary line

    Verification: Unit Test (run-display.test.ts -t "needs a person")
    Scenario: Given a result with one needs-human AC → When displaySummary runs → Then stdout has AC-N needs a person: `<command>` . The command is backticked and verbatim, because #1655 AC-2 greps needs a person: .npx tsx --env-file. The line prints whatever the QA verdict or output said.

    AC-5: No skill edits

    Verification: constraint (the git diff grep returns 0).

    AC-6 (derived): The qa dispatch passes the block

    Verification: Unit Test, mutation-verified.
    Scenario: Given an issue with one needs-human AC → When the batch executor dispatches qa → Then the promptContext in the ExecutionConfig it hands to executePhaseWithRetry contains the reach block.
    Mutation: delete the promptContext line at the qa dispatch; this test must fail while AC-2 stays green.


    Implementation Plan

    Phase 1: Classifier (src/lib/evidence-reach.ts, new)

    1. Add classifyEvidenceReach(evidence). It returns { reach, reasons } and applies these rules to each backticked span:
      • Split the span on &&, ||, ; and |.
      • For each segment, strip leading VAR=x assignments and a runner prefix (npx, pnpm dlx, bunx, pnpm exec), then take the first word.
      • env-file: --env-file anywhere, or a token matching (^|[\s/'"=])\.env(\.[\w-]+)*\b.
      • production-cli: the first word is in the fixed P-9 list (vercel, supabase, netlify, fly, heroku, wrangler, railway, aws, gcloud, az).
      • live-url: an https?:// host that isn't localhost, 127.0.0.1, 0.0.0.0 or [::1], unless the segment's first word is a text-search tool (grep, rg, git grep, ag). This is OQ-1.
      • Reasons are de-duplicated and kept in a stable order.
    2. Add evidenceCommands(evidence): string[], which returns the backticked spans. The needs-human ones are the commands the prompt and summary show.
    3. Add buildEvidenceReachContext(items: {id, evidence?}[]): string | undefined. It returns undefined when no AC is needs-human. Otherwise it returns a block headed for the qa agent: "Do not run these Evidence commands. Report each AC as PENDING with the command shown, for a person to run." It then lists one line per AC: - AC-N: \``.

    Phase 2: Wiring (batch-executor.ts, ac-status.ts, types.ts)

    1. In ac-status.ts, export acRecordFor (or a thin loadAcRecord) so the dispatch reads the same AC record recordAcStatuses uses. That record comes from state, falling back to the issue body.
    2. At the qa dispatch (batch-executor.ts:2187, phase === "qa" only), compute the reach once per issue and cache it on IssueRunState. Join the reach block with any existing issueConfig.promptContext using "\n\n", and pass the result as promptContext. getPhasePrompt keeps appending one sentinel block, so phase-executor.ts likely needs no change. Pull the config build into a small exported helper so AC-6 can test it directly.
    3. In recordAcStatuses, accept an optional reach map and add reach/reachReasons to each AcStatusEntry. In run-log-schema.ts:393, add reach: z.enum(["worktree","needs-human"]).optional() and reachReasons: z.array(z.enum([...])).optional(). The log stays at version: 1 (I-2). log-writer.ts serialises acs whole, so check that it passes the new fields through.
    4. Add an optional needsHuman?: { id: string; command: string }[] to IssueResult (types.ts). Set it from the cached reach whenever qa was dispatched, whatever the verdict (E-4).

    Phase 3: Summary and docs

    1. In run-display.ts displaySummary, after the ready-gate block, print #N AC-N needs a person: `<command>` for each entry. Print one line per command when an AC has more than one needs-human command.
    2. Add one paragraph to docs/reference/run-command.md under ### Phase agent environment and a CHANGELOG entry.

    Design Review

    1. Where does this logic belong? The pure classifier goes in src/lib/evidence-reach.ts, next to ac-parser.ts, the other Evidence consumer. The wiring goes in the orchestrator's qa dispatch. Neither change touches skills, which stay frozen.
    2. What's the simplest correct approach? A fixed list plus regexes, routed through the existing promptContext channel.
      • Rejected: a configurable list (P-9), a second sentinel (E-2), a hook (D-5).
      • Rejected: reading the reach back from the QA output. OQ-3 says obedience is unverified, so the summary trusts the classifier, not the agent.
    3. What existing pattern does this follow, and how often has it been re-patched?
    4. What would a senior reviewer challenge?
      • "Why not export splitEvidenceClause?" The AC record already carries evidence (ac-parser.ts:211, state schema :249), so there's nothing new to parse.
      • "Isn't the URL rule too broad?" gh api https://api.github.com/… would be needs-human. That's accepted, because it is a live call.
      • "Why is the classifier applied to the whole span rather than to argv?" Shell parsing is out of scope. Splitting on operators covers the E2c cases.
    5. Every producer and consumer of the changed artifact:
      • Producers of acs[]: ac-status.ts recordAcStatuses → LogWriter.setAcStatuses. There is only one.
      • Consumers of acs[]: log-writer.ts:349, run-log-schema.ts, scripts/qa/ac-attribution-rate.ts and scripts/qa/ac-status-parse-coverage.ts. Both scripts read id/status, so additive fields are safe.
      • Producers of promptContext: the loop dispatch (batch-executor.ts:2671), the ready-gate loop (ready-gate.ts:817), and qa (new).

    Sibling site (not widened, your call): the ready gate dispatches qa a second time (ready-gate.ts:724, through runReadyGateForIssue and sequant ready), with no promptContext. "Done when: every qa dispatch" covers it, but May-touch leaves ready-gate.ts out. See OQ-2.


    Feature Quality Planning

    All standard checks pass. Notable items:

    • No secrets are read. The classifier only matches strings and never opens .env files.
    • Prompt injection: the command is quoted verbatim into the qa prompt. It comes from the issue body, which already reaches qa through gh, so no new trust surface is added.
    • Run-log compatibility: both new fields are optional, and the AC-3 old-log case covers this.

    Derived ACs

    Source Derived AC Priority
    Gate coverage (AC-2 only reaches getPhasePrompt) AC-6: the qa dispatch's ExecutionConfig.promptContext carries the reach block. Mutation-verified per CLAUDE.md. High

    Open Questions

    1. How should the URL rule handle a search pattern? Recommendation: exempt segments whose first word is grep, rg, git grep or ag. The alternative, "a quoted URL is a pattern", would miss curl "https://…". Impact if wrong: AC-1's grep case fails, or a live curl slips through.
    2. Should the ready gate's qa dispatch get the reach block too? Recommendation: file a follow-up rather than widen this issue. ready-gate.ts isn't in May-touch, and docs(ready): the ready gate's docs drop the second-look claim — describe the qa → loop → qa mechanism and its policy, cite #1344 for what was measured #1650 is editing the ready-gate docs. Impact: until then, sequant ready and --ready-gate QA passes can still run needs-human Evidence. The run summary still names those ACs.
    3. IssueResult.needsHuman lives in types.ts, which isn't in May-touch. Recommendation: accept it, because it is the only path from the executor to displaySummary. Reading the run log back from disk is the alternative, and it fails under --no-log.

    Recommended Workflow

    Phases: spec → testgen → exec → qa
    Quality Loop: disabled
    Reasoning: AC-1 to AC-4 declare unit-test Evidence on new test files, so testgen should stub them first. Scope is OK, and the change is additive behind optional fields.


    Label Review

    • Current labels: graph-2026-11-simplify
    • Recommended: add enhancement and planned.
    • Reason: this is a new feature, an additive classifier and summary line, with no UI.
    • Quality Loop: won't auto-enable, because the scope verdict is OK.
  4. added
    planned
    enhancement
    on Nov 11, 2026
  5. admarble commented on Nov 11, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 6/6 met

    Gaps:

    • The sequant ready / --ready-gate QA pass does not receive the needs-human do-not-run block, while the issue's Done-when says every qa dispatch — unresolved (file or drop)
    • Production CLIs invoked via npm exec, env, sh -c, or the flyctl binary name bypass the production-cli rule
    • Required CI checks were still pending when QA ran; re-check before merge

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

  6. added 2 commits that reference 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

    enhancementgraph-2026-11-simplifyplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions