Repository navigation
Description
Epic: graph-2026-10-ergonomics Tier: judgment Execution: sequant_run Blocked by: #1602
Problem
CLAUDE.md's gate-test rule and /qa §6i ask the agent to mutate, run, restore and then type a <!-- SEQUANT_MUTATION … --> line by hand. That procedure has wiped uncommitted work five times (#817, #906, #939, #1044, #1050; #883 deleted a worktree), tripped 2 of 4 gate PRs on the marker contract (#1104), lost markers to a } (#1305) and to a four-hop PR-body chain (#1316). Nothing today proves the cited test ran: §6i checks only that the named file is in the diff. 33 of 184 memories are some form of "QA claimed it without running it". §4 of the founding doc.
Decisions
| ID | Decision | Rejected alternative |
|---|---|---|
| D-2.1 | begin --issue N exits 2 on a dirty tree ("commit first"), records HEAD + time in .sequant/mutations/<N>.json |
tolerating a dirty tree and stashing (the stash is the thing that gets lost) |
| D-2.2 | The agent applies the mutation with its own edit tools | a mutation DSL |
| D-2.3 | check --issue N --ac AC-K --test <file> --name "<describe> > <case>" --mutation "<text>", in order, aborting at the first failure with the state file untouched: (1) no commit since begin; (2) npx vitest list <file> -t <escaped name> prints exactly one test; (3) git add -A then git diff --cached --binary captured as the patch (created and deleted files included); (4) npx vitest run <file> -t <escaped name> exits non-zero; (5) git apply -R --index the patch, then git status --porcelain empty; (6) the same run exits 0 without the mutation (a broken test cannot be certified); (7) append {ac, test, name, mutation, mutatedExit, restoredExit, ranAt, sha}. On abort the patch stays at .sequant/mutations/<N>.patch. All paths resolve against the current worktree, never the main checkout |
reverting with git checkout -- <file> (misses deletions and new files; the historical wipe); accepting any non-zero exit without the restored-pass check |
| D-2.4 | The PR body stays the source of truth (#1316 owner decision, ADR-0004); QA keeps reading $PR_BODY. render --issue N prints the marker lines via renderMutationMarker from the state file, exec pastes them into its ## Summary, and under the orchestrator the PR-body assembly can read the same state file directly. Skills stop typing markers (the swap is #1606). #1316 asked whether to move the channel; this leaves the channel and fixes the origin |
moving the channel off the PR body (rejected on #1316); keeping hand-typed markers as a fallback (two producers) |
| D-2.5 | Scope stays gate-test ACs; widening is #939 AC-5's backtest | widening now |
Acceptance Criteria
- AC-1:
beginrefuses a dirty tree and records HEAD on a clean one. Evidence:npx vitest run src/commands/mutation.test.ts -t "begin"→≥ 2 passed, 0 failed - AC-2:
checkrecords a result only when the named test fails under the mutation and passes after the restore, and restores the tree byte-for-byte including a deleted and a newly added file. Evidence:npx vitest run src/commands/mutation.test.ts -t "check restores"→≥ 4 passed, 0 failed(test passes under mutation → exit 2, no record; test fails under mutation and passes after restore → one record withmutatedExit != 0andrestoredExit == 0; test fails both ways → exit 2, no record, message names the broken test; a mutation that deletes one file and adds another →git status --porcelainempty after) - AC-3: A commit between
beginandcheckaborts the check. Evidence:npx vitest run src/commands/mutation.test.ts -t "commit mid-mutation"→≥ 1 passed, 0 failed - AC-4:
-tmatching exactly one test is required, checked withvitest listbefore anything runs. Evidence:npx vitest run src/commands/mutation.test.ts -t "ambiguous name"→≥ 2 passed, 0 failed(two tests match → exit 2 naming both; zero match → exit 2) - AC-5:
renderoutput round-trips throughparseMutationMarkers, including a mutation text containing}and>. Evidence:npx vitest run src/lib/workflow/mutation-marker.test.ts -t "round-trip from state"→≥ 2 passed, 0 failed - AC-6: Under the orchestrator, exec's PR body carries the markers from the state file without the agent writing them. Evidence:
npx vitest run src/lib/workflow/batch-executor.test.ts -t "mutation state"→≥ 1 passed, 0 failed(a fake state file with two records → two marker lines in the body; empty state → none) - AC-7: A reference page documents the three subcommands and the state file. Evidence:
grep -cE '^## (begin|check|render)' docs/reference/mutation-verification.md→3 - AC-8: 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)
May touch
src/commands/mutation.ts (new) and test, bin/cli.ts, src/lib/workflow/mutation-marker.ts and test, the PR-body assembly after exec (in batch-executor.ts or the stage module #1507 split it into), docs/reference/mutation-verification.md (new), CHANGELOG.
Non-Goals
- Editing
/qa§6i or/execprose (frozen; feat(skills): the human-surface reference — decisions viaAskUserQuestion, waiting per mode, completion with a link; skills callsequant comment renderandsequant mutation …instead of hand-rendering #1606). - Running the whole suite;
checkruns one file with one-t. - Widening beyond gate-test ACs.
Done when
The only way a SEQUANT_MUTATION marker reaches a PR body is through a recorded run that actually failed, from a tree that was clean before and after.
Activity
admarble commentedon Oct 27, 2026
Runner context (2026-10-26, before the W0 launch). For the spec, exec and qa phases.
main:docs/internal/graph-2026-10-ergonomics/PROJECT-DISCUSSION.md(the §N citations in this issue point there) andphase0-evidence.md. Read the cited section before planning; D-rows there are decisions, not suggestions. If implementing shows a D-row is wrong, say so in the PR body rather than quietly deviating..claude/skills/**,templates/skills/**orplugin/**. Skill-side changes belong to feat(skills): the human-surface reference — decisions viaAskUserQuestion, waiting per mode, completion with a link; skills callsequant comment renderandsequant mutation …instead of hand-rendering #1606.npm testat most once, in the foreground, withtimeout 1500, and only after a WIP commit. Prefer targetednpx vitest run <file>while iterating. Each phase has a hard 30-minute wall; the suite takes 10–13 minutes.CLAUDE.mdrule: a mutation-verified record in the PR body,failedTeststarting with the test file path. A mutation must still type-check (delete the block, neverfalse &&).Issue-specific: §4 D-2.3 fixes the check sequence (clean tree →
vitest listresolves exactly one test →git add -A+git diff --cached --binaryas the patch → run must fail under the mutation →git apply -R --index→ tree clean → run must pass without the mutation → record under.sequant/mutations/<N>.json). D-2.4: the PR body stays the marker's source of truth; only the producer changes.renderMutationMarker/parseMutationMarkers/classifyMutationMarkeralready live insrc/lib/workflow/mutation-marker.ts;sequant mutation rendermust call the existing renderer, not a second one. If the PR-body assembly turns out to have more than one writer, surface it in the PR body instead of adding a third.admarble commentedon Oct 27, 2026
Complexity: Standard (8 ACs, 4 directories:
src/commands,src/lib/workflow,bin,docs/reference)AC Quality Check
All 8 ACs are one line, each has an
Evidence:clause, and the issue has a## Non-Goalssection.d6d66a9cf). AC-1–4 name a test file that does not exist yet, so they fail today. AC-7's file does not exist. AC-5 and AC-6 exit 0 today:npx vitest run src/lib/workflow/mutation-marker.test.ts -t "round-trip from state"exits 0 with26 skipped, because vitest exits 0 when-tmatches nothing. Those ACs gate only on the≥ N passedcount, not on the exit code. QA has to read the passed count.Scope Assessment
Non-Goals: present (no edits to
/qa§6i or/execprose; no full suite run; no widening beyond gate-test ACs).Verdict:⚠️ SCOPE_WARNING (directory spread). This turns the quality loop on.
Acceptance Criteria
beginruns, then it exits 2 with "commit first" and writes no file. Given a clean tree, it writes{sha: HEAD, startedAt}to.sequant/mutations/<N>.json. Assumption:.sequant/*is gitignored (.gitignore:50), so the state file never makes the tree dirty.git status --porcelainempty plus a byte compare of the deleted file.begin, thencheckexits 2. The state file is unchanged and the tree is not touched.listreturns 2 matches, then 0 matches. Both exit 2 before anyrun. The message names both matches.mutation-marker.test.ts: record →renderMutationMarker→parseMutationMarkers, with}and>inmutation.batch-executor.test.ts: two records → two markers in the bodycreatePRreceives; an empty or missing state file → none.docs/reference/mutation-verification.mdwith## begin,## check,## renderand the state-file schema.Implementation Plan
Phase 1: Core module
src/lib/workflow/mutation-state.ts. It holds the zod schema for{issue, sha, startedAt, records: [{ac, test, name, mutation, mutatedExit, restoredExit, ranAt, sha}]}, read and write helpers keyed on acwd(git rev-parse --show-toplevelof the current worktree), andrecordToMarker(r)→{ac, mutation, failedTest: \${r.test} > ${r.name}`}.failedTest` starts with the repo-relative test file path, as §6i requires.checktakes aVitestRunnerinterface (list(file, pattern)returns the matched names;run(file, pattern)returns{exit, testState}). The default runner shells out tonpx vitest list --jsonandnpx vitest run --reporter=json. Tests inject a fake. This keepsmutation.test.tswithin the 5 s unit-project timeout and keeps real-vitest-inside-vitest out of the suite.Phase 2: CLI,
src/commands/mutation.ts+bin/cli.tsbegin,checkandrenderare subcommands ofprogram.command("mutation"), the same shape asstateCmd(bin/cli.ts:778).checkruns the D-2.3 steps in order. It aborts with exit 2 at the first failure, leaves the state file untouched, and writes the patch to.sequant/mutations/<N>.patchonce step 3 has captured it. It also aborts on an empty patch ("no mutation applied").render --issue Nprints onerenderMutationMarker(recordToMarker(r))line per record, latest per AC. It calls the existing renderer; it does not add a second one.Phase 3: Orchestrator consumer
openOrUpdatePR(batch-executor.ts:1355), read<prPath>/.sequant/mutations/<issue>.jsonand pass the rendered markers tocreatePRthrough a newopts.mutationMarkers.composeExecSummary/buildAutomatedPRBody(worktree-manager.ts:2483,:2661) append them after the same key-based dedup they already do. A marker exec pasted fromrenderand the same marker read from the file then appear once.postReadFirstForPR(batch-executor.ts:3083) reads its markers from exec output. Point it at the same state-file reader.Phase 4: Docs
docs/reference/mutation-verification.mdand a CHANGELOG line. ADR: see Design Review Q4.Design Review
src/lib/workflow/next tomutation-marker.ts. The git and vitest procedure goes in the command. The PR body keeps the one composer it has today,buildAutomatedPRBody. This step adds a source to it, not a second writer.AskUserQuestion, waiting per mode, completion with a link; skills callsequant comment renderandsequant mutation …instead of hand-rendering #1606); a separatemutation-rendermodule (D-2.4 requires the existing renderer).SEQUANT_MUTATIONmarker has had repeated fixes: docs(exec/qa): the SEQUANT_MUTATION failedTest contract (<test file> > <name>) is enforced by the classifier but never told to authors — tripped 2 of 4 gate PRs #1104, fix(run): PR body falls back to the placeholder when exec writes no "## Summary" heading, dropping exec's mutation markers and AC table #1297 (PR fix(#1297): PR body falls back to the placeholder when exec writes no "## Summary" heading, dropping exec's mutation markers and AC table #1300), fix(qa): a SEQUANT_MUTATION marker whose text contains "}" parses to nothing — renderMutationMarker and the parser do not round-trip #1305 (PR fix(#1305): a SEQUANT_MUTATION marker containing } now round-trips #1465), investigation(qa): mutation markers travel through a four-hop PR-body chain that has broken four ways — should QA's evidence move to a sequant-owned channel? #1316. That is past the ≥2 threshold. This issue is the class fix (C-3: one producer), so it is not one more local patch. Not a divergence.exits non-zerocertifies the wrong failures." If the mutation deletes the test file or breaks its import, vitest exits 1 ("No test files found", or a collection error), and D-2.3 step 4 would certify a test that never ran. Recommendation: step 4 requires the named test's own state to befailin vitest's JSON report, not just a non-zero exit. Step 6 requirespass. This makes D-2.3 stricter, not looser. Per the runner context, say so in the PR body. An ADR indocs/adr/(next is 0022) records this and the injected-runner choice.parseMutationMarkersFromExecOutputincomposeExecSummary(worktree-manager.ts:2496) and inpostReadFirstForPR(batch-executor.ts:3085); (b) new: the state file. Consumers:/qa§6i ($PR_BODY),review-residue(read-first), and the testsworktree-manager.build-pr-body.test.tsandexec-orchestrated-no-pr-skill.test.ts. There are still 2 producers until feat(skills): the human-surface reference — decisions viaAskUserQuestion, waiting per mode, completion with a link; skills callsequant comment renderandsequant mutation …instead of hand-rendering #1606 (see OQ-1). There is one PR-body writer (createPR, fix(run): sequant run has two PR producers — exec opens the PR itself and createPR returns it untouched, dropping the QA note, ready-gate report and summary #1247), so no third writer is added.Feature Quality Planning
beginhas passed,checknever runsgit checkout,stashorreset. Restoring uses onlygit apply -R --indexof the captured patch. A gitignored file the mutation creates is not in the patch; the docs page says so.-tis a regex. Escape the regex metacharacters in--name. The full name invitest list --jsonuses>(checked:mutation-marker > renderMutationMarker round-trip (#1305) > …). Exec must check how-tmatches a>-joined name in vitest 5.0.4 and convert the separator if it needs to. That is an assumption to check before writing code.state-exit-code).SEQUANT_MUTATIONrecord. Dogfood it: exec generates its own records withsequant mutation check(from the worktree'sdist/) once the command is built.Open Questions
AskUserQuestion, waiting per mode, completion with a link; skills callsequant comment renderandsequant mutation …instead of hand-rendering #1606. This PR adds the state file as a source and dedupes. feat(skills): the human-surface reference — decisions viaAskUserQuestion, waiting per mode, completion with a link; skills callsequant comment renderandsequant mutation …instead of hand-rendering #1606 removes the hand-typed path when skills switch over. Impact if wrong: filtering now would drop every gate-test marker from orchestrated runs until feat(skills): the human-surface reference — decisions viaAskUserQuestion, waiting per mode, completion with a link; skills callsequant comment renderandsequant mutation …instead of hand-rendering #1606 lands, because the frozen skills still tell exec to type them, and §6i would floor those ACs atAC_NOT_MET. The "Done when" line is fully met only after feat(skills): the human-surface reference — decisions viaAskUserQuestion, waiting per mode, completion with a link; skills callsequant comment renderandsequant mutation …instead of hand-rendering #1606. The PR body says so..sequant/mutations/, which is theprPathopenOrUpdatePRalready gets. A QA-only re-run with no worktree finds no file and adds nothing.Recommended Workflow
Phases: exec → qa⚠️ , so the quality loop is on.
Quality Loop: enabled
Reasoning: The ACs declare unit-test evidence, but their test names are already fixed in the issue, so testgen stubs would only repeat them. testgen is skipped on purpose. The command runs git operations that can lose uncommitted work, and the directory spread is
Label Review
Current: graph-2026-10-ergonomics. Recommended: add
planned,enhancement. The quality loop is on because of the scope warning.admarble commentedon Oct 27, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
Gaps:
fix(#1604): check restores the tree when the runner throws, three fil…
chore(#1604): merge origin/main (ADR README keeps rows 0022 and 0023)
feat(#1604): sequant mutation begin | check | render — mutation verif…