fix(server): stop maintaining the unused event correlation index #23211
main fromrefs/pull/23211/head·merged by juliusmarminge View on GitHubProblem#
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.
- 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:S
Approvability#
Verdict: Approved at
63325c7Macroscope's review found this PR approvable — The migration removes an unused, non-unique event correlation index while preserving the column and all event data. Its impact is limited to internal database storage and index maintenance.
No code changes detected at
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).a0ca3f3. Prior analysis still applies.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 +16 B (+0.3%) 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 +16 B (+1.3%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.5 KiB 21.6 KiB +41 B (+0.2%) 24.4 KiB ✅ Codex Live turn messages 1 2 +1 (+100.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.2 KiB 1.2 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:
07a1e79· PR result:a0ca3f3· 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.
Important
Review skipped#
Review was skipped as selected files did not have any reviewable changes.
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: fix/issue-20534
- File: .coderabbit.config.ts
- Commit: a0ca3f3
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
a8157f00-6ba7-4809-a4f3-46429b6563e1
Commits-
Reviewing files that changed from the base of the PR and between 63325c7f9902c5a20c5e426d16cab0418c0f77fc and a0ca3f3305c1789ee634cf7017d6264957d47e40.
You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- Trigger review
No actionable comments were generated in the recent review.
Walkthrough
-
Migration 78 removes
idx_orch_events_correlation_idwhile leaving thecorrelation_idcolumn and its values intact. The migration registry and preview expectations include migration 78. Tests verify index removal, retained indexes, and value preservation.Changes: Correlation index migration
Layer / File(s) Summary Implement and register migration
apps/server/src/persistence/Migrations/078_DropOrchestrationEventCorrelationIndex.ts,apps/server/src/persistence/Migrations.tsMigration 78 drops idx_orch_events_correlation_idif it exists and adds the migration to the registry.Verify migration behavior and upgrade lists
apps/server/src/persistence/Migrations.test.ts,apps/server/src/persistence/reconcileV2PreviewMigration.test.tsThe migration test checks that the index is removed, specified indexes remain, and the event retains its correlation value. Preview-upgrade and retry expectations include migration 78. Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
pingdotgg/t3code#20534— The migration removes the index identified in the issue while preserving the correlation column and values.
Suggested reviewers:
yash-singh1
Merge Risk:
Minimal · previous review63325-
No actionable merge-blocking risk was identified in the migration or upgrade-path changes.
Pre-merge checks:
4-
Check name Status Explanation Title check The title "fix(server): stop maintaining the unused event correlation index" matches the main change: migration 078 drops idx_orch_events_correlation_id, which no server query uses. It uses a conventi… Description check The description follows the template's Problem, Change, Scope and approval, and Verification sections. It explains the unused index and its insert cost, and it names the migration, the preserved colum… Linked Issues check Issue [ #20534] requires removal of onlyidx_orch_events_correlation_id, preservation ofcorrelation_idvalues, and retention of the other event indexes, including `idx_orchestration_events_agent_s…Out of Scope Changes check The whole-PR diff contains the migration, its registry entry, migration-preview expectation updates, and the regression test. These changes directly implement and validate issue [ #20534]. No unrelated…Full details: Title check
-
Explanation
The title "fix(server): stop maintaining the unused event correlation index" matches the main change: migration 078 drops idx_orch_events_correlation_id, which no server query uses. It uses a conventional commit prefix and is specific, and it does not mention the preserved column or other indexes, which is acceptable.
Full details: Description check
-
Explanation
The description follows the template's Problem, Change, Scope and approval, and Verification sections. It explains the unused index and its insert cost, and it names the migration, the preserved column and indexes, and the regression test. It links issue
#20534and reports focused tests, targeted lint, typecheck, and a runtime upgrade check. The template's wording says the verification must not be "tests pass" alone, and this description gives observed results. Minor gaps: the Change section says "migration 68" while the file is 078, and the agent/model attribution line is present. These are non-critical, so the check passes.
Full details: Linked Issues check
-
Explanation
Issue [
#20534] requires removal of onlyidx_orch_events_correlation_id, preservation ofcorrelation_idvalues, and retention of the other event indexes, includingidx_orchestration_events_agent_stream_sequence. Migration 078 executes onlyDROP INDEX IF EXISTS idx_orch_events_correlation_id. The new migration test verifies the target index is absent, the correlation value remains, and the required indexes remain. The migration is registered inMigrations.ts, and both migration-preview expectations include it. The implementation uses migration 78 rather than the description's stated migration 68; the issue does not require a specific migration number.
Full details: Out of Scope Changes check
-
Explanation
The whole-PR diff contains the migration, its registry entry, migration-preview expectation updates, and the regression test. These changes directly implement and validate issue [
#20534]. No unrelated client, contract, or product-behavior changes are present in the diff.
-
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
CodeRabbit Verify#
- Run CodeRabbit Verify to test the changes in this pull request.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: fix/issue-20534
- File: .coderabbit.config.ts
- Commit: 63325c7
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
090c95f0-a05a-40c5-a332-24c5f806d2f9
Commits-
Reviewing files that changed from the base of the PR and between 059313e6e999294ab8d71cc9c95e4108738594d7 and 63325c7f9902c5a20c5e426d16cab0418c0f77fc.
Files selected for processing: 3-
apps/server/src/persistence/Migrations.tsapps/server/src/persistence/Migrations/078_DropOrchestrationEventCorrelationIndex.tsapps/server/src/persistence/reconcileV2PreviewMigration.test.ts
Limit details: You’ve used all 10 included reviews currently available.
-
-
juliusmarminge added labelsvia-triage:gates-failing
juliusmarminge added labelsbugfix
juliusmarminge removed labelsvia-triage:gates-failing
juliusmarminge added labelspr:gate-failed
juliusmarminge removed labelspr:gate-failed
juliusmarminge added labelspr:ready
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this93a3e8f
juliusmarminge closed this
The automated pipeline stopped on this pull request and will not merge it:
the proof has no capture anyone can open:
- Base reproduction: the specified merge-base lacks the affected Swift client; an unfixed Swift commit is needed for a valid comparison.
- Head behavior: folder browsing, clone destination defaults, environment reseeding, blank-setting fallback, and preservation of manual edits were not exercised.
- No captures were produced, so there are no public evidence URLs. No upload was attempted.
It stays open for a person to finish or close.
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed