Open History to see the last commit
1# Server updates
2
3A [stable launcher](../../apps/server/src/serviceLauncher.ts) owns the runtime
4selected by systemd or launchd. It is the only runtime writer of durable service
5state. Server children request updates over inherited IPC; they never rewrite
6their service definition or select their own replacement. Local service commands
7may replace the launcher and state while the service is stopped. Foreground CLI
8processes do not self-update.
9
10Exact-version installs keep restarts independent of npm cache eviction or a moving
11release tag. Installation and preflight happen in staging before publishing an
12immutable runtime. Preflight checks the launcher protocol because a target that
13needs new rollback guarantees cannot safely run under an older launcher. Upgrading
14that launcher requires a local service update.
15
16## Commit boundary
17
18The launcher durably records the pending update before acknowledging it, then
19stops the old child and starts the target as a trial. Service-state writes use
20same-directory replacement with file and directory fsync. Invalid state stops
21startup rather than guessing which runtime to boot.
22
23The trial must finish migrations, acquire dependencies, bind HTTP, and park every
24long-running root at the activation gate before reporting `prepared`. The launcher
25then commits the target version durably and replies `committed`. Only then may the
26child release its gates, accept commands, and publish ready. Keep fallible startup
27acquisitions before this boundary. A listener alone does not prove the runtime is
28ready to commit.
29
30A failed or timed-out trial returns to the old version. After commit, the target
31is authoritative and the service manager's ordinary restart policy applies.
32
33## Database rollback
34
35After the old child exits, the launcher snapshots SQLite's main file, WAL, and
36shared-memory file. This makes trial migrations reversible without down
37migrations. The snapshot is made once per update and survives launcher restarts;
38replacing it during a retry could capture changes from the failed trial.
39
40Rollback stops the trial before restoring. A durable restore marker makes an
41interrupted restore finish before either version boots. Keep the snapshot until
42commit, or until both restoration and the terminal rollback state are durable.
43Attachments and other files outside SQLite are outside this rollback boundary.
44
45## Client acknowledgement
46
47An accepted update is still pending. Clients correlate the launcher's update ID
48with the ready event after reconnecting, then check the outcome and target version.
49A reconnect alone cannot distinguish successful replacement from rollback. Older
50servers without an update ID retain version-only correlation.
51
52Desktop updates have a separate two-phase handoff because installing the app stops
53its bundled backend. Preparation returns a token while the connection is alive;
54the client commits that token only after receiving it. Otherwise backend shutdown
55could lose the only successful RPC result. The client must then observe the
56prepared version after reconnecting. If installation fails, desktop restarts the
57stopped backends and replays the failure for the same token.