fix(strategy): warn when ambiguous worktree sessions block commit linking - #1856
Merged
Conversation
…king When the sibling/parent worktree fallback finds live sessions but they span multiple worktrees, it refuses to guess and the commit silently loses its Entire-Checkpoint linkage with only a DEBUG trace. Surface that refusal at WARN with the candidate worktrees and a pointer to 'entire session adopt' as the explicit remedy. Requested in #1852 alongside the matching fix that landed in #1440. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Entire-Checkpoint: 01KYAQV3Z2X1A2FTS5K5MXTT83
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves observability for the manual-commit strategy’s worktree session matching by emitting a WARN when fallback session matching finds active sessions across multiple worktrees but refuses to guess, preventing commits from silently losing Entire-Checkpoint linkage (follow-up to #1440 / #1852).
Changes:
- Add WARN-level structured logging when ambiguous multi-worktree fallback matches are detected, including an explicit
entire session adopt --from <worktree>remedy hint. - Extend strategy worktree-session tests to assert the WARN is written to
.entire/logs(since hook stderr is intentionally discarded).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
cmd/entire/cli/strategy/manual_commit_session.go |
Adds warnAmbiguousWorktreeSessions and calls it when fallback matching is refused due to multi-worktree ambiguity. |
cmd/entire/cli/strategy/manual_commit_worktree_session_test.go |
Adds a test that initializes logging, reproduces ambiguous sibling sessions, and asserts WARN-level logging plus the adopt hint in .entire/logs. |
Log messages elsewhere are short and factual with structured attrs carrying the detail; none embed remedy commands. Drop the inline 'entire session adopt' hint and the 'sibling' qualifier (the warning also covers the parent-checkout tier) — the candidate_worktrees attr already identifies the worktrees involved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Entire-Checkpoint: 01KYAS4TEW84CS9DAPEP7PSYPV
computermode
approved these changes
Jul 24, 2026
ColeDriver
pushed a commit
that referenced
this pull request
Jul 26, 2026
…runnable remedy #1856 added warnAmbiguousWorktreeSessions for the #1852 case where live sessions span multiple worktrees and matching refuses to guess, so the commit is left unlinked. But it only logs to the internal .entire/logs file and prints no remedy, so the person running `git commit` still sees nothing -- the "silent" part of #1852 is unchanged for them. This keeps the structured WARN (diagnostics) and additionally writes a user-facing notice to stderrWriter -- the same channel warnIfAttributionDiverged and warnStaleEndedSessions use -- with a directly runnable remedy: entire: this commit was not linked to a checkpoint (live agent sessions span multiple worktrees: ../a, ../b). run 'entire session adopt <session-id> --from ../a --yes' to link one explicitly. The command names a concrete session ID rather than the bare `--from <path>` form: bare --from relies on adoption's auto-detect, which only considers sessions within adoptRecentWindow (12h) and fails outright when a worktree has multiple sessions; and same-repo adoption requires --yes. The named session is the most-recently-active candidate that adoption will accept (mirrors isAdoptableSourceSession), so the suggested command actually runs. Additive only: the warning trigger and the existing log line are unchanged. Refs #1852 Follow-up to #1856 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
https://entire.io/gh/entireio/cli/trails/940
Summary
Follow-up to #1440 for the last ask in #1852: when the sibling/parent worktree fallback finds live sessions but they span multiple worktrees, it refuses to guess — and until now the commit silently lost its
Entire-Checkpointlinkage with only a DEBUG-level trace.entire session adoptremedy stays in docs/issue guidance rather than log prose.entire/logs(level, message, and candidate_worktrees attr)Terminal output was considered but the installed
prepare-commit-msgandpost-commithooks intentionally redirect stderr to /dev/null, so the log-file WARN is the available surface.Validation
mise run fmt/mise run lint(0 issues)mise run test— 8377 tests green🤖 Generated with Claude Code
Note
Low Risk
Observability-only: matching behavior is unchanged; adds structured WARN logging and test coverage for an existing refusal path.
Overview
When sibling/parent worktree fallback finds live sessions but they span more than one worktree,
findSessionsForWorktreestill returns no match (no guessing). This change emits a WARN via the checkpoint logger instead of leaving the refusal effectively invisible.The warning lists the commit worktree, candidate session count, and distinct candidate worktrees, and tells users to run
entire session adopt --from <worktree>to link a session explicitly. That targets the case where commits in a third worktree silently lose Entire-Checkpoint linkage (#1852).A new integration test initializes logging, reproduces ambiguous sibling sessions, and asserts WARN level plus the refusal and adopt hints appear under
.entire/logs(hooks redirect stderr, so logs are the intended surface).Reviewed by Cursor Bugbot for commit a19d840. Configure here.
Before / after
Captured from a real run of the ambiguous scenario (live sessions in two worktrees,
git commitin a third worktree of the same repo); temp paths shortened.Before — the only trace, visible only with
log_level: DEBUG:{"level":"DEBUG","msg":"prepare-commit-msg: no active sessions","component":"checkpoint","strategy":"manual-commit","source":"message"}After — visible at the default level, names the worktrees involved:
{"level":"WARN","msg":"session matching: ambiguous sessions across worktrees; commit will not be linked","component":"checkpoint","commit_worktree":"/repo/.worktrees/commit","candidate_sessions":2,"candidate_worktrees":["/repo/.worktrees/first","/repo/.worktrees/second"]} {"level":"DEBUG","msg":"prepare-commit-msg: no active sessions","component":"checkpoint","strategy":"manual-commit","source":"message"}