Skip to content

Push finalized checkpoint transcripts on turn-end#636

Open
khaong wants to merge 11 commits intomainfrom
alex/stop-hook-updates-remote-checkpoints
Open

Push finalized checkpoint transcripts on turn-end#636
khaong wants to merge 11 commits intomainfrom
alex/stop-hook-updates-remote-checkpoints

Conversation

@khaong
Copy link
Contributor

@khaong khaong commented Mar 6, 2026

Summary

  • When an agent commits and pushes during a turn, PrePush now marks ACTIVE sessions with TurnCheckpointIDs by setting PushedDuringTurnRemote on session state
  • HandleTurnEnd checks this flag after finalizing transcripts and pushes entire/checkpoints/v1 to the same remote
  • Flag is cleared on turn-end (after push attempt) and on new turn start (InitializeSession)

Closes the gap where the remote had a provisional transcript after a mid-turn push, but the finalized version (with trailing conversation) stayed local.

Design doc

docs/plans/2026-03-06-turn-end-checkpoint-push-design.md (in worktree, not committed — contains full analysis of multi-session scenarios and known limitations)

Known limitation

In the concurrent multi-session edge case where a session has both pushed and unpushed checkpoints, the turn-end push will push the entire entire/checkpoints/v1 branch — including metadata for unpushed code commits. This is rare and can be addressed with future checkpoint GC.

Test plan

  • Unit tests for markActiveSessionsPushed (ACTIVE/IDLE/no-checkpoint cases)
  • Unit tests for HandleTurnEnd push behavior (flagged vs not flagged)
  • Unit test for InitializeSession clearing the flag
  • Integration tests for full lifecycle (flag set → stop → cleared)
  • Integration test for new prompt clearing stale flag
  • E2E: manual push triggers pre-push hook, checkpoints arrive at remote
  • E2E: mid-turn push + turn-end pushes finalized transcripts (local == remote transcript)
  • E2E: no push during turn = no remote checkpoint advancement
  • Vogon push support added (regex parsing + git push origin HEAD)
  • All existing tests pass (mise run test:ci — 46/46 including new E2E canary tests)

🤖 Generated with Claude Code

When an agent commits and pushes during a turn, the remote checkpoint
contains a provisional transcript. HandleTurnEnd finalizes it with the
complete conversation but previously didn't push the update, leaving the
remote stale.

Now PrePush marks ACTIVE sessions with TurnCheckpointIDs by setting
PushedDuringTurnRemote on their state. HandleTurnEnd checks this flag
after finalizing transcripts and pushes entire/checkpoints/v1 to the
same remote, keeping the remote consistent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 738ef53b2521
Copilot AI review requested due to automatic review settings March 6, 2026 10:27
@cursor
Copy link

cursor bot commented Mar 6, 2026

PR Summary

Medium Risk
Adds new state tracking and additional git push behavior in PrePush/HandleTurnEnd, which could affect when checkpoint metadata is published to remotes (especially in multi-session/concurrent scenarios). Changes are best-effort and well-covered by new unit/integration/e2e tests, reducing but not eliminating behavioral risk.

Overview
Ensures checkpoint transcripts on entire/checkpoints/v1 stay consistent on the remote when a push happens mid-turn by introducing a per-session PushedDuringTurnRemote flag.

PrePush now marks ACTIVE sessions with TurnCheckpointIDs as having pushed to a specific remote, and HandleTurnEnd uses that flag to (best-effort) push the finalized checkpoint transcripts to the same remote after finalization, then clears the flag (also cleared on new prompt start).

Adds coverage for the flag lifecycle and turn-end push behavior via new unit tests, integration tests, and an e2e canary flow (including extending the Vogon prompt parser/executor to support push).

Written by Cursor Bugbot for commit aca417a. Configure here.

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

This PR adds a “turn-end push” mechanism to ensure that when checkpoints are pushed mid-turn (with provisional transcripts), the finalized checkpoint transcripts are also pushed at turn end to keep the remote metadata consistent.

Changes:

  • Track mid-turn remote pushes via a new session-state flag (PushedDuringTurnRemote) set during PrePush.
  • On HandleTurnEnd, finalize transcripts and (if flagged) best-effort push the checkpoints metadata branch to the same remote, then clear the flag.
  • Add unit + integration coverage for flag marking/clearing and turn-end push behavior; deduplicate test transcript fixtures.

Reviewed changes

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

Show a summary per file
File Description
cmd/entire/cli/strategy/phase_postcommit_test.go Adds unit tests covering turn-end push behavior (flagged vs unflagged).
cmd/entire/cli/strategy/manual_commit_test.go Adds unit test ensuring InitializeSession clears the new push flag.
cmd/entire/cli/strategy/manual_commit_push_test.go New unit tests for markActiveSessionsPushed behavior across phases / checkpoint presence.
cmd/entire/cli/strategy/manual_commit_push.go Marks ACTIVE sessions as “pushed during turn” after checkpoint-branch push in PrePush.
cmd/entire/cli/strategy/manual_commit_hooks.go Implements best-effort turn-end push when PushedDuringTurnRemote is set; clears the flag.
cmd/entire/cli/strategy/common_test.go Introduces shared minimal transcript constant to satisfy goconst.
cmd/entire/cli/session/state.go Adds PushedDuringTurnRemote to persisted session state with lifecycle documentation.
cmd/entire/cli/integration_test/turn_end_push_test.go New integration tests validating full lifecycle and stale-flag clearing on new prompt.
CLAUDE.md Documents the new turn-end push behavior and key file locations.

khaong and others added 4 commits March 6, 2026 21:54
- Remove unreachable error branches in pushFinalizedCheckpointsIfNeeded
  (doPushBranch always returns nil, handling errors internally via stderr)
- Add multi-session test for markActiveSessionsPushed verifying all
  ACTIVE sessions get marked while IDLE sessions are skipped

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 80c2d8b615c0
…ls push

- Only mark sessions as pushed when push_sessions is not disabled,
  preventing incorrect flag state when pushing is off
- Remove trails push from pushFinalizedCheckpointsIfNeeded — trails
  have a different lifecycle and don't need to be coupled here

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 67f4c6e88c77
- Add push support to Vogon agent (regex parsing + git push execution)
- Add 3 E2E tests:
  - Manual push triggers pre-push hook, checkpoints arrive at remote
  - Mid-turn push + turn-end pushes finalized transcripts (agent-agnostic)
  - No push during turn = no remote checkpoint advancement

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 37bb6a89bb73
@khaong
Copy link
Contributor Author

khaong commented Mar 6, 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.

✅ Bugbot reviewed your changes and found no new issues!

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

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 12 out of 12 changed files in this pull request and generated 2 comments.

khaong and others added 2 commits March 6, 2026 22:37
- Remove `continue` after commit in parseNumberedSteps so push check
  runs on combined steps like "(2) commit and push"
- Add comment on pushBranchIfNeeded error check explaining it's defensive
  (currently always returns nil but kept for correctness if that changes)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 7f7c3a582840
@khaong khaong marked this pull request as ready for review March 6, 2026 11:53
@khaong khaong requested a review from a team as a code owner March 6, 2026 11:53
khaong added 4 commits March 6, 2026 23:12
…s-remote-checkpoints

# Conflicts:
#	cmd/entire/cli/strategy/manual_commit_test.go
…eckpoints' into alex/stop-hook-updates-remote-checkpoints
Entire-Checkpoint: ebaa181741e1
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