Repository navigation
Closed
Labels
Description
Description
createCheckpointCommit in chain mode runs git add -A before committing, staging every dirty file in the worktree — including files unrelated to the issue. On a recent chain run (portfolio-2025 #27 → #28), this swept 23 unrelated .claude/* / .sequant-manifest.json files from a dirty tree into a01fe91 checkpoint(#27): QA passed, and those files became the base for PR #37. PR #37 shipped +5600 lines of noise until I manually rebased it off.
Root cause
src/lib/workflow/worktree-manager.ts:1009— hardcodedgit add -Asrc/commands/run.test.ts:452-601— tests assert["add", "-A"]exactly, pinning the bug in place- Upstream contributor:
.claude/*and.sequant-manifest.jsonare tracked (by design — shareability). Claude Code's memory writes,sequant sync, andsequant updatecan legitimately dirty those paths during phase execution. Combined with-A, any dirty file ships as "checkpoint."
Reproduction
sequant inita project (creates tracked.claude/*and.sequant-manifest.json)- Leave one of those tracked paths modified (e.g., run
sequant sync, don't commit; or let Claude Code memory write occur mid-run) sequant run --chain <issueA> <issueB>- After issueA's QA passes, inspect
checkpoint(#<A>): QA passed— dirty infra files are included - issueB's PR base now contains the contamination
Acceptance Criteria
- AC-1: Checkpoint stages only paths already touched by the issue's commits (diff vs chain base), not
git add -A - AC-2: If other dirty files exist outside the issue's scope, emit a visible warning listing them and skip the checkpoint rather than sweep them in
- AC-3: Update
src/commands/run.test.ts:452-601— drop the["add","-A"]assertion, add tests for scoped staging and the dirty-file abort path - AC-4: Integration test: chain run with a pre-existing dirty non-feature file produces a checkpoint that excludes it (or no checkpoint + warning)
- AC-5: No behavior change when the tree is clean (still logs "No changes to checkpoint")
- AC-6: Update
CHANGELOG.mdunder [Unreleased]
Additional context
- Call site:
src/lib/workflow/batch-executor.ts:996-999 - Found via
/reflectafter manually cleaning PR feat: Add smoke test step for UI issues in /exec #37 on portfolio-2025 - Pure TypeScript fix, ships in next npm release, benefits all users
Complexity
complex (quality loop) — test suite changes + integration test + careful design of "scoped" vs "unrelated" detection
Activity
admarble commentedon Apr 17, 2026
→ PROCEED — Chain checkpoint sweeps dirty tree (hardcoded
git add -Aatworktree-manager.ts:1009)Workflow:
spec → exec → qa· 6 ACs⚠ Design work in ACs — scoped-vs-unrelated detection algorithm (AC-1), abort-vs-warn policy (AC-2), rewrites pinned test assertions at
src/commands/run.test.ts:452-601(AC-3)⚠ Updates
CHANGELOG.md [Unreleased]— conflicts possible with #529 and #531 if merged concurrentlyadmarble commentedon Apr 17, 2026
QA Review for Issue #528
Size Gate
AC Coverage
git add -Aadd -Awith scopedadd -- ...inScope, but.trim()bug on porcelain output corrupts path parsing —" M src/file.ts".trim()→"M src/file.ts", then.slice(3)→"rc/file.ts"instead of"src/file.ts". Scoping never matches correctly..trim()bug — dirty files always misclassified as out-of-scope, so warning fires even for in-scope files.add -Aassertion, add scoped staging + dirty-file abort tests.trim()bug. 10 total failures (4 direct + 6 cascading).statusOutputcheck returns true early.Coverage: 1/6 AC items fully met
Quality Metrics
any)Build Verification
Test Coverage Analysis
src/lib/workflow/worktree-manager.tssrc/commands/run.test.tssrc/lib/workflow/batch-executor.tssrc/lib/workflow/batch-executor.test.tssrc/commands/run.test.tsCoverage: 2/2 changed source files have tests
Code Review
Strengths:
git diff --name-only baseBranch...HEADto identify feature paths, then classifying dirty files as in-scope vs out-of-scopeworktree-manager.tsowns the logic,batch-executor.tspassesbaseBranchthroughspawnOk/spawnFailhelpersIssues:
CRITICAL —
.trim()corrupts porcelain parsing (line 1000):git status --porcelainoutput uses fixed-width columns:XY filename. ForM src/file.ts, the leading space is the index status column..trim()strips it, shifting all subsequent.slice(3)calls by 1 character. Result:"rc/file.ts"instead of"src/file.ts".Fix: Replace
.trim()with splitting on newlines and filtering empty lines:Fallback
HEAD...HEADis a no-op diff (line 1017):When
baseBranchis not provided,HEAD...HEADreturns zero files, so ALL dirty files are classified as out-of-scope. Checkpoint always skipped with spurious warning. While the only real call site providesbaseBranch, this is a latent bug.Anti-Pattern Detection
worktree-manager.ts:1000.trim()destroys porcelain column layoutworktree-manager.ts:1017HEAD...HEADfallback always emptybaseBranchrequired or meaningful defaultCall-Site Review
Modified function:
createCheckpointCommit(newbaseBranch?param)createCheckpointCommit()batch-executor.ts:998if (success && chainMode && worktreePath)run-compat.ts:24Test Quality Review
child_process.spawnSyncmockedCHANGELOG Verification
Risk Assessment
.trim()bug means checkpoints would be skipped with false "unrelated dirty files" warnings even when all files are in-scope. This silently degrades chain mode by removing checkpoint recovery points.Verdict: AC_NOT_MET
5 of 6 ACs are not met. The implementation approach is sound but has a critical parsing bug (
.trim()on porcelain output) that breaks the core scoping logic. All new tests fail. Missing integration test (AC-4) and CHANGELOG entry (AC-6).Next Steps
.trim()bug inworktree-manager.ts:1000— split on newlines and filter empty strings instead of trimming the full outputHEAD...HEADfallback at line 1017 — makebaseBranchrequired or use a meaningful default[Unreleased]→ Fixed sectionadmarble commentedon Apr 18, 2026
QA Review for Issue #528 (Re-run)
Size Gate
Stale Branch Check
AC Coverage
git add -Aworktree-manager.ts:1020-1070—git diff --name-only ${baseBranch}...HEADcollects feature paths;dirtyFiles.filter(f => featurePaths.has(f))narrows scope;git add -- ...inScopereplacesadd -A. Previous.trim()bug fixed by splitting on newlines and filtering empties before.slice(3).worktree-manager.ts:1044-1054— whenoutOfScope.length > 0, prints yellow "Skipping checkpoint" warning enumerating each out-of-scope file and returnsfalse.add -Aassertion, add scoped + abort testsrun.test.ts:452-712— old["add","-A"]assertion removed. New tests: scoped staging (AC-1), warn+skip (AC-2, 2 variants), non-chain fallback, clean-tree, and failure paths. All 10createCheckpointCommittests pass (136/136 suite-wide).run.test.ts:647-711(labeled "AC-4 integration"), which verify "no checkpoint + warning" for the dirty non-feature case. However, these are not integration tests per the repo convention —*.integration.test.tsfiles (e.g.,src/commands/cli.integration.test.ts) spawn real CLI processes. No such file was added. Behavior is verified, but not end-to-end through a real chain run.worktree-manager.ts:1004-1011— emptystatusLines.length === 0still logs "No changes to checkpoint (already committed)" and returns true. Test atrun.test.ts:470-482validates.CHANGELOG.md:10-12— entry added under### Fixedwith issue reference(#528).Coverage: 5/6 AC items fully met, 1 partially met
Quality Plan Verification
N/A — No quality plan found in issue comments.
CI Status
No PR exists yet — CI not triggered.
Quality Metrics
any)Build Verification
Test Coverage Analysis
src/lib/workflow/worktree-manager.tssrc/commands/run.test.tssrc/lib/workflow/batch-executor.tssrc/commands/run.test.tssrc/commands/run.test.tsCHANGELOG.mdCoverage: 2/2 changed source files have tests.
Code Review
Strengths:
\n, filters empties, applies.slice(3)per line — preserves fixed-width column layout (previous.trim()bug resolved).if (baseBranch)scopes to feature paths in chain mode;elsetreats all dirty files as in-scope for non-chain callers. Eliminates the priorHEAD...HEADno-op fallback.spawnOk/spawnFailhelpers for readability.Issues:
*.integration.test.tsfiles that spawn real processes (e.g.,cli.integration.test.ts). The mocked test covers the scenario, but doesn't exercise realgitagainst a real worktree with actual dirty infra files — which is precisely the regression mode AC-4 was written to guard against.Suggestions:
src/lib/workflow/checkpoint.integration.test.tsthat (a) creates a temp git repo, (b) stages a fake feature commit, (c) dirties an unrelated path (.claude/memory.md), (d) invokescreateCheckpointCommit, and (e) asserts the checkpoint is skipped and the dirty file remains untracked. This would fully satisfy AC-4's literal wording..slice(3).split(" -> ").pop()!.trim()— the trailing.trim()on just the path is harmless, but worth a comment explaining it's for rename path extraction only, not for fixing column widths.Test Quality Review
child_process.spawnSyncmockedAnti-Pattern Detection
No code pattern issues. No dependency changes.
Call-Site Review
createCheckpointCommit()batch-executor.ts:998if (success && chainMode && worktreePath)New
baseBranch?: stringparameter is passed from the orchestration layer's existingbaseBranch(line 384 destructure). No other call sites outside the re-export inrun-compat.ts.Execution Evidence
N/A — No
scripts/or CLI command file changes. Verification covered by unit tests + build.Skill Command Verification
N/A — No skill files changed.
CLI Registration Verification
N/A — No option interface changes (no new
RunOptionsfields).Smoke Test
Not Required — No workflow-affecting changes at skill/CLI/script level. Behavior verified via unit tests.
CHANGELOG Verification
### Fixed#528)Risk Assessment
R old -> new), quoted paths with spaces, or untracked files from Claude Code memory writes mid-phase. The.slice(3).split(" -> ").pop()logic is correct for common cases but untested against real git output.?? pathentries (whichgit diff --name-only baseBranch...HEADwill not include, meaning they'd always be classified as out-of-scope — possibly correct, possibly surprising).Verdict: AC_NOT_MET
AC-1, AC-2, AC-3, AC-5, AC-6 are fully MET. The
.trim()bug andHEAD...HEADfallback bug from the prior review are both resolved, tests pass, CHANGELOG is added. However, AC-4 is PARTIALLY_MET: the scenario is exercised by a mocked unit test, not by a true integration test in the repo's established*.integration.test.tsconvention. Per AC literal wording ("Integration test: chain run..."), this does not yet satisfy AC-4.Per the QA verdict algorithm, any
PARTIALLY_METblocksREADY_FOR_MERGE. This is a minor gap — the implementation itself looks correct — but the AC text is explicit about the test type.Documentation
[Unreleased]→ Fixed)Next Steps
src/lib/workflow/checkpoint.integration.test.tsthat spawns realgitin a temp worktree with a dirty non-feature file and asserts the checkpoint-skip + warning behavior. Or: amend the issue AC to accept the mocked unit test as sufficient, explicitly.R old.ts -> new.ts) to harden the parsing./qa 528once AC-4 is addressed.admarble commentedon Apr 18, 2026
QA Review for Issue #528 (Re-run #3)
Size Gate
Stale Branch Check
AC Coverage
git add -Aworktree-manager.ts:1021-1046—git diff --name-only -z baseBranch...HEADdefines feature paths; dirty files are filtered to the intersection;git add -- ...inScopereplaces-A.worktree-manager.ts:1059-1069— prints yellow "Skipping checkpoint" enumerating each out-of-scope file, returnsfalse.add -Aassertion, add scoped + abort testsrun.test.ts:452-784— 12createCheckpointCommittests covering scoped staging, warn+skip, rename pairs, unicode paths, untracked files, non-chain fallback, clean tree, and all failure paths.checkpoint.integration.test.ts— 4 tests that spawn realgitagainst a temp worktree (no mocks). Covers: dirty non-feature file → warn+skip, clean-out-of-scope → scoped commit, clean tree → no-op, unicode path round-trip.worktree-manager.ts:1002-1011— emptystatusRawstill logs "No changes to checkpoint" and returns true. Covered by both unit test (run.test.ts:470) and integration test.CHANGELOG.md:10-12— Fixed entry with(#528)reference, mentions both scope fix and-zunicode robustness.Coverage: 6/6 AC items fully met
Quality Plan Verification
N/A — No quality plan found in issue comments.
CI Status
No PR exists yet — CI not triggered. PR should be opened after this verdict.
Quality Metrics
any)Build Verification
npm run buildnpm run lintnpm test(targeted)Test Coverage Analysis
src/lib/workflow/worktree-manager.tssrc/commands/run.test.ts+checkpoint.integration.test.tssrc/lib/workflow/batch-executor.tssrc/commands/run.test.ts(call-site)src/commands/run.test.tssrc/lib/workflow/checkpoint.integration.test.tsCHANGELOG.mdCoverage: 2/2 changed source files have tests (both unit and integration).
Code Review
Strengths:
-z(NUL-terminated), eliminating an entire class of bugs around quoted paths for unicode/special characters.R/Cstatus char.if (baseBranch)branch does the diff-based filter;elsetreats all dirty files as in-scope for non-chain callers.-cflags scoped to the temp repo,commit.gpgsign=falseto avoid signing prompts in test envs).Issues:
Minor observations (not blocking):
checkpoint.integration.test.tsruns 4 sequential tests with real git setup (~2s total). Acceptable givenfileParallelism: falsefor the integration project.-c core.quotePath=falseon the verification read to defeat git's default display quoting. Sensible; documented inline.Test Quality Review
child_process.spawnSync. Integration tests use no mocks.commit.gpgsign=falseand scopeduser.email/nameto avoid CI flakinessIssues Found: None.
Anti-Pattern Detection
No code pattern issues. No dependency changes.
Call-Site Review
createCheckpointCommit()batch-executor.ts:998if (success && chainMode && worktreePath)baseBranchpassed throughNo new exported functions introduced in this re-run.
Execution Evidence
N/A — no
scripts/or CLI-command files changed. Behavior verification via unit + integration tests (real git).Script Verification Override
N/A — no scripts changed.
Skill Command Verification
N/A — no skill files changed.
CLI Registration Verification
N/A — no option interface changes (no new
RunOptionsfields).Smoke Test
Not Required — no skill/CLI/script changes. Real-git integration tests provide equivalent workflow-level verification.
CHANGELOG Verification
### Fixed#528, mentions both scoping and-zunicode robustness)Risk Assessment
Mwith submodule-specific XY combinations), worktrees withcore.quotePath=trueproducing quoted paths on legacy git (< 1.6.x). Neither is relevant in practice —-zis supported since git 1.x and submodule entries use standard XY syntax.Verdict: READY_FOR_MERGE
All 6 ACs fully MET:
-Asweep bug (AC-1, AC-2)checkpoint.integration.test.ts(the blocker from the prior QA re-run)Build, lint, and all 143 tests pass. The unicode path handling via
-zis a bonus hardening beyond the original AC scope and closes the latent quoting gap flagged in the prior Risk Assessment.Documentation
[Unreleased] → FixedDocumentation: Before merging, consider running
/docs 528if feature-user-facing documentation applies (it doesn't here — this is an internal chain-mode fix).Next Steps
feature/528-fix-checkpoint-scope-chain-mode-checkpoint-to-feat→mainfix(#528): scope chain-mode checkpoint to feature paths only
test(#528): add integration test + rename/untracked edge cases
fix(#528): use -z git output to support unicode/special char paths
fix(#528): scope chain-mode checkpoint to feature paths, not git add …
admarble commentedon Apr 18, 2026
Documentation Updated
File:
docs/reference/run-command.md(Chain Mode → Checkpoint Commits section, +17 lines)Rather than creating a new orphan page for this internal bug fix, the existing chain-mode reference was extended with the new user-observable behavior.
What the update covers
git add -A)Status
Committed locally as
fc59ca1onmain. Not yet pushed.Ready to push when you are.
docs(#528): document chain checkpoint scoping + warn-and-skip behavior
admarble commentedon Apr 23, 2026
→ CLOSE — PR #535 merged 2026-04-18, resolving this issue.
admarble commentedon Apr 23, 2026
Resolved by PR #535 (merged 2026-04-18).
chore(#689): ready-gate backtest driver script (#691)
fix: close three pre-2.10.0 gaps found by release verification (#851)