Repository navigation
fix: let Doctor repair a release install while its Gateway runs, without lsof or ss - #204017
Conversation
…of or ss A release install's service runs the resident launcher, and the Gateway serves as its child. Maintenance drain accepted that child only from port listener attribution, which needs lsof or ss. Without them Doctor and update repair refused with 'Gateway process changed during maintenance drain' while the same Gateway kept serving. When the listener is unattributed, require the kernel parent of the reporting process to be the service's main process instead.
|
🦞👀 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. |
…ut an owner ss prints a LISTEN row without process details when it cannot see the socket's owner. Treat a busy port whose listener rows all lack a PID like an unattributed one and use the kernel-parent check; rows that name a different PID still refuse.
|
Codex review: needs maintainer review before merge. What this changesAllow maintenance drain to verify a launcher’s Gateway child through kernel parentage when port-listener ownership is unavailable. Example: A Linux release install runs launcher PID 7957 and Gateway child PID 7964 without lsof or ss.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR repairs a source-confirmed Doctor refusal with a focused change, and no introduced correctness defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor and update repair use the shared maintenance drain to connect to the resident Gateway, verify its relationship to the owned service, and authorize a graceful service stop. flowchart TD
A[Doctor or update repair] --> B[Owned service inspection]
B --> C[Maintenance drain]
C --> D[Gateway identity response]
D --> E[Listener or kernel parent verification]
E --> F[Service stop and repair]
F --> G[Gateway restart and verification]
Technical reviewBest possible solution: Keep resident verification in the existing drain owner, using kernel parentage only when no listener identifies its process. Do we have a high-confidence way to reproduce the issue? Current main rejects a serving launcher child when listener attribution is empty; supplied real systemd logs show that refusal and isolate missing attribution by installing ss. Is this the best way to solve the issue? The patch repairs the shared identity check with the existing procfs reader, preserves attributed-listener refusals, and avoids new state, configuration, or competing ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against db2f0c561254. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +8, Tests +42, Docs +5. Total +55 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 23, 2026, 4:58 AM ET / 09:58 UTC. |
|
Merged via squash.
|
…e Node (#203152) * fix(update): drain a Gateway that runtime recovery reran under another Node A service whose Node is unsupported or lacks a recommended security patch reruns the Gateway under a compatible Node as a child of the launcher, so the service's main PID never equals the PID the resident reports. Maintenance drain refused every such update with 'Gateway process changed during maintenance drain'. Accept the resident when every Gateway port listener is that process and its parent is the service's main process, matching restart port ownership. Refs #202954 * docs(update): runtime recovery reruns the Gateway only when its Node fails admission Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit a27f0c3) Release-companions: #204017 is a separate Linux release-install Doctor fallback when lsof/ss cannot attribute listeners; it is not required for this attributed-listener runtime-recovery case. #203486 pnpm recovery, #201668 data-risk repair, and #202591 snapshot cleanup only overlap documentation; #203236 is independent auto-update retry policy. The neighboring native drain suite remains unchanged. Co-authored-by: RomneyDa <[email protected]>
…out lsof or ss (openclaw#204017) * fix: let Doctor drain a release install's Gateway on hosts without lsof or ss A release install's service runs the resident launcher, and the Gateway serves as its child. Maintenance drain accepted that child only from port listener attribution, which needs lsof or ss. Without them Doctor and update repair refused with 'Gateway process changed during maintenance drain' while the same Gateway kept serving. When the listener is unattributed, require the kernel parent of the reporting process to be the service's main process instead. * fix: also drain the launcher's Gateway when ss lists its socket without an owner ss prints a LISTEN row without process details when it cannot see the socket's owner. Treat a busy port whose listener rows all lack a PID like an unattributed one and use the kernel-parent check; rows that name a different PID still refuse.
…ate acts on it (#201668) * fix(update): verify recorded data-at-risk marks before repair acts on them * fix(update): verify any unverified data-at-risk mark and honor receipts in handoff recovery * fix(update): recognize a Git release-mode service as its checkout's own * fix(update): check a recorded data-at-risk mark before the next update, including already-current runs * fix(update): lead data-at-risk refusals with triage and record them on the refused run * fix(update): keep data-at-risk refusals within the recorded warning limit * test(e2e): finish the seeded data-at-risk run with a terminal phase * fix(update): name the agent route in killed-update recovery refusals * fix(update): drop an unused import * test(update): expect the agent route in killed-update refusals * fix(update): verify the newest mark before restoration without comparing run ids * fix(update): address review: keep the Gateway down on any inconsistent mark, resolve all marks, harden release ownership * fix(update): break the admission-root import cycle and type the e2e schema read * fix(update): address rating findings: agent rollback leftovers, helper restart, blocking findings first, shared Git metadata * test(e2e): prove the next plain update resolves a mark with the Gateway running * fix(update): address rating round 2: refuse marks before Doctor, registry-based rollback check, handoff fallback, async history read * test(update): pick the repair run, not a settlement row, in the data-at-risk cell * fix(update): resolve live-writer marks after Doctor holds the state * fix(doctor): say a skipped stale-Gateway stop left the PID running * fix(update): address rating round 3: leftovers before deferrals, retained rollback files, refusal after Doctor fails finalization * docs(update): note retained rollback files and refusals after Doctor * fix(doctor): say a stale Gateway stop could not be confirmed when nothing shows it running * fix(update): address landing review: revert release-mode ownership, check leftovers first, handoff entry guard, durable rollback evidence * test(update): follow main's Git release link layout in the launcher refusal test * fix(update): treat uninspectable leftovers and unreadable databases as unchecked; true wording after Doctor Release adaptation: Retain the stable installed-recovery harness. Do not add main's installed Docker service cell, later retired by #203808, or Git release-launcher wording/test because stable uses the in-place Git updater. Keep the state-verification, next-update, repair and interrupted-handoff paths and their compatible regressions. Companion audit: #203486 is present-equivalent at 3081077 (preserved). #201978 is selected next in this lane. #203808 and #203966 involve the inapplicable installed service-cell layout; #203497 and #203194 change main's package/Git activation layout and are not applicable; #204017 depends on that release-install layout. #204077, #204043, #203555 and #203520 are independent authority, cleanup, helper-fixture and config-validation changes. #204151, #203917, #203849 and #203406 are separate guidance, cleanup or status changes, not required by the data-risk verifier. #203569 fixes a separate cron receipt fixture in the same Doctor suite; the touched stale-stop cases do not depend on it. (cherry picked from commit a28f211) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit f8d4bc138ed2512c413cf96f66fe0eefb3b28d65)
…out lsof or ss (#204017) * fix: let Doctor drain a release install's Gateway on hosts without lsof or ss A release install's service runs the resident launcher, and the Gateway serves as its child. Maintenance drain accepted that child only from port listener attribution, which needs lsof or ss. Without them Doctor and update repair refused with 'Gateway process changed during maintenance drain' while the same Gateway kept serving. When the listener is unattributed, require the kernel parent of the reporting process to be the service's main process instead. * fix: also drain the launcher's Gateway when ss lists its socket without an owner ss prints a LISTEN row without process details when it cannot see the socket's owner. Treat a busy port whose listener rows all lack a PID like an unattributed one and use the kernel-parent check; rows that name a different PID still refuse. (cherry picked from commit cff8782) Backport review: #205736 changes update cohort settlement and #204676 changes Git service layout; their only overlap is the update docs. Neither is a prerequisite for resident-child proof. Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Related: #202954 (same refusal class; #203152 fixed it for hosts that have
lsoforss)What Problem This Solves
After
openclaw updatemoves an install onto releases, its Gateway service runs the resident launcher (~/.openclaw/git-install/openclaw-launcher.mjs) and the Gateway serves as the launcher's child. On a Linux host withoutlsoforss,openclaw doctor --fixwith the Gateway running stops with exit 1:Nothing changed: the same launcher and child keep serving before and after. Doctor is the repair path that update messages and docs point to, so on this layout it does no repair and tells the user to stop services by hand.
openclaw update repairruns the same maintenance stop.User Impact
On a release install,
openclaw doctor --fixandopenclaw update repairnow do their maintenance with the Gateway running and bring it back, as they already do on an in-place install, whether or notlsoforssis installed. No step is left to the user.Why This Change Was Made
Maintenance drain must confirm that the Gateway answering on the port is the service's own before it stops the service. When the service's main PID is a launcher, #203152 accepts the child only from port listener attribution (
lsoforss): every listener is that PID and its parent is the service's main PID. Without either tool the listener is unattributed, the check fails, and the drain reports a changed process that never changed.The fix stays in that one check (
isServiceResidentinsrc/cli/update-cli/update-command-service-drain.ts, the single owner every drain caller uses). When the port is busy but no listener names its process, it accepts the reported PID only if its kernel parent (/proc/<pid>/stat,readLinuxProcessStat) is the service's main PID. Attributed listener evidence still decides when present. A Gateway that is not the service's child, a host with no procfs, and a Gateway replaced mid-drain (boot id pin) are still refused. When no listener row names a PID (nolsof/ss, orsslists the socket without an owner), it accepts the reported PID only if its kernel parent is the service's main PID; a row that names another PID still refuses. Production change: about 10 lines plus an import. No config, stored field, schema, protocol, dependency or permission change.Route served (bridge rule in
src/cli/update-cli/AGENTS.md): Doctor's maintenance stop andopenclaw update repairon owned release installs, plus the immutable-activation and in-place stops that share the drain. The release update path insrc/update/restarts through the Gateway itself and has no equivalent check, so it needs no change.Update behavior for published updaters: the check runs in the installed CLI, so an install gets this fix when the release it runs contains this commit. A release install made by main before this change gets it on its next
openclaw update; that update runs throughsrc/update/, which restarts the Gateway through the Gateway itself and does not use this drain, so it is not blocked by the bug. Published in-place updaters (2026.11.7 and earlier) never create release installs. Their Gateway runs as the service's main process unless runtime recovery reran it under another Node (#202954); on such a host withoutlsoforss, they keep refusing until the install runs a release with this fix. No backport is intended. The release-install layout exists only on main.Steps left to a person: none.
Root cause and hypotheses ruled out
origin/mainc40587d3511(real systemd cell, below): launcher PID 7970 and Gateway child 7977 have the same PIDs, start times andNRestarts=1before and after Doctor. The journal shows no stop or restart. This rules out (a) the launcher replacing its child during the drain and (c) a restart racing the drain.origin/mainbuild and cell with onlyiproute2(ss) installed before the cell. Doctor exits 0, does its maintenance, and reports "Gateway restarted and verified after Doctor maintenance." The only difference is listener attribution, so missinglsof/ssis the cause.lsofand noss.psis present.pid === runtimePidpath accepts it. The launcher takes over at T to T1.Evidence
All cells: published
[email protected]installed with npm, real systemd user Gateway service written byopenclaw gateway install, 256 MiB agent database with a busy writer, thenopenclaw update --yesto T (2026.11.11) and T1 (2026.11.12), a no-op update, then the step shown. T and T1 are built from the named source commit plus a version-bump-only commit. Docker on OrbStack with systemd as PID 1; synthetic state only. Each candidate step is a published updater (2026.11.6) driving the candidate, which makes it the published-driver × candidate cell.lsof, noss)origin/mainc40587d3511openclaw doctor --fix --non-interactive --yes, Gateway runningc40587d3511withssinstalled33fd225, driver published 2026.11.7 (currentlatest)09618b0, driver 2026.11.633fd225from 2026.11.7openclaw update repair --yes, Gateway running09618b0from 2026.11.6openclaw doctor --fixon the release install with the Gateway stopped bysystemctl --user stop--fix --yesThe outage is Doctor's own stop, repair and verified restart, and it matches the falsifier's 46.8 s on base. The update hops in all three cells exit 0 (T: 165 s with a 59.5 s outage; T1: about 110 s with a 12 s outage), which also makes them the published-driver (2026.11.6) × candidate cells.
Decisive raw lines (RED, then GREEN)
Update proof rules (#203915), from the cells' raw logs:
openclaw update --yes. The shipped updater's run records triggercli, and the candidate hops record triggerapi. The Gateway journal has[gateway] update.run <runId> actor=gateway-clientfor both candidate hops in the red, green and green-2026.11.7 cells. NoOPENCLAW_UPDATE_PACKAGE_SPEC,--tag,--no-restartor shortened--timeoutwas used.openclaw gateway install. After each step the cell saved the unit'sExecStart,MainPID,NRestarts,ActiveStateandSubState, and the running process tree.ExecStartis the package entry before the first release hop and~/.openclaw/git-install/openclaw-launcher.mjs gatewayafter it.NeedDaemonReloadwas not captured.33fd225. The final headba03d34adds only a merge ofmain, andgit diff 33fd225 ba03d34is empty forsrc/cli/update-cli,src/daemon,src/infra/ports-inspect.ts,src/shared/pid-alive.ts,src/cli/daemon-cli,src/commands,src/updateanddocs/cli/update. Publicnpm view openclaw dist-tagsat landing:latest2026.11.7 (the driver of the final green cell),beta2026.11.10-beta.1,extended-stable2026.10.33.src/update/launcher.ts,run.ts,preflight.tsorconvert-service.ts, so the T to T+1 to T+2 rule does not apply.Adjacent guards (behavior unchanged, base vs head):
c40587d3511--fixon a plain in-place install (after the first hop), Gateway running--fixon the release install, Gateway stopped withsystemctl --user stop--fix --yeskeeps recovery)Negative control for a Gateway that is really not the service's: covered by the unit table (another parent, another PID, no procfs, boot id change) because a foreign Gateway cannot be injected mid-drain in the cell. Final head
ba03d34is33fd225plus a merge of unrelatedmaincommits; none touch update, Doctor, daemon, port inspection orsrc/update/.Unit regression (
src/cli/update-cli/update-command-service-drain.test.ts): the launcher-child table gains unattributed-port cases (no listener rows, and a row without a PID). On basec40587d3511the three "kernel parent is the launcher" cases fail withGateway process changed during maintenance drain(3 failed, 69 passed). On the head, 72 of 72 pass. Negative controls in the same table: an unattributed port whose kernel parent is another process (normal and explicit drain), no procfs, and attributed listeners of another PID (even when the kernel parent matches), and a PID-less row next to a row naming another PID. All are refused and the native stop is never called. The existing boot-id case still refuses a Gateway replaced mid-drain.Checks on the head: focused tests including
test/scripts/update-restart-module-outcome.test.tsandtest/scripts/eager-import-closure.test.ts(all pass),pnpm tsgo:core,pnpm tsgo:test:src, oxlint on touched files,pnpm check:docs, the session identity ratchet,pnpm check:baseline-ratchets --base 08eaf404075 --no-merge-base, andgit diff --check: all pass.Recordings: replay of each cell's raw step output, home paths shortened to
~. Full raw logs are not attached because the Crabbox artifact store rejected uploads from this machine (http 401).RED (unmodified
origin/mainc40587d3511):doctor-release-red.mp4
FALSIFIER (same base,
ssinstalled):doctor-release-falsifier.mp4
GREEN (first PR commit, driver 2026.11.6):
doctor-release-green.mp4
GREEN (final PR code, driver 2026.11.7):
doctor-release-green-final.mp4
Tests audited: the whole of
update-command-service-drain.test.ts(fixtures, helpers, imports, setup and teardown). The launcher-child table was extended in place, not duplicated. The newreadLinuxProcessStatmock is reset tonullinbeforeEach. Nothing was removed. An independent reviewer audited the file; its two suggestions (cover the explicit-drain refusal, and word the fallback as "unattributed listener" instead of only "no lsof or ss") are applied. A ClawSweeper local review (one round, GPT 6.2 Sol) found thatsscan list the socket with no owner; that input is now handled and tested, and the 2026.11.7 driver cell it asked for is above.autoreviewdoes not run on this machine.Not proven
lsof; no launchd cell was run.src/update/launcher.tsforks the Gateway as a child), so the same check applies, but no Git-checkout cell was run.ssruns but cannot see the socket's owner take the same fallback. This is covered only by the unit test.systemctl --user stopon the launcher service leaves the unitfailed(launcher exits 1 after force-terminating its child), on base and head alike.