Skip to content

fix(strategy): warn when a commit is left unlinked with a live sibling-worktree session#1858

Closed
ColeDriver wants to merge 1 commit into
mainfrom
fix/warn-unlinked-commit-live-sibling-session
Closed

fix(strategy): warn when a commit is left unlinked with a live sibling-worktree session#1858
ColeDriver wants to merge 1 commit into
mainfrom
fix/warn-unlinked-commit-live-sibling-session

Conversation

@ColeDriver

@ColeDriver ColeDriver commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

What & why

Fixes the silent no-trailer case in #1852. Commits made in a worktree with no matching session were silently left without an Entire-Checkpoint trailer — even when a live agent session ran in another worktree of the same repo. In one reported case this unlinked 101 of 108 commits (94%). The miss was logged at DEBUG, so nothing surfaced it to the person running git commit.

Change

On the no-session path in prepare-commit-msg, the hook now checks whether a live agent session exists in a different worktree of the same repo. When one does, it (1) prints a notice to stderr during the commit — the same channel warnIfAttributionDiverged uses, so the failure is actually visible — and (2) keeps a structured WARN in .entire/logs for diagnostics. The stderr notice reads:

entire: this commit was not linked to a checkpoint (live agent session in ../feature).
  run 'entire session adopt --from ../feature --yes' to link this worktree.

Sessionless commits — the common case — stay quiet; the check is skipped when listing errored. Underlying matching is unchanged — this makes the residual silent case visible, it doesn't change what gets linked.

Notes / decisions

  • "Live" = non-ended AND recently interacted (24h activeSessionInteractionThreshold), mirroring the staleness guard used elsewhere in this file — a crashed session that never reaches ENDED won't nag forever. ENDED / stale / adopted-away / imported don't count.
  • --yes is required in the hint: same-repo adoption routes through adoptFromSameSessionStore, which needs it even on first adoption — the bare command would always error.

⚠️ Tradeoff — maintainer call before merge

  1. Overlaps in-flight matching work (use github runners #1/Move "clean" root command to "session cleanup", some refactoring #2 in the issue). That fix will shrink when this warning fires, possibly to just the ambiguous multi-worktree case it can't resolve. Whoever owns matching should confirm they want the interim warning now vs. folding it in later.
  2. Prints on every affected commit (each is a real, separate miss). Repo has throttle mechanisms — happy to rate-limit / show-once-per-session if preferred.

Tests

  • Table-driven unit tests (t.Parallel()): isLiveSessionInOtherWorktree (same-worktree / sibling-active / sibling-idle / stale / never-interacted / ended / adopted-away / imported), uniqueWorktreePaths, formatUnlinkedCommitNotice.
  • Full strategy suite passes; maintidx + golangci-lint v2.11.3 clean on changed files; go build ./..., go vet, gofmt clean.

Refs #1852

@ColeDriver
ColeDriver requested a review from a team as a code owner July 26, 2026 04:43
@ColeDriver
ColeDriver force-pushed the fix/warn-unlinked-commit-live-sibling-session branch 3 times, most recently from b4e0715 to 6cd68db Compare July 26, 2026 05:12
…g-worktree session

Commits made in a worktree with no matching session were silently left
without an Entire-Checkpoint trailer even when a live agent session was
running in another worktree of the same repo -- the silent no-trailer
case in #1852 (94% of commits unlinked in one reported case). The miss
was logged at DEBUG, so nothing surfaced it.

On the no-session path, prepare-commit-msg now checks whether any
non-ended session exists in a different worktree of the same repo (the
session store is already scoped to this repo's git common dir). When one
does, it logs at WARN with the offending worktree(s) and the
`entire session adopt` remedy instead of swallowing the miss at DEBUG.
A plain sessionless commit -- the common case -- stays quiet, and the
check is skipped entirely when session listing errored so the hook stays
resilient.

This makes the failure visible; the underlying cross-worktree matching
is unchanged.

Refs #1852

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ColeDriver
ColeDriver force-pushed the fix/warn-unlinked-commit-live-sibling-session branch from 6cd68db to 41e5807 Compare July 26, 2026 05:25
@ColeDriver ColeDriver closed this Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant