Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): a slow baseline checkpoint no longer holds every prompt for 30 seconds #34849

Mergedjuliusmarmingemerged 0 commits intomain fromrefs/pull/34849/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

The review item is correct and is fixed. captureBaseline takes the per-cwd KeyedLock before checking hasCheckpointRef, and a stopped run's post-turn capture holds that lock while writing the same ordinal's ref. With Effect.timeout around the whole captureBaseline call in RunExecutionService, a lock wait longer than 5 s gave up and started the provider while that git add -A was still running, so the agent's first edits could be snapshotted into the baseline. RunExecutionService.ts is now back to main. The 5 s BASELINE_CAPTURE_BUDGET is applied in CheckpointService.captureBaseline to checkpointStore.captureCheckpoint only, after the lock is held and the existing ref has been checked. Lock waits and existing refs behave as on main; only a fresh slow snapshot is interrupted, which stops the git process, and it surfaces as CheckpointBaselineCaptureError. RunExecutionService already catches that error and starts the provider without a baseline, as it did after the 30 s timeout. The repro-branch test in RunExecutionService.test.ts mocked the whole captureBaseline as a 30 s sleep; it could only pass with the budget around the lock wait, which is exactly the reported race, so it is restored to main's version. The regression test now lives in CheckpointService.test.ts: (1) a baseline queued behind an in-flight post-turn capture of the same ref waits for it and succeeds without a second snapshot; (2) a slow fresh baseline snapshot fails at 5 s and writes no ref. With the budget moved back around the lock, the test fails with 'expected Failure to equal Success'. No new regex or parser.

Fixes pingdotgg/t3code#28996

Reproduction on main

Commit a18a458f25 (origin/main). Made a git repo with one committed README and 4 GB of untracked random files (40 x 100 MB); git add -A there takes 83 s. Started T3CODE_DEV_SEED=0 vp run dev on a fresh database, ran t3 project add <repo>, then t3 thread start --provider devReplay --model showcase --wait <repo> "go". Turn 1 was sent at 06:52:25.6; the server logged 'orchestration V2 checkpoint baseline capture failed; starting provider without a baseline' at 06:52:56.4, and only then did the provider turn start. Trace: RunExecutionService.startRootRun 30,049 ms (Success), captureCheckpoint 30,025 ms (Failure), git processRunner.runProcessCore 30,000 ms (Interrupted), VcsProcessTimeoutError after 30000ms. A follow-up t3 thread send was sent at 06:54:00.6, and the same failure was logged at 06:54:31.3 before the provider started, so every turn waits about 31 s and still gets no baseline. The steer refusal in step 4 of the report was not tested (tracked in #23271). The failing test on factory/repro-28996 fails on main with 'expected 30000 to be below 30000' and passes when the capture is temporarily made non-blocking.

Evidence

Run the real dev server with empty-initialized isolated state and seeding disabled. Add a Git workspace containing one committed README and 4 GB of untracked random files. Send go with t3 thread start --wait, then go again with t3 thread send --wait. Both sides use identical file bytes and the same replay fixture and driver. A separate git add -A calibration took 85.935 seconds; proof repositories started with cold Git object stores.

These are timestamped real-server/CLI event recordings rendered at 1x speed, not browser recordings or test results. Both sides logged baseline-capture failure before starting the provider.

BeforeAfter
a18a458f25d554ec9bee
Before: both turns wait roughly 30 seconds after the run becomes runningAfter: both baseline waits end after roughly five seconds
Before recordingAfter recording
Prompt accepted → provider started: 30.163 s / 35.905 sPrompt accepted → provider started: 5.266 s / 13.049 s
Run running → provider started: 30.061 s / 30.047 sRun running → provider started: 5.061 s / 5.028 s
Persisted events, server warnings, transcript, terminal recordingPersisted events, server warnings, transcript, terminal recording

The fix bounds the observed baseline wait to roughly five seconds. It does not make all startup instantaneous: the fixed follow-up took another 8.021 seconds before entering the running state.

Reproduction artifacts: driver, seed script, recording renderer, event exporter, matching file hashes.

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • Browser rendering and the visible working indicator were not captured; this proof exercises the real server through its CLI and records persisted run/provider events.
  • Stop followed immediately by another turn while checkpoint capture holds the workspace lock was not exercised; the reproduction waits for each turn to complete.
  • Steer refusal tracked in #23271 was not tested.

Tests

vp test run src/orchestration-v2/CheckpointService.test.ts src/orchestration-v2/RunExecutionService.test.ts: 2 files, 70 tests passed. With the budget temporarily moved to wrap withWorkspaceLock, vp test run src/orchestration-v2/CheckpointService.test.ts -t "bounds a slow" failed with 'expected Failure to equal Success'; the fix was then restored. vp run check:changed: the first run failed only on format; after vp fmt on the new test it passed format, lint, knip, graphql, typecheck (3 packages) and tests (2 files).

Not in this change

  • Backing off missing-baseline retries after repeated timeouts per workspace (open PR #29196) would also remove the remaining 5 s wait on later turns in very slow workspaces.
  • The post-turn checkpoint capture still uses the full 30 s VCS timeout and still fails every turn in a workspace where git add -A takes longer, so those turns get no diff.
  • Refusal to steer while the baseline is pending (tracked in #23271).
  • The post-turn checkpoint capture still uses the full 30 s VCS timeout and still fails every turn in a workspace where git add -A takes longer.

AI-assisted; verified with the tests and tools listed above.

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

    2. Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — Fresh baseline snapshots now time out after five seconds, while lock waits remain unchanged. A human needs to confirm the default tradeoff between faster prompt startup and proceeding without a baseline in slower workspaces.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: 1a1f9ac · PR result: d554ec9 · 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: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

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

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      Baseline checkpoint capture now has a five-second timeout. A new test covers coordination with an in-flight post-turn capture and failure when the baseline capture exceeds that budget.

      Changes: Baseline capture timeout

      Layer / File(s)Summary
      Baseline capture budget and coordination test
      apps/server/src/orchestration-v2/CheckpointService.ts, apps/server/src/orchestration-v2/CheckpointService.test.ts
      Baseline capture applies a five-second timeout to the snapshot operation. The test checks that baseline capture waits for an in-flight post-turn capture of the same reference and fails when the clock advances past the timeout.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related issues

      • Issue 17825: The timeout bounds fresh baseline capture, but does not bound waiting for the workspace lock.
      • Issue 26227: The timeout affects the baseline snapshot path, but temporary-directory cleanup and post-turn capture timeouts remain unaddressed.

      Possibly related PRs

      • pingdotgg/t3code#29196: Both PRs change when provider-turn startup waits on baseline capture; this PR adds a five-second snapshot budget, while PR 29196 skips capture after repeated timeouts.

      Suggested reviewers: navidnadali, t3dotgg, macroscopeapp

      Merge Risk: Minimal · up to d554e

      Slow workspaces no longer hold up the start of a provider turn for the full 30-second timeout. A fresh baseline snapshot is limited to 5 seconds, and the turn then starts without a baseline. No merge-blocking risk is identified.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title "fix(server): a slow baseline checkpoint no longer holds every prompt for 30 seconds" describes the main change. The PR moves a 5-second budget onto the fresh baseline snapshot in Checkpoint…
      Linked Issues checkPassed[#28996] The issue asks that slow or failing baseline capture not hold the provider turn for the full 30 s VCS timeout. The issue lists three acceptable approaches: a shorter budget before the turn st…
      Out of Scope Changes checkPassedThe reviewed diff against the merge base touches CheckpointService.ts (a 5 s timeout constant, the Effect.timeout call, and comments) and the regression tests in CheckpointService.test.ts. RunExecutio…
      Description checkPassedThe description follows the repository template closely. It has the Problem, Change, Scope, and Verification sections, and it links the issue (pingdotgg/t3code#28996). The Problem section explains the…
      Full details: Title check

      Explanation

      The title "fix(server): a slow baseline checkpoint no longer holds every prompt for 30 seconds" describes the main change. The PR moves a 5-second budget onto the fresh baseline snapshot in CheckpointService.captureBaseline so a slow baseline no longer stalls the provider turn for the full 30-second timeout. The title is specific and follows the conventional commit style the template recommends. It is slightly long at 83 characters, but it stays clear and accurate.

      Full details: Linked Issues check

      Explanation

      [#28996] The issue asks that slow or failing baseline capture not hold the provider turn for the full 30 s VCS timeout. The issue lists three acceptable approaches: a shorter budget before the turn starts, capture alongside the turn, or backoff after repeated timeouts. The PR uses the first. In apps/server/src/orchestration-v2/CheckpointService.ts, captureBaseline applies Effect.timeout(BASELINE_CAPTURE_BUDGET) with BASELINE_CAPTURE_BUDGET = "5 seconds" to checkpointStore.captureCheckpoint. The timeout sits after the per-cwd lock is taken and after hasCheckpointRef is checked. A timeout failure is mapped to CheckpointBaselineCaptureError. RunExecutionService.ts has no diff against the merge base, so its existing catch path starts the provider without a baseline. Limits: lock waits are not bounded. A baseline queued behind a long post-turn capture on the same cwd can still delay the turn. This is a known gap, and the PR description states it. Backoff, post-turn timeout, and steer refusal are not covered; the issue allows these to be addressed separately.

      Full details: Out of Scope Changes check

      Explanation

      The reviewed diff against the merge base touches CheckpointService.ts (a 5 s timeout constant, the Effect.timeout call, and comments) and the regression tests in CheckpointService.test.ts. RunExecutionService.ts has no diff, and the PR description says its test was restored to the main version. All code changes map to the baseline-capture budget objective in #28996. The changes do not add unrelated behavior. Post-turn capture timeout, backoff, and steer refusal are explicitly excluded from this PR and are not implemented here.

      Full details: Description check

      Explanation

      The description follows the repository template closely. It has the Problem, Change, Scope, and Verification sections, and it links the issue (pingdotgg/t3code#28996). The Problem section explains the lock-wait race, and the Change section explains why the budget moved into CheckpointService.captureBaseline and why RunExecutionService.ts was reverted. Scope gives the issue link as the reason the bug needs no separate issue. Verification lists focused tests, before/after reproduction evidence with timings, and states what was not checked (browser rendering, stop-then-turn during lock hold, steer refusal). The description does not include a conventional commit title, and the template's note about naming the agent model and harness is not clearly satisfied. Those are minor gaps. The description is detailed and specific, not vague.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 1a1f9ac18ed7cfa246207884aea93e3ce06851ce and d554ec9bee8aea5a229236bb9a9028804550a177.

      Files selected for processing: 2

      • apps/server/src/orchestration-v2/CheckpointService.test.ts
      • apps/server/src/orchestration-v2/CheckpointService.ts

      Limit details: You’ve used all 10 included reviews currently available.

    5. juliusmarminge merged thisc085a0a

    6. juliusmarminge closed this

Sign in to join this conversation.