The best way to control Claude Code, Codex and more from any computer or phone
fix(server): dev database copies drop links to other environments (#27313)
Co-authored-by: Nik <64274427+eyeveil@users.noreply.github.com>
maria committed
Oct 30, 2026 at 21:24 UTC
4fb9e5d34e832825327be740a35a9f96f50f61f0
3 files changed
+16
-3
AGENTS.md
+1
-1
@@ -91,7 +91,7 @@ The most common defect in this repo is a change that works on the path you teste
91
An empty database is a bad test. Seed your worktree's `.t3` with a copy of real data instead of pointing at live state:
92
93
- The first `vp run dev` in a worktree does this for you when its database is missing and the source is at most 500 MiB. Larger sources warn and dev starts with an empty database. `--no-seed` or `T3CODE_DEV_SEED=0` skips seeding. Manual migration still accepts larger sources and may use substantial disk space before pruning.
94
-- Run `vp run migrate-dev-db` with your dev server stopped to refresh. It rebuilds `<worktree>/.t3/userdata/statev2.sqlite` from a read-only snapshot of `~/.t3/userdata/statev2.sqlite`, the developer's real data. It keeps recent projects and their stopped threads, and drops scheduled tasks, pending work, and auth sessions, so your dev server never runs the developer's agents. Raise `--projects` and `--threads-per-project` for more data.
94
+- Run `vp run migrate-dev-db` with your dev server stopped to refresh. It rebuilds `<worktree>/.t3/userdata/statev2.sqlite` from a read-only snapshot of `~/.t3/userdata/statev2.sqlite`, the developer's real data. It keeps recent projects and their stopped threads, and drops scheduled tasks, pending work, auth sessions, and links to other environments, so your dev server never runs the developer's agents or reaches their other machines. Raise `--projects` and `--threads-per-project` for more data.
95
- Refresh `statev2.sqlite`, not `state.sqlite`. The server copies the V1 `state.sqlite` only when `statev2.sqlite` is missing.
96
- Bring `secrets` and `settings.json` only if the flow under test needs them.
97
- Copy in, never symlink. Data flows one way: into your sandbox, never back out.
apps/server/scripts/migrate-dev-db.test.ts
+14
-2
@@ -95,6 +95,10 @@ const createFixtureSource = Effect.fn("createMigrateDevDbFixtureSource")(functio
95
VALUES ('delivery-1', 'task-1', 'key-1', 1900000000000, '{}', '{}', '[]')`;
96
yield* sql`INSERT INTO auth_sessions (session_id, subject, scopes, method, issued_at, expires_at)
97
VALUES ('session-1', 'user', '[]', 'pairing', '2026-08-01', '2027-08-01')`;
98
+ yield* sql`INSERT INTO peer_environment_links
99
+ (environment_id, secret_name, label, urls_json, access, linked_at, expires_at)
100
+ VALUES ('environment-box', 'peer-link-box', 'Box', '["https://box.example"]', 'auto',
101
+ '2026-08-01', '2027-08-01')`;
102
}),
103
);
104
return databasePath;
@@ -130,13 +134,15 @@ it.layer(NodeServices.layer)("migrate-dev-db", (it) => {
134
tasks: number;
135
webhooks: number;
136
transfers: number;
137
+ links: number;
138
}>`
139
SELECT
140
(SELECT COUNT(*) FROM auth_sessions) AS auth,
141
(SELECT COUNT(*) FROM scheduled_tasks) AS tasks,
142
(SELECT COUNT(*) FROM scheduled_task_webhook_replay_keys) +
143
(SELECT COUNT(*) FROM scheduled_task_webhook_pending) AS webhooks,
139
- (SELECT COUNT(*) FROM orchestration_v2_projection_context_transfers) AS transfers`;
144
+ (SELECT COUNT(*) FROM orchestration_v2_projection_context_transfers) AS transfers,
145
+ (SELECT COUNT(*) FROM peer_environment_links) AS links`;
146
return { threads, events, sessions, leftovers };
147
}),
148
);
@@ -152,7 +158,13 @@ it.layer(NodeServices.layer)("migrate-dev-db", (it) => {
158
kept.sessions.map((row) => row.provider_session_id),
159
["session-shared"],
160
);
155
- assert.deepStrictEqual(kept.leftovers, { auth: 0, tasks: 0, webhooks: 0, transfers: 0 });
161
+ assert.deepStrictEqual(kept.leftovers, {
162
+ auth: 0,
163
+ tasks: 0,
164
+ webhooks: 0,
165
+ transfers: 0,
166
+ links: 0,
167
+ });
168
}),
169
);
170
apps/server/scripts/migrate-dev-db.ts
+1
@@ -211,6 +211,7 @@ const CLEARED_TABLES: ReadonlyArray<string> = [
211
"provider_session_runtime",
212
"auth_sessions",
213
"auth_pairing_links",
214
+ "peer_environment_links",
215
];
216
217
const PROVIDER_SESSIONS_TABLE = "orchestration_v2_projection_provider_sessions";