perf(server): narrow delegated recovery reads to delivery records #29435
main fromrefs/pull/29435/head·merged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHubDelegated-task startup recovery loaded an entire thread's provider threads, user messages, and runs to recover a few pending result deliveries. The production trace included a 684 ms broad read inside the 1.55 s delegated-recovery phase.
Select the current delivery's message, parent and delivery runs, provider thread, active-attempt turns, and task cohort by identity. Keep ownership checks, mailbox-steer recovery, delivery generations, and startup ordering unchanged. Candidate discovery and child-result recovery remain unchanged.
Validation:
- Both new regressions fail on the baseline and pass with the patch. They cover identity selection and recovery without historical message ordering.
vp run check:changedpassed on the branch after merging current main, including format, lint, knip, GraphQL validation, affected typechecks, and 99 tests across five files.- Native Electron 44.10.0 / SQLite 3.53.4 synthetic operation benchmarks with 10,000 historical records reduced median delegated recovery from 192.2 ms to 53.7 ms. Shared ownership reduced it from 226.1 ms to 51.8 ms. These are warm operation measurements, not full production-startup measurements.
Model: GPT 6.1 Sol. Harness: Codex through T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Yash-Singh1(GitHub profile, opens in a new tab) changed the title
Approvability#
Verdict: Approved at
d884754Macroscope's review found this PR approvable — Delegated-completion recovery now reads only the records relevant to each delivery rather than loading broader thread history. The change retains existing delivery safeguards and introduces no product-default, permission or data-lifecycle changes.
No code changes detected at
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).b162fb0. Prior analysis still applies.No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: t3/reduce-delegated-recovery-startup-cost
- File: .coderabbit.config.ts
- Commit: b162fb0
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
99a02819-66f0-49a1-869b-7c079faf9517
Commits-
Reviewing files that changed from the base of the PR and between edc37c96c810d42761ab510c6a3e9d0a741547dc and b162fb099abc80413c3c543c7a9d903df81387af.
Files selected for processing: 4-
apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.tsapps/server/src/orchestration-v2/Orchestrator.tsapps/server/src/orchestration-v2/ProjectionStore.test.tsapps/server/src/orchestration-v2/ProjectionStore.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.
-
Walkthrough
-
Projection reads now support provider-thread ID and provider-turn attempt filters. Delegated completion delivery uses targeted projection reads for offering and finalization. Tests cover filtered reads and recovery query behavior.
Changes: Projection reads and delegated completion delivery
Layer / File(s) Summary Provider projection filters
apps/server/src/orchestration-v2/ProjectionStore.ts,apps/server/src/orchestration-v2/ProjectionStore.test.tsProjectionRecordFiltersupports provider-thread ID and provider-turn attempt ID filters. Reads return matching records, return none for empty selections, and can read a selected thread when an unselected thread payload is unreadable.Targeted delivery reads and recovery coverage
apps/server/src/orchestration-v2/Orchestrator.ts,apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.tsDelivery offering and finalization load selected projection records. Recovery tests verify that message reads use message_id IN, avoidMIN(ordinal), and emit a continuation request for the parent run.Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Suggested reviewers:
juliusmarminge,t3dotgg
Merge Risk:
Minimal · up tob162f-
Recovery now reads targeted delivery records; no material merge risk has been identified.
Pre-merge checks:
4-
Check name Status Explanation Title check The title is concise, specific, and accurately describes the main change: narrowing delegated recovery reads to delivery records. Description check The description clearly explains the performance problem, the implementation scope, preserved behavior, regression coverage, checks, and benchmark results. It does not use the template headings and do… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Description check
-
Explanation
The description clearly explains the performance problem, the implementation scope, preserved behavior, regression coverage, checks, and benchmark results. It does not use the template headings and does not provide explicit scope or approval details, but it is otherwise mostly complete and directly related to the change.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
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
mainmeasurement shown below.Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB +6 B (+0.1%) 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.3 KiB +6 B (+0.5%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.6 KiB 21.6 KiB 0 B (0.0%) 24.4 KiB ✅ Codex Live turn messages 2 2 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.3 KiB 1.3 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 2 2 0 (0.0%) 8 ✅ Baseline:
ac8dce0· PR result:b162fb0· Source CI: successScenario 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.
Yash-Singh1(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes