Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): wait for terminal checkpoints before new messages #10297

Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 14 commits intot3code/debt-gzuf-4-runtime-finalization fromt3code/debt-gzuf-5-completionopened View on GitHub

A follow-up message can edit files before the previous turn's checkpoint captures them. Slow pull request lookups can extend that window.

Track terminal events before logging or runtime consumers receive them. The application owns one capture service shared by the provider and both reactors. Hold new messages for that thread until capture succeeds, skips, or fails. Reserve the known active turn before an interrupt returns. Keep git status and pull request refresh work outside the capture worker.

Active-turn steering still goes through. A second stop cancels messages waiting for capture. Capture failures and non-git projects do not block the next message.

Verified after restacking with 195 focused server tests, the server typecheck, and targeted lint. The two new ordering tests fail on current main because the next turn edits files before capture. One existing real-Codex test requires a local binary and was skipped.

This covers known terminal events and explicit interrupt ordering. It does not make native turn admission atomic with terminal events that arrive during send preparation, or change ambiguous interrupt error recovery.

Stacked on #10120 to keep the related server changes in merge order.

Created with Codex. Updated with Codex.

Note

Wait for terminal checkpoint capture before starting next provider message

  • Adds TurnCheckpointCapture service in TurnCheckpointCapture.ts to track per-thread pending captures for terminal provider events (completed/aborted) and interrupt reservations
  • ProviderService.publishRuntimeEvent in ProviderService.ts now observes events through TurnCheckpointCapture before canonical logging and PubSub publication; interruptTurn and stopSession register interrupt expectations before adapter calls
  • ProviderCommandReactor in ProviderCommandReactor.ts holds turn-start requests for a thread with pending checkpoint capture and resumes them via internal capture-ready inputs once the capture completes; cancellation commands remove delayed requests and still invoke the provider interrupt or stop
  • CheckpointReactor in CheckpointReactor.ts delegates completed/aborted event handling to processTurnCompletion, which signals TurnCheckpointCapture.complete on exit and moves Git status refresh to a separate drainable worker
  • Behavioral Change: ProviderService construction now requires TurnCheckpointCapture; RuntimeCoreDependenciesLive in server.ts provides it, and all test layers updated to include it
Macroscope summarized 42e41b3.
    1. Bugbot is paused — on-demand spend limit reached

      Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

      A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/f5e0572c3c3d8c5db855394dc45253098c911ccd/apps/server/src/provider/Layers/ProviderService.ts#L754

      A blocked canonicalEventLogger.write prevents checkpointCapture.observe from running, so a follow-up thread.turn-start-requested can proceed before the terminal checkpoint is created. Because the production writer may synchronously flush its batch, put checkpointCapture.observe before the logger tap so the ordering guarantee does not depend on log I/O completing.

      No longer relevant as of 20cdc7f718317f7b7cea11be7dc0fadc8ade6e32

    4. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire—13.6 KiB—15.1 KiB✅
      CodexThread snapshot wire—7.0 KiB—7.3 KiB✅
      CodexLive turn WebSocket wire—6.5 KiB—7.8 KiB✅
      CodexLive turn WebSocket decoded—57.1 KiB—66.4 KiB✅
      CodexLive turn messages—10—21✅
      ClaudeTotal thread wire—13.6 KiB—15.1 KiB✅
      ClaudeThread snapshot wire—7.0 KiB—7.3 KiB✅
      ClaudeLive turn WebSocket wire—6.5 KiB—7.8 KiB✅
      ClaudeLive turn WebSocket decoded—57.8 KiB—66.4 KiB✅
      ClaudeLive turn messages—9—21✅

      Baseline: unavailable · PR result: 427ecc7 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 113.8 KiB
      • Claude decoded thread snapshot: 114.5 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This is a large, cross-cutting server concurrency change that alters existing message admission, checkpoint ordering, interrupt handling, and worker coordination across several production services. Although it has focused ordering and failure tests, the new asynchronous state machine and runtime behavior warrant human review.

      No code changes detected at 427ecc7. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. t3dotgg(GitHub profile, opens in a new tab)commented

      Note

      🤖 Codex responding on behalf of Theo

      Fixed in 20cdc7f718. Capture observation now runs before the logger tap. The existing canonical-event test now holds the log write with a Deferred and verifies that terminal capture is already pending. The new assertion failed before the ordering change.

    7. Note

      🤖 Claude Fable 5.1 responding on behalf of Theo

      Closing in favor of #10347, which extracts the statusRefreshWorker split so checkpoint capture no longer waits behind the remote PR lookup. That closes most of the window on its own. The remaining cross-reactor gate (TurnCheckpointCapture threaded through ProviderService, both reactors and server.ts, plus the delayed turn start queue and interrupt reservations) adds a fourth coordination map to an 1800-line reactor and new user-visible stop behavior for a residual window of one git write-tree. Not worth that surface right now.

Sign in to join this conversation.