Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): narrow delegated recovery reads to delivery records #29435

MergedYash-Singh1(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/29435/headmerged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHub

Delegated-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:changed passed 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

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at d884754

      Macroscope'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 b162fb0. Prior analysis still applies.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      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.ts
      • apps/server/src/orchestration-v2/Orchestrator.ts
      • apps/server/src/orchestration-v2/ProjectionStore.test.ts
      • apps/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.ts
      ProjectionRecordFilter supports 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.ts
      Delivery offering and finalization load selected projection records. Recovery tests verify that message reads use message_id IN, avoid MIN(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 to b162f

      Recovery now reads targeted delivery records; no material merge risk has been identified.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title is concise, specific, and accurately describes the main change: narrowing delegated recovery reads to delivery records.
      Description checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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
    4. 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 main measurement shown below.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB+6 B (+0.1%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.3 KiB+6 B (+0.5%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.6 KiB21.6 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.3 KiB1.3 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: ac8dce0 · PR result: b162fb0 · 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: 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.

Sign in to join this conversation.