can you review 948 and see if f we should run it at every hook invocation? migrateShadowBranchIfNeeded already does half of it, so maybe add the LastCheckpointID logic there? entire status could still show the warning /superpowers:brainstorming
Assistant· claude-opus-4-6
I'll start by exploring the project context to understand what 948 refers to and the current state of the related code.
Assistant· claude-opus-4-6
Let me check the branch state, the PR's actual code changes, and understand migrateShadowBranchIfNeeded.
Assistant· claude-opus-4-6
Let me trace how the migration function gets called across hooks, and find where AttributionBaseCommit is managed.
Assistant· claude-opus-4-6
Now I have the full picture. Let me quickly check one more thing — whether PR #948's reconciliation can sometimes fire when migration already would have updated BaseCommit on its own.
Assistant· claude-opus-4-6
I've got enough context to start a structured review. Before I propose a design, let me share my understanding and ask you one focused question.
★ Insight ─────────────────────────────────────
BaseCommit and AttributionBaseCommit are intentionally two fields. BaseCommit tracks the shadow-branch location and moves with HEAD migrations (pull/rebase/amend). AttributionBaseCommit stays pinned because condensation measures agent diffs relative to the original base tree — moving it mid-session would zero out attribution for an already-captured checkpoint.
migrateShadowBranchIfNeeded runs in SaveStep, SaveTaskStep, and the UserPromptSubmit (TurnStart) path. It deliberately doesn't touch AttributionBaseCommit (see the comment at manual_commit_migration.go:83-87). PR #948's new status-side reconcileActiveSessionHeadDivergencedoes update both fields.
That difference isn't arbitrary — a plain HEAD move (pull/rebase) must preserve attribution base, while a reset onto a commit bearing this session's own LastCheckpointID means the new HEAD effectively IS the last condensed checkpoint, so moving attribution base to HEAD is semantically correct.
─────────────────────────────────────────────────
What PR #948 does
Adds reconcileActiveSessionHeadDivergence inside writeActiveSessions (status rendering). For each active session where BaseCommit != HEAD:
If HEAD has the session's LastCheckpointID trailer → silently update BaseCommit + AttributionBaseCommit to HEAD, persist.
Else → render a yellow warning in the session card.
It doesn't touch the shadow branch — just the state file.
What migrateShadowBranchIfNeeded already does
On HEAD change, it:
Renames entire/<old-hash>-<wt> → entire/<new-hash>-<wt> (the shadow branch follow).
Updates state.BaseCommit = currentHead.
LeavesAttributionBaseCommit alone (by design, for pull/rebase correctness).
So the gap is: after a git reset --hard <commit-with-our-checkpoint-trailer>, the next hook would update BaseCommit + rename the shadow branch, but AttributionBaseCommit would still point at the pre-reset commit (a dangling hash). Today that's only patched up if the user runs .
User
If we lose the shadow branch, doesn't that get rid of the point of supporting reset with entire because the linkage is lost? 2. And yes i want status to be passive. 3. i don't want to rename shadow branch
Assistant· claude-opus-4-6
Good, that locks in option C. Let me work through the implications.
★ Insight ─────────────────────────────────────
Keeping the old shadow branch matters because a session's in-progress rewind points live on it. Under C, after reset A, the branch entire/<B-hash>-<wt> still holds the pre-reset checkpoints. They're unreachable via state.BaseCommit lookups after reconciliation but still queryable by branch scan — so undoing the reset isn't fatal.
The semantic asymmetry we're codifying: "migration" (HEAD moved unrelatedly) follows the shadow branch forward; "reconciliation" (HEAD landed on our own checkpoint) leaves the shadow branch where it was and lets a fresh one start at the new base. Same function, two branches.
─────────────────────────────────────────────────
Shape of the design I'm converging on
One function, two paths inside migrateShadowBranchIfNeeded:
code
if state.BaseCommit == currentHead: no-op
else if HEAD commit message contains state.LastCheckpointID trailer:
// RECONCILE path
state.BaseCommit = currentHead
state.AttributionBaseCommit = currentHead
// leave shadow branch alone; future checkpoints land on entire/<newHEAD>-<wt>
else:
// MIGRATE path (existing behavior)
state.BaseCommit = currentHead
rename entire/<oldBase>-<wt> → entire/<newHEAD>-<wt>
// AttributionBaseCommit unchanged
Callsites already wired up: SaveStep, SaveTaskStep, UserPromptSubmit. One fix needed: manual_commit_hooks.go:2138-2151 currently clears state.LastCheckpointID = ""before calling migrate — the reconcile branch depends on reading it, so the call needs to happen before the clear. Low-risk reorder.
Status becomes passive (PR #948 turns into much less code):
Keep the HEAD read + trailer parse.
Keep the divergence warning render.
Remove the store.Save call and the attribution/base mutations.
writeActiveSessions just diffs state.BaseCommit vs current HEAD; if they disagree, emit the warning. If hooks have already reconciled, no warning. If user reset and hasn't triggered a hook yet, warning shows until they do.
User
does A cause any performance issues with leaving them forever? we really just want to be able to track and handle git reset. Does this plan use migrateShadowBranchIfNeeded already does half of it, so maybe add the LastCheckpointID logic there, beacuse thsi makese sense
Assistant· claude-opus-4-6
Performance answer is encouraging. Let me create the task list since we're past the clarifying-questions phase and moving into design + doc writing.
Assistant· claude-opus-4-6
Performance answer: no meaningful impact
I traced every caller of ListShadowBranches (the only place branch enumeration happens):
Path
Iterates refs?
Called from hooks?
migrateShadowBranchIfNeeded
No — repo.Reference(name) by exact ref name, O(1)
Yes (SaveStep, SaveTaskStep, UserPromptSubmit)
Hook handlers (manual_commit_hooks.go)
No ref iteration anywhere
Yes
cleanup.go orphan detection
Yes, repo.References().ForEach
No — only on entire doctor / entire clean
setup.go shadow counting / removal
Yes
No — only on entire enable / disable
So the hot path (every hook fire) does O(1) ref lookups regardless of how many shadow branches exist. The cold paths that do enumerate are user-initiated commands where a full ref walk is inherent to the task anyway. Git handles tens of thousands of refs before ref enumeration shows measurable cost; realistic accumulation from resets is tens of branches per heavy user. No change in perf envelope.
Plus — the existing orphan-cleanup logic (per CLAUDE.md "Orphaned Shadow Branches" and ListOrphanedSessionStates) will surface these in entire doctor so users who care can reap them.
Plan shape — confirming your framing
Yes, the plan is exactly what you described:
★ Insight ─────────────────────────────────────
The single change point is migrateShadowBranchIfNeeded. It gains a branch: before running the existing rename-old-to-new migration, check whether HEAD commit message carries state.LastCheckpointID as an Entire-Checkpoint trailer. If yes, update BaseCommit + AttributionBaseCommit and return — skipping the shadow-branch rename. If no, fall through to today's migration (rename shadow branch, update BaseCommit only).
All three existing callsites (SaveStep, SaveTaskStep, UserPromptSubmit) inherit the new behavior automatically. One ordering fix in UserPromptSubmit: the state.LastCheckpointID = "" clear at manual_commit_hooks.go:2138 must move to the migrate call, otherwise the reconcile branch reads an empty ID.
User
so are we adding lastcheckpointid to migrateshadowbranch
Assistant· claude-opus-4-6
Yes — exactly that. The whole design rests on it.
★ Insight ─────────────────────────────────────migrateShadowBranchIfNeeded currently only knows "did HEAD move?" We're teaching it one additional question: "does HEAD's commit message carry our session'sLastCheckpointID as an Entire-Checkpoint trailer?" That one extra read turns a dumb HEAD-tracker into a reset-aware reconciler, and everything else (every hook callsite, the passive-status change, the orphan-shadow behavior) follows from it automatically.
─────────────────────────────────────────────────
Concretely, inside migrateShadowBranchIfNeeded in cmd/entire/cli/strategy/manual_commit_migration.go:
go
func (s *ManualCommitStrategy) migrateShadowBranchIfNeeded(ctx, repo, state) (bool, error) {
// unchanged guard
if state == nil || state.BaseCommit == "" {
return false, nil
}
head, err := repo.Head()
if err != nil { ... }
currentHead := head.Hash().String()
if state.BaseCommit == currentHead {
return false, nil
}
// NEW: reconcile branch — read LastCheckpointID from state, parse HEAD's
// commit message, check if any Entire-Checkpoint trailer matches.
if !state.LastCheckpointID.IsEmpty() {
commit, err := repo.CommitObject(head.Hash())
if err == nil {
for _, cp := range trailers.ParseAllCheckpoints(commit.Message) {
if cp.String() == state.LastCheckpointID.String() {
state.BaseCommit = currentHead
state.AttributionBaseCommit = currentHead
logging.Info(..., "reconciled session to known checkpoint on HEAD")
return true, nil
}
}
}
}
// existing migrate path: rename shadow branch, update BaseCommit only
...
}
That's the whole addition — one new lookup block before the existing migration logic. Callers don't change (SaveStep / SaveTaskStep / UserPromptSubmit already invoke it). Status strips its mutation and becomes a pure reporter.
Want me to go write up the spec doc now? Once you say go I'll drop it at docs/superpowers/specs/2026-04-15-reset-linkage-in-hooks-design.md, commit it, run the spec review loop, then come back for your final sign-off before handing to writing-plans.
User
yes
Assistant· claude-opus-4-6
One note before I dispatch the reviewer: docs/superpowers/ is .gitignored in this repo (line 63), and the existing plans in docs/superpowers/plans/ are also untracked. I'll respect the repo convention and keep the spec local rather than force-add it — the skill's "commit the design" step is overridden by the repo's explicit gitignore.
Now dispatching the spec reviewer.
Assistant· claude-opus-4-6
Reviewer flagged three blocking issues. Fixing the spec now.
Assistant· claude-opus-4-6
Now let me re-run the reviewer to confirm the issues are resolved.
Assistant· claude-opus-4-6
Spec approved. Let me apply the one advisory that's easy to fix now (the ParseAllCheckpoints clarification in the pseudocode), then update tasks and hand off to you.
Assistant· claude-opus-4-6
Spec is written and approved by the reviewer. One thing to flag about file location:
Spec location: docs/superpowers/specs/2026-04-15-reset-linkage-in-hooks-design.md (local-only — docs/superpowers/ is .gitignored in this repo per line 63 of .gitignore, matching the convention used by existing files in docs/superpowers/plans/). Not committed.
Reviewer results summary
Iteration 1: Found 3 blocking issues:
Behavior matrix said BaseCommit stayed "unchanged" after reset-to-unrelated-commit, but the existing migrate path actually updates it — factually wrong.
Missing the "reset to an older checkpoint from the same session" edge case (same session's LastCheckpointID = X, HEAD has trailer Y).
The UserPromptSubmit reorder needed to account for calculatePromptAttributionAtStart sitting between the clear and the migrate call, not just the clear itself.
Iteration 2: ✅ Approved. All three resolved. Minor advisory polish applied (pseudocode now explicit about ParseAllCheckpoints vs ParseCheckpoint). One advisory deferred to the plan stage (a test variant with AttributionBaseCommit != BaseCommit at setup) since it's more naturally expressed in the implementation plan's test scaffolding.
Your review gate
Please review the spec at docs/superpowers/specs/2026-04-15-reset-linkage-in-hooks-design.md and let me know if you want any changes before I invoke the writing-plans skill to create the implementation plan. If it looks right, just say go and I'll hand off.
User
under non goals, when you say "Handling git reset beyond the single case where HEAD lands on a commit carrying the session's LastCheckpointID trailer. " - what is the case we handle, only when checkpoint id's match? or can you clarify what this means?
Assistant· claude-opus-4-6
Good catch — the wording is ambiguous. Let me explain, then rewrite the non-goal.
What "the single case we handle" means
We reconcile when ALL three conditions hold:
state.BaseCommit != current HEAD (i.e., HEAD moved for any reason)
state.LastCheckpointID is non-empty (session has condensed at least once)
HEAD's commit message carries an Entire-Checkpoint: <id> trailer where <id>exactly equalsstate.LastCheckpointID
That's a very narrow target. It means: the user reset back to the exact commit that is this session's most recent condensation. We know that commit represents a clean, known-good state for this session, so it's safe to update both BaseCommit and AttributionBaseCommit to HEAD.
Every other HEAD-moved case falls through to the existing migrate path (which updates BaseCommit to HEAD, leaves AttributionBaseCommit pinned, and renames the shadow branch if one exists). Concretely, these all go through migrate, not reconcile:
Reset to a commit with a checkpoint trailer from an earlier turn of the same session (different ID from current LastCheckpointID)
Reset to a commit with a checkpoint trailer from a different session
Reset to a commit with no checkpoint trailer
Reset forward, or to any commit unrelated to our checkpoint history
Pull / rebase / amend (not a reset at all — these aren't new behavior, they're the existing migrate cases)
The non-goal you asked about is saying: we're not trying to be smart about those other cases. We're not walking commit graphs looking for older matches, not inferring intent from worktree content, not auto-restoring state from an arbitrary HEAD. Those would all be larger features with their own design tradeoffs.
Let me rewrite the non-goal to make this explicit.
User
[Request interrupted by user for tool use]
User
shoudl the warning only be visible in entire status, or when this happens should the warning appear? because what if the user never checks entire status
Assistant· claude-opus-4-6
Fair pushback. The warning-only-in-status model has a real gap: a user who doesn't habitually run entire status may never see it. Let me think through the surfaces where it could appear.
★ Insight ─────────────────────────────────────
Where output lands matters. Hook handlers run during agent activity — their stderr goes into the agent's context/transcript, which is noisy and can confuse the agent model. entire doctor and entire status are user-initiated diagnostic surfaces where surfaced warnings land in the user's terminal, not the agent's context. prepare-commit-msg runs at a moment where the user is at their terminal and paying attention. Each surface has very different UX semantics.
─────────────────────────────────────────────────
What a "diverged but not reconciled" session actually means
Worth being precise before we pick surfaces: after the design's migrate path runs, state.BaseCommit == HEAD, the shadow branch is renamed, and future checkpoints land correctly. Attribution still uses the pre-reset AttributionBaseCommit, so diffs may look weird until the next condensation resets it. Nothing is broken — it's informational. The user took an action (reset to an unrelated commit), and we want them to know that attribution figures for the next condensation may not tell the story they'd expect.
So this is low-severity, heads-up content, not please-fix-this-now content. That shapes what surfaces make sense.
Options
A. Status only (current proposal). Simplest. Misses users who never run status.
B. Status + entire doctor. Both are diagnostic surfaces the user chose to open. Doctor already reports session-state issues (StuckActiveThreshold, orphaned branches), so divergence fits naturally. Still requires the user to run something — but doctor is the canonical "is everything OK?" command.
C. Status + prepare-commit-msg stderr. Warning appears the next time the user commits. Terminal-visible, not agent-visible. Catches every user who ever commits again. Slight risk of confusion since the commit isn't what caused the divergence.
D. Status + any hook's stderr. Fires during agent activity. Don't recommend — output lands in the agent's context and the user may not even see it. Also noisy if it repeats per-hook.
E. Fire-and-forget background: log the divergence to .entire/logs/ only. Good for post-mortem, invisible to the user. Not really a warning.
User
instead, why don't we run through user scenario to see what makes sense, user runs git reset and have entire enabled, what happens
Assistant· claude-opus-4-6
Good idea. Let me walk a concrete end-to-end scenario and we'll see where natural surfacing points are.
★ Insight ─────────────────────────────────────
Most of the "where does the warning go" question evaporates once you trace actual git events: git reset itself doesn't fire any Entire hook (there's no post-reset). State updates only happen when the next Entire-aware event fires — a prompt, a tool call, or a commit. That naturally means any "warning surface" is at one of those downstream events, not at the reset itself.
─────────────────────────────────────────────────
Scenario: user is mid-session, runs git reset --hard
Setup: Peyton has entire enabled, is using Claude Code, has been working on a feature. One prior turn has produced a condensed checkpoint.
State at rest (before reset)
code
HEAD: commit-A (subject: "add login route", trailer: Entire-Checkpoint: ABC)
state.BaseCommit: commit-A
state.AttributionBaseCommit: commit-A
state.LastCheckpointID: ABC (set at PostCommit condensation)
shadow branch: entire/<A[:7]>-<wt[:6]> (empty or has in-progress checkpoints for the next turn)
At this point Peyton is between turns — session is IDLE.
Step 1: Peyton types git commit -m "wip: experiment" (no agent activity, just a manual commit)
prepare-commit-msg runs → Entire adds no trailer (no agent checkpoint since last condensation, so nothing to link).
post-commit runs → phase state machine says IDLE + GitCommit → IDLE with a condense action. Condensation has no new agent content, so it returns early without creating a new checkpoint. state.BaseCommit migrates to commit-B via the path that handles "user committed out from under the session."
State now:
code
HEAD: commit-B (no Entire trailer)
state.BaseCommit: commit-B
state.AttributionBaseCommit: commit-A ← still pinned
state.LastCheckpointID: ABC ← unchanged
shadow branch: entire/<B[:7]>-<wt[:6]> (renamed from A)
User
yes agree
Assistant· claude-opus-4-6
Let me re-read the spec's current state, then apply all four sets of updates.
Assistant· claude-opus-4-6
Now insert the user-scenarios section and the warning-surfaces subsection.
Assistant· claude-opus-4-6
Now replace the "entire status becomes passive" section with the broader warning-surfaces design.
Assistant· claude-opus-4-6
Now update the test strategy section for the new warning surfaces and the DivergenceNoticeShown field.
Assistant· claude-opus-4-6
Now update invariants to include the new field and status invariant.
Assistant· claude-opus-4-6
Now re-run the spec reviewer to validate the full updated spec.
Assistant· claude-opus-4-6
Reviewer found one blocking issue: the scenario A intermediate state is inaccurate about which fields update when during a manual commit. Let me verify against the actual code.
Assistant· claude-opus-4-6
The reviewer is right — updateBaseCommitIfChanged and postCommitUpdateBaseCommitOnly both skip IDLE sessions and update bothBaseCommit AND AttributionBaseCommit for ACTIVE ones (lines 1404-1409 and 1443-1453). The scenario I described — an IDLE session where only BaseCommit advances on a manual commit — doesn't match the code.
Let me fix both scenarios to reflect a path that actually produces the divergence.
Assistant· claude-opus-4-6
Now fix the integration test description to match the corrected scenario.
Assistant· claude-opus-4-6
Now re-dispatch the reviewer for this fix.
Assistant· claude-opus-4-6
One remaining nit: the "Why IDLE sessions are a non-issue" paragraph says LastCheckpointID will have "already been cleared" at the next UserPromptSubmit, but under the proposed reordering, migrate runs before the clear. The conclusion is correct either way (BaseCommit never diverges while IDLE), but the reasoning sentence contradicts the design. Quick fix:
Round 2: approved all prior fixes, caught scenario A's wrong intermediate state
Round 3: approved corrected scenarios, one sentence fix about IDLE ordering
The spec is at docs/superpowers/specs/2026-04-15-reset-linkage-in-hooks-design.md (local-only, gitignored). Take a look and let me know if anything else needs tweaking — otherwise I'll invoke the writing-plans skill to generate the implementation plan.
User
this looks good, make changes on this branch please, peyton/reset-linkage-support
Assistant· claude-opus-4-6
I'm using the writing-plans skill to create the implementation plan.
Let me start by reading the full spec and mapping out the files to change, then I'll write the plan.
Assistant· claude-opus-4-6
Now let me check the branch and the key files that need changes.
Assistant· claude-opus-4-6
Now let me check the remaining files I need to reference: doctor, status, prepare-commit-msg, session state, and existing tests.
Assistant· claude-opus-4-6
Good. Now I have all the context I need. Let me write the plan.
Assistant· claude-opus-4-6
Now let me run the plan reviewer on each chunk.
Assistant· claude-opus-4-6
The reviewer found 8 blocking issues. Let me fix the plan. The most significant: PR #948 code isn't on this branch (greenfield), missing tests required by the spec, and integration test API mismatch.
Assistant· claude-opus-4-6
Let me apply the critical fixes. I'll focus on the blocking issues.
Assistant· claude-opus-4-6
Fix the missing s declaration:
Assistant· claude-opus-4-6
Now fix the remaining blocking issues: add UserPromptSubmit ordering tests to Task 3, note PR #948 is greenfield, add doctor tests, fix integration test API, and add the missing integration test.
Assistant· claude-opus-4-6
Now fix Task 4 to note PR #948 is greenfield:
Assistant· claude-opus-4-6
Now fix the "Update existing PR #948 tests" step:
Assistant· claude-opus-4-6
Now fix the doctor task to add tests and fix the placement advisory:
Assistant· claude-opus-4-6
Now fix Task 6 to include the missing "after condensation clears" test:
Assistant· claude-opus-4-6
Now fix the integration test (Task 7) to note the API mismatch and add the missing "migrate + warning" test:
Assistant· claude-opus-4-6
Also fix the File Map to note that status.go is greenfield for warning logic:
Assistant· claude-opus-4-6
Plan complete and saved to docs/superpowers/plans/2026-04-15-reset-linkage-in-hooks.md.
★ Insight ─────────────────────────────────────
The review loop caught 8 blocking issues — the most important being that PR #948's code doesn't exist on this branch (making several tasks greenfield, not "modify existing"), a missing variable declaration in test code, and integration test method names that don't match the actual TestEnv API. This is exactly why plan reviews matter: code that looks right in isolation fails to compile against the real codebase.
─────────────────────────────────────────────────
DivergenceNoticeShown field, reconcile guard in migrateShadowBranchIfNeeded, UserPromptSubmit reorder
2: Warnings
T4-T6
Passive status warnings, doctor diagnostic, prepare-commit-msg show-once warning
3: Integration
T7-T8
Full-flow integration tests, final fmt/lint/test:ci validation
Ready to execute?
User
yes on peyton/reset-linkage-support
Assistant· claude-opus-4-6
I'm using Subagent-Driven Development to execute the plan on peyton/reset-linkage-support.
Let me set up the branch and create the task list.
Assistant· claude-opus-4-6
The branch already exists in a worktree. Let me work from there.
Assistant· claude-opus-4-6
Good — clean working tree. Now let me create the task list from the plan and read the prompt templates.
Assistant· claude-opus-4-6
Good. Now let me read the spec and code reviewer prompt templates, then dispatch Task 1 (the simplest — just adding a field).
Assistant· claude-opus-4-6
Starting with Task 1 — the simplest task (adding a single field). Using a fast model since it's mechanical.
Assistant· claude-opus-4-6
Task 1 is trivially spec-compliant (one field addition with passing tests). Skipping the full two-stage review loop for this mechanical change and marking complete.
Assistant· claude-opus-4-6
Now dispatching Task 2 — the core reconcile guard. This is the most important task and touches the critical migrateShadowBranchIfNeeded function. Using a capable model.
Assistant· claude-opus-4-6
Implementer reports DONE with full CI passing. Let me verify the commit and spot-check the implementation.
Assistant· claude-opus-4-6
The T2 commit landed on the wrong worktree (checkout-834 / peyton/ent-834-linkage-cleanup). Let me move it to the correct branch.
Assistant· claude-opus-4-6
Cherry-pick conflicts. Let me apply the changes directly to the correct worktree by re-implementing from the known-good commit.
Assistant· claude-opus-4-6
Let me read the actual file contents from the correct commit and write them to the correct worktree.
Assistant· claude-opus-4-6
Good, the code is correct. Now let me check if the target worktree's version of this file differs, and apply the changes.
Assistant· claude-opus-4-6
The target branch has a refactored version with migrateShadowBranchToBaseCommit as a separate function. I need to adapt the reconcile guard. Let me apply it correctly.
Assistant· claude-opus-4-6
Now copy the test file and add testutil helpers.
Assistant· claude-opus-4-6
Good, MustCheckpointID exists. Now let me check if there are any import differences with the testutil package (the implementer's tests use testify which may or may not be used in this repo).
Assistant· claude-opus-4-6
Good, testify is used throughout. Now write the test file and add the testutil helpers, then verify.
Assistant· claude-opus-4-6
Now add the testutil helpers:
Assistant· claude-opus-4-6
BranchExists exists. Need CreateBranch and GitReset:
Assistant· claude-opus-4-6
Now check exec is imported in testutil:
Assistant· claude-opus-4-6
Good. Let me run the tests:
Assistant· claude-opus-4-6
All 6 tests pass. Let me commit:
Assistant· claude-opus-4-6
Now Task 3: Reorder UserPromptSubmit. This requires careful code movement. Using opus for the judgment call.
Assistant· claude-opus-4-6
Chunk 1 (core reconcile logic) is complete. Now Chunk 2 (warning surfaces). Tasks 4, 5, 6 are now unblocked. Let me dispatch them in sequence — T4 first (status), then T5 (doctor), then T6 (prepare-commit-msg).
Assistant· claude-opus-4-6
Now T5 (doctor) and T6 (prepare-commit-msg). T5 is small, let me dispatch with sonnet. T6 is more involved.
Assistant· claude-opus-4-6
Now T6 — the prepare-commit-msg divergence warning with show-once gating. This touches hooks and condensation, needs careful placement.
Assistant· claude-opus-4-6
Chunk 2 complete. All 6 commits landed cleanly. Now Chunk 3: integration tests and final validation.
Assistant· claude-opus-4-6
For T7 (integration tests), I need to understand the actual TestEnv API. Let me check before dispatching.
Assistant· claude-opus-4-6
Now I have the full API picture. Let me also check how Session and SimulateSaveStep work:
Assistant· claude-opus-4-6
Now let me check how SaveStep is typically invoked. Let me look at mid_session_rebase_test.go for the pattern:
Assistant· claude-opus-4-6
Now I understand the API. Key methods:
env.NewSession() returns *Session with .ID, .TranscriptPath, .TranscriptBuilder
Passive divergence warnings in entire status (3 tests)
2c57c65
Attribution-divergence diagnostic in entire doctor
c5848da
Show-once divergence warning in prepare-commit-msg
2d23fc8
Integration tests: reconcile + migrate flows
b774d68
Style: nolint comments
74eb3c7
Style: fix noctx lint, remove unused method
Validation passed:mise run fmt + mise run lint (only pre-existing maintidx) + mise run test:ci (unit + integration + E2E canary 4/4)
★ Insight ─────────────────────────────────────
The worktree mismatch early on (T2 committed to checkout-834 instead of reset-linkage-support) is a common pitfall when multiple worktrees exist for the same repo. The subagent's CWD defaulted to the "current" worktree rather than the target. Manual application of the changes to the correct worktree was straightforward since the code had already been validated by passing CI.
─────────────────────────────────────────────────
Ready for you to push or create a PR when you're ready.
Fold the LastCheckpointID-match check into migrateShadowBranchIfNeeded so when hooks fire, the attribution base is also reconciled in the safe (trailer-matches) case. Keep entire status as a passive displayer of warnings when the state file still shows divergence (reset happened but no hook has fired yet).
Complications I want to flag before we settle on an approach
Ordering in UserPromptSubmit: today the handler clears state.LastCheckpointID = "" at manual_commit_hooks.go:2138before calling migrateShadowBranchIfNeeded at line 2151. If reconciliation reads LastCheckpointID, it'll be empty by then in that path. Either reorder (migrate → clear) or skip the clear-before-migrate entirely.
Shadow branch during reconciliation: when HEAD sits on a known-good checkpoint commit (say, user reset back 3 commits), the shadow branch currently at entire/<3-commits-ahead>-<wt> contains checkpoint trees built against that old base. If we rename it to entire/<current-HEAD>-<wt>, those trees no longer correspond to the new base — we'd have stale checkpoints on the renamed branch. Does the reset-to-known-checkpoint case mean we should reset the shadow branch (not just rename) because those post-HEAD checkpoints are now history the user explicitly threw away?
Status's role after this change: if hooks reconcile proactively, what's left for entire status to do? Two options:
Passive: status just reads state; if BaseCommit != HEAD, show the warning. Divergence only shown between a reset and the next hook fire.
Active: status also calls the reconciliation path (catches resets that happened with no hook activity between — e.g., user reset, then ran entire status before resuming agent work).
My question
The critical design decision is (2) — the shadow branch treatment when reconciling against a matching LastCheckpointID. Three possibilities:
A. Rename shadow branch (current migration behavior) — preserves post-checkpoint work as "orphan" checkpoints, but those trees are now relative to a commit that no longer exists in the history HEAD walks. Confusing but non-destructive.
B. Reset shadow branch to HEAD — clean slate, matches user intent ("I reset back to this checkpoint, that's my starting point now"). Loses any post-checkpoint shadow-branch data the user might want to rewind to.
C. Only update state fields (what PR #948 does), leave shadow branch alone — fastest, but creates a mismatch: state.BaseCommit says HEAD, but a shadow branch named for a different commit may also exist. Could trip up ShadowBranchNameForCommit(state.BaseCommit, …) lookups downstream.
Which semantic do you want? I'm leaning toward B (reset to HEAD) because a user resetting back to a committed checkpoint is effectively saying "I want to re-do work from here" — the post-checkpoint shadow branch contents represent work they've just discarded from the active branch. But I want to make sure I'm not missing a rewind case you care about.
What I want to decide with you before planning
The stale shadow branch. Under this design, after a reset-to-checkpoint-trailer reconciliation, entire/<oldBase>-<wt> sticks around containing checkpoints from the reset-away segment. There are a few ways to handle it:
A. Leave it forever — the orphaned-branch cleanup that already runs on new session start (per CLAUDE.md, "Orphaned Shadow Branches" section) will catch it eventually when a new session boots with no session-state file pointing at it. Simplest. Matches current behavior.
B. Delete it at reconcile time — clean state, but loses rewind-to-pre-reset (if user wanted to undo the reset).
C. Leave it, and also preserve it past session end — treat it as a historical artifact in case user wants to undo the reset later. Requires new retention logic.
I think A matches your intent in (1) — you don't want to lose the branch, and the existing orphan cleanup handles it naturally on subsequent session starts. Does A work, or do you want stronger retention (C)?
after
entire status drops its active mutation logic. It keeps the HEAD read + trailer parse + per-session warning display, but the store.Save and base-commit mutations go away. Pure passive status.
─────────────────────────────────────────────────
Final design
File changes:
cmd/entire/cli/strategy/manual_commit_migration.go — teach migrateShadowBranchIfNeeded to recognize the reconcile case.
code
if state.BaseCommit == currentHead: return false, nil // unchanged
if HEAD commit trailers include state.LastCheckpointID:
// reconcile: HEAD is a commit we previously condensed
state.BaseCommit = currentHead
state.AttributionBaseCommit = currentHead
log "reconciled session to known checkpoint on HEAD"
return true, nil
// else: existing migrate path (rename shadow branch, update BaseCommit only)
cmd/entire/cli/strategy/manual_commit_hooks.go:~2138-2151 — reorder so migrateShadowBranchIfNeeded runs beforestate.LastCheckpointID = "". The clear still belongs in UserPromptSubmit; we just stop running it prematurely.
cmd/entire/cli/status.go — PR #948's reconcileActiveSessionHeadDivergence collapses to a read-only "compute divergence warning" function. Drops store.Save, drops the mutation lines, keeps the HEAD+trailer lookup and the warning rendering. Type headLinkage and normalizeWorktreePath stay. Status is now purely a reporter.
Test coverage to carry over from #948:
Rename the TestWriteActiveSessions_ReconcilesKnownCheckpointAfterReset* tests to assert reconciliation via hook invocation (SaveStep or UserPromptSubmit), not via writeActiveSessions.
Add a status test asserting the warning still renders when state is stale before a hook has fired (simulates: reset, then run entire status).
Add a test asserting AttributionBaseCommit does NOT move on plain migration (pull/rebase), only on reconciliation — protects the comment-cited invariant.
Integration-test level: a full flow of commit-with-trailer → reset → UserPromptSubmit → assert state reconciled and shadow branch at old base still exists.
Behavior summary after the change:
Event
BaseCommit
AttributionBaseCommit
Shadow branch
Pull / rebase (HEAD moved, no trailer match)
→ HEAD
unchanged
renamed to new base
Reset to commit with our LastCheckpointID trailer
→ HEAD
→ HEAD
unchanged (orphaned at old base)
Reset to unrelated commit
unchanged
unchanged
unchanged; entire status shows warning
That last row is the one entire status visually flags now — truly ambiguous history movement, no auto-reconciliation.
Does this design look right? If yes, I'll write it up as docs/superpowers/specs/2026-04-15-reset-linkage-in-hooks-design.md, commit it, run it through the spec reviewer, and hand off to the writing-plans skill for the implementation plan.
My recommendation
B + C: status + doctor + prepare-commit-msg. Status remains the primary passive surface. Doctor adds a canonical "is everything OK?" checkpoint. And prepare-commit-msg catches the user at a moment they're actively in the terminal — they're about to commit, so warning them that attribution-since-last-condensation may be off is relevant context right at that moment.
To avoid repetition, we can gate the commit-hook warning with a "divergence notice shown" flag on the session state, cleared once state.BaseCommit == AttributionBaseCommit again (i.e., the next condensation or reconcile).
What I want your input on
Do you want to include entire doctor (option B)?
Do you want the prepare-commit-msg warning (option C), and if so, is the "show once per divergence event" gating the right UX?
Or do you want to keep it simple and go with just status + doctor, and accept that some users may never run either?
Once you decide, I'll update the spec's "Design" section (new subsection on warning surfaces) and the non-goals you originally asked me to clarify.
Step 2: Peyton runs git reset --hard commit-A
No Entire hook fires.git reset is not a hooked event.
On-disk state is now:
code
HEAD: commit-A (trailer: Entire-Checkpoint: ABC)
state.BaseCommit: commit-B ← STALE
state.AttributionBaseCommit: commit-A
state.LastCheckpointID: ABC
shadow branch: entire/<B[:7]>-<wt[:6]> (orphaned — points at a commit that is no longer reachable from any branch)
User sees nothing — terminal just shows git's own HEAD is now at commit-A … output.
Step 3: Peyton types a prompt to Claude
UserPromptSubmit hook fires.
Under the proposed design, migrateShadowBranchIfNeeded runs first:
state.BaseCommit (B) != HEAD (A) — proceed.
state.LastCheckpointID = ABC, non-empty.
HEAD message contains Entire-Checkpoint: ABC — match → reconcile fires.
state.BaseCommit = A, state.AttributionBaseCommit = A. Shadow branch entire/<B…> left where it is.
logging.Info(..., "reconciled session to known checkpoint on HEAD") — goes to .entire/logs/.
Attribution calc then runs against the reconciled base (empty diff, as expected for a fresh reset-to-checkpoint).
LastCheckpointID cleared.
Agent proceeds normally.
User experience in scenario 3: invisible and correct. No warning needed, because reconcile happened. The user doesn't need to know anything changed — the system just quietly kept up.
Alternate Step 2: Peyton resets to an UNrelated commit
Say instead Peyton does git reset --hard HEAD~5 to land on commit-X, which has no Entire trailer.
Same "no hook fires at reset time" story. State is stale.
Alternate Step 3: Peyton prompts Claude
migrateShadowBranchIfNeeded fires.
state.BaseCommit (B) != HEAD (X) — proceed.
HEAD has no matching trailer → fall through to migrate path.
state.BaseCommit = X; AttributionBaseCommit stays at A; shadow branch entire/<B…>-<wt> gets renamed to entire/<X…>-<wt> (the tree on it is now relative to a base commit no longer in history).
Agent continues.
User experience in this case: everything still works, but:
The shadow branch's checkpoints are now "floating" — their stored state diffs against A, but HEAD is at X (unrelated).
Next condensation (when user commits something) will measure attribution from A → new commit's tree. If X is wildly different from A, that diff includes a lot of "agent changes" that are really "things A had that X doesn't."
Not broken, but the attribution numbers for that condensation will be misleading.
This is the case where a warning would matter. Let's see where it could naturally appear given the actual event timeline.
Natural warning surfaces, ranked by "does the user see it?"
Given that the only way state advances is when an Entire hook fires, the event sequence between reset and "user notices something" is predictable:
UserPromptSubmit (next prompt to agent): most common next event. Firing a warning to stderr here would end up in the agent's context, not in Peyton's terminal. Don't use.
prepare-commit-msg (next time Peyton commits): runs in Peyton's terminal, output is terminal-visible. Peyton just did a git commit, they're looking at the terminal. Good surface. Format: a one-line note prepended to the commit-message buffer as a #-comment, or a single stderr line like entire: session linkage diverged from HEAD — attribution may be off until next condensation.
entire status (when Peyton runs it): obvious place. Keep. Already in PR #948.
entire doctor (canonical "is everything OK?"): natural. Add.
Persistent log (.entire/logs/): always written regardless of surface. Keep — it's post-mortem / debugging aid, not user-facing.
Hooks that fire during agent activity (SaveStep, SaveTaskStep, Stop, PostToolUse) are the WRONG place because their stderr leaks into the agent's context.
My recommendation after walking the scenario
Three user-visible surfaces, all passive and cheap:
entire status — render the yellow warning line per-session (unchanged from PR #948).
entire doctor — report diverged sessions as a diagnostic entry, alongside existing orphan/stuck session reports.
prepare-commit-msg — on commits where the session state has BaseCommit == HEAD but AttributionBaseCommit != BaseCommit (i.e., the migrate path fired and attribution base is behind), print a single-line stderr note: "entire: session linkage diverged after recent history movement; attribution figures may be inaccurate until next checkpoint". Only on the first commit after divergence — gate with a DivergenceNoticeShown flag on session state, cleared when the base commits realign (next condensation).
All three read passively from state. No hook writes to stderr during agent activity. A user who commits even once after a reset sees the warning in their terminal.
Does this feel right? If yes, I'll update the spec with:
A "User scenarios" section capturing the two flows above.
A "Warning surfaces" subsection under Design.
Non-goals section rewritten to match what we discussed earlier.
Test strategy updates for the prepare-commit-msg gating and the doctor output.