Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
9e33d7c to
3c903dd
Compare
Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
… slot results Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
Co-authored-by: obviyus <[email protected]>
…uncher, stage per attempt - chat /update and the Control UI stage the runtime slot inside the Gateway, restart it, and the Gateway that confirms or rolls back the slot finishes the update run - a slot layout's Gateway service runs <state>/runtime/launcher.mjs; the first slot update rewrites the service once - each staging attempt uses its own directory and renames onto the slot, so an orphaned npm/pnpm child cannot block or corrupt the next update - git slots import pnpm packages with clones or hardlinks - drop OPENCLAW_RUNTIME_SLOT and OPENCLAW_RUNTIME_TRIAL: a Gateway reads its trial from slots.json Co-authored-by: obviyus <[email protected]>
…ncher Co-authored-by: obviyus <[email protected]>
d9e52d0 to
b38809a
Compare
…ackage, Bun, app and container installs Co-authored-by: obviyus <[email protected]>
The task supervisor stays on the origin install; each Gateway child it starts reaches the launcher through the origin entry. Co-authored-by: obviyus <[email protected]>
… delete the in-place updater entry openclaw update, the wizard, Doctor's update offer and automatic updates now dispatch only to immutable activation or runtime slots. The hidden protocol subcommands that earlier releases' helpers call (admit, preflight, finalize, migrate/restore/finish, migration-plan) stay registered for the upgrade window. update repair now points at doctor --fix. Co-authored-by: obviyus <[email protected]>
|
Closing in favor of #198835, which reaches the same goal (stage the new release beside the old one, switch with one rename, roll back by switching back) through the linked package root accepted in #197949. That design rejects the launcher and service-definition rewrite this PR uses. Git checkouts are out of scope for #198835 and keep the copy-and-swap. A possible route for them from this branch: |
What failed in the field
openclaw updatechanges the running install in place, then stops, rewrites and restarts the service. Most failures happen in that activation step, after the candidate already passed its checks.XDG_RUNTIME_DIR/D-Bus in cron, a different PID namespace. Two more were the 256 MB pack cap on a git update that had passed every check.evidence/class*.jsonl, layerservice: 295 reports. Largest causes: managed-service handoff/preflight/stop failed (~75), service file not regenerated or regenerated wrongly (~30), Gateway left stopped after the update (~25), ownership/manager identity not verifiable (~15), systemd/launchctl inspection deadlines and a missing user bus.What changed
An update only ever writes into a runtime slot that no Gateway runs, and switches with one rename.
openclaw update, chat/updateand the Control UI use the same path on Linux and macOS for user npm and git installs.Layout
<state>/runtime/:launcher.mjs— frozen copy ofscripts/openclaw-runtime-launcher.mjs(~100 lines, no dependencies). Written once, mode set withfchmod(not the umask).slots.json—{current, previous, origin, trial?, failed?, run?}. Every write is temp + fsync + rename(2).a/,b/— the two slots.originis the existing install and is never changed by a slot update.Update:
.stage-<slot>-<uuid>, then rename it onto the slot. npm:npm install --prefix. git:git worktree add --detachof the checkout (shared object store), thenpnpm install --frozen-lockfile --package-import-method=auto(copy-on-write clones or hardlinks from the pnpm store) andpnpm build, thengit worktree move. No copy, no pack cap. A killed updater's orphaned npm/pnpm child writes only into its abandoned stage directory.<slot>/openclaw.mjs --versionwith the Node named in the service definition (read from the unit/plist file, notPATH).slots.json:{current: slot, previous, trial: 2, run?}.systemctl --user restart/launchctl kickstart -k; neither answers → "applies on the next Gateway start", exit 0), then wait up to 180 s for confirmed (exit 0), returned (exit 1) or pending (exit 0)./update/ Control UI (update.run): the Gateway acknowledges, persists the restart sentinel, stages in-process, flips, then restarts itself. The Gateway that confirms the slot finishes the update run assucceeded; a Gateway the launcher returned to finishes it asrolled-back. The existing run watcher delivers the chat notice.gateway install --forceonce (its program arguments now name the launcher) and that restart is the update's restart. Without a reachable service manager the update uses the restart request instead; the origin entry still hands off to the launcher (below), and the next CLI update or Doctor repair rewrites the unit.Start:
node <state>/runtime/launcher.mjs gateway --port N. The launcherexecvescurrent/openclaw.mjs(same PID: supervisor identity and existing ownership checks do not change).trialis set spends one attempt; at zero the launcher selectspreviousand recordsfailed(keepingrun). A Gateway on trial exits 1 instead of 78 on config errors, soRestartPreventExitStatus=78cannot park a bad slot. It reads its trial fromslots.json; there is no new environment variable.trialwhen it reports "gateway ready" (listening, channels started).program-argsnames the launcher for every Gateway service of a slot layout, sogateway install, Doctor's expected plan and the update agree; the service definition never changes when the version changes.service-layoutmaps a launcher entry to the selected slot, so status and Doctor drift checks compare the right package root.PATH, node-host services and units that still name the origin entry runruntime-slot-redirect.mjsfirst, which hands off to the launcher (a CLI call never spends a trial).The updater needs no D-Bus,
XDG_RUNTIME_DIR, Node onPATH, umask or PID namespace. It holdsruntime/update.lockwith a heartbeat; a killed updater's lock goes stale after 60 s.What got deleted, and what did not
doctor --fixremoves leftoveropenclaw-update-runtime-*directories again (Report on 78 days of automated upgrades on the dev branch using Codex #197195: 48 retained runtimes, 142 GB).openclaw updatenorupdate.runreaches runtime retention, update-capture sets, the managed-service stop/handoff, the service-definition refresh or the in-place swap.--recovery/resume workers and the Doctor source update still run it, and fix(update): refuse missing host prerequisites in one line and record a cause per attempt #198355 (plan item 3) and the copy-and-swap work (plan item 4) edit those files. Deleting it is the next stage: move Windows onto slots (needs a Windows VM proof), then remove the in-place pipeline, retained runtimes, capture sets, the process census and service regeneration in one cutover. See design note 1.Lines vs. the PR #198268 head: production +1344 −57; tests +212 −152; docs +37. Net production is still positive; see "Open" below.
Proof
Status: partial. Runs below are on
60f8c83/d9e52d0(same slot code as the current head except the service-port fix inb38809a). Hosts: OrbStack Ubuntu 24.04 VM (systemd user service) and macOS 27 (launchd). Each run starts from a fresh install of this head as 2026.11.3 whose service still runs the origin entry. Updates run cron-like (env -i,umask 077, Node offPATH, no D-Bus).<state>/runtime/launcher.mjsfailedrecorded, exit 1, healthy 5 s later/update/updatethrough a non-owner client and got the owner refusal; rerun through an owner chat client is pendingGit slot disk (btrfs VM,
dfdelta): worktree checkout files 855 MiB;node_moduleswith--package-import-method=hardlink33 MiB (vs. ~3.1 GiB copied before);dist~480 MiB per slot is the remaining cost.Found by the proof and fixed: the first launcher rewrite dropped the service's
--port(macOS Gateway moved to the configured port; fixed inb38809a).Open
check-lint-core-3flags three files this PR does not change (same oxlint result on the base).help-exit.process.test.tsreproduces red on baseb6c6aef. The qa-lab e2e,update-command-runtimeand Codex worker reds are not yet reproduced on the base; perf(update): replace the candidate canary with a runtime contract check #198268's own CI skips these jobs, and main is green.Accepted edge cases
current)..pre-<ver>); until it lands, an old slot can refuse a newer state schema.origin/main(dev) orv<release>tags (stable/beta); a pinned dev target must be reachable fromorigin/main. Custom upstreams are not followed.Design note: owner decisions
current. A developer who wants their own edits runs another worktree.Coordination
update-slots.ts.