Skip to content

fix(doctor): restore Gateways after systemd inspection failures - #153017

Merged
steipete merged 6 commits into
mainfrom
upd/systemd-loadunit-restoration
Sep 20, 2026
Merged

steipete merged 6 commits into
mainfrom
upd/systemd-loadunit-restoration

Conversation

@steipete

@steipete steipete commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #152879

What Problem This Solves

Fixes openclaw doctor --fix leaving a healthy systemd user Gateway stopped when repeated update-admission checks exhaust restoration inspection. Thanks @xilopaint for isolating the LoadUnit delays and providing the timing trace.

User Impact

Doctor restores and verifies the service it stopped when inspection is inconclusive. Explicit ownership refusals remain refusals with their actual reason. Before stopping a systemd Gateway, Doctor retains its native manager and account identity; activation revalidates that identity before both reset-failed and start/restart. If the identity cannot be captured, Doctor leaves the service running and reports the diagnostic warning. Deadline failures identify the inspection budget and guards instead of prescribing session-bus repairs.

Machine-mode lint failures retain exit 2 and their redacted error object while also emitting the readiness fields required by published updaters.

Why This Change Was Made

Metadata-only LoadUnit inspection now uses Doctor's lightweight custody check. Full update admission remains around inspection and activation. Typed ownership refusals now survive service discovery, runtime projections, nested errors, and Doctor restoration. The native lifecycle owner revalidates the retained unit, service account, broker ID, manager unique name, and manager UID, then sends activation on the same broker connection to that specific manager. There is no unbound systemctl fallback after a native refusal. This additional native code is necessary because a root-privilege check does not establish ownership of the service being restored.

The Doctor output owner also preserves the released readiness envelope on runtime exceptions; the frozen 2026.9.5 validator protects success, warning, and failure output independently of the current reader.

Evidence

Final candidate: d42cefb21114eca1b172c392398d17e7992865fc. node scripts/check-changed.mjs --base 89d4fde384f4b54d2997ad3f378b40b3f8ae7b8b and git diff --check passed.

  • Linux before/after: injected 2602 ms and 4770 ms full-guard delays left the baseline Gateway inactive with PID 0. The candidate selected lightweight custody, restored the unchanged unit, and verified health.

  • Published 2026.9.5 → candidate through openclaw update --tag file:<candidate> --yes --json: exit 0, terminal succeeded, no rollback, exact candidate build and Gateway readiness verified. Subsequent doctor --fix --non-interactive with the same delay instrumentation restarted the upgraded Gateway with a new PID, unchanged unit hash, and healthy status.

  • Blacksmith Testbox tbx_01m2x4d6dxz4m5dx5zs9xgf4e7, Linux x64/systemd 255/Node 24.19.0 (lease workflow); isolated service accounts and ports. Native wrapper exit 0; lease stopped after proof.

  • Compatibility attribution: the earlier failing fixture set OPENCLAW_DISABLE_BUNDLED_PLUGINS=1. Lint then could not load the memory health API and emitted {ok:false,error} without checksRun or findings. The same exception route exists in v2026.9.5: this was a fixture-triggered, preexisting failure-envelope gap, not a post-9.5 success-schema regression affecting every update. A native control without that flag emitted ok:true, checksRun:3, and findings:[], accepted by the frozen reader. The successful update proof uses normal plugin discovery.

  • The frozen validator comes from release commit ec9c1a13db8938e5a3eaa51fca2e981cde2395a9, reader blob 11aa934996ef1bd6bf1afe571e897cfb6efd982f. It ignores unknown fields, so additive schemaVersion and retained error metadata are accepted. Its rejection reproduced before the emitter fix; the repaired failure remains non-successful and passes validation.

  • Refusal regressions fail against the previous owner: Doctor attempted activation in four refusal cases, and five native identity-drift cases reached unbound systemctl activation. The fixed tests exercise direct/wrapped/runtime refusals, diagnostic recovery, account reassignment, manager replacement, broker replacement, and authority loss.

  • Seven Doctor production-path tests use the real maintenance flow, service registry, native readers, identity revalidation, and lifecycle owner; only host transport and health RPC are isolated. The native activation tests assert zero reset/start calls when the captured owner has changed.

  • New real Linux native proof: Blacksmith Testbox tbx_01m2xq5bq0a4aera38pgdan1sg, systemd 255/Node 24.19.0 (lease workflow), wrapper exit 0. Owned system/user units start successfully through the candidate native lifecycle. Reassigning the system unit to another account returns systemd-account-refused; restarting the task-owned user manager returns systemd-manager-changed. Both refused units remain inactive and produce no start marker. Fixtures and lease were cleaned up.

  • The new live proof exercises real native activation using task-owned synthetic service units; the full Doctor wiring is covered by the production-path tests. The earlier real Gateway delay and published-updater proofs above are retained; this P1 follow-up does not change the readiness emitter or frozen released-reader contract.

  • Launchd: the same catch could misreport a refusal, but start/restart already call assertNoSystemLaunchDaemonOwnership before enable/kickstart/handoff. Those independent refusal guards remain intact; the shared typed outcome now also preserves the reason in Doctor. Launchd sibling tests pass.

  • Final focused rerun after rebasing onto 89d4fde384f4b54d2997ad3f378b40b3f8ae7b8b: 1,117 tests passed across 29 files (750 daemon, 18 CLI subprocess, 278 CLI, 71 Doctor). Main changed the pinned fs-safe dependency; the worktree was reconciled with the frozen lockfile before this successful rerun.

  • Fresh independent Codex autoreview is scoped-clean at P1. The four-commit rebase was mechanical: range-diff reports every patch unchanged. Subsequent test-fixture lint corrections passed all 16 affected cases and a fresh full-candidate P1 review on the rebased source.

Native proof output (task-owned synthetic units):

{"proof":"native system restoration","started":true,"twoStringStartReply":true}
{"proof":"account reassignment","refusal":"systemd-account-refused","started":false}
{"proof":"native user restoration","started":true,"twoStringStartReply":true}
{"proof":"manager replacement","refusal":"systemd-manager-changed","started":false}

ClawSweeper disposition

Addressed [P1] Preserve native ownership refusals before falling back to start (review), reviewed on ad5b4c6979cf538c654fdce73491054b97cc1de8. Native validation produces a typed refusal, all restoration projections preserve it, and Doctor reports it without activating the service. Diagnostic failures still permit restoration through retained native identity. Account and manager revalidation now belongs to the native activation owner before each effect; root privilege alone cannot authorize restoration. The new production-path tests and real native refusal traces address the requested authority-chain proof.

P1 repair: production +603/-64 lines (net +539), tests +882/-16 (net +866), documentation +6/-1. Full PR against the rebased main: production +783/-130, tests and frozen test support +1199/-77, documentation +20/-6. No configuration, CLI, environment, schema, or dependency contract is added.

Latest ClawSweeper pre-merge disposition

The latest exact-head ClawSweeper review of 344557a63b6b2264300fb67b1ae6b6f7f5a389cb at 2026-09-20 04:59 UTC reports no actionable code findings and accepts the recovery, upgrade, and native refusal evidence. Its remaining request, Add data-model compatibility proof, is addressed by the published 2026.9.5 → candidate update and frozen released-reader proof recorded above.

The data-model detector's references to doctor-lint.ts and doctor-maintenance.ts do not represent a persistent schema migration: the former formats the transient stdout readiness envelope, and the latter retains service identity within the maintenance operation. This PR adds no database tables, columns, schema version, persisted record format, or migration/backfill. A database migration test is therefore not applicable. The relevant external compatibility contract is the published updater's readiness JSON: the frozen v2026.9.5 validator accepts success, warning, and repaired failure output; failures retain exit 2 and the redacted error object. The real published-driver upgrade completed with exit 0, terminal succeeded, no rollback, and verified candidate Gateway readiness. No code change or additional re-review is needed for this disposition.

@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes commands Command implementations size: L maintainer Maintainer-authored PR labels Sep 19, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 2:41 AM ET / 06:41 UTC (Revision 7).

ClawSweeper review

What this changes

Doctor restores managed Gateways after inconclusive systemd inspection while preserving ownership refusals, and emits lint failures that published updaters can parse.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary on current main. No actionable introduced defect remains; the earlier ownership finding is addressed, and the published-updater evidence resolves the previous compatibility-proof blocker.

Priority: P1
Reviewed head: 344557a63b6b2264300fb67b1ae6b6f7f5a389cb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, well-supported repair with no remaining actionable findings or additional compatibility-proof requirement.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Captured Linux proof exercises Doctor recovery under the reported delays and a published 2026.9.5 upgrade; separate real native traces show allowed activation and rejection after account or manager replacement without a start effect. Production-path tests supplement the wiring and revocation coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Captured Linux proof exercises Doctor recovery under the reported delays and a published 2026.9.5 upgrade; separate real native traces show allowed activation and rejection after account or manager replacement without a start effect. Production-path tests supplement the wiring and revocation coverage.
Evidence reviewed 10 items Current main still needs the repair: Fetched main still runs full update admission inside the restoration inspection guard and requires inspection to succeed before restarting. It lacks this branch’s inconclusive-inspection recovery.
Restoration retains live authority: Doctor preserves nested ownership refusals, rechecks maintenance custody and update admission, and passes the identity captured before stopping into the native lifecycle owner.
Final native effects revalidate ownership: Activation revalidates broker identity, manager identity, unit and account before reset-failed and start/restart. Calls target the retained manager on the same connection, with current authority checked inside queued execution; failure does not fall back to unbound systemctl.
Findings None None.
Security None None.

How this fits together

Doctor coordinates offline repair with the operating system’s Gateway service manager. It must restore the service it stopped, verify readiness, and report failures to users and the updater.

flowchart TD
  A[Doctor repair request] --> B[Capture service identity]
  B --> C[Stop Gateway and repair]
  C --> D[Inspect restoration state]
  D --> E[Revalidate ownership and custody]
  E -->|Authorized| F[Activate and verify Gateway]
  E -->|Ownership changed| G[Report refusal]
  F --> H[Report readiness]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +655, Tests +1169, Docs +14, Other +39. Total +1877 across 50 files.

View PR surface stats
Area Files Added Removed Net
Source 22 786 131 +655
Tests 24 1272 103 +1169
Docs 2 20 6 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 2 40 1 +39
Total 50 2118 241 +1877

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +786/-131; tests/support +1272/-103; tooling +40/-1 Production growth has a concrete justification: retaining native ownership through restoration instead of authorizing an unbound fallback.
Compatibility surface 1 released JSON-reader contract; 0 persistent-format changes Published-updater compatibility applies; a database migration proof gate does not.

Stored data model

Persistent data-model change detected: database schema: src/commands/doctor-lint.ts, migration/backfill/repair: scripts/lib/vitest-worker-build-entries.mts, migration/backfill/repair: src/commands/doctor-lint.ts, migration/backfill/repair: src/commands/doctor-maintenance.ts, serialized state: src/commands/doctor-lint.ts, unknown-data-model-change: src/commands/doctor-lint.ts, and 1 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #152879
Summary: This PR is the candidate repair for the measured Linux restoration-inspection failure; the macOS shutdown repair is related but distinct.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep recovery in Doctor’s existing maintenance owner, with native identity revalidation before activation and a failure envelope compatible with published updaters.

Do we have a high-confidence way to reproduce the issue?

Yes, a high-confidence source-backed path exists: slow LoadUnit admission exhausts restoration inspection before restart on current main, matching the supplied timing trace. This read-only review did not execute a reproduction.

Is this the best way to solve the issue?

Yes. The patch repairs the existing maintenance and native lifecycle owners, preserves refusal boundaries, and validates the actual released updater contract without introducing persistence or configuration changes.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d0192ed506c8.

Labels

Label justifications:

  • P1: The reported Doctor failure leaves a previously healthy Gateway stopped until manual recovery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Captured Linux proof exercises Doctor recovery under the reported delays and a published 2026.9.5 upgrade; separate real native traces show allowed activation and rejection after account or manager replacement without a start effect. Production-path tests supplement the wiring and revocation coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. Captured Linux proof exercises Doctor recovery under the reported delays and a published 2026.9.5 upgrade; separate real native traces show allowed activation and rejection after account or manager replacement without a start effect. Production-path tests supplement the wiring and revocation coverage.

Evidence

What I checked:

  • Current main still needs the repair: Fetched main still runs full update admission inside the restoration inspection guard and requires inspection to succeed before restarting. It lacks this branch’s inconclusive-inspection recovery. (src/commands/doctor-maintenance.ts, d0192ed506c8)
  • Restoration retains live authority: Doctor preserves nested ownership refusals, rechecks maintenance custody and update admission, and passes the identity captured before stopping into the native lifecycle owner. (src/commands/doctor-maintenance.ts:203, 344557a63b6b)
  • Final native effects revalidate ownership: Activation revalidates broker identity, manager identity, unit and account before reset-failed and start/restart. Calls target the retained manager on the same connection, with current authority checked inside queued execution; failure does not fall back to unbound systemctl. (src/daemon/systemd-service-identity.ts:172, 344557a63b6b)
  • No persistent data-model change: Reference tracing shows the added identity is passed within one maintenance operation. The lint change formats stdout; neither addition introduces a stored format, database schema, migration or backfill. The previous generic migration-proof request does not apply. (src/daemon/service-types.ts:64, 344557a63b6b)
  • Published readiness contract inspected: The v2026.9.5 reader requires boolean ok, nonnegative integer checksRun and findings, and ignores additive fields. The frozen fixture preserves those acceptance rules; the repaired exception envelope supplies them while retaining ok:false, error details and exit 2. (src/infra/update-doctor-lint.ts:49, ec9c1a13db89)
  • Captured real recovery, upgrade and refusal proof: The supplied complete PR body records Linux/systemd 255 recovery after injected 2602 ms and 4770 ms admission delays, a successful published 2026.9.5-to-candidate update without rollback, and healthy Gateway readiness. Native output records successful system/user activation and account-reassignment/manager-replacement refusals with inactive units and no start marker. Proof identifies candidate d42cefb and a mechanical rebase; this review did not rerun it. (d42cefb21114)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Dallin Romney: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-19T16:07:34.680Z sha 32d4635485a3b860911c885b2f05bbcec1a33e24 :: needs real behavior proof before merge. :: [P1] Preserve native ownership refusals before falling back to start
  • reviewed 2026-09-19T17:21:50.229Z sha 79f7a68 :: needs real behavior proof before merge. :: [P1] Preserve native ownership refusals before falling back to start
  • reviewed 2026-09-19T18:00:54.539Z sha ad5b4c6 :: needs real behavior proof before merge. :: [P1] Preserve native ownership refusals before falling back to start
  • reviewed 2026-09-19T22:30:40.536Z sha d42cefb :: blocked before merge. :: none
  • reviewed 2026-09-20T00:38:19.662Z sha d42cefb :: blocked before merge. :: none
  • reviewed 2026-09-20T04:59:12.760Z sha 344557a :: blocked before merge. :: none

@steipete
steipete force-pushed the upd/systemd-loadunit-restoration branch from 32d4635 to 79f7a68 Compare September 19, 2026 17:14
@steipete
steipete force-pushed the upd/systemd-loadunit-restoration branch from ad5b4c6 to d42cefb Compare September 19, 2026 22:21
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 19, 2026
steipete added a commit that referenced this pull request Sep 19, 2026
…#153097)

Doctor can reject verified session SQLite migrations while a plugin remains pending, reporting false transcript errors or leaving plugin configuration locked after the legacy index is retired.

Reuse verified receipt source identities, accept verified archive-only prerequisites when no live legacy inputs remain, and let the existing post-session plugin owner settle migration and unlock retained configuration. Warning-only session commands exit successfully; genuine refusals preserve their actionable failure facts across Doctor and update reporting. Schemas, retention, dependencies, and options are unchanged.

Fixes #153079. Fixes #152744. Thanks @berklingtools for the recovery report and @wiipud and @ozp for diagnosing the index-free prerequisite failure. Additional pinned-plugin validation followed @ericpearson's Docker report.

Validation: published 2026.9.5 and candidate CLI fixtures preserved session/event counts, archive hashes, and SQLite integrity; candidate Doctor completed the pending plugin row and unlocked retained config. The 78 focused owner tests, 24 shard tests, changed-file checks, and exact-head CI passed. The scoped review was clean and both rebased commits are patch-identical to the reviewed versions. Full published-updater-to-candidate finalization and Linux service-restoration proof remain unperformed; service restoration is tracked separately in #153017.
Use live custody for metadata reads and retain full update admission around
activation. Restore after inconclusive inspection while preserving observed
identity changes and report inspection deadlines accurately.

Preserve the published 2026.9.5 readiness contract on lint exceptions, retaining
nonzero status and redacted error details. Freeze the released validator in
contract coverage.

Fixes #152879. Thanks @xilopaint for the diagnosis and timing evidence.
@steipete
steipete force-pushed the upd/systemd-loadunit-restoration branch from d42cefb to 344557a Compare September 20, 2026 04:52
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 20, 2026
@steipete
steipete merged commit e375277 into main Sep 20, 2026
216 checks passed
@steipete
steipete deleted the upd/systemd-loadunit-restoration branch September 20, 2026 06:49
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 20, 2026
Main recognized historical systemd timeouts, but maintenance could stop the
resident before repair, and Doctor and already-current or no-restart updates
could preserve stale computed policy. A published 2026.9.5 resident also retains
its startup shutdown budget after the unit changes.

Refresh owned policy through the existing definition-mutation and backup owners,
confirm daemon reload, preserve operator drop-ins, and retain restore/reload/input
retirement ordering. Share maintenance between update and Doctor, and warn when
a non-stopping refresh still has a short effective manager timeout.

Publish process-owned shutdown budgets and lifecycle write-custody facts. Reuse
the suspension owner and existing update deadline: stop when idle, warn and stop
at the deadline for ordinary work or unknown custody, and refuse only current
reported write custody with its exact owner phase. Reread native policy when the
new Gateway accepts shutdown without resetting its elapsed budget or watchdog.

Thanks @ezimerman for the installed-unit and shutdown evidence.
Fixes #153153. Refs #150898, #152879, #153017.
steipete added a commit that referenced this pull request Sep 20, 2026
Main recognized historical systemd timeouts, but maintenance could stop the
resident before repair, and Doctor and already-current or no-restart updates
could preserve stale computed policy. A published 2026.9.5 resident also retains
its startup shutdown budget after the unit changes.

Refresh owned policy through the existing definition-mutation and backup owners,
confirm daemon reload, preserve operator drop-ins, and retain restore/reload/input
retirement ordering. Share maintenance between update and Doctor, and warn when
a non-stopping refresh still has a short effective manager timeout.

Publish process-owned shutdown budgets and lifecycle write-custody facts. Reuse
the suspension owner and existing update deadline: stop when idle, warn and stop
at the deadline for ordinary work or unknown custody, and refuse only current
reported write custody with its exact owner phase. Reread native policy when the
new Gateway accepts shutdown without resetting its elapsed budget or watchdog.

Thanks @ezimerman for the installed-unit and shutdown evidence.
Fixes #153153. Refs #150898, #152879, #153017.
steipete added a commit that referenced this pull request Sep 20, 2026
Main recognized historical systemd timeouts, but maintenance could stop the
resident before repair, and Doctor and already-current or no-restart updates
could preserve stale computed policy. A published 2026.9.5 resident also retains
its startup shutdown budget after the unit changes.

Refresh owned policy through the existing definition-mutation and backup owners,
confirm daemon reload, preserve operator drop-ins, and retain restore/reload/input
retirement ordering. Share maintenance between update and Doctor, and warn when
a non-stopping refresh still has a short effective manager timeout.

Publish process-owned shutdown budgets and lifecycle write-custody facts. Reuse
the suspension owner and existing update deadline: stop when idle, warn and stop
at the deadline for ordinary work or unknown custody, and refuse only current
reported write custody with its exact owner phase. Reread native policy when the
new Gateway accepts shutdown without resetting its elapsed budget or watchdog.

Thanks @ezimerman for the installed-unit and shutdown evidence.
Fixes #153153. Refs #150898, #152879, #153017.
steipete added a commit that referenced this pull request Sep 20, 2026
Main recognized historical systemd timeouts, but maintenance could stop the
resident before repair, and Doctor and already-current or no-restart updates
could preserve stale computed policy. A published 2026.9.5 resident also retains
its startup shutdown budget after the unit changes.

Refresh owned policy through the existing definition-mutation and backup owners,
confirm daemon reload, preserve operator drop-ins, and retain restore/reload/input
retirement ordering. Share maintenance between update and Doctor, and warn when
a non-stopping refresh still has a short effective manager timeout.

Publish process-owned shutdown budgets and lifecycle write-custody facts. Reuse
the suspension owner and existing update deadline: stop when idle, warn and stop
at the deadline for ordinary work or unknown custody, and refuse only current
reported write custody with its exact owner phase. Reread native policy when the
new Gateway accepts shutdown without resetting its elapsed budget or watchdog.

Thanks @ezimerman for the installed-unit and shutdown evidence.
Fixes #153153. Refs #150898, #152879, #153017.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…claw#153017)

Doctor could leave a healthy systemd Gateway stopped when repeated update-admission checks exhausted restoration inspection. Use lightweight custody for metadata reads, retain the native service identity before shutdown, and restore with a warning after inconclusive diagnostics while verifying readiness. Revalidate broker, manager, unit, account, and current authority at activation; preserve explicit ownership refusals without an unbound fallback.

Keep failed Doctor lint output compatible with published updaters by retaining the readiness envelope, redacted error metadata, and exit 2. No persistent schema, configuration, CLI, or dependency contract changes.

Thanks @xilopaint for isolating the LoadUnit delays and providing the timing trace.

Validated by green exact-head CI, focused regression coverage, real Linux recovery and native refusal observations, and a published 2026.9.5-to-candidate update that completed successfully without rollback. The frozen released reader accepts success, warning, and repaired failure output. Independent Codex review found no actionable P0/P1 findings.

Fixes openclaw#152879.
vincentkoc added a commit that referenced this pull request Sep 21, 2026
…#153636)

* fix: refresh stale Gateway stop policies before maintenance

Main recognized historical systemd timeouts, but maintenance could stop the
resident before repair, and Doctor and already-current or no-restart updates
could preserve stale computed policy. A published 2026.9.5 resident also retains
its startup shutdown budget after the unit changes.

Refresh owned policy through the existing definition-mutation and backup owners,
confirm daemon reload, preserve operator drop-ins, and retain restore/reload/input
retirement ordering. Share maintenance between update and Doctor, and warn when
a non-stopping refresh still has a short effective manager timeout.

Publish process-owned shutdown budgets and lifecycle write-custody facts. Reuse
the suspension owner and existing update deadline: stop when idle, warn and stop
at the deadline for ordinary work or unknown custody, and refuse only current
reported write custody with its exact owner phase. Reread native policy when the
new Gateway accepts shutdown without resetting its elapsed budget or watchdog.

Thanks @ezimerman for the installed-unit and shutdown evidence.
Fixes #153153. Refs #150898, #152879, #153017.

* fix: preserve the resident shutdown budget in Gateway status

The kernel request-context adapter copied host lifecycle control methods but
dropped the recorded shutdown-budget getter. Real Linux package proof observed
a 325-second startup budget while status omitted it, forcing maintenance onto
the legacy unknown-budget path.

Forward the live getter through the existing adapter without changing request
authority or adding another budget owner. Add a real-kernel registered-status
regression for short and adequate budgets; the corrected test fails on the
original adapter and passes with the forwarding line.

Refs #153153.

* test: control the Gateway shutdown clock consistently

Restore the explicit node:perf_hooks performance import for the run-loop regressions that retain their own fake-clock assertions. They must control the same monotonic clock as the production shutdown-budget owner. Keep the deadline assertions, timers, and production behavior unchanged.

* fix: preserve Doctor legacy reads during Gateway preflight

The stale-Gateway probe opened the canonical owner-lease database without
Doctor's existing legacy-catalog admission. With a built install and a busy
Gateway port, that read created WAL/SHM files and rejected a supported repair
before maintenance could stop the Gateway.

Carry the existing read admission through restart inspection to the lease owner.
Keep ordinary restart validation unchanged and preserve canonical artifacts.
Use synthetic port, build, and reachability facts in the regression fixture while
retaining real lease reads and byte-preservation assertions.

Refs #153153.

* refactor: keep Gateway maintenance owners within line limits

The L903 stop-policy repair exceeded the existing line-growth gate after
composition with current restart and service identity handling. Move request
upgrade policy into its existing request owner and service revalidation into
one sibling implementation without changing their behavior.

Preserve original request admission time and Doctor's statically primed
maintenance facade across package replacement. The bounded drain, recorded
custody-only refusal, warning policy, and native backup/reload ordering remain
unchanged. No options, schema changes, suppressions, or baseline growth.

Validation: 398 focused tests, core typecheck, line-growth ratchet, and fresh
Codex P1 review passed. Full changed checks continue on the frozen source.

* test: retain backup custody coverage through the archive walker

The rebase incorporated the maintained archive walker, but the L903 custody
regression still referenced the retired tar-create mock. Use the existing
walker mock bound to the real backup command without changing assertions or
production code.

Validation: 132 backup, migration, cron, coordinator, and suspension tests
passed. Fresh Codex P1 review is clean. Full changed checks continue.

* fix: preserve maintenance lifecycle and wrapper contracts

Doctor fixtures advertised a running native service without the matching
resident identity, effective policy, or lifecycle readiness response. Supply
those facts through the same RPC and native-query boundaries used by the real
maintenance owner, including fresh readiness without a resident budget.

Keep exact suspension assertions current with the additive custody category.
Install the model-acquisition fixture's manager after normal PATH setup so
startup and shutdown observe the same policy under the original deadlines.
Include the custody owner in the canonical PR-wrapper source inventory.

Move the unchanged Doctor inspection assertion and shared fixtures into their
existing policy/support owners to preserve the line-growth ratchet. Do not
change the bounded-deferral, warning, or reported-write-custody refusal policy.

* fix: preserve Stop ownership through shutdown budget refresh

An asynchronous systemd budget read could resume after Stop captured a
foreground updater and re-arm the hard-exit worker. Keep watchdog admission
with the run loop's current successor owner, and represent an absent cleanup
deadline with no process-cleanup budget.

Preserve foreground no-op service ownership and the full native allowance
after verified parking. Keep one fake clock for boundary tests, prepare
fixture operations before held scripts, and join cancelled fixture work
before the next case. Move unchanged budget cases into their support owner.

Retain the ruling that unknown custody cannot block an update and only
reported write custody may refuse maintenance. Preserve all existing test
assertions and limits. The full Linux changed gate, 790 focused Linux tests,
and a fresh P1 review passed; local host limitations are recorded in the PR.

* refactor(doctor): extract update-run admission from doctor-maintenance

* fix: preserve native policy and write custody during maintenance

* fix: keep shutdown integration within source and type gates

* fix(test): own survivor model endpoint before baseline setup

---------

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…openclaw#153636)

* fix: refresh stale Gateway stop policies before maintenance

Main recognized historical systemd timeouts, but maintenance could stop the
resident before repair, and Doctor and already-current or no-restart updates
could preserve stale computed policy. A published 2026.9.5 resident also retains
its startup shutdown budget after the unit changes.

Refresh owned policy through the existing definition-mutation and backup owners,
confirm daemon reload, preserve operator drop-ins, and retain restore/reload/input
retirement ordering. Share maintenance between update and Doctor, and warn when
a non-stopping refresh still has a short effective manager timeout.

Publish process-owned shutdown budgets and lifecycle write-custody facts. Reuse
the suspension owner and existing update deadline: stop when idle, warn and stop
at the deadline for ordinary work or unknown custody, and refuse only current
reported write custody with its exact owner phase. Reread native policy when the
new Gateway accepts shutdown without resetting its elapsed budget or watchdog.

Thanks @ezimerman for the installed-unit and shutdown evidence.
Fixes openclaw#153153. Refs openclaw#150898, openclaw#152879, openclaw#153017.

* fix: preserve the resident shutdown budget in Gateway status

The kernel request-context adapter copied host lifecycle control methods but
dropped the recorded shutdown-budget getter. Real Linux package proof observed
a 325-second startup budget while status omitted it, forcing maintenance onto
the legacy unknown-budget path.

Forward the live getter through the existing adapter without changing request
authority or adding another budget owner. Add a real-kernel registered-status
regression for short and adequate budgets; the corrected test fails on the
original adapter and passes with the forwarding line.

Refs openclaw#153153.

* test: control the Gateway shutdown clock consistently

Restore the explicit node:perf_hooks performance import for the run-loop regressions that retain their own fake-clock assertions. They must control the same monotonic clock as the production shutdown-budget owner. Keep the deadline assertions, timers, and production behavior unchanged.

* fix: preserve Doctor legacy reads during Gateway preflight

The stale-Gateway probe opened the canonical owner-lease database without
Doctor's existing legacy-catalog admission. With a built install and a busy
Gateway port, that read created WAL/SHM files and rejected a supported repair
before maintenance could stop the Gateway.

Carry the existing read admission through restart inspection to the lease owner.
Keep ordinary restart validation unchanged and preserve canonical artifacts.
Use synthetic port, build, and reachability facts in the regression fixture while
retaining real lease reads and byte-preservation assertions.

Refs openclaw#153153.

* refactor: keep Gateway maintenance owners within line limits

The L903 stop-policy repair exceeded the existing line-growth gate after
composition with current restart and service identity handling. Move request
upgrade policy into its existing request owner and service revalidation into
one sibling implementation without changing their behavior.

Preserve original request admission time and Doctor's statically primed
maintenance facade across package replacement. The bounded drain, recorded
custody-only refusal, warning policy, and native backup/reload ordering remain
unchanged. No options, schema changes, suppressions, or baseline growth.

Validation: 398 focused tests, core typecheck, line-growth ratchet, and fresh
Codex P1 review passed. Full changed checks continue on the frozen source.

* test: retain backup custody coverage through the archive walker

The rebase incorporated the maintained archive walker, but the L903 custody
regression still referenced the retired tar-create mock. Use the existing
walker mock bound to the real backup command without changing assertions or
production code.

Validation: 132 backup, migration, cron, coordinator, and suspension tests
passed. Fresh Codex P1 review is clean. Full changed checks continue.

* fix: preserve maintenance lifecycle and wrapper contracts

Doctor fixtures advertised a running native service without the matching
resident identity, effective policy, or lifecycle readiness response. Supply
those facts through the same RPC and native-query boundaries used by the real
maintenance owner, including fresh readiness without a resident budget.

Keep exact suspension assertions current with the additive custody category.
Install the model-acquisition fixture's manager after normal PATH setup so
startup and shutdown observe the same policy under the original deadlines.
Include the custody owner in the canonical PR-wrapper source inventory.

Move the unchanged Doctor inspection assertion and shared fixtures into their
existing policy/support owners to preserve the line-growth ratchet. Do not
change the bounded-deferral, warning, or reported-write-custody refusal policy.

* fix: preserve Stop ownership through shutdown budget refresh

An asynchronous systemd budget read could resume after Stop captured a
foreground updater and re-arm the hard-exit worker. Keep watchdog admission
with the run loop's current successor owner, and represent an absent cleanup
deadline with no process-cleanup budget.

Preserve foreground no-op service ownership and the full native allowance
after verified parking. Keep one fake clock for boundary tests, prepare
fixture operations before held scripts, and join cancelled fixture work
before the next case. Move unchanged budget cases into their support owner.

Retain the ruling that unknown custody cannot block an update and only
reported write custody may refuse maintenance. Preserve all existing test
assertions and limits. The full Linux changed gate, 790 focused Linux tests,
and a fresh P1 review passed; local host limitations are recorded in the PR.

* refactor(doctor): extract update-run admission from doctor-maintenance

* fix: preserve native policy and write custody during maintenance

* fix: keep shutdown integration within source and type gates

* fix(test): own survivor model endpoint before baseline setup

---------

Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 2026.9.5 Doctor restoration still times out in LoadUnit admission guards after #149970

1 participant