Address review findings on seeding and worktree resolution

- dev:seed wrote projector cursors at 1..9 while leaving the target's
  event log intact. The cursor is exclusive and a fresh log restarts at
  sequence 1, so every projector would skip a different slice of the
  user's first real events; the retained events would also replay over
  the copied projections and resurrect the target's deleted threads. All
  nine cursors now start at 0, and the event log and command receipts
  are emptied with the projections.
- The thread-selection query referenced archived_at and
  latest_user_message_at unconditionally, so a source older than
  migrations 017/023 threw before copying anything. It now builds its
  filter and ordering from the columns the source actually has, matching
  how the rest of the copy handles drift. A table missing from the
  target is likewise skipped rather than aborting the seed.
- --threads/--activities accepted negatives, which SQLite reads as "no
  limit" — a capped copy silently became a full-table one. Both now
  require a positive integer.
- resolveGitWorktreePath only looked at cwd, so running dev:pair from a
  subdirectory fell through to the shared home. It walks up to the
  repository root now.
- resolveWorktreeT3Home no longer returns undefined when .t3 is absent:
  inside a worktree that is the answer, and falling back to the shared
  home is precisely the accident the default prevents.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Theo BrowneandClaude Opus 5 committed 2026-07-25 21:59:16 -07:00
1 parent 02594421d2
commit 93f0f96b3f
7 files changed
+295 -57

No files matched your search

+12 -11
View File
@@ -68,21 +68,22 @@ vp run dev --share
What it does, and why:
- **Projections only.** `orchestration_events` is never copied. The projector
cursor is exclusive (`WHERE sequence > cursor`), so an empty event log means
bootstrap streams nothing and leaves the copied rows alone. Copying a partial
event range is the actual hazard — the projector would replay a tail whose
creating events are missing.
- **Writes all nine `projection_state` rows.** Without them
`computeSnapshotSequence` returns 0 and every shell snapshot advertises
sequence 0.
- **Projections only.** `orchestration_events` is never copied, and the target's
own event log is emptied: the copied projections describe a different world,
so replaying the target's retained history over them would resurrect threads
and projects it had deleted.
- **Writes all nine `projection_state` rows, at sequence 0.** Without the rows
`computeSnapshotSequence` returns 0 anyway; with a _positive_ cursor each
projector would skip that many of the first real events — a different count
each — since the cursor is exclusive and the emptied log restarts at 1.
- **Neutralizes live state.** Sessions are forced to `stopped` with no active
turn (a copied `running` session has no agent behind it and would spin
forever, and the session reaper skips anything with an active turn), and
pending approval/input counts are zeroed since approvals are not copied.
- **Copies the intersection of columns.** The two databases are often on
different migrations; a column only one side has is skipped and reported
rather than failing the copy.
- **Tolerates migration drift both ways.** The two databases are often on
different migrations, so a column only one side has is skipped and reported,
a table the target lacks is passed over, and an older source is read with
whichever recency columns it actually has.
- **Refuses to write to `~/.t3`.** It replaces projection tables wholesale, so
the shared home is rejected outright.