Skip to content

fixed wrong reusage of checkpoint id for multiple commits#268

Open
Soph wants to merge 2 commits intomainfrom
soph/fix-issue-with-reusing-checkpoint-id
Open

fixed wrong reusage of checkpoint id for multiple commits#268
Soph wants to merge 2 commits intomainfrom
soph/fix-issue-with-reusing-checkpoint-id

Conversation

@Soph
Copy link
Collaborator

@Soph Soph commented Feb 11, 2026

This fixes a bug that could lead to creating multiple commits with the same checkpoint id. A checkpoint id should only be used in one commit.

Copilot AI review requested due to automatic review settings February 11, 2026 16:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Entire-Checkpoint: 50e6e7e6ec02
@Soph Soph requested a review from Copilot February 11, 2026 19:34
@Soph Soph marked this pull request as ready for review February 11, 2026 19:34
@Soph Soph requested a review from a team as a code owner February 11, 2026 19:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@khaong
Copy link
Contributor

khaong commented Feb 12, 2026

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

if err != nil {
return fmt.Errorf("failed to generate checkpoint ID: %w", err)
}
checkpointID = cpID
Copy link

Choose a reason for hiding this comment

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

Earlier commit IDs become unreachable

High Severity

PrepareCommitMsg now always generates a new checkpoint ID for new content, but session state still keeps only one PendingCheckpointID. In multi-commit active turns, later PostCommit calls overwrite earlier IDs, and turn-end condensation uses only the last one. Earlier commits keep trailers pointing to checkpoint IDs that never get condensed.

Additional Locations (2)

Fix in Cursor Fix in Web

if err != nil {
return fmt.Errorf("failed to generate checkpoint ID: %w", err)
}
checkpointID = cpID
Copy link

Choose a reason for hiding this comment

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

Message commits skip confirmation unexpectedly

Medium Severity

After switching to fresh IDs, hasNewContent commits are still marked as restoring when any session has PendingCheckpointID. For source == "message", this routes to the non-confirmation path even though a brand-new checkpoint is being created, so trailer insertion can bypass the intended interactive confirmation.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

| Field | Set By | Cleared By | Purpose |
|-------|--------|------------|---------|
| `PendingCheckpointID` | PostCommit (ACTIVE → ACTIVE_COMMITTED) | `condenseAndUpdateState` | Deferred condensation coordination |
| `LastCheckpointID` | `condenseAndUpdateState` | `InitializeSession` (new prompt) | Amend trailer restoration |
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

LastCheckpointID is documented as only for “Amend trailer restoration”, but in the manual-commit strategy it’s also used to reuse/link an existing condensed checkpoint when there’s no new content (e.g., split Claude’s work across multiple commits). Consider expanding the Purpose (and/or the surrounding text) to reflect both behaviors so readers don’t assume it’s amend-only.

Suggested change
| `LastCheckpointID` | `condenseAndUpdateState` | `InitializeSession` (new prompt) | Amend trailer restoration |
| `LastCheckpointID` | `condenseAndUpdateState` | `InitializeSession` (new prompt) | Amend trailer restoration and reusing/linking an existing condensed checkpoint when new commits have no additional content (e.g., manual-commit strategy) |

Copilot uses AI. Check for mistakes.
Comment on lines +383 to +391
// New content: generate a fresh checkpoint ID.
// Idempotency for hook re-runs is handled by the trailer existence check above.
// NOTE: Do NOT reuse PendingCheckpointID here - it's from a previous commit's
// PostCommit and would cause duplicate IDs across different commits.
cpID, err := id.Generate()
if err != nil {
return fmt.Errorf("failed to generate checkpoint ID: %w", err)
}
checkpointID = cpID
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

This hunk correctly stops reusing PendingCheckpointID when generating a checkpoint ID for new content, but later in PrepareCommitMsg the isRestoringExisting logic is still influenced by PendingCheckpointID when hasNewContent is true. With fresh IDs now always generated here, PendingCheckpointID should no longer cause the commit to be treated as “restoring existing” (it can incorrectly bypass the interactive confirmation path for source == "message"). Consider removing/reworking that PendingCheckpointID check so only actual reuse/restoration paths skip confirmation.

Copilot uses AI. Check for mistakes.
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.

2 participants