Skip to content

fix(#528): scope chain-mode checkpoint to feature paths, not git add -A - #535

Merged
admarble merged 3 commits into
mainfrom
feature/528-fix-checkpoint-scope-chain-mode-checkpoint-to-feat
Apr 18, 2026
Merged

admarble merged 3 commits into
mainfrom
feature/528-fix-checkpoint-scope-chain-mode-checkpoint-to-feat

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Replaces hardcoded git add -A in createCheckpointCommit with a scoped git add -- <inScope>. In chain mode, staging is limited to paths touched by the issue's commits (git diff --name-only -z baseBranch...HEAD).
  • If unrelated dirty files exist (e.g. .claude/*, .sequant-manifest.json dirtied by sequant sync or Claude Code memory writes), the checkpoint is skipped with a warning rather than sweeping them into the PR base. This eliminates the regression documented in fix(checkpoint): scope chain-mode checkpoint to feature paths, don't sweep dirty tree #528 (PR feat: Add smoke test step for UI issues in /exec #37 shipped +5600 lines of contamination).
  • Uses -z (NUL-terminated) output on both git status --porcelain and git diff --name-only, so paths with unicode or special characters aren't misclassified by git's default quoting.

Test plan

  • npm run build clean
  • npm run lint clean (0 warnings)
  • 139 unit tests pass — src/commands/run.test.ts (12 new createCheckpointCommit tests covering scoped staging, warn+skip, rename pairs, unicode paths, untracked files, non-chain fallback, clean tree, and failure paths)
  • 4 integration tests pass — src/lib/workflow/checkpoint.integration.test.ts spawns real git against a temp worktree; covers: dirty non-feature file → warn+skip, clean-out-of-scope → scoped commit, clean tree → no-op, unicode path round-trip
  • CI green on both Node versions

AC coverage

  • AC-1: Checkpoint stages only paths in baseBranch...HEAD, not git add -A
  • AC-2: Unrelated dirty files → warning + skip
  • AC-3: Tests rewritten (no ["add","-A"] assertion), scoped + abort paths covered
  • AC-4: Integration test against real git in temp worktree
  • AC-5: Clean tree still logs "No changes to checkpoint" and returns true
  • AC-6: CHANGELOG.md entry under [Unreleased] → Fixed

- Replace .trim() with split/filter to preserve git status porcelain
  column layout (leading space is the index status, not whitespace)
- Only run scope filtering when baseBranch is provided (chain mode);
  non-chain mode treats all dirty files as in-scope
- Skip checkpoint with warning when unrelated dirty files exist (AC-2)
- Update tests: drop HEAD...HEAD fallback, add AC-4 integration tests
- Add CHANGELOG entry
Closes AC-4 by adding src/lib/workflow/checkpoint.integration.test.ts,
which exercises createCheckpointCommit against a real temp worktree:
- dirty tracked infra file (.claude/memory.md) → checkpoint skipped + warning
- only feature file dirty → scoped checkpoint commit
- clean tree → returns true, no commit (AC-5 end-to-end)

Also adds two unit tests in run.test.ts:
- porcelain rename entries extract the new path, not the old
- untracked (??) files in chain mode are classified out-of-scope

Clarifies the rename-target .trim() in worktree-manager.ts with a comment.
Without -z, git status --porcelain and git diff --name-only quote paths
with non-ASCII or control characters (e.g. "caf\303\251.ts"). The scoping
logic would then compare quoted/unquoted strings and misclassify the file
as out-of-scope, silently skipping the checkpoint.

-z switches to NUL-terminated unquoted output. Rename/copy entries emit
the new path followed by a separate old-path entry, which the parser
consumes as a pair.

Tests: +1 unit (unicode path), +1 integration (unicode path in real git),
rewrite rename test to the -z two-entry format.
@admarble
admarble merged commit 45decdc into main Apr 18, 2026
5 checks passed
admarble added a commit that referenced this pull request Apr 18, 2026
Extends the Chain Mode → Checkpoint Commits section in run-command.md
to explain:
- Checkpoints stage only files touched by the issue's commits (not git add -A)
- The new warn-and-skip output users will see when unrelated dirty files exist
- How to respond to the warning
- That unicode/special-char paths are handled

Pairs with the behavior change shipped in #535.

Entire-Checkpoint: 27f002f3c8e8
@admarble
admarble deleted the feature/528-fix-checkpoint-scope-chain-mode-checkpoint-to-feat branch April 23, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant