fix(server): drop V1 projections nothing reads after the V2 upgrade #20947
main fromrefs/pull/20947/head·merged by juliusmarminge View on GitHubUpgrading to 0.1.0 starts statev2.sqlite as a full copy of the V1 database. V2 never reads six of those V1 tables, so long-time users keep them forever: 5.9 GiB in #20922, mostly the old activity log.
Migration 63 drops projection_thread_activities, projection_turns, projection_thread_proposed_plans, projection_pending_approvals, projection_state and checkpoint_diff_blobs. Nothing on main or in 0.1.0 reads them outside migrations and tests. The V1 transcript import still reads threads, messages and pull request links, so those tables stay. Builds before 0.1.0 read state.sqlite, never this file, so rolling back is unaffected.
Dropping only frees pages, which is quick: 696 MiB dropped in 168 ms. Upgraded databases have auto_vacuum off, so those pages count as reclaimable space. The Settings notice from #19437 suggests t3 doctor at 1 GiB, and its existing "Reclaim database space" repair returns them to disk.
The mobile showcase seed still wrote into these tables and waited for them to exist. Those rows were never shown by V2 clients (#15013), so the seed no longer writes them.
Verification#
Migration test: the six tables are gone, while the transcript import tables and their rows are kept. The V1 cutover integration test and the showcase test still pass.
On a copy of a real 8.58 GiB V2 database, a normal server start ran migration 63:
before: Database: 8.58 GiB, 0 KiB reclaimable.
after: Database: 8.58 GiB, 694.9 MiB reclaimable.
Part of #20922. #20948 adds the opt-in repair for the V1 file itself.
🤖 Generated with Claude Code
Closes #20922
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge changed the title
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
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 +7 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.2 KiB +7 B (+0.6%) 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 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.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 2 2 0 (0.0%) 8 ✅ Baseline:
4b1024d· PR result:e910922· 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.
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:
d1846242-2877-452b-85b2-d58427508d24
📥 Commits
-
Reviewing files that changed from the base of the PR and between 4b1024dafe4766ea7c59546936c21ce0fab8acb3 and e910922a9be903434eb759a50bbece9e5129f102.
📒 Files selected for processing: 6
-
apps/server/src/persistence/Migrations.tsapps/server/src/persistence/Migrations/055_OrchestrationV2.test.tsapps/server/src/persistence/Migrations/063_DropUnusedV1Projections.test.tsapps/server/src/persistence/Migrations/063_DropUnusedV1Projections.tsapps/server/src/persistence/reconcileV2PreviewMigration.test.tsscripts/mobile-showcase-environment.ts
💤 Files with no reviewable changes: 1
-
- scripts/mobile-showcase-environment.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
-
📝 Walkthrough
-
Migration 63 drops six projection tables and is added to migration registration and upgrade expectations. Migration tests check that transcript tables and message data remain. The mobile showcase seed no longer creates or clears the removed projection data.
Changes: V1 Projection Cleanup
Layer / File(s) Summary Register and verify migration 63
apps/server/src/persistence/Migrations/063_DropUnusedV1Projections.ts,apps/server/src/persistence/Migrations.ts,apps/server/src/persistence/Migrations/063_DropUnusedV1Projections.test.ts,apps/server/src/persistence/Migrations/055_OrchestrationV2.test.ts,apps/server/src/persistence/reconcileV2PreviewMigration.test.tsMigration 63 drops six tables if they exist. Registration and upgrade expectations include the migration. Its test checks that three transcript-related tables and an inserted message remain. Update mobile showcase seeding
scripts/mobile-showcase-environment.tsThe seed no longer inserts projection turns, activity records, or projection-state rows. Its cleanup list now includes only thread messages, thread sessions, and threads. Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix
Suggested reviewers:
realhasanshoaib,maria-rcks
Merge Risk: ⚪ Minimal · up to
e9109-
The change drops unused V1 tables so upgraded databases can reclaim space. No remaining code path reads those tables, and the transcript import tables are kept. No merge-blocking risk was found.
Pre-merge checks:
4-
Check name Status Explanation 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. Title check The title clearly and concisely describes the main change: removing unused V1 projections after the V2 upgrade. Description check The description explains the problem, the migration changes, retained tables, scope, issue references, rollback impact, and focused verification results. It is sufficiently complete despite not using … Full details: Description check
-
Explanation
The description explains the problem, the migration changes, retained tables, scope, issue references, rollback impact, and focused verification results. It is sufficiently complete despite not using all template headings explicitly.
-
✨ 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
-
juliusmarminge merged this7e0418a
juliusmarminge closed this
Sign in to join this conversation.
Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — The upgrade now automatically deletes six existing SQLite tables and their stored rows, while the other changes update tests and a development showcase seed. Although the migration is tested and intended tables are obsolete, its irreversible production data/schema impact warrants deliberate review.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).