You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 331fc71
Browse filesBrowse the repository at this point in the historyBrowse files
Review of the seeding path found five ways a seeded database could
describe something the copy cannot back up:
- Nothing stopped `dev:seed` from running against a live server. SQLite
locking lets the seed take the write lock between the server's own
writes and commit cleanly; what it cannot do is tell that server its
projections and event log were replaced underneath it. Refuse instead,
via a pid probe over both state directories.
- A thread copied mid-turn kept `state = 'running'`. The session override
did not cover it — the turn is read independently, and an unsettled one
leaves the thread spinning and its timeline unfoldable forever. Settle
those to "interrupted", matching what the server does when a session
leaves "running". Streaming messages are finished for the same reason.
- Attachment metadata was copied without the files behind it, so a seeded
thread rendered an image whose request 404s. Report the referenced ids
and copy the matching files alongside the rows.
- Orphaned `provider_session_runtime` rows survived the seed naming
threads it had just deleted, which the session reaper then tried to
stop against a provider instance the worktree may not define.
- `--threads` had no upper bound, so a large enough value died with "too
many SQL variables" after the target was already emptied.
Also corrects the projector-cursor comment: `orchestration_events.sequence`
is AUTOINCREMENT, so emptying the log does not reset its high-water mark
and sequence does not restart at 1. Zero remains the right cursor, for the
reason now stated.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copy file name to clipboardExpand all lines: .agents/skills/test-t3-app/SKILL.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ It finds the live server state under either the `dev` or `userdata` state direct
62
62
Read [references/sqlite-fixtures.md](references/sqlite-fixtures.md) before changing the database.
63
63
64
64
- Use `node apps/server/scripts/t3-sqlite-state.ts query` for schema discovery and read-only checks.
65
-
- To populate realistic list and thread data, stop the server and run `bun run dev:seed`, then restart it. This copies recent projections from the shared home while refusing to write to it.
65
+
- To populate realistic list and thread data, stop the server and run `bun run dev:seed`, then restart it. This copies recent projections from the shared home while refusing to write to it. It also refuses to run while a server is still using the target directory, so stop the server first rather than expecting the seed to wait.
66
66
- Stop the dev server before using `node apps/server/scripts/t3-sqlite-state.ts exec`, then restart it with the same base directory.
67
67
- Seed projection tables only for disposable UI fixtures. Use application commands and APIs when testing business behavior or projection correctness.
68
68
- Use the auth CLI, not direct `auth_*` table edits, for pairing and sessions.
Copy file name to clipboardExpand all lines: .agents/skills/test-t3-app/references/sqlite-fixtures.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,8 @@ The web UI primarily reads these projection tables:
49
49
-`projection_pending_approvals`
50
50
-`projection_thread_proposed_plans`
51
51
52
+
`projection_state` holds one cursor row per projector and is not read by the UI, but a fixture that omits it still breaks: `computeSnapshotSequence` returns 0 unless every projector has a row, which makes every shell snapshot advertise sequence 0. Write all of them (`PROJECTOR_NAMES` in `scripts/lib/projection-tables.ts`), at a sequence no higher than the event log actually reaches.
53
+
52
54
Inspect `PRAGMA table_info(<table>)` and the current migrations under `apps/server/src/persistence/Migrations/` before constructing inserts. Keep identifiers unique, timestamps as ISO strings, JSON columns valid, and related project/thread/turn IDs consistent.
53
55
54
56
For a substantial current example, inspect `seedDatabase` in `scripts/mobile-showcase-environment.ts`. Adapt its column set to the target database instead of assuming copied SQL remains current.
Copy file name to clipboardExpand all lines: AGENTS.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@
18
18
- In a linked git worktree, dev state defaults to that worktree's gitignored `.t3`. This deliberately outranks an ambient `T3CODE_HOME`, which could otherwise select the installed app's live `~/.t3/userdata` database. An explicit `--home-dir` still wins.
19
19
- Start the web stack with `bun run dev`. Use `bun run dev:share` when someone needs to open it from another device on the tailnet.
20
20
- Use `bun run dev:pair` to issue a fresh URL for the running server without reconstructing its port or origin.
21
-
- Use `bun run dev:seed` while the server is stopped to populate an isolated database with recent projects and threads from the shared home.
21
+
- Use `bun run dev:seed` while the server is stopped to populate an isolated database with recent projects and threads from the shared home. It refuses to run against a directory a live server is using.
22
22
- Browser dev is single-origin: Vite proxies `/api`, `/ws`, `/oauth`, and `/.well-known` to the backend. Do not set `VITE_HTTP_URL` or `VITE_WS_URL` for `dev`/`dev:web`.
23
23
- Worktree paths supply stable preferred port offsets. Read the actual server and web ports from the `[dev-runner]` line because occupied ports can still shift them.
Copy file name to clipboardExpand all lines: docs/reference/scripts.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,9 @@
47
47
48
48
Worktrees derive a preferred port offset from their path. The runner shifts both ports together when either is occupied, so treat the `[dev-runner]` output as authoritative.
49
49
50
-
An isolated dev database starts empty. `vp run dev:seed` copies projection data only, clears the target event log, and resets every projector cursor to zero so later events are not skipped or replayed over unrelated projections. Copied sessions are stopped and pending interaction counts are cleared because no live agent accompanies the copy. The copy tolerates source/target migration drift and remains local because it includes real message bodies and host paths.
50
+
An isolated dev database starts empty. `vp run dev:seed` copies projection data only, clears the target event log, and resets every projector cursor to zero so later events are not skipped or replayed over unrelated projections. Because no live agent accompanies the copy, it also settles anything that would otherwise wait on one: sessions are stopped, running turns are interrupted, streaming messages are finished, pending interaction counts are cleared, and orphaned provider bindings are removed. Files backing copied image attachments are copied alongside the rows. The copy tolerates source/target migration drift and remains local because it includes real message bodies and host paths.
51
+
52
+
`dev:seed` refuses to run while a server is using the target directory: it replaces the projections and event log that server is holding open, and it has no way to tell the running process its read model was swapped underneath it. Stop the server, seed, then start it again.
0 commit comments