Skip to content

fix(server): shell reads no longer scan every runless item per failed thread - #14181

Merged
juliusmarminge merged 1 commit into
t3code/codex-turn-mappingfrom
v2/shell-blocking-failure-index
Sep 28, 2026
Merged

juliusmarminge merged 1 commit into
t3code/codex-turn-mappingfrom
v2/shell-blocking-failure-index

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

The V2 preview froze on startup for minutes at 100% CPU: the server never answered, so the app showed no providers. #13877 added a per-thread lookup of the failed run's error item to the thread shell query. When that run has no root node, SQLite matched items by `node_id IS NULL` through the node index. Imported history leaves tens of thousands of items with a null `node_id`, so the query walked all of them once for every failed thread. A real database (1,918 threads, 304k turn items) spent 91 of 92 profiled seconds inside this synchronous query.

Both failure lookups now use the thread and run index.

  • Timing: on a copy of real data with 1,900 failed threads and 67k runless items, the shell query went from 185 s to 76 ms, with identical rows.
  • Test: the new plan test in `ProjectionSettlement.test.ts` captures the real shell query and checks that both item lookups use `turn_items_thread_run_idx`. It fails without this change.
  • Checks: ProjectionStore, settlement, control-read and runtime-layer tests pass (89), and the server typecheck is clean.

🤖 Generated with Claude Code


Devin Review

… thread

The failure lookups in the thread shell query matched turn items by
node_id when the failed run had no root node. Imported history leaves
tens of thousands of items with a null node_id, so SQLite walked all of
them once per thread and blocked startup for minutes.

Pin both lookups to the thread and run index.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Sep 28, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at d7aac6c

Macroscope's review found this PR approvable — This is a narrowly scoped server bug fix that keeps shell failure results unchanged while constraining both lookups to the current thread and an existing index, preventing expensive scans of unrelated runless history. A targeted regression test verifies both query plans, and no defaults, schemas, capabilities, or sensitive areas are changed.

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

@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

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

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire — 4.9 KiB — 6.8 KiB ✅
Codex Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Codex Live turn WebSocket wire — 1.1 KiB — 2.0 KiB ✅
Codex Live turn WebSocket decoded — 20.4 KiB — 29.3 KiB ✅
Codex Live turn messages — 1 — 8 ✅
Claude Total thread wire — 4.9 KiB — 6.8 KiB ✅
Claude Thread snapshot wire — 3.7 KiB — 4.9 KiB ✅
Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Claude Live turn WebSocket decoded — 20.8 KiB — 29.3 KiB ✅
Claude Live turn messages — 2 — 8 ✅

Baseline: unavailable · PR result: d7aac6c · 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: 106.1 KiB
  • Claude decoded thread snapshot: 106.4 KiB

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

@juliusmarminge
juliusmarminge merged commit 977bf4a into t3code/codex-turn-mapping Sep 28, 2026
24 of 25 checks passed
@juliusmarminge
juliusmarminge deleted the v2/shell-blocking-failure-index branch September 28, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR 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