BEFORE — 0775dc450fcf4a6f85cc7db955f3c5b5f7d4f42a Linux x86_64; Node 26.13.1; same machine and local filesystem; cold OS file cache before each service call Actual ProjectionStore.getThreadRecords providerThreads-only read used before provider-session detach/release, not message.dispatch Fresh server-migrated synthetic database: 5,523 completed acknowledged tasks; 3,768 completed thread runs; 80,000 shuffled other runs, 3 KB payloads; ANALYZE. Database bytes: 390569984 Production service cold reads (milliseconds): 1: 553.132 2: 592.830 3: 575.686 4: 551.631 5: 533.957 6: 533.138 7: 745.105 8: 612.643 9: 531.305 Median: 553.132 ms Range width: 213.801 ms All nine results identical: True Same records across commits: True Returned records: [ { "id": "pt:0", "driver": "codex", "providerInstanceId": "codex", "providerSessionId": "session:shared", "appThreadId": "thread:child:0", "ownerNodeId": null, "nativeThreadRef": null, "nativeConversationHeadRef": null, "status": "idle", "firstRunOrdinal": null, "lastRunOrdinal": null, "handoffIds": [], "forkedFrom": null, "pendingBackgroundTasks": [], "contextUsage": null, "nativeMetadata": null, "goal": null, "createdAt": "2026-01-01T00:00:00.000Z", "updatedAt": "2026-01-01T00:00:00.000Z" } ] EXPLAIN QUERY PLAN (system SQLite): [3, 0, 0, 'SCAN orchestration_v2_projection_provider_threads'] [10, 0, 0, 'LIST SUBQUERY 1'] [14, 10, 0, 'SEARCH owned USING COVERING INDEX orchestration_v2_projection_provider_threads_owner_idx (owner_node_id>?)'] [18, 10, 0, 'SEARCH owner USING INDEX sqlite_autoindex_orchestration_v2_projection_nodes_1 (node_id=?)'] [41, 0, 0, 'LIST SUBQUERY 4'] [43, 41, 0, 'SEARCH orchestration_v2_projection_subagents USING INTEGER PRIMARY KEY (rowid=?)'] [47, 41, 0, 'LIST SUBQUERY 3'] [49, 47, 0, 'SEARCH candidate USING COVERING INDEX orchestration_v2_projection_subagents_settled_idx (thread_id=?)'] [112, 47, 0, 'CORRELATED SCALAR SUBQUERY 2'] [117, 112, 0, 'SEARCH run USING INDEX sqlite_autoindex_orchestration_v2_projection_runs_1 (run_id=?)'] [176, 0, 0, 'LIST SUBQUERY 5'] [178, 176, 0, 'SCAN orchestration_v2_projection_provider_session_bindings'] [193, 0, 0, 'CORRELATED SCALAR SUBQUERY 6'] [198, 193, 0, 'SEARCH owner USING INDEX orchestration_v2_projection_subagents_provider_thread_idx (provider_thread_id=?)'] [219, 0, 0, 'USE TEMP B-TREE FOR ORDER BY'] Cold sqlite3 -readonly replay of the captured production statement (3 runs): {"id": "pt:0", "appThreadId": "thread:child:0", "driver": "codex", "providerInstanceId": "codex", "providerSessionId": "session:shared", "ownerNodeId": null, "nativeThreadRef": null, "nativeConversationHeadRef": null, "lastRunOrdinal": null, "handoffIds": [], "forkedFrom": null, "status": "idle", "firstRunOrdinal": null, "createdAt": "2026-01-01T00:00:00.000Z", "updatedAt": "2026-01-01T00:00:00.000Z"} Memory Used: 2360312 (max 3056136) bytes Number of Outstanding Allocations: 2772 (max 2831) Number of Pcache Overflow Bytes: 2022120 (max 2079520) bytes Largest Allocation: 87360 bytes Largest Pcache Allocation: 4368 bytes Lookaside Slots Used: 51 (max 123) Successful lookaside attempts: 194 Lookaside failures due to size: 5 Lookaside failures due to OOM: 446 Pager Heap Usage: 2102776 bytes Page cache hits: 28395 Page cache misses: 5552 Page cache writes: 0 Page cache spills: 0 Schema Heap Usage: 172728 bytes Statement Heap/Lookaside Usage: 18064 bytes Fullscan Steps: 5522 Sort Operations: 1 Autoindex Inserts: 0 Virtual Machine Steps: 325966 Reprepare operations: 0 Number of times run: 1 Memory used by prepared stmt: 18064 Bytes received by read(): 22754705 Bytes sent to write(): 8 Read() system calls: 5571 Write() system calls: 8 Bytes read from storage: 20340736 Bytes written to storage: 32768 Cancelled write bytes: 0 Run Time: real 0.540 user 0.010233 sys 0.044903 {"id": "pt:0", "appThreadId": "thread:child:0", "driver": "codex", "providerInstanceId": "codex", "providerSessionId": "session:shared", "ownerNodeId": null, "nativeThreadRef": null, "nativeConversationHeadRef": null, "lastRunOrdinal": null, "handoffIds": [], "forkedFrom": null, "status": "idle", "firstRunOrdinal": null, "createdAt": "2026-01-01T00:00:00.000Z", "updatedAt": "2026-01-01T00:00:00.000Z"} Memory Used: 2360312 (max 3056136) bytes Number of Outstanding Allocations: 2772 (max 2831) Number of Pcache Overflow Bytes: 2022120 (max 2079520) bytes Largest Allocation: 87360 bytes Largest Pcache Allocation: 4368 bytes Lookaside Slots Used: 51 (max 123) Successful lookaside attempts: 194 Lookaside failures due to size: 5 Lookaside failures due to OOM: 446 Pager Heap Usage: 2102776 bytes Page cache hits: 28395 Page cache misses: 5552 Page cache writes: 0 Page cache spills: 0 Schema Heap Usage: 172728 bytes Statement Heap/Lookaside Usage: 18064 bytes Fullscan Steps: 5522 Sort Operations: 1 Autoindex Inserts: 0 Virtual Machine Steps: 325966 Reprepare operations: 0 Number of times run: 1 Memory used by prepared stmt: 18064 Bytes received by read(): 22754705 Bytes sent to write(): 8 Read() system calls: 5571 Write() system calls: 8 Bytes read from storage: 20324352 Bytes written to storage: 28672 Cancelled write bytes: 28672 Run Time: real 0.560 user 0.008002 sys 0.047717 {"id": "pt:0", "appThreadId": "thread:child:0", "driver": "codex", "providerInstanceId": "codex", "providerSessionId": "session:shared", "ownerNodeId": null, "nativeThreadRef": null, "nativeConversationHeadRef": null, "lastRunOrdinal": null, "handoffIds": [], "forkedFrom": null, "status": "idle", "firstRunOrdinal": null, "createdAt": "2026-01-01T00:00:00.000Z", "updatedAt": "2026-01-01T00:00:00.000Z"} Memory Used: 2360312 (max 3056136) bytes Number of Outstanding Allocations: 2772 (max 2831) Number of Pcache Overflow Bytes: 2022120 (max 2079520) bytes Largest Allocation: 87360 bytes Largest Pcache Allocation: 4368 bytes Lookaside Slots Used: 51 (max 123) Successful lookaside attempts: 194 Lookaside failures due to size: 5 Lookaside failures due to OOM: 446 Pager Heap Usage: 2102776 bytes Page cache hits: 28395 Page cache misses: 5552 Page cache writes: 0 Page cache spills: 0 Schema Heap Usage: 172728 bytes Statement Heap/Lookaside Usage: 18064 bytes Fullscan Steps: 5522 Sort Operations: 1 Autoindex Inserts: 0 Virtual Machine Steps: 325966 Reprepare operations: 0 Number of times run: 1 Memory used by prepared stmt: 18064 Bytes received by read(): 22754705 Bytes sent to write(): 8 Read() system calls: 5571 Write() system calls: 8 Bytes read from storage: 20324352 Bytes written to storage: 28672 Cancelled write bytes: 28672 Run Time: real 0.532 user 0.016237 sys 0.033357