fix(server): validate update rollback boundaries

This commit is contained in:
Theo Browne committed 2026-08-01 00:07:09 -07:00
1 parent c072888cff
commit cd25a3de9a
14 files changed
+499 -48

No files matched your search

+9 -4
View File
@@ -90,9 +90,12 @@ successfully. Boot-service setup and self-update share the same process-wide ins
they cannot mutate a pinned runtime concurrently.
Before any restart, the current Node executable runs the replacement with `--version`, then asks
the target artifact to validate its migration identities against the live database in read-only
mode. A failed install, version preflight, or compatibility check leaves the current server running.
Targets old enough to lack the compatibility command are not eligible for remote activation.
the target artifact to validate the live database in read-only mode. Automatic activation requires
the target and database to be on the exact same migration frontier. This rejects both downgrades and
updates that would migrate the database because a binary rollback cannot undo a schema change. Use
the manual host service update path for those releases. A failed install, version preflight, or
compatibility check leaves the current server running. Targets old enough to lack the compatibility
command are not eligible for remote activation.
Candidate cleanup is narrower than "any failed preflight". The candidate runtime is removed only when
the preflight process actually completes and reports a bad exit code or the wrong version: that is
@@ -118,7 +121,9 @@ For `boot-service`, the request process writes a typed plan but leaves its live
starts a fixed-name `t3code-self-update.service` transient unit with `systemd-run --user`; the
transient unit has a separate cgroup and acts as the cross-process update lock. After a short grace
period it atomically installs the candidate unit, reloads systemd, performs a blocking restart, and
probes the public environment descriptor for the exact target version. If activation or readiness
probes the public runtime-readiness endpoint for the exact target version. The endpoint does not
respond until the server's command runtime is usable and its lifecycle `ready` event has been
published, so an HTTP listener alone cannot make an activation healthy. If activation or readiness
fails, the helper restores the previous unit, clears systemd's failed state, restarts it, and proves
the previous version is ready. The plan and latest receipt live under the environment state
directory's `self-update` folder for diagnosis.
+17
View File
@@ -190,6 +190,23 @@ connect the new client to a server on the previous version and verify that the u
reconnects to the matching server. Test one automatic path and the manual or desktop-managed
guidance when those environments are available.
The automatic boot-service path also requires a real systemd user-manager acceptance run. Use a
disposable T3 home and uniquely named host and helper units, never the developer's daily
`t3code.service`. Exercise both outcomes:
1. A same-migration-frontier candidate becomes runtime-ready, the helper survives the host-unit
restart, and the receipt reaches `healthy` with a new runtime PID and the exact target version.
2. A candidate that binds HTTP but never becomes runtime-ready times out, the previous unit is
restored, and the receipt reaches `rolled-back` with the old version command-ready again.
Treat the systemd run as a release blocker when the update lifecycle changes. CI jobs without a
user manager may skip it, but a Linux release host must record the run before publishing.
```bash
T3_SYSTEMD_SELF_UPDATE_ACCEPTANCE=1 vp test run \
apps/server/src/cloud/systemdSelfUpdate.acceptance.test.ts
```
## Desktop auto-update notes
- Updater runtime: `apps/desktop/src/updates/DesktopUpdates.ts`.