Skip to content

Conversation

@arosenfeld2003
Copy link

@arosenfeld2003 arosenfeld2003 commented Feb 13, 2026

Summary

  • Store the git tree hash of HEAD at condensation time in checkpoint metadata (commit_tree_hash field)
  • This provides a content-addressable anchor that survives history rewrites (rebase, squash, force-push) — a rebased commit has a different SHA but the same tree hash when file content is unchanged
  • A future entire repair command can use this field to re-link orphaned checkpoints by scanning the current branch for commits whose tree hash matches

Closes #321

Changes

  • checkpoint/checkpoint.go — Add CommitTreeHash string field to WriteCommittedOptions, CommittedMetadata (json:"commit_tree_hash,omitempty"), and CheckpointSummary (json:"commit_tree_hash,omitempty")
  • checkpoint/committed.go — Pass CommitTreeHash through in writeSessionToSubdirectory() and writeCheckpointSummary()
  • strategy/common.go — Add GetHeadTreeHash() helper (same pattern as GetCurrentBranchName)
  • strategy/manual_commit_condensation.go — Call helper and pass to WriteCommittedOptions
  • strategy/auto_commit.go — Call helper and pass to options in both commitMetadataToMetadataBranch() and commitTaskMetadataToMetadataBranch()
  • checkpoint/checkpoint_test.go — Round-trip test: write with tree hash and verify in both metadata levels; write without and verify omitempty omits the key
  • strategy/manual_commit_test.go — End-to-end condensation test: SaveChanges → user commit → CondenseSession → verify commit_tree_hash matches HEAD's tree hash

What is NOT changed

  • No read paths, CLI commands, or display logic — field is write-only for now
  • No changes to temporary checkpoints (shadow branches)
  • No migration needed — omitempty means old checkpoints deserialize cleanly

Test plan

  • go test ./cmd/entire/cli/checkpoint/ -run TestWriteCommitted_CommitTreeHashField -v
  • go test ./cmd/entire/cli/strategy/ -run TestCondenseSession_IncludesCommitTreeHash -v
  • gofmt -s -w . — no formatting issues
  • golangci-lint run — 0 issues
  • go test -tags=integration -race ./... — all tests pass

🤖 Generated with Claude Code

Store the git tree hash of HEAD at condensation time in checkpoint
metadata. This provides a content-addressable anchor that survives
history rewrites (rebase, squash, force-push) — a rebased commit has
a different SHA but the same tree hash when file content is unchanged.

A future `entire repair` command can use this field to re-link orphaned
checkpoints by scanning the current branch for commits whose tree hash
matches a checkpoint's stored value.

Changes:
- Add CommitTreeHash field to WriteCommittedOptions, CommittedMetadata,
  and CheckpointSummary structs (omitempty for backward compat)
- Add GetHeadTreeHash() helper in strategy/common.go
- Wire into manual-commit condensation and auto-commit metadata
  (both session and task checkpoint paths)
- Add round-trip test for the checkpoint package
- Add end-to-end condensation test for manual-commit strategy

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: d008cfcd3b30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Checkpoint metadata lost after history rewrites (rebase, squash merge, force-push)

1 participant