Skip to content

fix(server): turn starts skip a timing-out folder's baseline without waiting on its lock - #47138

Merged
juliusmarminge merged 1 commit into
mainfrom
factory/issue-47116
Dec 2, 2026
Merged

juliusmarminge merged 1 commit into
mainfrom
factory/issue-47116

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

When a folder's checkpoint captures had timed out repeatedly, a new turn in another thread of that folder still waited for that thread's post-turn capture to release the folder lock (up to its 30 s timeout), only to then skip its baseline. The turn start now checks the timeout streak before taking the lock, so it skips at once and starts the agent.

Fixes #47116

Reproduction on main

Commit aa6c98f (origin/main, 2026-12-01). Linux VM, real server from source: T3CODE_DEV_SEED=0 node apps/server/src/bin.ts serve --base-dir <scratch> --port 41987 --host 127.0.0.1 --dev-url http://127.0.0.1:41988 (the dev URL only registers the free Replay (dev) provider), fresh database. Repo: one committed README plus 40 x 100 MB untracked random files (4 GB). On a cold copy, git add -A took 72 s, well over the 30 s VCS timeout. t3 project add ., then thread A: t3 thread start --provider devReplay --model showcase --wait . "go A". Its baseline timed out at the 5 s budget and its post-turn capture timed out at 30 s, so the folder's timeout streak is 2. Each round: t3 thread send --wait <A> ...; 1 s after A's reply returns (A's post-turn capture now holds the folder lock), t3 thread start --provider devReplay --model showcase --wait . "go B" on a new thread B. Durations are from logs/server.trace.ndjson. Three rounds, CheckpointService.captureBaseline for new thread B: 28.03 s, 27.86 s, 27.65 s (median 27.86 s, spread 0.38 s). ProviderTurnStartService.start: 28.05 / 27.88 / 27.67 s. Each of B's baselines ended at the same moment A's 30 s withCaptureLock span ended, then logged 'orchestration V2 checkpoint baseline skipped after repeated capture timeouts'. So all of B's wait was spent on the lock, only to skip. Comparison in the same folder and the same rounds: A's own turn-start baseline, with no capture holding the lock, took 0.013 / 0.018 / 0.023 s and gave the same skip. End to end, B's thread start --wait took about 34 s, against about 6 s for A's turns.

Evidence

On each commit, start the real source server on Linux with T3CODE_DEV_SEED=0, a fresh --base-dir, loopback host, and --dev-url to register Replay (dev). Seed one committed README and 40 x 100 MB untracked random files (identical SHA-256 on both sides). Wait 20 s for Replay model discovery; t3 project add the repo; start A with devReplay/showcase --wait. Wait 34 s for its post-turn capture timeout, making the timeout streak 2. Three rounds: send A --wait; 1 s after its reply, start fresh B with devReplay/showcase --wait; wait 65 s before the next round. Measure CLI wall time and CheckpointService.captureBaseline / ProviderTurnStartService.start server spans. Both commits logged six repeated-timeout baseline skips; all six B threads completed with byte-identical replies.

Same Linux x86_64 VM, sequential runs, fresh databases, same driver and file bytes. Three rounds per commit; spread means max minus min. This is server/CLI performance evidence; the scenario runner explicitly excludes timing regressions.

Before After
63f7006a05 74033789b6
Before: real server timing measurements After: real server timing measurements
B baseline: 27.566 s median, 0.117 s spread B baseline: 0.024 s median, 0.015 s spread
Provider turn start: 27.689 s median Provider turn start: 0.140 s median
CLI start --wait: 34.209 s median, 0.813 s spread CLI start --wait: 6.383 s median, 0.224 s spread
Timestamped CLI playback · Terminal recording · Measurement output and selected trace spans Timestamped CLI playback · Terminal recording · Measurement output and selected trace spans

Driver / seed script · Capture renderer and span extraction script

The videos render the actual timestamped driver output at real-time speed. Every B baseline began during another capture on both commits. The baseline median improves by 27.542 s, exceeding both spreads; all B threads still skip the baseline and complete with the identical recorded showcase reply.

Tests

  • vp test run src/orchestration-v2/CheckpointService.test.ts (apps/server): 10 passed. With the fix stashed, the extended shared-folder test hangs on the lock until the test times out.
  • vp run typecheck (apps/server): exit 0, no errors
  • vp run check:changed: format, lint, knip, graphql, typecheck and tests all pass
  • Real-server measurement with three rounds each, the way triage did it: new thread B's CheckpointService.captureBaseline took 27.64 / 28.34 / 27.83 s on main and 11.2 / 18.4 / 8.7 ms with the fix
  • CI on 7403378: all check runs success or skipped

Not in this change

  • A baseline with a ref to copy (sourceOrdinalWithinScope set) still waits for the folder lock before copying and before seeing the streak; bounding that wait would change the ordering fix(server): a slow baseline checkpoint no longer holds every prompt for 30 seconds #34849 chose.
  • A turn start in a folder whose streak is still below 2 still waits for another thread's in-flight capture to release the lock, up to its 30 s timeout; the 5 s budget covers only the capture itself, not the lock wait.
  • t3 thread start can race provider registration right after the server starts ("Model showcase is not advertised by provider devReplay"); the CLI does not wait for providers to finish registering.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

…waiting on its lock

Once a folder's checkpoint captures had timed out repeatedly, a new turn in
another thread still queued behind that thread's post-turn capture (up to its
30 s timeout) only to learn it should skip its baseline. Check the timeout
streak before taking the folder lock when there is no earlier ref to copy; the
check inside the lock stays for streaks that grow while waiting.

Fixes #47116

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Dec 2, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 7403378

Macroscope's review found this PR approvable — Turn starts can skip an already timeout-prone folder’s baseline without waiting for its lock. The existing timeout threshold, checkpoint-copy path, and recovery probes remain unchanged.

You can add or adjust custom eligibility rules. Learn more.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.5 KiB 92.5 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 78.3 KiB 78.3 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 75 75 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 79.2 KiB 79.2 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 75 75 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 946d88b · PR result: 7403378 · 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.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The baseline path now checks for repeated capture timeouts before acquiring the workspace lock when no source ordinal is supplied. With a source ordinal, it retains the locked, copy-first flow. The test verifies that a new thread skips without increasing the capture attempt count.

Changes: Baseline timeout handling

Layer / File(s) Summary
Timeout skip and baseline flow
apps/server/src/orchestration-v2/CheckpointService.ts, apps/server/src/orchestration-v2/CheckpointService.test.ts
A helper skips baselines when at least two capture timeouts are recorded. The wrapper checks before locking when no source ordinal is supplied. With a source ordinal, the locked flow checks after the source-ref copy attempt. The test verifies that a new thread does not start another capture attempt after repeated timeouts.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: mauricecrrr, macroscopeapp

Merge Risk: Minimal · up to 74033

This change lets a new turn skip a baseline immediately when the folder has repeated capture timeouts, instead of waiting for the folder lock. It is a narrow, low-risk change, and no merge-blocking issue remains. Lock waits are still unbounded for baselines with a ref to copy, as the PR notes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and its scope: a turn start skips a timing-out folder's baseline without waiting on the folder lock. The raw summary confirms the change adds an early timeout-streak check befo…
Linked Issues check Passed [#47116] The issue asks that a turn-start baseline which will be skipped (folder timeout streak >= 2) not wait for the folder lock. At head, captureScopeBaseline (CheckpointService.ts) calls `skipBa…
Out of Scope Changes check Passed All changes serve the #47116 objective. The CheckpointService.ts diff extracts the existing timeout-streak check into skipBaselineAfterRepeatedTimeouts, reuses it inside the locked flow, and adds an…
Description check Passed The description follows the repository template closely. It has a clear Problem section (repeated capture timeouts make a new turn wait up to 30 s for the folder lock before skipping its baseline), a …
Full details: Title check

Explanation

The title names the fix and its scope: a turn start skips a timing-out folder's baseline without waiting on the folder lock. The raw summary confirms the change adds an early timeout-streak check before the lock for baselines with no source ordinal. The title is specific, follows the conventional commit form, and matches the main change.

Full details: Linked Issues check

Explanation

[#47116] The issue asks that a turn-start baseline which will be skipped (folder timeout streak >= 2) not wait for the folder lock. At head, captureScopeBaseline (CheckpointService.ts) calls skipBaselineAfterRepeatedTimeouts before captureScopeBaselineLocked when sourceOrdinalWithinScope is undefined. The helper reads captureTimeouts from the in-memory cache and returns true when the streak is 2 or more, so the baseline returns without withWorkspaceLock. The lock-path check is kept, so a streak that grows during the wait still skips. The new test in CheckpointService.test.ts runs captureBaseline for a new thread while a capture holds the lock, asserts the baseline completes, and asserts the attempt count stays at 3. Two cases remain on the lock path: baselines with a ref to copy, which may copy instead of skip, and streaks below 2, which are not skip-eligible. The issue's second option (applying the 5 s budget around lock acquisition) is not implemented; the issue presents it as an alternative to the cache check. The PR description states these limits.

Full details: Out of Scope Changes check

Explanation

All changes serve the #47116 objective. The CheckpointService.ts diff extracts the existing timeout-streak check into skipBaselineAfterRepeatedTimeouts, reuses it inside the locked flow, and adds an unlocked pre-check in the captureScopeBaseline wrapper. The test diff adds a regression assertion for the early skip. No unrelated files are changed in the reviewed diff. The extraction is a small refactor that supports the reuse, not a separate behavior change.

Full details: Description check

Explanation

The description follows the repository template closely. It has a clear Problem section (repeated capture timeouts make a new turn wait up to 30 s for the folder lock before skipping its baseline), a Change section (the turn start checks the timeout streak before taking the lock), a Scope section linking issue #47116, and a detailed Verification section with reproduction steps, before/after measurements, and test results. It also names the tools and models used, as the template requests. The title is not in the description block, so the conventional-commit title cannot be checked here. The Scope section does not explain why the change is a bug fix rather than a feature, but the linked issue describes a bug, so this is a minor gap. The description is thorough, though long, and the template asks for focused verification.

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 f96d66d and 7403378.

Files selected for processing: 2

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

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@juliusmarminge
juliusmarminge merged commit 5cac91c into main Dec 2, 2026
39 checks passed
@juliusmarminge
juliusmarminge deleted the factory/issue-47116 branch December 2, 2026 01:22
imetn added a commit to imetn/t4code that referenced this pull request Dec 2, 2026
…ce-control & server fixes)

Ported 15 commits from 772e3d4..1e6e7d7:
- ff548ac (pingdotgg#46552), 4025a2f (pingdotgg#46733), abf106f (pingdotgg#46759), c4f3661 (pingdotgg#46960), 5cac91c (pingdotgg#47138)
- 7cf7446 (pingdotgg#46736 mobile Usage filter env 'all', Lock pingdotgg#5 icons preserved)
- 0a5e0e3 (pingdotgg#46848 Android saved route priority)
- b6ac305 (pingdotgg#47096 mobile Git branch grapheme/flag cuts)
- 946d88b (pingdotgg#47098 mobile SVG pixel dimensions)
- c3faadd (pingdotgg#45111 mobile confirm stop once per run)
- a32c694 (pingdotgg#43968 PR Author menu replaces typed author qualifier)
- 6baa47d (pingdotgg#46934 preserve repeated JSON keys in tool output)
- aef9eb9 (pingdotgg#46497 Forgejo PR org labels)
- c57dd42 (pingdotgg#47143 Forgejo issue detail newest comments)
- a7256d6 (pingdotgg#46622 GitLab multiline issue titles)
(Note: pingdotgg#46702 8184b93 already functionally present via useOpenOrReturnToThread.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Turn-start checkpoint baseline waits for the folder lock before checking its repeated-timeout skip

1 participant