Skip to content

fix(update): enter maintenance before repairing source artifacts - #180356

Merged
RomneyDa merged 2 commits into
mainfrom
fix/update-repair-runtime-publication
Oct 26, 2026
Merged

RomneyDa merged 2 commits into
mainfrom
fix/update-repair-runtime-publication

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Fixes #180349

Problem and result

openclaw update repair reaches changed source-artifact publication before maintenance, so a running managed Gateway correctly refuses publication and repair cannot complete. Enter the existing Doctor maintenance owner at beforePublication, retain its custody through convergence, and restore only with current authority. Package installations and unchanged-artifact paths keep their existing behavior.

Preserve the existing service-inspection deadline; elapsed preparation consumes its allowance. Keep admission/deadline checks separate from a delegated updater continuation, so a bounded managed repair reaches its own stop instead of waiting for that Gateway to exit first.

Native macOS proof also exposed an inherited Doctor restoration defect: a later explicit native disable was overridden by restoration. Doctor now captures native enable policy immediately before its stop and checks it before installation and final activation under the service operation lock. Missing policy inspection refuses before stop. Restoration preserves initially disabled autostart policy. Windows retains its existing task-recovery owner; two unchanged settlement functions move into that existing module to satisfy the source-size gate. No new config, schema, retention, or permission contract.

Verification

  • Ordering regression fails before the initial fix; the bounded-owner regression fails against current-main ownership code (8 pass / 1 fail).
  • Public repair/refusal: 14/14; contention owner: 9/9. Combined wrapper 78.75s (Vitest 53.50s / 16.92s).
  • Source-publication helper: 30 passing cases recorded for physical publication/rollback. Its initial combined invocation was interrupted later in a separate frozen-clock fixture; this is reused helper evidence, not a successful whole-command receipt.
  • New restoration regressions fail against immutable 40735674 (3 fail / 26 skipped; 37.76s), including later disable, final activation, and preservation of initially disabled policy.
  • Affected maintenance, identity, and restoration suites: 91 passed / 5 skipped, wrapper 79.02s (5.56s / 8.37s / 31.00s Vitest durations). Windows recovery: 10/10, wrapper 31.91s (28.25s Vitest). Added coverage also checks missing native policy capability before stop and policy revocation at installation.
  • Test cost: the five added policy cases total 0.551s local test execution in the existing fixture (estimated incremental CI test time about 0.55s, excluding shared setup and host variance; hosted incremental time was not isolated).
  • Official production, CLI-update test, and Doctor test typegraphs; typed lint (including source-size gate), format, and diff checks pass. Fresh independent review and canonical autoreview: no actionable P0–P2 findings.
  • All hosted checks passed at exact final head fcb14b3799c73930424519ddc51fde0f2cf746e9. The CI workflow completed successfully in 22m58s elapsed across its parallel jobs.

Native macOS evidence and limits

Sanitized native proof, commands, build identity, hashes, failures, and cleanup.

Exact fcb14b3799c73930424519ddc51fde0f2cf746e9 runtime build passed (75.9s), with matching build metadata. All native work used uniquely named synthetic profiles and task-owned LaunchAgents; the operator's installation was untouched.

  • Allowed repair: unmodified real source publication completed, stale artifact removed, Gateway restored (PID 37065 → 42000), health --json and gateway status --deep --require-rpc passed, plugin errors/unavailable empty. Synthetic config/history/SQLite SHA256 values and logical configuration stayed identical.
  • Publication failure: a disclosed staging-adapter timing fixture delegated to the original real publisher. Actual EACCES rename failure returned exit 1 (40.64s), restored a healthy Gateway (PID 44986), and preserved artifact/config/history/database baseline.
  • Later operator disable: after actual publication and release of its native service lock, with Doctor custody still held, gateway stop --force --disable changed the owned native label from enabled to disabled. Finalization returned exit 1 (86.31s), doctor-gateway-restoration-failed, explicitly refusing automatic restoration because native policy changed. The service remained absent/disabled and its port free. This reverses the native failure observed at 40735674.
  • Service-tree refusal: reused actual Gateway-owned terminal-child evidence at 40735674: explicit ancestry refusal before stop/publication, unchanged native PID/artifact hash, deep RPC passed. The ancestry owner/branch is unchanged; current policy capture is strictly after that refusal. This is not represented as a current-head child run.
  • Both task-owned services were uninstalled natively after settlement without reactivating the stopped profiles. Original source adapter restored byte-identical to HEAD; worktree clean.

The timing fixture is disclosed integration proof with real native service/authority code, not an unmodified full end-to-end scenario. A boolean policy comparison covers the observed enabled-to-disabled change; it does not detect a repeated disable when policy was already disabled. No production-data migration, broad release matrix, or live channel readiness is claimed. No live installation update or release was performed.

Published-driver cell

Sanitized exact-head upgrade receipt: one canonical local Docker cell, published 2026.10.7 → exact candidate 2026.10.7, Node 24.22.1, no version override or retries. Published updater exit 0 (314.664s); completion ledger, exact build identity, Gateway PID replacement/readiness, settings and durable history preservation, incognito removal, and retained synthetic credential-sidecar bytes all passed.

The wrapper exited 1 afterward in fixture-supervisor teardown, so a full-command pass is not claimed. Final supervisor exit 0 and zero remaining process IDs, removed container, and destroyed unique volume prove settled cleanup. This unchanged harness defect is tracked separately in #185208; no updater failure facts were observed.

Commands

pnpm test src/cli/update-cli/update-command-finalize-refusal.test.ts src/commands/doctor-maintenance.contention-wait.test.ts --maxWorkers=1
pnpm test src/commands/doctor-maintenance.installation.test.ts src/cli/update-cli/update-command-service-maintenance.test.ts src/cli/update-cli/update-command-service-maintenance-identity.test.ts --maxWorkers=1
pnpm test src/cli/update-cli/update-command-service-maintenance.windows-recovery.test.ts --maxWorkers=1

Fresh ClawSweeper review of the final head: ready for maintainer review, no code findings and no before-merge items; patch quality platinum, overall gold.

@clawsweeper

clawsweeper Bot commented Oct 22, 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.

@RomneyDa RomneyDa changed the title fix(update): repair source artifacts while the Gateway is running fix(update): enter maintenance before repairing source artifacts Oct 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Oct 22, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR acquires Doctor maintenance before source-artifact publication and preserves later native autostart changes during restoration.

Example: A running launchd-managed source installation needs refreshed runtime artifacts during openclaw update repair.

  • Before: Publication refuses because the Gateway is still running, before repair reaches maintenance.
  • After: Repair stops the owned Gateway before publication and restores it afterward, unless the operator disables its native service.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and has meaningful native behavior evidence; required upgrade validation remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The recommended repair command cannot refresh source artifacts while its managed Gateway is running.
Reason: The maintainer-authored direction restores documented repair behavior and preserves operator control using existing owners.

Merge readiness

✅ Ready for maintainer review

This maintainer-authored PR fixes a current-main repair failure; no actionable introduced code defect was found.

Priority: P2
Reviewed head: fcb14b3799c73930424519ddc51fde0f2cf746e9

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply one latest-stable published-driver-to-candidate upgrade run preserving existing settings and data, as required by the update contract.
Agent review details

How this fits together

Update finalization coordinates source-artifact preparation, Doctor, plugin convergence, and managed Gateway restoration through existing maintenance and native-service owners.

flowchart TD
  A[Update repair CLI] --> B[Source preparation]
  B --> C[Doctor maintenance owner]
  C --> D[Guarded artifact publication]
  D --> E[Doctor and plugin convergence]
  E --> F[Native authority revalidation]
  F --> G[Restore or refuse activation]
Loading

Technical review

Best possible solution:

Keep the existing Doctor owner responsible for publication custody, convergence, and restoration under current native authority.

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

Current-main ordering and the publication guard establish the reported failure; supplied native receipts exercise the repaired path, and this read-only review ran no target code.

Is this the best way to solve the issue?

The smallest complete repair uses the existing beforePublication hook and Doctor maintenance owner; the native-policy follow-up addresses an observed restoration failure without introducing another lifecycle owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Source completion and parent-owned maintenance keeps the original intent (fix(update): restore Gateway and clear stale warnings after repair #151003: The update parent owns stopping and restoring the Gateway while fresh Doctor children own database work; improve: skip unused state leases during update finalization #165326 separately preserves no-op source preparation without unnecessary leases.)
  • Deadline admission versus delegated continuation changes intended behavior with a stated reason (a200356: Service inspection consumes the original Doctor allowance; this PR retains that deadline while separating it from the continuation callback that authorizes waiting for a replaced Gateway.)
  • Native Gateway restoration changes intended behavior with a stated reason (18a0b30: Doctor reverses its own stop under retained custody; observed native proof showed that restoration also needed to respect a later operator disable.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 18a0b30 adds src/commands/doctor-maintenance-restoration.ts:57 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 18a0b30d69cb; files: src/commands/doctor-maintenance-restoration.ts)
  • Dallin Romney: Raw commit 72e16e3 adds src/commands/doctor-maintenance-foreground.ts:158 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 72e16e331e1f; files: src/commands/doctor-maintenance-foreground.ts)

PR surface

Source +58, Tests +124. Total +182 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 8 103 45 +58
Tests 4 135 11 +124
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 238 56 +182

Review metrics

Metric Value Why it matters
Production versus test changes Production +103/-45; tests and test support +135/-11. Growth adds native-policy checks and distinct ordering, admission, and restoration regressions within existing owners; the Windows helper relocation preserves behavior.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Repair fails for managed source installations requiring artifact refresh, while the existing publication guard prevents unsafe replacement.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-22T06:09:18.004Z sha f9f19a5 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-26T22:53:23.477Z sha 4073567 :: needs real behavior proof before merge. :: none

Reviewed October 26, 2026, 7:35 PM ET / 23:35 UTC (Revision 3).

@RomneyDa
RomneyDa marked this pull request as ready for review October 26, 2026 22:37
@RomneyDa
RomneyDa force-pushed the fix/update-repair-runtime-publication branch from f9f19a5 to 4073567 Compare October 26, 2026 22:47
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Oct 26, 2026
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review current head 40735674cbbc7ef73d384e8b4e75bc8ad6cdef31. Conflicts with main are resolved while retaining the service-inspection deadline contract. The repair now distinguishes deadline admission from an actual caller continuation, so bounded managed repair reaches its stop path without changing foreground-updater waiting. Public repair/refusal and owner regressions pass; current proof and remaining native macOS proof limits are in the updated PR body.

This is ready-for-review preparation only; do not merge.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@RomneyDa
RomneyDa enabled auto-merge (squash) October 26, 2026 23:38
@RomneyDa
RomneyDa merged commit 8346eba into main Oct 26, 2026
187 checks passed
@RomneyDa
RomneyDa deleted the fix/update-repair-runtime-publication branch October 26, 2026 23:45
@RomneyDa

Copy link
Copy Markdown
Member Author

Published-driver × candidate proof: exact fcb14b3

One invocation, no retry/version stamp/guard override:
OPENCLAW_DOCKER_E2E_IMAGE=openclaw-pr180356-published-driver /bin/bash scripts/e2e/published-driver-update-docker.sh '' /private/tmp/pr180356-published-driver latest

Docker29.7.2; canonical bare Node24.22.1 image; disposable Linux systemctl shim, synthetic state, no model inference/host Gateway changes. Registry latest resolved2026.10.7, same as candidate. Clean exact-head package build192.6s, integrity check42s.
Candidate buildId2026.10.7-fcb14b3799c7-2026-10-26T23-40-24.565Z
Tarball SHA2569f28726aa470f86d8fa0cc6d30eeb8ceb1df6f210cec05b07b709f3409b63948

Published updater exit0,314.664s, processTreeState terminated. Durable run9381ad5d-28a4-447d-b536-d7c6e115237c finished/succeeded; update.status ok. Installed build-info exactly candidate. Serving PID10853 version/build exact; serviceRunning/versionMatch/channelsReady/readyz/coreReady/settled true; pluginErrors empty. Postcommands recorded-run, after-ready, running-version, durable-after, incognito-after all exit0. Assertions prove durable session ID/messages retained, incognito history removed, synthetic retained credential sidecar bytes unchanged, managed PID replaced. Summary readyz200; harness printed PASS.

Wrapper exit1 ONLY later fixture teardown: stop-service exit1,0.372s; stderr "Survivor supervisor has not settled; retaining process custody." Full-command pass NOT claimed. Unchanged owner scripts/e2e/lib/upgrade-survivor/update-restart-auth.sh:105-133(stop_gateway); supervisor polling returned before final settlement. Final gateway.log.exit.json: exit0 at2026-10-26T23:54:18.426Z. Final gateway.log.runtime.json: pid/supervisorPid/groupPid0, stopFailed false. No updater failure facts. No root cause beyond observed settlement race claimed. Docker container93e8fa430ca7 removed by lane cleanup; no owned-image containers remain. Lane EXIT trap removes its unique runtime volume. No code edits/reruns.

Evidence /private/tmp/pr180356-published-driver: inputs.json,summary.json,update-exit.json,update.stdout,recorded-run.stdout,running-version.stdout,durable-after.stdout,incognito-after.stdout,stop-service-exit.json,stop-service.stderr,gateway.log.exit.json,gateway.log.runtime.json. Wrapper log /private/tmp/pr180356-published-driver-cell.log.
Worktree clean, exact head unchanged. Artifacts/task image retained for review and closeout.

Native Docker cleanup receipt: docker inspect93e8fa430ca7 reports no such object; docker ps -a --filter ancestor=openclaw-pr180356-published-driver empty. Docker volume events: d99ffca56ff7c686931d0faad0a988fdd871b420986fb3306066da5a5b76ca53 created1793058481,mounted1793058482,unmounted1793058858,destroyed1793058859. No retained writer/process uncertainty.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…nclaw#180356)

* fix(update): repair source artifacts under managed maintenance

* fix(doctor): preserve later native autostart changes during repair
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…0356)

* fix(update): repair source artifacts under managed maintenance

* fix(doctor): preserve later native autostart changes during repair

(cherry picked from commit 8346eba)

Co-authored-by: RomneyDa <[email protected]>
sectrgt pushed a commit to sectrgt/openclaw that referenced this pull request Nov 2, 2026
The openclaw#180356 backport (7065121) refuses Gateway restoration when native
autostart policy changes during Doctor repair. The managed doctor-health fixture
reported isEnabled as the current running state, so stopping the Gateway looked
like a policy change. Main fixed the fixture in openclaw#185277; the release's
legacy-update fixture already carried the equivalent adaptation.

Release adaptation: applied the managed test-support hunk by hand; the file's
structure diverged from main.

(cherry picked from commit 217817b, src/flows/doctor-health.managed.test-support.ts hunk only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. cli CLI command changes commands Command implementations gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

fix(update): repair publishes source artifacts before entering maintenance

1 participant