Skip to content

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

Done

Description

@Mordydev

Version: v0.1.13 (macOS desktop). The same order is on main as of 2026-12-01.

What happens

In apps/server/src/orchestration-v2/CheckpointService.ts, captureScopeBaseline runs everything inside withWorkspaceLock(input.scope.cwd, ...) (v0.1.13 lines 477-482). Only after it holds the lock does it:

  • check the folder's timeout streak (timeouts.value >= 2, line 502);
  • apply BASELINE_CAPTURE_BUDGET (5 s, line 41), which wraps the capture alone (line 419).

So when a folder's end-of-turn captures keep hitting the 30 s VCS timeout, a turn starting in another thread of that folder waits up to ~30 s. It waits only to learn it should skip, or to spend 5 s more on a baseline.

#40411 stopped queued messages from waiting out every timed-out capture on the end-of-turn side. This is the turn-start side of the same lock.

Measured

One Mac, one 39-minute server trace, two busy folders whose captures time out:

  • ProviderTurnStartService.start: 45 turn starts, median 2.7 s, mean 10.4 s, worst 74.0 s. The baseline was 77% of the total.
  • 26 baselines ended in the "skipped after repeated capture timeouts" warning, and still took 225 s in total. Seven of them took 29.8-31.8 s.
  • One baseline took 57.8 s: about 53 s waiting for the lock, then 4.8 s of git.

Steps to reproduce

  1. Use a repository where git add -A takes more than 30 s, for example several GB of untracked, un-ignored media.
  2. Run two threads in the same folder.
  3. Let thread A's turn end, so its checkpoint capture runs and times out.
  4. Send a message to thread B while A's capture still holds the folder lock.

B's turn start waits until A's capture times out (~30 s) before it reaches the skip check or the 5 s budget.

Expected

A baseline that is going to be skipped should not wait for the lock. The 5 s budget should bound the whole baseline, lock wait included. On timeout the turn would start without a baseline, as the existing timeout fallback already does.

Possible fix

  • Read captureTimeouts (an in-memory cache) before withWorkspaceLock, and return early when the streak is 2 or more.
  • Apply BASELINE_CAPTURE_BUDGET around the withWorkspaceLock(...) call instead of around the capture alone.

Investigated with Claude Code (Claude Opus 5.5) from the installed v0.1.13 bundle, the v0.1.13 source and server traces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions