feat: preserve session linkage after git rewrites#947
feat: preserve session linkage after git rewrites#947peyton-alt wants to merge 6 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds first-class post-rewrite hook handling to keep Entire’s manual-commit session linkage consistent after Git history rewrites (amend/rebase), so sessions continue to track the rewritten commits without relying on later fallback relinking.
Changes:
- Add managed installation support for the
post-rewriteGit hook and exposeentire hooks git post-rewrite <rewrite-type>. - Implement
ManualCommitStrategy.PostRewriteto remap sessionBaseCommit/AttributionBaseCommitbased on Git-provided old→new SHA pairs. - Add unit + integration tests covering parsing and session state remapping behavior.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/strategy/manual_commit_hooks.go | Adds PostRewrite handler and post-rewrite input parsing. |
| cmd/entire/cli/strategy/manual_commit_session.go | Introduces rewrite pair type + helper to remap session commit fields. |
| cmd/entire/cli/strategy/hooks.go | Adds post-rewrite to managed hook list and installs hook script. |
| cmd/entire/cli/strategy/hooks_test.go | Verifies managed hook names + hook installation includes post-rewrite. |
| cmd/entire/cli/hooks_git_cmd.go | Wires post-rewrite subcommand into the hooks command tree. |
| cmd/entire/cli/hooks_git_cmd_test.go | Ensures the new post-rewrite subcommand is discoverable and has the expected usage. |
| cmd/entire/cli/root_test.go | Updates hidden-parent command-tree test to use the new hook leaf command. |
| cmd/entire/cli/strategy/manual_commit_test.go | Adds unit tests for parsing + remapping behavior at the strategy layer. |
| cmd/entire/cli/integration_test/testenv.go | Adds helper to invoke the post-rewrite hook with explicit mappings. |
| cmd/entire/cli/integration_test/phase_transitions_test.go | Adds integration tests validating state remap for amend/rebase flows. |
| CLAUDE.md | Documents the new post-rewrite hook behavior in strategy docs. |
|
@BugBot review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 01c8314. Configure here.

Summary
Add CLI-side
post-rewritetracking so Entire preserves local session linkage after Git rewrites instead of relying on fallback relinking later.This PR:
post-rewritehook supportentire hooks git post-rewrite <rewrite-type>wiringBaseCommitandAttributionBaseCommitafteramendandrebaseLastCheckpointIDunchanged so the checkpoint linkage follows the rewritten commitScope
Supported rewrite flows in this PR:
git commit --amendgit rebasepost-rewrite, includingreword,squash, andfixupNot in scope here:
git resetfilter-repo/filter-branchWhy
The goal is to keep Entire tracking native Git commands during an active session. Git already provides deterministic old-SHA -> new-SHA mappings through
post-rewrite, so the CLI can preserve linkage locally without depending on UI/Darwin reconciliation or custom non-Git linkage metrics.Verification
GOCACHE=/tmp/go-build go test ./cmd/entire/cli/strategy -run 'Test(ParsePostRewritePairs|ShadowStrategy_PostRewrite_)' -count=1 -vGOCACHE=/tmp/go-build go test -tags=integration ./cmd/entire/cli/integration_test -run 'TestShadow_(AmendPreservesTrailer|PostRewriteAmendRemapsSessionState|PostRewriteRebaseRemapsSessionState)' -count=1 -vclaude -psmoke test confirmed a real Entire-tracked commit still gets anEntire-Checkpointtrailer and session state in.git/entire-sessions; the follow-up live amend flow was not used as the primary verifier because Claude hit a write-permission prompt before completing the second turn.Follow-up
A later PR can add lightweight reset/head-divergence guidance without coupling that to rewrite handling.
Note
Medium Risk
Adds a new managed
post-rewritegit hook and updates session state/shadow-branch migration logic after amend/rebase, which could affect how checkpoints are linked and recovered across rewritten history.Overview
Adds first-class support for Git’s
post-rewritehook so Entire can immediately preserve local checkpoint/session linkage aftergit commit --amendandgit rebase.The CLI now installs and exposes
entire hooks git post-rewrite <rewrite-type>, andManualCommitStrategy.PostRewriteparses old→new SHA mappings from stdin to remap per-worktree session state (BaseCommitand sometimesAttributionBaseCommit) while keepingLastCheckpointIDstable.Shadow-branch migration logic is refactored to a reusable
migrateShadowBranchToBaseCommithelper and is reused during rewrites; tests are expanded with new unit + integration coverage for amend/rebase remapping and hook installation/command wiring, and docs are updated to mentionpost-rewritebehavior.Reviewed by Cursor Bugbot for commit 01c8314. Configure here.