fix(session): auto-adopt across git common dirs on commit#1777
Open
suhaanthayyil wants to merge 1 commit into
Open
fix(session): auto-adopt across git common dirs on commit#1777suhaanthayyil wants to merge 1 commit into
suhaanthayyil wants to merge 1 commit into
Conversation
When prepare-commit-msg runs in an enabled repo with no local ACTIVE session, discover a unique recent cross-common-dir candidate (live registry or sibling scan) whose FilesTouched overlaps staged paths and adopt it so Entire-Checkpoint trailers are not silently dropped.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses cross-repository agent session continuity by enabling prepare-commit-msg to automatically adopt a unique, recent session from another git common dir when the current repo has no local adoptable session state—so commits in the new repo can still receive an Entire-Checkpoint trailer.
Changes:
- Introduces a best-effort per-user “live session” registry in the user cache to enable fast cross-common-dir discovery without filesystem scans.
- Adds
prepare-commit-msgauto-adopt logic that filters candidates by recency and requiredFilesTouched↔ staged-file overlap, falling back to scanning sibling repos when the registry is inconclusive. - Extends
session adoptinternals with an option to skip transcript-path validation for auto-adopt, clearing invalid transcript paths instead of failing adoption.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/session/state.go | Registers/unregisters sessions in the live registry on save/clear. |
| cmd/entire/cli/session/live_registry.go | Implements the live-session registry stored under the user cache. |
| cmd/entire/cli/session/live_registry_test.go | Unit tests for registry behavior and Save/Clear integration. |
| cmd/entire/cli/session_auto_adopt.go | Implements hook-time cross-common-dir auto-adoption and candidate selection logic. |
| cmd/entire/cli/session_auto_adopt_test.go | Regression tests covering registry-based and sibling-scan adoption plus skip cases. |
| cmd/entire/cli/session_adopt.go | Adds SkipTranscriptValidation and transcript-path clearing for auto-adopt safety. |
| cmd/entire/cli/hooks_git_cmd.go | Invokes auto-adopt during prepare-commit-msg before trailer insertion. |
Comment on lines
+50
to
+53
| func RegisterLiveSession(state *State, commonDir string) error { | ||
| if !ShouldRegisterLive(state) { | ||
| return UnregisterLiveSession(state.SessionID) | ||
| } |
Comment on lines
+222
to
225
| // When an ACTIVE agent session lives in another git common dir, | ||
| // adopt it into this repo before trailer insertion (#1439). | ||
| tryAutoAdoptCrossCommonDirSession(g.ctx) | ||
| hookErr := g.strategy.PrepareCommitMsg(g.ctx, commitMsgFile, source) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trail: https://entire.io/gh/entireio/cli/trails/875
Summary
Fixes #1439
What
Auto-adopt a unique ACTIVE agent session from another git common dir during
prepare-commit-msg, so commits in an enabled repo B get anEntire-Checkpointtrailer when the live session state still lives under repo A.Why / how it helps
Long agent sessions often move across independently enabled repos. Hooks fire in B, but B's
.git/entire-sessionsis empty, so the trailer is silently skipped even though Entire is installed. Manualentire session adopt(#1472) already exists; this wires a safe automatic path on commit.How
prepare-commit-msg, if the current repo is enabled and has no local ACTIVE session, discover exactly one recent cross-common-dir candidate via:FilesTouchedoverlap with staged paths. Process-owner match only disambiguates among overlap candidates — never adopts alone.session adoptmachinery (retires source, seeds target-local bookkeeping).Testing
entire-sessionsempty./tmp/entire-1439):Entire-Checkpoint: …Entire-Checkpoint: …and session state present under B.TestAutoAdopt_*,TestLiveRegistry_*, existingTestSessionAdopt_*.tryAutoAdoptCrossCommonDirSession→TestAutoAdopt_PrepareCommitMsg_ViaLiveRegistryFAIL; restore → PASS.mise run fmt && mise run lintgreen;go test ./cmd/entire/cli/session ./cmd/entire/cligreen on committed tree.