Skip to content

feat(#1604): sequant mutation begin | check | render — mutation verification refuses a dirty tree, requires a real failing run, restores by patch, and is the only producer of SEQUANT_MUTATION markers - #1620

Merged
admarble merged 5 commits into
mainfrom
feature/1604-feat-cli-sequant-mutation-begin-check-render-mutat
Oct 28, 2026

Conversation

@admarble

@admarble admarble commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

What changed

  • sequant mutation begin --issue N exits 2 with "commit first" if the tree has changes. On a clean tree it records HEAD and the time in .sequant/mutations/N.json, keeping any earlier records.
  • sequant mutation check runs the D-2.3 steps in order:
    • HEAD has not moved since begin.
    • vitest list finds exactly one test for the name.
    • It captures the mutation as a patch with git add -A and git diff --cached --binary.
    • The named test must fail under the mutation.
    • It restores the tree with git apply -R --index and checks the tree is clean.
    • The test must then pass.
    • Only then does it append the record.
  • check never runs git checkout, stash or reset. Its own record file is never counted as a change, even in a repo that doesn't ignore .sequant/.
  • sequant mutation render prints one marker per AC (the latest record wins) through the existing renderMutationMarker. It does not add a second renderer.
  • Under the orchestrator: openOrUpdatePR reads the worktree's record file and passes its markers to createPR. buildAutomatedPRBody adds each marker the exec summary doesn't already contain, so a pasted marker still appears once. The "Read first" comment uses the same reader. There is still only one PR-body writer (createPR).
  • Docs: docs/reference/mutation-verification.md, ADR-0022, index rows in docs/README.md, docs/adr/README.md and the cheat sheet, and a CHANGELOG entry.

Where this goes beyond the spec (for review)

Acceptance criteria

AC Status Evidence
AC-1 ✅ -t "begin": 4 passed, 0 failed
AC-2 ✅ -t "check restores": 6 passed (passes under mutation → 2, no record; fails then passes → 1 record; fails both ways → 2, names the test; delete + add restored byte-for-byte; plus "did not run" and empty mutation)
AC-3 ✅ -t "commit mid-mutation": 1 passed
AC-4 ✅ -t "ambiguous name": 3 passed
AC-5 ✅ mutation-marker.test.ts -t "round-trip from state": 2 passed
AC-6 ✅ batch-executor.test.ts -t "mutation state": 2 passed
AC-7 ✅ grep -cE '^## (begin|check|render)' gives 3
AC-8 ✅ skill-directory diff count is 0

Mutation records. All six come from real node dist/bin/cli.js mutation check runs on this branch (each about 14 s). I also ran the real refusal paths: an ambiguous name (exit 2, both names listed), a mutation the test doesn't catch (exit 2, tree restored, record file byte-identical) and begin on a dirty tree (exit 2). All six markers classify valid under `

Fixes #1604

QA verdict: AC_MET_BUT_NOT_A_PLUS — acceptance criteria met, but not A+. The run broke to this PR for review rather than entering the quality loop; see the QA review comment for improvement notes.

Runner verification (graph-run, 2026-10-26)

Executed in the worktree at 1185e29, then again at 7552a80:

  • AC-1 -t "begin" → 4 passed; AC-3 -t "commit mid-mutation" → 1 passed; AC-4 -t "ambiguous name" → 3 passed; whole src/commands/mutation.test.ts → 15 passed, now 16.
  • AC-5 npx vitest run src/lib/workflow/mutation-marker.test.ts -t "round-trip from state" → 2 passed.
  • AC-6 npx vitest run src/lib/workflow/batch-executor.test.ts -t "mutation state" → 2 passed.
  • AC-7 grep -cE '^## (begin|check|render)' docs/reference/mutation-verification.md → 3. AC-8 skill-dir diff count → 0.
  • npx tsc --noEmit, eslint --max-warnings 0 and npm run lint:health clean after the fix commit (unusedExports back at the 339 baseline).

Fix commit 7552a80 beyond the agent's work, from the QA fix_now findings: checkMutation step (4) now catches a throwing runner, restores by patch first and names the patch path (test restores the tree and names the patch when the runner throws under the mutation); defaultVitestRunner, renderMutation and VitestRunResult are file-local. The ADR is renumbered 0022 → 0023 in all five places because #1618 ships ADR-0022 and lands first; grep 0022 over the branch's files finds nothing.

The SEQUANT_QA_VERDICT on the issue names commit 1185e29; the runner fix is the only commit after it. This PR lands after #1618 and needs one CHANGELOG.md / docs/adr/README.md re-merge round from main.


🤖 Generated by sequant run

…ication refuses a dirty tree, requires a real failing run, restores by patch, and produces the SEQUANT_MUTATION markers

begin records HEAD on a clean tree; check resolves one test with vitest list, captures the mutation with git add -A + git diff --cached --binary, requires the named test to fail under it and pass after git apply -R --index, and appends the record to .sequant/mutations/<N>.json; render prints markers through renderMutationMarker. Under sequant run, openOrUpdatePR reads the record file and buildAutomatedPRBody appends its markers, deduped against exec's. renderMutationMarker escapes backticks. ADR-0022, docs/reference/mutation-verification.md.

Entire-Checkpoint: 8b53a986ce4a
…e-local exports unexported, ADR renumbered to 0023 behind #1603

QA fix_now items from the #1604 verdict: a runner that throws after the patch is captured now restores by patch and names the patch path (new test); defaultVitestRunner, renderMutation and VitestRunResult are file-local so lint:health returns to the baseline. The ADR moves from 0022 to 0023 because #1603's PR #1618 ships ADR-0022 and lands first.

Entire-Checkpoint: 776551c51856
@admarble
admarble merged commit ba5510b into main Oct 28, 2026
9 of 10 checks passed
@admarble
admarble deleted the feature/1604-feat-cli-sequant-mutation-begin-check-render-mutat branch October 28, 2026 06:45
admarble added a commit that referenced this pull request Oct 28, 2026
…, #1620), D-4.2 ADR numbers assigned at merge, next W0b #1605 (#1623)

Entire-Checkpoint: 0d581f61c4e9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant