Two more from Macroscope review:
- `ORDER BY COALESCE(...)` throws on a source down to one recency
column. SQLite requires at least two arguments, so the pre-017 schema
the column filter exists to support was exactly the case that aborted.
Emit the column directly when only one survives the filter.
- `seedDevDatabase` accepted non-positive limits. Both are bound into
`LIMIT ?`, where SQLite reads a negative as "no limit" — a caller
bypassing the CLI flags silently got a full-table copy instead of the
bounded one the options contract promises. Rejected before the target
is touched, alongside the existing upper-bound check.
Both regression tests confirmed failing without their fix.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Self-review of the settle path, which has been the source of every
regression in this branch. The server filters `turnId !== null &&
state === "running"` before settling; this filtered only on state.
No row is both null-id and running today — the sole null-id insert
writes 'pending' — so this changes no behavior. It is the invariant the
UPDATE already depends on, written down where it is relied upon, and it
keeps the two predicates directly comparable if a null-id running row
ever becomes possible.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Three findings from Macroscope review:
- Settling `pending` rows to `interrupted` was the wrong verb. The server
deletes them (`clearPendingProjectionTurnsByThread`) once the turn
starts or the thread stops, and never settles one in place. They also
cannot be settled coherently: `turn_id` is NULL, so an "interrupted"
pending row is a terminal turn with no id, a shape no real turn has.
Now deleted, matching the server's predicate exactly so a checkpoint
row is never caught by it.
- `COALESCE(completed_at, requested_at)` preserved a stale completion on
a running turn. One can carry a completion from an earlier settle that
a later checkpoint reverted to "running" — the `...existingTurn` spread
in ProjectionPipeline keeps the old value — and dating the interruption
to that checkpoint gives a wrong duration. Overwritten unconditionally.
- The CLI hard-coded `<base>/userdata/state.sqlite` while a dev server
under an implicit dev home stores state in `<base>/dev`. A main-checkout
`bun run dev` was therefore unseedable, and said so by claiming no
database existed and suggesting the user start the server that was
already running. Source and target now follow whichever directory holds
a database, `userdata` breaking the tie; attachments follow the same
directory. Verified both a dev-only target and the precedence order.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The cap was declared in the CLI while the constraint belongs to the
seeder's statements, and the number appeared in three places. That split
is the mechanism behind the last regression: a change to a statement in
the library silently invalidated a bound stated in the CLI, and the
mismatch only surfaced at the maximum — after the target was emptied.
Move it to `MAX_SEED_THREAD_LIMIT` beside the statements that have to
satisfy it, have the flag derive its bound from there, and check it in
`seedDevDatabase` before anything is opened so a caller bypassing the
flag fails while the target is still intact.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Adding "pending" to the settled states bound them as parameters, costing
two bindings on top of one per thread. `--threads` is capped at 32766 —
SQLite's ceiling — so the documented maximum landed exactly two over and
threw "too many SQL variables", after the target had already been
emptied. Inline the literals; they are internal constants, never input.
The regression test seeds at the cap for real rather than asserting the
statement text, since the property is that no code path adds a binding.
Fixture rows are batched into one transaction and the scale case builds
thread rows only, keeping it near a second.
Caught by Macroscope review.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Follow-up review of the pairing path and a second pass over seeding:
- `isPersistedServerRuntimeStateLive` reported non-positive pids as live.
`process.kill` reads 0 and -1 as signal-group targets rather than
process lookups, so neither throws and both were caught by the "it
didn't throw, so it's running" branch. A truncated or hand-edited file
recording either would be believed forever — the dev candidate wins the
devUrl preference, so it also outranks a genuinely live server
elsewhere and mints tokens into a database nothing reads. Rejected in
the schema and re-checked at the call site; the errno cast is now a
guard, since an out-of-range pid throws a TypeError with no `code`.
- `pairing url --json` emitted warnings on stdout ahead of the payload.
The probe reads both state directories, so a corrupt file in the one
*not* in use broke JSON for any consumer piping it; the quiet-logs
layer was only applied around the issuing step that runs after. Verified
with a crafted fixture: stdout is now valid JSON.
- Turns copied in the `pending` state were left unsettled. Same defect as
the `running` case fixed previously — a user message accepted before its
provider turn started, which only that thread's next message would ever
clear.
- The source was read across a dozen implicit transactions while the
installed app may be writing to it, so a project could vanish between
the query that selected it and the copy that read its row. One deferred
read transaction pins every query to a single snapshot.
- `--from` and `--to` resolving to the same directory is now refused. Not
for the data loss it appears to be (the source reads a pre-transaction
snapshot, so the rows come back — verified in both journal modes), but
because the event log, the cursors, and everything outside the caps do
not.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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]>
* Stage production icons for desktop builds and publish
- add shared brand asset paths and a Windows .ico asset
- stage Linux/Windows icons in desktop artifact builds
- override and restore publish favicon during server CLI publish
* 'blip'
* Fix PR review issues for publish icon staging
* Refactor brand assets and harden Windows desktop build setup
* Apply remaining server orchestration updates
* Fix production mac icon asset
Co-authored-by: Theo Browne <[email protected]>
---------
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Theo Browne <[email protected]>