Skip to content

fix: entire attach preserves BaseCommit and active phase#1102

Merged
Soph merged 2 commits into
entireio:mainfrom
rkfir-dn:fix/session-init-and-attach-base-commit
May 4, 2026
Merged

fix: entire attach preserves BaseCommit and active phase#1102
Soph merged 2 commits into
entireio:mainfrom
rkfir-dn:fix/session-init-and-attach-base-commit

Conversation

@rkfir-dn
Copy link
Copy Markdown
Contributor

@rkfir-dn rkfir-dn commented May 4, 2026

Related to #411

When entire attach was called on a session with an empty BaseCommit (e.g., after a hook initialization failure, or on a session created before entire was enabled), saveAttachSessionState wrote PhaseEnded and left BaseCommit empty. This prevented the prepare-commit-msg hook from recognizing the session, so subsequent commits never received Entire-Checkpoint trailers.

Two changes in saveAttachSessionState:

  1. Populate BaseCommit (and AttributionBaseCommit) from repo.Head() when the state's BaseCommit is empty. This activates the session so the prepare-commit-msg hook attaches trailers to future commits in the same session — eliminating the need to call entire attach again after a hook failure.

  2. Do not unconditionally set Phase to PhaseEnded. If the session is already active (Phase.IsActive()), preserve that phase. Previously, calling entire attach on a running session would set PhaseEnded and break all subsequent commits in that session.

When entire attach was called on a session with an empty BaseCommit
(e.g., after a hook initialization failure, or on a session created
before entire was enabled), saveAttachSessionState wrote PhaseEnded
and left BaseCommit empty. This prevented the prepare-commit-msg hook
from recognizing the session, so subsequent commits never received
Entire-Checkpoint trailers.

Two changes in saveAttachSessionState:

1. Populate BaseCommit (and AttributionBaseCommit) from repo.Head()
   when the state's BaseCommit is empty. This activates the session so
   the prepare-commit-msg hook attaches trailers to future commits in
   the same session — eliminating the need to call entire attach again
   after a hook failure.

2. Do not unconditionally set Phase to PhaseEnded. If the session is
   already active (Phase.IsActive()), preserve that phase. Previously,
   calling entire attach on a running session would set PhaseEnded and
   break all subsequent commits in that session.
@rkfir-dn rkfir-dn requested a review from a team as a code owner May 4, 2026 12:53
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

TestAttach_PopulatesBaseCommitFromHEAD covers the issue #411 symptom:
attach used to leave BaseCommit empty, so the prepare-commit-msg hook
never recognized the session and skipped Entire-Checkpoint trailers.

TestAttach_PreservesActivePhase covers the second bug fixed here:
calling attach on an already-active session must not clobber Phase
to PhaseEnded.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Entire-Checkpoint: c71032ce5a68
Copy link
Copy Markdown
Collaborator

@Soph Soph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkfir-dn thanks for your contribution, I added tests validating it but your changes look good.

@Soph Soph merged commit 231844a into entireio:main May 4, 2026
9 checks passed
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.

3 participants