[Bug]: Worktree pairing can migrate the live desktop database
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 23k
- Forks
- 5.9k
- Avg merge
- 11h 14m
- Merged PRs (30d)
- 357
Description
Before submitting
- I searched existing issues and did not find a duplicate of this specific failure.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Keep the installed desktop server running.
- In a development worktree with a pending migration, run
node apps/server/src/bin.ts pairwithout--base-dir, with no discoverable worktree server. - Discovery falls back to the installed server; token creation opens its database using the development checkout's migrations.
Expected behavior
Worktree pairing must not silently target the live install. Minting a token should not run a different checkout's schema migrations.
Actual behavior
An agent trying to pair a dev browser migrated my live database. On September 3, the command returned the installed server on port 3773. The live DB recorded migration 48 (ProjectionThreadMessageContext, unmerged work) and the t3 pair token in the same second: 16:33:46 UTC.
Updating later broke both installed builds: released migration 48 is ProjectionThreadBranchPullRequest, so it was skipped and startup failed on the missing column.
Code path: cli/pair.ts shared-home fallback → EnvironmentAuth.runtimeLayer → SQLite setup → runMigrations().
Related: #8896 covers migration identity validation; this report concerns the pairing command that unexpectedly applies development migrations to live data.
Impact
Blocks work completely
Version or commit
Affected installed builds: 0.0.39 and 0.0.40-nightly.20260907.1346; pairing ran from an unmerged inline-context worktree.
Environment
macOS, Electron desktop; Node CLI invoked from a linked git worktree.
Logs or stack traces
Pairing with MacBook Pro (http://127.0.0.1:3773).
PersistenceSqlError: ProjectionSnapshotQuery.getCommandReadModel:listThreads:query
Error: no such column: branch_pull_request_json
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cli/pair.ts and trace the shared-home fallback through EnvironmentAuth.runtimeLayer to SQLite setup and runMigrations(). Reproduce the worktree pairing scenario with an installed server and pending development migration, then verify which server and database are selected. Done means pairing cannot silently target the installed server or apply development migrations to its live database.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sqlite, typescript
- Domain
- cli, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100