Skip to content

test(server): replay scenarios no longer run checkpoints against the real checkout - #41192

Open
juliusmarminge wants to merge 1 commit into
mainfrom
fix/claude-todo-list-flake
Open

juliusmarminge wants to merge 1 commit into
mainfrom
fix/claude-todo-list-flake

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

ClaudeAdapterV2 background wake turns > persists a todo_list from inline Claude task-tool frames failed intermittently. The run stayed waiting until the scenario's 60s idle wait gave up.

Cause. A replay scenario whose thread has no worktree got cwd: null from the stub RuntimePolicy.layer, so the Orchestrator fell back to process.cwd(). The post-turn checkpoint capture then ran git against the checkout running the tests. On a machine where that repository has many refs and worktrees (29k refs and 597 worktrees here), one git log --walk-reflogs --all --max-age=… from listImportedCommits takes about 45s. A capture runs several of these, so the run did not reach completed within the 60s idle wait. The test also wrote checkpoint refs into the developer's repository on every run. It was not an adapter bug.

Fix. layerWithRegistry now gives each scenario a temporary git repository (checkpointWorkspace, removed when the scenario scope closes) as the default workspace. Threads that set their own worktreePath and scenarios with an explicit runtimePolicyOverride.cwd keep their workspace. The stub RuntimePolicy.layer had no other users, so it is deleted.

No replay test needed the real tree, so there is no opt-in. All 46 test files that use the replay harness pass: 1,557 tests.

Proof (vp test run src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts -t "persists a todo_list"):

  • Before (main): 2 of 8 serial runs failed, and 2 of 6 runs failed with two copies running at once.
  • After: 20 of 20 serial runs passed, and 20 of 20 passed across 10 rounds of two concurrent copies. The test went from about 60s to about 7s.

The reflog walk's cost in large repositories is a separate product performance issue, handled outside this PR.

Model: Claude Opus 5.5, harness: Claude Code (in T3 Code).

🤖 Generated with Claude Code

…real checkout

A replay scenario whose thread had no worktree fell back to process.cwd(),
so checkpoint capture ran git against the checkout running the tests. In a
repository with many refs and worktrees, one `git log --walk-reflogs --all`
there takes ~45s, so turns stayed `waiting` past the scenario's 60s wait and
tests such as "persists a todo_list from inline Claude task-tool frames"
failed intermittently. It also wrote checkpoint refs into that repository.

The replay harness now gives each scenario a temporary git repository as the
default workspace, removed when the scenario's scope closes. Threads with their
own worktreePath and scenarios with an explicit cwd override keep theirs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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 Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

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.4 KiB 92.4 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 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 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 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 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: 8634955 · PR result: 29a3a8e · Source CI: failure

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 Nov 23, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The default RuntimePolicyV2 layer was removed. The replay harness now creates a scenario-specific checkpoint workspace and uses it when a thread has no worktree path. A supplied runtime policy override is layered over the harness policy.

Changes: Runtime policy and replay harness

Layer / File(s) Summary
Scenario runtime policy
apps/server/src/orchestration-v2/RuntimePolicy.ts, apps/server/src/orchestration-v2/testkit/ProviderReplayHarness.ts
The default RuntimePolicyV2 layer was removed. The replay harness creates a scoped checkpoint workspace from the sanitized scenario name and uses it when a thread has no worktreePath. If runtimePolicyOverride is supplied, the harness layers it over the scenario policy.

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

Change: Other

Suggested reviewers: macroscopeapp, voltcrash

Merge Risk: Minimal · up to 29a3a

This change isolates replay-harness checkpoint capture from the developer's checkout, which is a test-infrastructure improvement with a narrow blast radius. One CI server test shard failed on an assertion that does not appear related to this change, so confirm it is a flake or rerun before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: replay scenarios now use an isolated checkpoint repository instead of the real checkout. It follows the conventional commit format and matches the raw summary and PR o…
Description check Passed The description covers the required template sections. Problem is described with cause, reproduction context, and the flaky test symptom. Change explains the per-scenario temporary git repository and …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: replay scenarios now use an isolated checkpoint repository instead of the real checkout. It follows the conventional commit format and matches the raw summary and PR objectives, which both describe the default temporary repository for checkpoint capture.

Full details: Description check

Explanation

The description covers the required template sections. Problem is described with cause, reproduction context, and the flaky test symptom. Change explains the per-scenario temporary git repository and the deleted stub layer. Scope explains the bug fix with no feature and the test that was affected. Verification lists focused test runs with before and after results plus the 46-file pass count. It names the model and harness as the template asks. Issue links are not present, but the Scope section does not link an issue or say why none is needed, which is a small gap.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • 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 8634955 and 29a3a8e.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/RuntimePolicy.ts
  • apps/server/src/orchestration-v2/testkit/ProviderReplayHarness.ts
Files with no reviewable changes: 1

  • apps/server/src/orchestration-v2/RuntimePolicy.ts

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

This branch has not been deployed

No deployments
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.

1 participant