Here's what the investigations found:
#3: Dedup migration logic vs hooks.go
Verdict: Minor duplication, low priority.
The git reference operations (create new ref, delete old ref) are byte-for-byte identical between manual_commit_migration.go and manual_commit_hooks.go:847-861. But the surrounding context is quite different:
| migration.go | hooks.go (InitializeSession) |
|---|
| When called | Mid-session (Claude does a rebase via tool call) | Session startup (user submits prompt) |
| Return type | (bool, error) — caller needs to know if migration happened | error — part of init flow |
| Missing branch | Handles gracefully (just updates BaseCommit) | Only enters path if branch exists |
| Preconditions | Checks state == nil, empty BaseCommit | Assumes state fully initialized |
The shared part is ~15 lines of ref creation/deletion. Could extract a migrateGitReference(storer, oldRef, newRef, hash) helper, but it's small enough that the cure might be worse than the disease (adds indirection for little gain).
#7: Stale shadow branch on reset to old commit
Verdict: Real gap, but MEDIUM-LOW risk in practice.
The scenario Soph was worried about is valid:
- Session A on commit
abc1234 creates shadow branch entire/abc1234-xyz123
- User commits → PostCommit condenses & deletes shadow branch
- User does
git reset --hard abc1234 (back to same commit)
- New session starts →
getOrCreateShadowBranch() finds... nothing (branch was deleted). Safe path.
But if step 2's deletion fails (non-fatal error, just a warning):
- The stale branch still exists at
entire/abc1234-xyz123
- New session at same commit would append to the stale branch, mixing old metadata with new session data
getOrCreateShadowBranch() (temporary.go:649-676) doesn't verify the branch belongs to the current session — it just returns the tip commit as parent