GeezerVison is showing github.com — perf(server): index unfinished work during startup recovery by spencermorris04 · Pull Request #20302 · pingdotgg/t3code
Conversation
Problem
Startup recovery looks for unfinished items across all item types, while the older partial index covers only selected types. Large finished histories are walked repeatedly. The run-candidate UNION also prevents the existing recovery index from matching its full predicate.
Change
Add a partial index on thread_id for pending/running/waiting turn items. Consolidate run candidates into the existing index predicate while preserving held-queue exclusion. Keep the query on its current connection; routing it to the reader worker is deliberately outside this fix.
Scope and approval
This is a focused query/index correction with unchanged selection semantics. Migration 63 is new and unreleased: renumber it against main before merge if another migration lands first. The Activity PR also independently adds migration 63.
Verification
Run vp test run apps/server/src/orchestration-v2/ProjectionStore.test.ts -t "without walking finished turn items|without scanning historical runs". Two regressions inspect plans from the actual recovery reads and verify their results. Both fail without the query/index fixes and pass after. An earlier copied-history measurement showed provider-query VM instructions dropping from 237k to 59k across three threads with identical results, approximately 4x less VM work. It omitted bulky payloads and is not an end-to-end launch speed claim. The live first index build previously took 106.616 seconds; migration cost must be considered separately from later launches.
The requester stopped the remaining heavy checks. Completed focused results are recorded in the attached log; no repo-wide check was run.
Reproduction and focused verification log · Earlier query measurement and limitations
Prepared with GPT-6.1-Sol through the Codex harness.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Approvability
Verdict: Approved at f8b290d
Macroscope's review found this PR approvable — This is a narrowly scoped startup-recovery performance optimization that adds a backward-compatible partial index and verifies query-plan usage. Existing recovery selection semantics remain intact, with no product-default, API, security, or deployment behavior changes.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7d4fce69-1ea5-442b-9acd-b67dfbbd8348
📥 Commits
-
Reviewing files that changed from the base of the PR and between cfafb4b and f8b290d.
📒 Files selected for processing: 4
-
apps/server/src/orchestration-v2/ProjectionStore.test.ts
apps/server/src/orchestration-v2/ProjectionStore.ts
apps/server/src/persistence/Migrations.ts
apps/server/src/persistence/Migrations/063_RuntimeRecoveryItemIndex.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
-
Runtime recovery now selects queued and active runs in one query, with held queued runs excluded when their payload is valid. Migration 63 adds an index for live turn items by thread ID. Tests check both recovery query plans.
Changes: Runtime recovery
| Layer / File(s) |
Summary |
Live turn-item index apps/server/src/persistence/Migrations/063_RuntimeRecoveryItemIndex.ts, apps/server/src/persistence/Migrations.ts, apps/server/src/orchestration-v2/ProjectionStore.test.ts |
Migration 63 creates and registers an index on thread_id for pending, running, and waiting turn items. A test checks that provider-thread recovery lookups use the index. |
Recovery candidate query apps/server/src/orchestration-v2/ProjectionStore.ts, apps/server/src/orchestration-v2/ProjectionStore.test.ts |
The query combines queued and active run statuses. It excludes queued runs when valid JSON has queueHeld set to 1; invalid JSON remains eligible. A test checks that run scans use runs_recovery_idx. |
Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix
Suggested reviewers: maria-rcks
Merge Risk: ⚪ Minimal · up to f8b29
-
No actionable issue was established in the recovery query, index, or regression tests. The PR is mergeable after normal checks.
Security architecture risk: 🔵 Low · up to f8b29
-
The query rewrite preserves recovery eligibility, including held-queue handling, without expanding access or execution authority. The remaining uncertainty concerns the first index build and migration-number coordination, not an identified security vulnerability.
Retained concerns
No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- inferred — The direct operational scope is the configured server SQLite database and its recovery workload. The index build affects that database during initialization; the selection rewrite does not itself expand recovery to another database, service or environment.
Trust Boundaries and Controls
- inferred — Persisted queueHeld data influences run eligibility through the same guarded JSON expression before and after this PR. The comparison does not establish a new path for overriding held-queue handling or gaining recovery authority, and the test-local detail property provides no external ingress.
Resilience and Maintainability Implications
- inferred — Recovery initiation, projection loading, shutdown preparation and downstream reconciliation remain unchanged. Candidate-set equivalence gives no identified PR-induced change to repetition, interruption or concurrent-update behavior. This does not establish end-to-end atomicity: selection and projection loading remain separate operations as before.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title is concise, uses the conventional commit format, and clearly describes the primary change: adding an index to improve startup recovery performance. |
| Description check |
 |
The description includes all required sections. It clearly explains the problem, change, scope, migration concern, focused verification, observed results, limitations, and incomplete checks. |
| 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. |
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Note Written by claude-opus-5-5 on behalf of Maria
Thanks for this. I'm closing it as part of PR triage. Right now we're only taking focused bug fixes from outside contributors (see Read this first), and this PR is not one.
From the review: The recovery query rewrite and unfinished-item index lack a measured startup improvement through the application. Please establish that benefit and agree on the performance work before proceeding.
If you think this was a mistake, message me on Twitter at @maria_rcks and I'll take another look.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:S
10-29 changed lines (additions + deletions).
vouch:unvouched
Author is not yet trusted in the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|