Skip to content

feat(server): vp run migrate-dev-db seeds worktree dev dbs with real data - #5773

Merged
t3dotgg merged 8 commits into
mainfrom
t3code/migrate-dev-database
Aug 9, 2026
Merged

feat(server): vp run migrate-dev-db seeds worktree dev dbs with real data#5773
t3dotgg merged 8 commits into
mainfrom
t3code/migrate-dev-database

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Aug 9, 2026

Copy link
Copy Markdown
Member

Worktree dev servers start with an empty database, so testing anything real means clicking around to fabricate projects and threads. And nothing checks that a new migration applies cleanly on top of the real database's applied-migration state — fresh CI databases always pass.

vp run migrate-dev-db fixes both. It snapshots the real ~/.t3 database read-only (VACUUM INTO), prunes it to a handful of recent projects and their fully-stopped threads, and drops it into the worktree's isolated .t3. Then it runs this checkout's migrations against the result, which is real applied state, and fails loudly if a migration slot id was already taken under a different name (the silent-skip collision that has bitten parallel PRs before).

Details:

  • Keeps threads only when their session is stopped and they are not settled, monitored, archived, or deleted. Working/monitoring liveness is in-memory only, so the persisted filter is exact.
  • Event-sourcing stays consistent: kept threads keep their full orchestration_events streams, and sqlite_sequence plus projection_state cursors carry over, so nothing rewinds.
  • Auth sessions, pairing links, command receipts, and provider runtime rows are dropped. Pair a fresh browser.
  • Refuses to touch the shared ~/.t3 and refuses while a dev server holds the destination db.
  • Flags: --projects (5), --threads-per-project (10), --base-dir, --source.
  • Tolerates the monitor_json column that exists in the live db without a matching migration.

Tested end to end on the real database (2.5 GB in, ~145 MB out, 17 threads across 5 projects) plus three colocated tests covering the lifecycle filter, slot-collision detection, and the shared-home guard.

Built by Claude Fable 5 running in Claude Code.

🤖 Generated with Claude Code


Note

Medium Risk
Touches real user database copies and rewrites worktree dev SQLite, but refuses the shared home and active servers; main risk is mistaken --base-dir/--source paths or incomplete prune semantics for edge thread states.

Overview
Adds migrate-dev-db (pnpm migrate-dev-db / vp run migrate-dev-db) so a git worktree can get a pruned copy of the real ~/.t3 SQLite state instead of an empty dev database.

The command read-only snapshots the source (VACUUM INTO), runs this checkout’s migrations on that clone (so new migrations are exercised against real effect_sql_migrations history), verifies migration slot names and fails with MigrateDevDbSlotCollisionError when a slot was applied under a different name, then prunes to recent live projects and fully stopped threads (skips running, settled, monitored, deleted/archived), drops auth/pairing/command receipts/provider runtime, trims orchestration_events per kept stream while leaving projection cursors/sequences intact, and compacts into the worktree’s isolated .t3/userdata/state.sqlite with 0600 and WAL.

Guards block rebuilding shared ~/.t3, using a source that resolves to the destination or temp snapshot path, and overwriting the DB while server-runtime.json indicates a live server or SQLite reports write/WAL contention.

Vitest coverage exercises the prune filter, slot collision, server-running refusal, source/destination overlap, and shared-home refusal.

Reviewed by Cursor Bugbot for commit 451a1ad. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add migrate-dev-db script to seed worktree dev databases with real data

  • Adds migrate-dev-db.ts — a new CLI script and programmatic API (runMigrateDevDb) that snapshots a source SQLite database, runs pending migrations, prunes it to recent stopped threads and their projects, strips auth/runtime state, and compacts the result into a destination dev database.
  • Pruning keeps the N most recently updated projects (default 5) and, per project, the M most recent stopped threads (default 10), dropping all auth sessions, pairing links, and provider runtime state.
  • Adds multiple guard checks before touching the destination: detects a live dev server via server-runtime.json, checks for write-locks and WAL holds on the destination file, refuses to target the shared ~/.t3 home, and rejects a source path that resolves to the destination.
  • Introduces typed errors (MigrateDevDbSlotCollisionError, MigrateDevDbServerRunningError, etc.) and phase-wrapped errors for snapshot, prune, compact, migrate, and verify stages.
  • Adds npm run migrate-dev-db in package.json as the CLI entrypoint.

Macroscope summarized 451a1ad.

…data

Clones the real ~/.t3 database into the worktree's isolated .t3, pruned
to recent fully-stopped threads, then runs this checkout's migrations
against it. Doubles as a pre-flight check that new migrations apply on
top of the real applied set, including loud detection of silent
migration slot collisions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 68658d86-d457-47ef-9246-80e03a8efa7d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 9, 2026
Comment thread apps/server/scripts/migrate-dev-db.ts Outdated
Comment thread apps/server/scripts/migrate-dev-db.ts Outdated
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 11.3 KiB 11.3 KiB −11 B (−0.1%) 15.1 KiB
Codex Thread snapshot wire 5.5 KiB 5.5 KiB +2 B (+0.0%) 7.3 KiB
Codex Live turn WebSocket wire 5.9 KiB 5.9 KiB −13 B (−0.2%) 7.8 KiB
Codex Live turn WebSocket decoded 49.7 KiB 49.7 KiB 0 B (0.0%) 66.4 KiB
Codex Live turn messages 16 16 0 (0.0%) 21
Claude Total thread wire 11.3 KiB 11.4 KiB +43 B (+0.4%) 15.1 KiB
Claude Thread snapshot wire 5.5 KiB 5.5 KiB −3 B (−0.1%) 7.3 KiB
Claude Live turn WebSocket wire 5.8 KiB 5.9 KiB +46 B (+0.8%) 7.8 KiB
Claude Live turn WebSocket decoded 50.6 KiB 50.6 KiB 0 B (0.0%) 66.4 KiB
Claude Live turn messages 16 16 0 (0.0%) 21

Baseline: 886195e · PR result: 451a1ad · 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: 94.6 KiB
  • Claude decoded thread snapshot: 95.4 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

… its snapshot

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the new apps/server/scripts/migrate-dev-db.ts (and its test) against the Effect service/error conventions. Imports, Schema.TaggedErrorClass usage, the phase discriminator, and dependency acquisition (yield* SqlClient.SqlClient, layers provided per-database) all look right. Three error-modeling findings inline: the busy error stores a prose fragment as its only variable data and carries no cause, the wrap at the probe discards the underlying SqlError, and the verify boundary hand-rolls a _tag comparison instead of Effect.catchTags.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/scripts/migrate-dev-db.ts
Comment thread apps/server/scripts/migrate-dev-db.ts
Comment thread apps/server/scripts/migrate-dev-db.ts
Comment thread apps/server/scripts/migrate-dev-db.ts
… and cause

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One convention finding on the new script: a wrapped failure drops its underlying cause. Everything else (namespace imports, Schema.TaggedErrorClass errors with structural attributes and messages derived from them, SqlClient acquired from the environment, NodeRuntime.runMain only at the CLI boundary) matches the conventions.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/scripts/migrate-dev-db.ts
Comment thread apps/server/scripts/migrate-dev-db.ts
…ore pruning

An idle server passes the SQL lock probes, so check the pid in
server-runtime.json first. Migrations now run on the snapshot before
pruning so a source older than the checkout cannot crash the prune
queries, and new migrations get exercised on full real data.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Aug 9, 2026
Comment thread apps/server/scripts/migrate-dev-db.ts
…ape hatch

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 81f3692. Configure here.

Comment thread apps/server/scripts/migrate-dev-db.ts
@macroscopeapp

macroscopeapp Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR adds 755 lines of new developer tooling for rebuilding isolated dev databases. While it doesn't affect production runtime and has comprehensive tests, the substantial amount of new logic (database operations, CLI commands, error handling) represents a new feature that benefits from human review.

You can customize Macroscope's approvability policy. Learn more.

… the dev db

A slot collision now aborts while the snapshot is the only thing
touched, so the old worktree db survives every failure except a
compact-phase crash.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread apps/server/scripts/migrate-dev-db.ts

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One finding: the destination-busy error uses its reason discriminator to select the user-facing message and carries a variant-only pid. Earlier feedback on cause, the structured reason, and Effect.catchTags is addressed.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/scripts/migrate-dev-db.ts Outdated
…er-running error

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread apps/server/scripts/migrate-dev-db.ts
…the db swap

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@t3dotgg
t3dotgg merged commit ddaa6af into main Aug 9, 2026
17 checks passed
@t3dotgg
t3dotgg deleted the t3code/migrate-dev-database branch August 9, 2026 02:51
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Aug 9, 2026
## What's Changed
* chore: vouch gfsaaser24 by @t3dotgg in pingdotgg/t3code#5761
* chore: vouch saphid by @t3dotgg in pingdotgg/t3code#5763
* fix(server): stop Codex threads with queued follow-ups by @t3dotgg in pingdotgg/t3code#5762
* fix(web): usage page loses the cost quality panel, gains a back button by @t3dotgg in pingdotgg/t3code#5756
* feat(server): agents can now open the images you paste into chat by @t3dotgg in pingdotgg/t3code#5757
* fix(web): pinned reorder no longer reshuffles while writes land by @t3dotgg in pingdotgg/t3code#5767
* feat(web): overhaul project settings into a real settings page by @t3dotgg in pingdotgg/t3code#5768
* fix(web): usage totals no longer jump while devices report in by @t3dotgg in pingdotgg/t3code#5772
* fix(server): settle no longer leaves monitors and dev servers running by @t3dotgg in pingdotgg/t3code#5774
* feat: pick worktree or current checkout per project by @t3dotgg in pingdotgg/t3code#5766
* fix(web): sidebar rows show the branch again, not a truncated plan step by @t3dotgg in pingdotgg/t3code#5776
* feat(server): vp run migrate-dev-db seeds worktree dev dbs with real data by @t3dotgg in pingdotgg/t3code#5773
* feat(web): keep unsent drafts one click away in the sidebar by @t3dotgg in pingdotgg/t3code#5777


**Full Changelog**: pingdotgg/t3code@v0.0.33-nightly.20260809.1039...v0.0.33-nightly.20260809.1040

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.33-nightly.20260809.1040
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Aug 10, 2026
## What's Changed
* fix(mobile): reconnects no longer shift the thread list by @t3dotgg in pingdotgg/t3code#5372
* feat(web): drag pinned threads into your own order by @t3dotgg in pingdotgg/t3code#5581
* chore(ci): vouch StiensWout by @t3-code[bot] in pingdotgg/t3code#5637
* feat(desktop): remember recently used sites in the Browser panel by @chrisdeeming in pingdotgg/t3code#5270
* chore: vouch chrisdeeming by @t3-code[bot] in pingdotgg/t3code#5641
* feat(web): make sidebar artwork theme-aware by @maria-rcks in pingdotgg/t3code#5636
* fix(web): reconnect the composer seam for remote non-Git projects by @caezium in pingdotgg/t3code#5633
* fix(web): show Stop button while input is pending by @ipanasenko in pingdotgg/t3code#5554
* feat(web): fold plan mode and token-by-token output into Legacy features by @t3dotgg in pingdotgg/t3code#5664
* feat: sidebar v2 is now the default sidebar by @t3dotgg in pingdotgg/t3code#5672
* fix(server): stop PR status lookups amplifying GitHub rate limits by @t3dotgg in pingdotgg/t3code#5673
* fix(web): delay transient reconnect warnings by @t3-code[bot] in pingdotgg/t3code#5670
* fix(web): inherit terminal size in simple typography by @chrisdeeming in pingdotgg/t3code#5628
* fix(server): stop the reaper from silently killing live background subagents by @t3dotgg in pingdotgg/t3code#5677
* fix(desktop): zoom shortcuts no longer die when the preview browser has focus by @t3dotgg in pingdotgg/t3code#5691
* feat(mobile): one sheet for model and thread settings by @t3dotgg in pingdotgg/t3code#5625
* feat(usage): usage page reading provider transcripts across environments by @t3dotgg in pingdotgg/t3code#5684
* fix(web): usage chart no longer makes Claude look like the bigger spender by @t3dotgg in pingdotgg/t3code#5697
* fix(web): persist diff view mode by @leorivastech in pingdotgg/t3code#5731
* feat(web): show how many subagents are running at a glance by @t3dotgg in pingdotgg/t3code#5745
* fix(web): add missing cursor-pointer styling to dropdowns and interactive buttons by @naMqe-h in pingdotgg/t3code#5716
* fix(server): stop Claude resume handshakes from completing turns that never ran by @gfsaaser24 in pingdotgg/t3code#5710
* chore: vouch gfsaaser24 by @t3dotgg in pingdotgg/t3code#5761
* chore: vouch saphid by @t3dotgg in pingdotgg/t3code#5763
* fix(server): stop Codex threads with queued follow-ups by @t3dotgg in pingdotgg/t3code#5762
* fix(web): usage page loses the cost quality panel, gains a back button by @t3dotgg in pingdotgg/t3code#5756
* feat(server): agents can now open the images you paste into chat by @t3dotgg in pingdotgg/t3code#5757
* fix(web): pinned reorder no longer reshuffles while writes land by @t3dotgg in pingdotgg/t3code#5767
* feat(web): overhaul project settings into a real settings page by @t3dotgg in pingdotgg/t3code#5768
* fix(web): usage totals no longer jump while devices report in by @t3dotgg in pingdotgg/t3code#5772
* fix(server): settle no longer leaves monitors and dev servers running by @t3dotgg in pingdotgg/t3code#5774
* feat: pick worktree or current checkout per project by @t3dotgg in pingdotgg/t3code#5766
* fix(web): sidebar rows show the branch again, not a truncated plan step by @t3dotgg in pingdotgg/t3code#5776
* feat(server): vp run migrate-dev-db seeds worktree dev dbs with real data by @t3dotgg in pingdotgg/t3code#5773
* feat(web): keep unsent drafts one click away in the sidebar by @t3dotgg in pingdotgg/t3code#5777
* feat(web): project icons can be chosen manually by @t3dotgg in pingdotgg/t3code#5775
* fix(server): one greedy agent process no longer takes down the whole server by @t3dotgg in pingdotgg/t3code#5788
* ci: label-gated hosted-web preview deploys by @t3dotgg in pingdotgg/t3code#5465
* Add cross-platform mobile usage dashboard by @juliusmarminge in pingdotgg/t3code#5743
* fix(web): preserve desktop route during Clerk auth by @wobsoriano in pingdotgg/t3code#5770
* fix(web): match create theme and import theme buttons to the standard outline style by @UtkarshUsername in pingdotgg/t3code#5860
* fix(server): favicon resolution no longer pins the event loop by @murenovich in pingdotgg/t3code#5538
* fix(shared): bound the file-link label so bracket runs stop rescanning by @tsouth89 in pingdotgg/t3code#5782
* fix(web): thread title button no longer eats the drag area by @nathangerday in pingdotgg/t3code#5857
* fix(web): unify usage page chrome by @t3-code[bot] in pingdotgg/t3code#5823
* fix(shell): add ~/.local/bin to the Windows CLI resolver so native-installed providers are found by @arhxam in pingdotgg/t3code#5074
* fix(web): match settings search shortcut styling to command palette's by @UtkarshUsername in pingdotgg/t3code#5841
* fix(mobile): long-pressing a thread row no longer navigates into the thread by @juliusmarminge in pingdotgg/t3code#5901
* fix(server): usage no longer double-counts forked Codex sessions by @t3dotgg in pingdotgg/t3code#5887
* fix(server): sandbox user-provided SVGs by @t3dotgg in pingdotgg/t3code#5916
* fix(web): match usage titlebar text styling by @t3-code[bot] in pingdotgg/t3code#5897
* Move project settings to contextual project routes by @juliusmarminge in pingdotgg/t3code#5923
* Retain thread sidebar data when navigating to /settings so back navigation is instant by @juliusmarminge in pingdotgg/t3code#5930
* Automate production mobile EAS releases by @juliusmarminge in pingdotgg/t3code#5609
* Add settings and usage breadcrumbs by @juliusmarminge in pingdotgg/t3code#5929
* fix(web): correct model picker trigger padding by @Chrono-byte in pingdotgg/t3code#5935
* fix(web): show worktree icon in sidebar v2 by @tris203 in pingdotgg/t3code#5909
* fix(web): enable restore defaults after theme mix changes by @Lucenx9 in pingdotgg/t3code#5928
* fix(web): trait menu closes after you pick a level by @t3dotgg in pingdotgg/t3code#5879
* fix(web): align project name with headline by @carterwsmith in pingdotgg/t3code#5864
* fix(web): update pills use readable theme foregrounds by @chrisdeeming in pingdotgg/t3code#5938
* fix(web): use themed confirmation dialogs by @StiensWout in pingdotgg/t3code#5624
* fix(web): use import/export-appropriate icons for theme buttons by @UtkarshUsername in pingdotgg/t3code#5964
* fix(mobile): detect PowerShell cmdlet errors in work log rows by @myacoub91 in pingdotgg/t3code#5726
* fix(mobile): stop Android user bubbles with code blocks from overlapping by @Brechard in pingdotgg/t3code#5659
* fix(mobile): parse EAS fingerprint JSON by @juliusmarminge in pingdotgg/t3code#5991

## New Contributors
* @chrisdeeming made their first contribution in pingdotgg/t3code#5270
* @wobsoriano made their first contribution in pingdotgg/t3code#5770
* @murenovich made their first contribution in pingdotgg/t3code#5538
* @tsouth89 made their first contribution in pingdotgg/t3code#5782
* @nathangerday made their first contribution in pingdotgg/t3code#5857
* @carterwsmith made their first contribution in pingdotgg/t3code#5864
* @myacoub91 made their first contribution in pingdotgg/t3code#5726

**Full Changelog**: pingdotgg/t3code@v0.0.32...v0.0.33

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant