fix(server): stop maintaining the unused event correlation index#23171
Problem
Every event insert maintains an unused correlation-ID index. On main, starting the real dev server and inspecting its isolated database with dbstat confirms the index remains; a larger read-only database has 2,211,840 bytes in it for 73,876 events. No server query filters or orders by that column. See #20534.
Change
Add migration 68 to drop only idx_orch_events_correlation_id. Preserve the correlation column, its values, and all other event indexes, including the agent-stream index required by legacy import. Add one upgrade regression test and update the existing migration-list expectations.
Scope and approval
Fixes #20534 GitCafe: https://git.cafe/pingdotgg/t3code/issues/20534 Triaged bug via the automated issue flow. This focused server performance fix removes an unused index without changing product behavior, contracts, or client code.
Verification
- Red: on main plus the regression test,
vp test run src/persistence/Migrations.test.tsfailed on the assertion that the unused index must be absent (1 failed, 7 passed). - Green: 33 focused tests passed across
Migrations.test.ts,reconcileV2PreviewMigration.test.ts,OrchestrationEventStore.test.ts,OrchestrationEventStore.sequence.test.ts,initializeV2Database.test.ts,orchestration-v2/legacy/LegacyV1ThreadImporter.test.ts, andorchestration-v2/legacy/LegacyV1Cutover.integration.test.ts. The upgrade test checks that correlation values and required indexes survive. - After merging current main with a merge commit, reran the same seven files: 33 passed at 4faeac5142.
- Targeted lint and the server package typecheck passed. No repo-wide checks.
- Runtime:
vp run dev --home-dir /tmp/issue20534-canonicalupgraded a canonical database from migration 67 to 68. The paired real web client loaded and created a thread. The index went from present (4,096 bytes on the empty fixture) to absent; four real events retained correlation values and all other event indexes remained. Runtime transcript. - Audited evidence index. Visual matrix: empty; no render paths changed. Server-only proof is the regression test plus runtime transcript. No native-client behavior was changed.
- The populated reproduction snapshot has local-fork migration records, so the upstream runtime upgrade used a separate canonical fixture. A large populated canonical database was not timed. Schema-copy insert timings were noisy; no percentage speedup is claimed. Dropping the index frees database pages for reuse, rather than shrinking the file automatically.
Implemented with Claude Opus 5.5 through the Claude Code harness; triaged and reviewed with GPT-6.1-Sol through the Codex harness and Claude Opus 5.5 through Claude Code.
Checks
- SuccessfulCodeRabbitGitHub
Review completed
- SuccessfulNative fingerprint diffGitHub
- SkippedEAS PreviewGitHub
- SkippedRemove preview downloadGitHub
- Skipped
- Skipped
- Skipped
- SkippedDeploy web previewGitHub
- SkippedBuild preview JS bundleGitHub
- SkippedEAS PreviewGitHub
- SkippedEAS PreviewGitHub
- Skipped
- Skipped
- Skipped
- SkippedRemove preview downloadGitHub
- SkippedBuild preview JS bundleGitHub
- SkippedDeploy web previewGitHub
- SkippedDeploy web previewGitHub
- SkippedBuild preview JS bundleGitHub
- SkippedDeploy web previewGitHub
- SkippedBuild preview JS bundleGitHub
- SkippedEAS PreviewGitHub
- SuccessfulCheckGitHub
- SkippedRustGitHub
- SkippedRelease SmokeGitHub
- SkippedTest WebGitHub
- Skipped
- SuccessfulTestGitHub
- SuccessfulBuild and TypecheckGitHub
- SuccessfulLabel PR 23211GitHub
- Skipped
- SuccessfulLabel PR sizeGitHub
- Skipped
- Successful
- SuccessfulPrepare PR size configGitHub
- SkippedEAS PreviewGitHub
- SuccessfulTest Server 7GitHub
- SuccessfulCollect PR targetsGitHub
- SuccessfulTest Server 4GitHub
- SuccessfulLintGitHub
- SuccessfulTest Server 3GitHub
- SuccessfulTest Server 6GitHub
- SuccessfulTest Server 2GitHub
- SuccessfulTest Server 5GitHub
- SuccessfulTest Server 1GitHub
- SuccessfulTest Server 8GitHub
- SuccessfulChangesGitHub
- Successful
- SuccessfulNative fingerprint diffGitHub
Added 3 commits
Approvability
Verdict: Approved at 4faeac5
Macroscope's review found this PR approvable — This focused server migration removes an unused SQLite index while preserving the correlation column, stored values, and other indexes. The accompanying tests verify the migration history and schema invariants, with no product-default or user-facing behavior changes.
You can add or adjust custom eligibility rules. Learn more.
Thread transfer impact
✅ Thread transfer remains within every enforced ceiling.
| Provider | Metric | Main baseline | This PR | Impact | PR ceiling | |
|---|---|---|---|---|---|---|
| Codex | Total thread wire | 5.0 KiB | 5.0 KiB | 0 B (0.0%) | 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.2 KiB | 0 B (0.0%) | 2.0 KiB | ✅ |
| Codex | Live turn WebSocket decoded | 20.9 KiB | 20.9 KiB | 0 B (0.0%) | 29.3 KiB | ✅ |
| Codex | Live turn messages | 2 | 2 | 0 (0.0%) | 8 | ✅ |
| Claude | Total thread wire | 5.0 KiB | 5.0 KiB | +7 B (+0.1%) | 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.2 KiB | 1.2 KiB | +7 B (+0.6%) | 2.0 KiB | ✅ |
| Claude | Live turn WebSocket decoded | 21.2 KiB | 21.2 KiB | 0 B (0.0%) | 29.3 KiB | ✅ |
| Claude | Live turn messages | 2 | 2 | 0 (0.0%) | 8 | ✅ |
Baseline: 89fe509 · PR result: 4faeac5 · 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.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
3ffe79b2-cc8f-4f62-9f7c-88edd361c164
📥 Commits
Reviewing files that changed from the base of the PR and between 89fe509232e787b51d0cf695861afe73316ce85b and 4faeac514204f78c537380ba5a8b7ae2401ce83c.
📒 Files selected for processing: 4
apps/server/src/persistence/Migrations.test.tsapps/server/src/persistence/Migrations.tsapps/server/src/persistence/Migrations/068_DropOrchestrationEventCorrelationIndex.tsapps/server/src/persistence/reconcileV2PreviewMigration.test.ts
Limit details: You’ve used all 10 included reviews currently available.
📝 Walkthrough
Migration 68 drops
idx_orch_events_correlation_idwithout changing thecorrelation_idcolumn or its values. The migration is registered, and migration tests verify index removal, retained indexes, correlation ID preservation, and upgrade migration lists.Changes: Correlation index migration
Layer / File(s) Summary Implement and register migration
apps/server/src/persistence/Migrations/068_DropOrchestrationEventCorrelationIndex.ts,apps/server/src/persistence/Migrations.tsMigration 68 drops idx_orch_events_correlation_idif it exists and is added to the migration entries.Verify migration behavior and upgrade lists
apps/server/src/persistence/Migrations.test.ts,apps/server/src/persistence/reconcileV2PreviewMigration.test.tsTests verify that the correlation ID and specified indexes remain, the correlation index is removed, and preview-upgrade expectations include migration 68. Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
shivamhwp
Merge Risk: ⚪ Minimal · up to 4faea
The index can be removed without a supported impact on event data or the inspected query paths. No actionable issue remains before merge.
Pre-merge checks: Passed 4
Check name Status Explanation Title check Passed The title clearly and concisely describes the main change: stopping maintenance of the unused event correlation index. Linked Issues check Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request. Description check Passed The pull request description includes all required sections. It clearly states the problem, change, scope and approval, verification results, limitations, runtime validation, and the agent and harness… Full details: Description check
Explanation
The pull request description includes all required sections. It clearly states the problem, change, scope and approval, verification results, limitations, runtime validation, and the agent and harness used.
✨ 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
Comment @coderabbitai help to get the list of available commands.