Open History to see the last commit
1# Server updates
2
3## Launcher ownership and compatibility
4
5A [stable launcher](../../apps/server/src/serviceLauncher.ts) owns the runtime selected by systemd,
6launchd, or Task Scheduler and is the only runtime writer of durable service state. Server children
7request updates over inherited IPC and never rewrite their service definition. Foreground CLI
8processes do not self-update.
9
10Remote updates replace only the server child, not the launcher, so every existing background service
11lags behind after a launcher-protocol bump. Keep new server runtimes compatible with the previous
12launcher protocol unless impossible, and validate protocol compatibility during preflight.
13
14Installations use exact versions and stage/preflight before publishing an immutable runtime so
15restarts never depend on npm cache eviction or a moving tag.
16
17## Commit boundary and database rollback
18
191. Record the pending update durably (atomic rename + fsync) before stopping the old child.
202. Refuse the update if a database snapshot will not fit on disk. After the old child exits, snapshot
21 SQLite (main, WAL, SHM) once per update so failed trial migrations are reversible without down
22 migrations. Never overwrite that snapshot on retry. Files outside SQLite (such as attachments)
23 are outside this rollback boundary.
243. Start the new runtime as a trial. It must finish migrations, acquire fallible dependencies, bind
25 HTTP, and hold long-running roots at the activation gate before reporting `prepared`.
264. Only after the launcher commits the new version durably and replies `committed` may the child
27 release activation gates and accept work. A failed or timed-out trial stops and restores the
28 snapshot before booting the old version.
29
30## Client acknowledgement
31
32An accepted update RPC is only pending. Clients correlate the launcher's update ID with the
33reconnected ready state to distinguish commit from rollback. Desktop updates use a two-phase handoff
34(prepare token while connected, commit after receiving it) because installing stops the bundled
35backend.
36
37## Recovering interrupted threads
38
39- On startup, retire effects tied to the lost process before admitting new work.
40- Persist restart-continuation intent in the durable outbox and wait for activation before running
41 it so slow providers never delay readiness or the launcher's commit boundary.
42- Cap consecutive crash recoveries per unfinished turn so a crashing turn cannot loop forever.
43- Never auto-continue a turn that is archived, settled, snoozed, user-stopped, or waiting on a
44 blocking user action (approval, question, or secret).