Skip to content

fix(update): keep retained service authority after a stopped-free inspection and let repair retire untouched preparations - #164997

Merged
steipete merged 1 commit into
mainfrom
upd/upd-managed-preflight-ownership-recovery-stopped-free
Oct 4, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-managed-preflight-ownership-recovery-stopped-free

Conversation

@steipete

@steipete steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Refs #164459

What Problem This Solves

Fixes updates losing retained systemd service authority after stopping the Gateway, and repair rejecting an untouched package preparation left by a pre-publication refusal.

User Impact

A previously running Gateway retains its recovery path after a refusal that changed nothing. openclaw update repair can retire a preparation that never published, leaving the original package and launchers unchanged and clearing the next update's pending-package gate. An already stopped service stays stopped. An older running updater cannot acquire this fix before publication; use a CLI containing the fix to repair retained preparation.

Why This Change Was Made

Systemd may collect an inactive unit. Post-stop schema revalidation now carries the original executor and manager identity into the existing metadata-loading owner instead of treating that collection as lost service authority. Package repair uses the existing publication owner under fresh executor authority to verify, abort, and retire untouched preparation; changed launchers, foreign generations, and active owners remain protected. Existing plugin preflight moved into candidate validation to meet the execution module's line cap without changing its lazy loading or admission rechecks.

Thanks @jorden2895 for the report and retained diagnostics.

Evidence

  • (b) Fixed for the reproduced stopped-unit path: recovery no longer leaves a previously running service stopped after a refusal that changed nothing. Retained service authority survives inspection, and the service-lifecycle fixture verifies restarting the collected unit and restoring serving health. This does not establish the missing native error from the reporter's original run.
  • (c) Fixed: repair retires verified untouched prepared/aborted package operations that never published, including the shipped legacy launcher-group descriptor. Package/launcher identity and content remain unchanged, and the pending-package admission check clears. Replaced launchers and active owners remain refused.
  • (a) Still open: the exact cause of the reporter's service-ownership-unverified needs the original stderr diagnostic. The collected-unit regression establishes one concrete inspection failure path; the post-installer service definition does not prove the original cause. This PR references the issue rather than closing it.
  • Both new regressions failed before their fixes. pnpm test src/cli/update-cli/update-command-execution.test.ts --maxWorkers=1: 75 passed, three runs, 21.01–21.42 s wrapper wall time and approximately 4.9–5.0 s test time per run. pnpm test src/cli/update-cli/update-repair-package-activation.test.ts --maxWorkers=1: 11 passed, three runs, 17.72–17.97 s wrapper wall time and approximately 1.6–1.7 s test time per run. PR CI seconds are not yet available.
  • Additional boundary proof: 121 service-lifecycle tests and 19 package-publication tests passed. The 102-file importer sweep was interrupted at the original slow-test gate; it is not claimed as a completed sweep.
  • Named performance follow-up (maintainer waiver): src/cli/update-cli/update-command-original-service.test.ts recorded 167.434 s across 50 completed passing cases; src/cli/update-cli.windows-lifecycle.test.ts recorded 167.099 s across 11 completed passing cases. These pre-existing fixture costs include repeated real schema/state-worker launches inside cases, rather than shared compiler preparation. Profile and share suitable process fixtures while preserving the cross-process recovery contracts; the lane's slow-test gate is explicitly waived for these files.
  • Local node scripts/check-changed.mjs: passed (exit 0), including core types, all 27 test type graphs, unused-export scans, lint, and the remaining source guards. The fixture drain signature was corrected after the first typecheck found its missing guard argument; no production change was needed.
  • Independent Codex P1 review: scoped-clean, no accepted/actionable findings. Production +93/−33 LOC, tests/support +199/−0, docs +16/−0. No dependency, schema, CLI-option, or config-option changes.

For (a), please paste the complete stderr from the original failed openclaw update run and the output of cat ~/.openclaw/logs/gateway-restart.log, including any Failed to restart managed gateway service after failed update: line, with secrets and private paths redacted as needed.

Retain the admitted executor and systemd manager identity during post-stop revalidation. Allow explicit repair to retire verified preparations that never published through the existing publication owner.

Refs #164459
@clawsweeper

clawsweeper Bot commented Oct 4, 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 cli CLI command changes size: M labels Oct 4, 2026
@steipete
steipete marked this pull request as ready for review October 4, 2026 15:57
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Oct 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 12:02 PM ET / 16:02 UTC.

ClawSweeper review

What this changes

The PR preserves update ownership when inspecting a stopped systemd service and lets explicit repair retire verified package preparations that never published.

Merge readiness

✅ Ready for maintainer review

This PR addresses two concrete recovery gaps still present on current main. No blocking introduced defect was found; the reporter’s original inspection refusal remains separate unresolved work.

Priority: P1
Reviewed head: c3aa5749a47f51abc457570c98835fa9c4979798

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-preserving repair with meaningful regressions, documented upgrade limits, and no blocking introduced finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a maintainer-authored PR, exempt from ordinary contributor proof. Inspected regressions exercise production execution and public repair with native service calls mocked and real package records; they are supplemental, not live systemd proof. No unresolved authority violation or stored-format change was identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a maintainer-authored PR, exempt from ordinary contributor proof. Inspected regressions exercise production execution and public repair with native service calls mocked and real package records; they are supplemental, not live systemd proof. No unresolved authority violation or stored-format change was identified.
Evidence reviewed 9 items Pinned introduced changes: Reviewed the merge-base-to-head changes across the service inspection, repair, publication, documentation, and regression coverage surfaces. The plugin preflight extraction preserves its lazy import and admission rechecks.
Current main still needs the repair: Current main revalidates post-stop admission without the retained executor assertion and refuses pending activation when the original package generation remains installed. Both targeted gaps therefore remain.
Live authority remains required: Post-stop metadata inspection passes the execution guard through the existing service owner. The systemd reader combines the native operation lock with that guard and retains the admitted manager UID; publication still rechecks service admission before mutation.
Findings None None.
Security None None.

How this fits together

OpenClaw’s updater checks the installed package, databases, and managed Gateway before activation. Its recovery owners use retained service identity and package-publication records to restore service or safely clear unfinished preparation.

flowchart TD
  A[Update or repair request] --> B[Current executor ownership]
  B --> C[Service and package inspection]
  C --> D[Retained systemd manager identity]
  D --> E[Activation or Gateway recovery]
  C --> F[Untouched package preparation]
  F --> G[Verified artifact retirement]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +60, Tests +199, Docs +16. Total +275 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 6 93 33 +60
Tests 3 199 0 +199
Docs 1 16 0 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 308 33 +275

Review metrics

Metric Value Why it matters
Production and regression coverage production +93/−33 LOC; tests/support +199/−0 LOC The stated growth supports retained-authority plumbing and preparation settlement through existing owners, with focused regression coverage.

Technical review

Best possible solution:

Keep recovery with the existing service and publication owners, preserving live authority checks and the original installed package during preparation retirement.

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

Yes, for the two narrowed source-level defects: post-stop inspection drops the retained executor context, and repair refuses untouched preparation. The reporter’s original native inspection failure is not independently reproduced.

Is this the best way to solve the issue?

Yes. The patch routes retained authority and retirement through existing owners without adding competing recovery policy, configuration, or publication machinery.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The linked official update failure stranded Gateway recovery and blocked subsequent package updates.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a maintainer-authored PR, exempt from ordinary contributor proof. Inspected regressions exercise production execution and public repair with native service calls mocked and real package records; they are supplemental, not live systemd proof. No unresolved authority violation or stored-format change was identified.

Label justifications:

  • P1: The linked official update failure stranded Gateway recovery and blocked subsequent package updates.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies a maintainer-authored PR, exempt from ordinary contributor proof. Inspected regressions exercise production execution and public repair with native service calls mocked and real package records; they are supplemental, not live systemd proof. No unresolved authority violation or stored-format change was identified.

Evidence

What I checked:

  • Pinned introduced changes: Reviewed the merge-base-to-head changes across the service inspection, repair, publication, documentation, and regression coverage surfaces. The plugin preflight extraction preserves its lazy import and admission rechecks. (src/cli/update-cli/update-command-execution.ts:138, c3aa5749a47f)
  • Current main still needs the repair: Current main revalidates post-stop admission without the retained executor assertion and refuses pending activation when the original package generation remains installed. Both targeted gaps therefore remain. (src/infra/package-update-activation.ts:195, 29c36b7ace8a)
  • Live authority remains required: Post-stop metadata inspection passes the execution guard through the existing service owner. The systemd reader combines the native operation lock with that guard and retains the admitted manager UID; publication still rechecks service admission before mutation. (src/cli/update-cli/update-command-service-plan.ts:295, c3aa5749a47f)
  • Retirement uses the existing publication owner: Repair acquires a fresh executor, admits the captured journal under its fence, rechecks the original package identity, and invokes existing preflight, abort, and retirement operations. Those operations check journal, helper, package, launcher, and artifact identities around awaited work and deletion. (src/infra/package-update-activation.ts:215, c3aa5749a47f)
  • Focused regression and existing-state coverage: Source-inspected cases cover collected-unit success, changed service definition, requester revocation before publication, and public repair with current and shipped legacy launcher descriptors. Repair assertions preserve package bytes, launcher contents and inode, and clear pending admission. These tests were not executed during this read-only review. (src/cli/update-cli/update-repair-package-activation.test.ts:127, c3aa5749a47f)
  • Reporter and maintainer scope: Discussion on Update failure: update-executor-settlement (2026.9.7) #164459 says the installer restored service, so the retained succeeded run does not establish updater recovery. The follow-up explicitly identifies this PR as addressing stopped-service recovery and untouched preparation, while requesting original stderr for the remaining ownership refusal.

Likely related people:

  • Peter Steinberger: Raw commit a0a1f18 adds src/infra/package-update-activation.ts:186 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a0a1f184a386; files: src/infra/package-update-activation.ts)

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.

@steipete
steipete merged commit 9497527 into main Oct 4, 2026
200 of 204 checks passed
@steipete
steipete deleted the upd/upd-managed-preflight-ownership-recovery-stopped-free branch October 4, 2026 16:15
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 5, 2026
RomneyDa added a commit that referenced this pull request Oct 8, 2026
Backport all required recovery fixes to 2026.10.1: #167302, #167330,
#167358, and #167377. Include their missing settlement prerequisites
#164997, #165238, and #165607.

Close obsolete recovery custody durably before best-effort evidence archival;
keep unfinished rollback and current mutation authority strict. Completed
history cannot block subsequent updates. Qualify authentic interruptions
from pinned 9.8/9.9 updaters plus the unchanged 9.7-to-9.8 negative control.

Adapt donor APIs to the release-owned publication and lease database owners.
No version, dependency, budget, permission, or publication changes.

Proof:619 focused tests passed, including14 release-profile cases;
fresh complete69-file P0-P2 review clean. Complete changed gate passed.
Exact combined release build and stable/all/soak qualification remain pending.

Sources:
3ed1e21 (#167302)
4821885 (#167330)
8879e5e (#167358)
bc860ad (#167377)
9497527 (#164997)
5ae6497 (#165238)
fb84dd5 (#165607)

Co-authored-by: Scott Hanselman <[email protected]>
Co-authored-by: Peter Steinberger <[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 docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

1 participant