Skip to content

feat: /checkpoint file-level snapshot + restore; hooks gate recipes - #366

Merged
dahai80 merged 1 commit into
mainfrom
feat-checkpoint-restore
Nov 27, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat-checkpoint-restore

Conversation

@dahai80

@dahai80 dahai80 commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Closes #360 (checkpoint half). Unblocks the biz-delivery pipeline design (insight/biz-team-pipeline-design-2026-11.md): stage gates need deterministic enforcement, and rnd's long S3 stage needs mid-state protection that survives non-git temp projects.

1. /checkpoint: log-only → restorable snapshots

  • create writes .claude/checkpoints/<name>.tar (excludes .git, node_modules, the checkpoints store) in addition to the existing git-ref log entry — rollback now works outside git repos and for uncommitted work. Snapshot failure degrades to log-only with a visible note, never throws.
  • New restore <name>: extracts the snapshot over the working tree after taking an automatic pre-restore backup (<name>-pre-restore.tar) — the operation is self-reversible (/checkpoint restore <name>-pre-restore). Overlay semantics are documented in the output: extract does not delete files created after the checkpoint.
  • list shows per-checkpoint snapshot availability; verify points at the snapshot; argumentHint updated.

2. docs/hooks-recipes.md — deterministic gate recipes

Contract verified against src/types/hooks.ts + hooksConfigManager.ts (stdin tool_name/tool_input JSON; Stop → {"decision":"block","reason"}; PreToolUse deny → hookSpecificOutput.permissionDecision:"deny"):

  • Stage-gate verdict lock: Stop hook blocks until docs/review-<stage>.md contains verdict: pass — the pipeline's blocked-until-verdict gate, fail-closed.
  • Document-contract presence check: required artifacts must exist and be non-empty before the session can stop.
  • Reviewer no-self-edit: PreToolUse deny on Edit|Write targeting prd.md/archi-plan.md/work-plan.md — reviewer sessions (running a different FUSION_MODEL) can write verdicts but never the artifact under review.

Verification

  • tests/commands/checkpoint.test.ts: 5/5 pass (restorable snapshot outside git, rollback roundtrip, post-checkpoint files kept + pre-restore undo, missing-snapshot guidance, list availability).
  • tsc --noEmit clean on the touched file; doc validator ERROR 0 (43 docs).
  • Full bun test + binary rebuild intentionally deferred until the in-flight benchmark finishes (thermal interference) — will confirm before merge or immediately after.

🤖 Generated with Claude Code

Two gaps blocking the biz-delivery pipeline design (insight/
biz-team-pipeline-design-2026-11.md):

1. /checkpoint was log-only (name -> git ref). create now also writes a
   file snapshot to .claude/checkpoints/<name>.tar (tar --exclude .git
   node_modules .claude/checkpoints), so rollback works outside git
   repos and for uncommitted work; new restore action extracts the
   snapshot over the working tree after taking an automatic pre-restore
   backup (undo: /checkpoint restore <name>-pre-restore); list shows
   snapshot availability; verify points at the snapshot. Overlay
   semantics documented: extract does not delete post-checkpoint files.
2. docs/hooks-recipes.md: deterministic gate recipes on the verified
   hook contract (stdin tool_name/tool_input JSON; Stop returns
   decision:block+reason; PreToolUse deny via hookSpecificOutput).
   Recipes: stage-gate verdict lock (blocked-until-verdict for
   review-<stage>.md), document-contract presence check, reviewer
   no-self-edit separation of duties.

Tests: tests/commands/checkpoint.test.ts (5 cases: restorable snapshot
outside git, rollback roundtrip, post-checkpoint files kept + pre-
restore backup undo, missing-snapshot guidance, list availability).
tsc clean on touched file; doc validator ERROR 0.

Co-Authored-By: Claude Code <[email protected]>
@dahai80
dahai80 merged commit dc9c2ea into main Nov 27, 2026
2 checks passed
@dahai80
dahai80 deleted the feat-checkpoint-restore branch November 27, 2026 06:07
@dahai80 dahai80 mentioned this pull request Nov 27, 2026
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.

feat: workdir snapshot on timeout + resume-task (Codex checkpoint/rollback parity)

1 participant