Skip to content

fix(update): stop an uninspected predecessor Gateway before candidate Doctor - #156138

Merged
steipete merged 9 commits into
mainfrom
fix/update-first-hop-retained-owner
Sep 23, 2026
Merged

steipete merged 9 commits into
mainfrom
fix/update-first-hop-retained-owner

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw update from 2026.9.5 to the 2026.9.6 candidate fails at the post-install Doctor with another OpenClaw process owns gateway-lifecycle when the shipped 2026.9.5 updater could not inspect the managed Gateway service, and the package is rolled back. Release blocker for 2026.9.6 (Package Acceptance lane update-first-hop-compat, release-checks run 35803842673 attempts 1 and 2).

User Impact

User impact: operators on 2026.9.5 whose service manager cannot be inspected by the old updater can now update in place; the candidate stops the still-running predecessor Gateway before Doctor and the updated service is restarted afterwards. No change for updates where the old updater already inspected and stopped the service, or on Windows. Under --no-restart the shipped 2026.9.5 driver gives the delegated Doctor no restart consent, so a Gateway the candidate had to stop for Doctor is restarted on the updated installation with an advisory rather than left down.

Why This Change Was Made

Root cause and why #155977 is not the cause

Release blocker for 2026.9.6: Package Acceptance lane update-first-hop-compat fails on the 2026.9.5 → candidate positive hop (release-checks run 35803842673, attempts 1 and 2; FRV 35801740038; Code SHA 2e7d779). The post-swap step update-migrated-finalize.worker.js --doctor exits 1 in 2.8 s with StateDatabaseCoordinatorContentionError: another OpenClaw process owns gateway-lifecycle, and the run records managed-service: Gateway service inspection is unavailable; automatic service restart was skipped.

Root cause: the 2026.9.5 updater (immutable) inspects the managed Gateway service with its own adapter before delegating finalization to the candidate's worker. When that inspection reports unavailable, it transfers an unstopped, still-running 2026.9.5 Gateway (preManagedServiceStop.serviceUpdateVerdict.kind === "unavailable"). The running predecessor holds the gateway-lifecycle coordinator lock; a supervised owner never releases it on its own (2026.9.5 has no installation-replacement self-detection), and Doctor only waits on a foreground lease owner, so maintenance admission is refused immediately. Baselines 2026.9.1–2026.9.4 pass because those Gateways do not hold the lifecycle coordinator. The lane's negative control (2026.9.1, ENOENT shared-DFJEouXv.js) is expected and unchanged.

This is not caused by #155977: the hard-link retention only wraps the candidate's own updateCommand, which never runs in the first hop. This targeted lane had not executed in Package Acceptance for the prior candidate (no update-first-hop-compat job in runs 35782428117 / 35787498943 / 35802245917 / 35802312114 / 35797937836), so 35803842673 is its first run against a 2026.9.5 baseline.

  • src/infra/update-candidate-predecessor-stop.ts (new): stopSupervisedPredecessorGateway runs in the candidate's --doctor entrypoint (runDelegatedDoctor), which is the step the immutable 2026.9.5 driver invokes as its post-verification Doctor and the step that fails in CI. When the current Gateway owner lease is live and supervised, it stops that predecessor through the candidate's service adapter (maybeStopManagedServiceBeforeMutableUpdate, phase prepare) under the composed executor + requester authority (assertCurrent, which throws UpdateRequesterRevokedError before any native mutation), then records managed-service:candidate-stop in the update-run ledger. A foreground owner keeps Doctor's existing wait. adoptCandidateManagedServiceStop runs in finalization: for a transferred uninspected unavailable verdict it re-inspects, adopts the ledger-recorded Doctor stop as stopped, and hands the state to finishUpdate so the existing restart path starts the updated service. Both paths are skipped on Windows so a candidate-created Scheduled Task suspension can never be dropped. The ledger step is recorded in the onStopped callback (the native mutation boundary) with the stopped service's pid, verdict fingerprint and manager uid; finalization adopts it only when its own fresh inspection reports the same fingerprint and manager uid, and restores (force-restarts, with an advisory step) when the run was --no-restart.

  • src/infra/update-migrated-finalize.worker.ts: wires the two hooks above; the finalization hook revalidates the requester (run.requesterAuthority.isCurrent()) as well as the executor fence before native mutation.

  • src/cli/update-cli/update-command-legacy-service-stop.ts: the decision helper (needsCandidateManagedServiceStop).

  • src/daemon/systemd-scope.ts / systemd-lifecycle.ts: start and restart admission use the same rule (assertNoSystemGatewayOwnershipForActivation), so the updated service can start under exactly the condition that admitted the stop; a proven system owner still refuses.

  • src/daemon/systemd-definition-mutation.ts: when the system-scope ownership probe is unverifiable (SERVICE_DEFINITION_UNKNOWN [system-ownership-unverified], seen in the CI log) and the caller requires a loaded unit, a loaded user unit whose artifacts this account owns keeps its writable capability. The refusal is unchanged without requireLoaded, for a system-owned unit, and when the user unit is not loaded or not owned.

  • src/cli/update-cli/update-command-service-drain.ts: a resident whose installation was already replaced closes every connection with gateway install changed (1011); the drain now warns and stops it directly instead of polling until the 30 min step deadline. The delegated Doctor stop is additionally bounded by the 330 s service stop budget. Found by the local lane rerun on the b2b8ada bytes, which reproduced the CI handoff (the 2026.9.5 updater skipped its own stop, the candidate --doctor hook fired) and then hung in the drain until the container timeout.

  • Hard-link retention (fix(update): retain the running updater by hard link instead of copying the package #155977) and the lane are untouched.

Evidence

  • CI: /private/tmp/openclaw-frv-triage/fhc/targeted-update-first-hop-compat/update-first-hop-compat.log lines 277–470 (positive-first doctor-failed, service-inspection-unavailable, rollback). Doctor durationMs 2849 shows no owner wait.
  • Local lane, flat worktree at the candidate, update-first-hop-compat-docker.sh restricted to the 2026.9.5 source (OPENCLAW_UPDATE_FIRST_HOP_SOURCE_PACKAGE_TGZ=openclaw-2026.9.5.tgz): Packaged updater first-hop compatibility E2E passed. Service PIDs 617 → 4372 → 9605 across the two hops; positive-systemctl.log.callers records {"action":"stop","roles":["update"]} before Doctor and restart after. Locally the 2026.9.5 adapter resolves the shim-managed service as owned, so the CI-only unavailable verdict cannot be reproduced here; the candidate-side stop covers it in CI.
  • Unit: update-command-legacy-service-stop.test.ts (7), update-migrated-finalize.worker.test.ts (22: three --doctor cases proving the supervised owner is stopped and recorded before runDoctorHealthFlow runs, a foreground owner and no owner are left alone; finalization cases for stop, no-stop, adoption of the Doctor's ledger stop, --no-restart restoration and reassigned-service refusal; the Doctor stop case has the native stop throw after onStopped and proves the ledger still records the identity), systemd-definition-loaded.test.ts (unverifiable-owner capability and activation admission: writable/admitted only for a loaded owned unit, refused without requireLoaded, when not loaded, and for a proven system owner), systemd-system.test.ts, systemd-definition-mutation.test.ts, systemd-maintenance.test.ts, update-command-migrated.test.ts all pass. pnpm tsgo:core clean. OPENCLAW_TESTBOX=1 pnpm check:changed passed on 1e5af47 (exit 0, Blacksmith Testbox) and is rerunning on the final head; the only failures on intermediate heads were knip (unused export) and the assertion-SAFETY ratchet, both fixed by follow-up commits.

Review follow-ups addressed: the hook now sits in the --doctor entrypoint the 2026.9.5 driver calls (not only in migrated finalization); requester authority is revalidated before the native stop; Windows is excluded so no candidate-created autostart recovery can be lost; a stop that reports mutation and then throws leaves the ledger step unrecorded and Doctor fails as before, with the service manager's own state visible via openclaw gateway status --deep.

Advisory, not addressed here: cross_os_release_checks / Windows / packaged upgrade in the same run fails with directory changed during durable directory operation: C:\Users\RUNNER~1\AppData\Local\Temp\openclaw 2 s into the 2026.9.5 → candidate update.

@clawsweeper

clawsweeper Bot commented Sep 23, 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 gateway Gateway runtime cli CLI command changes size: M maintainer Maintainer-authored PR labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 23, 2026, 1:05 AM ET / 05:05 UTC (Revision 4).

ClawSweeper review

What this changes

The candidate updater stops a running predecessor Gateway before Doctor, records restoration information, and adjusts Linux service admission and stale-install draining.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 9 items remain

Keep open: the published-updater failure remains on current main, and this protected PR has useful work. Earlier fixes improved the patch, but recovery and service-identity defects remain.

Priority: P1
Reviewed head: 79acea644a6e73c6d86758bf8a96c18be211a651

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) A useful candidate-side repair has meaningful follow-up work, but recovery defects and incomplete boundary proof prevent readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: Authority-chain proof required: show authorized candidate stop/restoration and rejection of a revoked requester or reassigned running service before native I/O. The captured Docker success used the old driver's owned-service path; the later unavailable-inspection attempt hung before the latest fix. The new persisted restoration receipt also lacks compatibility proof through real ledger compaction and published-parent writes. The maintainer exemption remains intact for unrelated proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: show authorized candidate stop/restoration and rejection of a revoked requester or reassigned running service before native I/O. The captured Docker success used the old driver's owned-service path; the later unavailable-inspection attempt hung before the latest fix. The new persisted restoration receipt also lacks compatibility proof through real ledger compaction and published-parent writes. The maintainer exemption remains intact for unrelated proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 9 items Pinned introduction and current-main necessity: Reviewed the merge-base d5225dd to head 79acea6 changes. Fetched main still calls Doctor without the predecessor-stop hook and has no update-candidate-predecessor-stop.ts. The supplied test merge is stale, so no base-only changes were attributed to this PR.
Published no-restart handoff: GitHub contents inspection of v2026.9.5 confirms that successful service inspection followed by shouldRestart=false returns inspected state without stopping the service. The candidate Doctor now stops any live supervised owner, but its adoption predicate still requires an unavailable, uninspected parent verdict.
Service identity checked after possible mutation: Finalization invokes phase=prepare with shouldRestart=true and no expectedService before comparing the recorded fingerprint and manager UID. The shared maintenance owner can stop a currently running service; the later identity comparison runs only when that call did not stop it.
Findings 3 actionable findings [P1] Restore Doctor-stopped services when the parent inspected them
[P1] Validate the recorded service identity before preparing another stop
[P2] Protect the restoration receipt from diagnostic eviction
Security Needs attention Reassigned service can inherit the earlier stop operation: Finalization freshly admits and may stop a running replacement before comparing Doctor's recorded service identity; validate the original binding before native I/O and prove rejection after reassignment or requester revocation.

How this fits together

The installed updater delegates post-install maintenance to the candidate package. Candidate Doctor and finalization coordinate service shutdown, database maintenance, and restarting the updated Gateway.

flowchart TD
  A[Installed updater] --> B[Candidate Doctor]
  B --> C[Check live authority and service ownership]
  C --> D[Stop predecessor Gateway]
  D --> E[Record stop in update ledger]
  E --> F[Run Doctor maintenance]
  F --> G[Candidate finalization]
  G --> H[Restore matching Gateway service]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: show authorized candidate stop/restoration and rejection of a revoked requester or reassigned running service before native I/O. The captured Docker success used the old driver's owned-service path; the later unavailable-inspection attempt hung before the latest fix. The new persisted restoration receipt also lacks compatibility proof through real ledger compaction and published-parent writes. The maintainer exemption remains intact for unrelated proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Restore Doctor-stopped services when the parent inspected them (P1) - The earlier no-restart finding remains for successfully inspected services. Published v2026.9.5 returns inspected: true with an owned verdict under --no-restart, leaving its supervised Gateway running. The new Doctor hook stops that Gateway, but this predicate still requires an unavailable, uninspected parent verdict, so it returns without adopting the recorded stop or setting restartRequired. Finalization consequently leaves the Gateway down. Process a candidate-recorded stop independently of the legacy unavailable-inspection predicate and cover the inspected-parent case.
  • Validate the recorded service identity before preparing another stop (P1) - When an operator replaces and starts the service between Doctor and finalization, this phase: "prepare" call can stop the replacement before comparing it with doctorStop. No expectedService is supplied, so a changed launcher still belonging to the same installation can pass fresh ownership inspection. Once it returns stopped: true, the identity comparison below is skipped altogether. Inspect and compare the recorded identity before any native mutation, retaining that binding through the stop. The current reassignment test only supplies a nonrunning service.
  • Protect the restoration receipt from diagnostic eviction (P2) - This recovery-critical receipt uses a disposable step key. update-run-write.ts evicts nonretained entries above 128 steps, and update-run-codec.ts evicts them above 16 KiB. Buffered steps are written before finalization reads this receipt, so a sufficiently verbose update can lose it and leave a candidate-stopped Gateway down under --no-restart. Preserve both the receipt and its identity payload through the ledger's count, byte, and detail-compaction limits, including writes by the published parent. The disposable-key issue was also visible in the earlier reviewed source and was missed.
  • Resolve security concern: Reassigned service can inherit the earlier stop operation - Finalization freshly admits and may stop a running replacement before comparing Doctor's recorded service identity; validate the original binding before native I/O and prove rejection after reassignment or requester revocation.
  • Resolve merge risk (P1) - Candidate shutdown can leave an inspected --no-restart installation offline, and diagnostic eviction can erase the restoration receipt.
  • Resolve merge risk (P1) - A service reassigned after Doctor can be stopped before its recorded identity is checked; final-effect rejection of reassignment and requester revocation remains unproven.
  • Resolve merge risk (P1) - The affected published v2026.9.5 unavailable-inspection upgrade has no recorded successful completion on the latest implementation.
  • Complete next step (P2) - Resolve the three findings and add redacted upgrade and authority-boundary terminal output or logs. Screenshots or recordings are useful when they show those diagnostics. Remove secrets and private endpoints; updating the PR body triggers re-review, or a maintainer can request @clawsweeper re-review.

Findings

  • [P1] Restore Doctor-stopped services when the parent inspected them — src/infra/update-candidate-predecessor-stop.ts:175-183
  • [P1] Validate the recorded service identity before preparing another stop — src/infra/update-candidate-predecessor-stop.ts:187-198
  • [P2] Protect the restoration receipt from diagnostic eviction — src/infra/update-candidate-predecessor-stop.ts:113-118
  • [medium] Reassigned service can inherit the earlier stop operation — src/infra/update-candidate-predecessor-stop.ts:187
Agent review details

Security

Needs attention: The new delayed service handoff checks recorded identity after a reachable native stop.

PR surface

Source +370, Tests +441. Total +811 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 7 380 10 +370
Tests 4 442 1 +441
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 822 11 +811

Review metrics

Metric Value Why it matters
Production versus test growth production +370 net lines; tests +441 net lines The production growth is justified as a candidate-side bridge for an immutable published updater, but its recovery state must survive the existing ledger lifecycle.

Merge-risk options

Maintainer options:

  1. Complete matching-service recovery (recommended)
    Handle every candidate-recorded stop, reject service reassignment before native mutation, preserve the receipt through ledger compaction, and supply the affected upgrade trace.

Technical review

Best possible solution:

Keep shutdown and restoration with the existing service owner, retain a durable matching-service receipt, and prove the published-driver handoff through successful recovery and rejected stale authority.

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

Yes, source inspection establishes deterministic paths for inspected-parent restoration failure, mutation before identity comparison, and receipt eviction. Runtime reproduction was not executed in this read-only review.

Is this the best way to solve the issue?

The candidate-side repair is appropriate because the published updater cannot be changed, but the current implementation does not yet preserve recovery and service identity across the complete handoff.

Full review comments:

  • [P1] Restore Doctor-stopped services when the parent inspected them — src/infra/update-candidate-predecessor-stop.ts:175-183
    The earlier no-restart finding remains for successfully inspected services. Published v2026.9.5 returns inspected: true with an owned verdict under --no-restart, leaving its supervised Gateway running. The new Doctor hook stops that Gateway, but this predicate still requires an unavailable, uninspected parent verdict, so it returns without adopting the recorded stop or setting restartRequired. Finalization consequently leaves the Gateway down. Process a candidate-recorded stop independently of the legacy unavailable-inspection predicate and cover the inspected-parent case.
    Confidence: 0.98
  • [P1] Validate the recorded service identity before preparing another stop — src/infra/update-candidate-predecessor-stop.ts:187-198
    When an operator replaces and starts the service between Doctor and finalization, this phase: "prepare" call can stop the replacement before comparing it with doctorStop. No expectedService is supplied, so a changed launcher still belonging to the same installation can pass fresh ownership inspection. Once it returns stopped: true, the identity comparison below is skipped altogether. Inspect and compare the recorded identity before any native mutation, retaining that binding through the stop. The current reassignment test only supplies a nonrunning service.
    Confidence: 0.97
  • [P2] Protect the restoration receipt from diagnostic eviction — src/infra/update-candidate-predecessor-stop.ts:113-118
    This recovery-critical receipt uses a disposable step key. update-run-write.ts evicts nonretained entries above 128 steps, and update-run-codec.ts evicts them above 16 KiB. Buffered steps are written before finalization reads this receipt, so a sufficiently verbose update can lose it and leave a candidate-stopped Gateway down under --no-restart. Preserve both the receipt and its identity payload through the ledger's count, byte, and detail-compaction limits, including writes by the published parent. The disposable-key issue was also visible in the earlier reviewed source and was missed.
    Confidence: 0.98
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The PR addresses a reproduced published-release upgrade failure and still contains defects that can leave the Gateway offline.
  • merge-risk: 🚨 compatibility: The candidate shutdown path affects inspected --no-restart installations beyond the intended unavailable-inspection handoff.
  • merge-risk: 🚨 security-boundary: Finalization can act on a reassigned service before validating the identity recorded by Doctor.
  • merge-risk: 🚨 availability: Missed adoption or eviction of the stop receipt can prevent restoration of a Gateway stopped by the candidate.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: show authorized candidate stop/restoration and rejection of a revoked requester or reassigned running service before native I/O. The captured Docker success used the old driver's owned-service path; the later unavailable-inspection attempt hung before the latest fix. The new persisted restoration receipt also lacks compatibility proof through real ledger compaction and published-parent writes. The maintainer exemption remains intact for unrelated proof. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Reassigned service can inherit the earlier stop operation — src/infra/update-candidate-predecessor-stop.ts:187
    Finalization freshly admits and may stop a running replacement before comparing Doctor's recorded service identity; validate the original binding before native I/O and prove rejection after reassignment or requester revocation.
    Confidence: 0.97

What I checked:

  • Pinned introduction and current-main necessity: Reviewed the merge-base d5225dd to head 79acea6 changes. Fetched main still calls Doctor without the predecessor-stop hook and has no update-candidate-predecessor-stop.ts. The supplied test merge is stale, so no base-only changes were attributed to this PR. (src/infra/update-migrated-finalize.worker.ts:255, 2559458e2b4c)
  • Published no-restart handoff: GitHub contents inspection of v2026.9.5 confirms that successful service inspection followed by shouldRestart=false returns inspected state without stopping the service. The candidate Doctor now stops any live supervised owner, but its adoption predicate still requires an unavailable, uninspected parent verdict. (src/cli/update-cli/update-command-service-maintenance.ts:503, ec9c1a13db89)
  • Service identity checked after possible mutation: Finalization invokes phase=prepare with shouldRestart=true and no expectedService before comparing the recorded fingerprint and manager UID. The shared maintenance owner can stop a currently running service; the later identity comparison runs only when that call did not stop it. (src/infra/update-candidate-predecessor-stop.ts:187, 79acea644a6e)
  • Recovery receipt is evictable: The new managed-service:candidate-stop key is not retained by isRetainedStep. The ledger removes disposable steps beyond 128 entries or 16 KiB; retained-detail compaction can also remove ordinary detail payloads. Finalization depends on this receipt to restore a candidate-stopped Gateway under --no-restart. The published v2026.9.5 codec has the same relevant eviction behavior. (src/infra/update-run-codec.ts:53, 79acea644a6e)
  • Prior review reconciliation: The current source aligns Linux activation admission with the new inspection fallback and records stops through onStopped, addressing those earlier findings. No-restart restoration now handles the uninspected-parent case but misses inspected-parent state. Exact earlier-head contents were read through GitHub after local historical blob retrieval failed; the earlier receipt key was already disposable. (src/infra/update-candidate-predecessor-stop.ts:175, 79acea644a6e)
  • Captured behavior proof and accepted restoration tradeoff: The supplied body at sourceRevision 8a1235d878ea9e34060cb9f19bb8c51e4ef72eb6e5aab2a7447cf688a4906b76 reports successful Docker upgrade hops with service PIDs 617 → 4372 → 9605, while explicitly saying the old adapter classified the service as owned. A later unavailable-inspection run reached candidate shutdown but hung before the latest drain fix. No completed after-fix trace covers that handoff or forbidden/reassigned authority. The maintainer-authored body explicitly accepts restoration despite --no-restart when candidate Doctor stopped the Gateway; this review does not reopen that tradeoff. (79acea644a6e)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Repair inspected-parent restoration, pre-mutation identity validation, and durable receipt retention with focused regressions.
  • Provide a completed v2026.9.5 unavailable-inspection upgrade trace, including the candidate-stop path and restored Gateway.
  • Provide final-effect evidence that revoked requesters and reassigned running services cannot trigger native stop or restart.

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 (3 earlier review cycles)
  • reviewed 2026-09-23T03:32:23.485Z sha 1e5af47 :: needs real behavior proof before merge. :: [P1] Run predecessor shutdown before the published driver's Doctor call | [P1] Revalidate the requester before native service shutdown | [P1] Preserve Windows recovery created by the candidate stop | [P2] Retain partial shutdown state when service stopping throws
  • reviewed 2026-09-23T04:00:16.179Z sha 021ae67 :: needs real behavior proof before merge. :: [P1] Preserve --no-restart before stopping the supervised Gateway | [P1] Align restart admission before allowing the new systemd stop path
  • reviewed 2026-09-23T04:11:05.998Z sha 4fd35f3 :: needs real behavior proof before merge. :: [P1] Preserve --no-restart before stopping the supervised Gateway | [P1] Align restart admission before allowing the new systemd stop path | [P2] Retain recovery state when native shutdown succeeds before an error

@steipete steipete self-assigned this Sep 23, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 23, 2026
Peter Steinberger added 5 commits September 22, 2026 21:23
…store it under --no-restart, and admit activation past an unverifiable system probe
…nd admit past an unverifiable probe as a fallback
…n-free identity match and keep its receipt through ledger compaction
@steipete
steipete merged commit 0f348ae into main Sep 23, 2026
198 checks passed
@steipete
steipete deleted the fix/update-first-hop-retained-owner branch September 23, 2026 06:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
… Doctor (openclaw#156138)

## What Problem This Solves

Fixes: `openclaw update` from 2026.9.5 to the 2026.9.6 candidate fails at the post-install Doctor with `another OpenClaw process owns gateway-lifecycle` when the shipped 2026.9.5 updater could not inspect the managed Gateway service, and the package is rolled back. Release blocker for 2026.9.6 (Package Acceptance lane `update-first-hop-compat`, release-checks run 35803842673 attempts 1 and 2).

## User Impact

User impact: operators on 2026.9.5 whose service manager cannot be inspected by the old updater can now update in place; the candidate stops the still-running predecessor Gateway before Doctor and the updated service is restarted afterwards. No change for updates where the old updater already inspected and stopped the service, or on Windows. Under `--no-restart` the shipped 2026.9.5 driver gives the delegated Doctor no restart consent, so a Gateway the candidate had to stop for Doctor is restarted on the updated installation with an advisory rather than left down.

## Why This Change Was Made

- `src/infra/update-candidate-predecessor-stop.ts` (new): `stopSupervisedPredecessorGateway` runs in the candidate's `--doctor` entrypoint (`runDelegatedDoctor`), which is the step the immutable 2026.9.5 driver invokes as its post-verification Doctor and the step that fails in CI. When the current Gateway owner lease is `live` and `supervised`, it stops that predecessor through the candidate's service adapter (`maybeStopManagedServiceBeforeMutableUpdate`, phase `prepare`) under the composed executor + requester authority (`assertCurrent`, which throws `UpdateRequesterRevokedError` before any native mutation), then records `managed-service:candidate-stop` in the update-run ledger. A `foreground` owner keeps Doctor's existing wait. `adoptCandidateManagedServiceStop` runs in finalization: for a transferred uninspected `unavailable` verdict it re-inspects, adopts the ledger-recorded Doctor stop as `stopped`, and hands the state to `finishUpdate` so the existing restart path starts the updated service. Both paths are skipped on Windows so a candidate-created Scheduled Task suspension can never be dropped. The Doctor records a retained `finalize:predecessor-stop:<stoppedAtMs>:<managerUid>:<pid>:<fingerprint>` receipt in the `onStopped` callback (the native mutation boundary); the identity lives in the step key because published parents strip `detail` from retained steps under the ledger byte limit. Finalization processes that receipt independently of the legacy verdict: it inspects without mutating (`phase: "inspect"`), adopts the stop only when the current service reports the same fingerprint and manager uid, leaves a replaced service untouched with an `exitCode: 1` advisory step, does not stop again a same-identity service that was started after Doctor, and restores (force-restarts, with an advisory) when the run was `--no-restart`, including the case where the old updater had inspected an owned service.

- `src/infra/update-migrated-finalize.worker.ts`: wires the two hooks above; the finalization hook revalidates the requester (`run.requesterAuthority.isCurrent()`) as well as the executor fence before native mutation.
- `src/cli/update-cli/update-command-legacy-service-stop.ts`: the decision helper (`needsCandidateManagedServiceStop`).
- `src/daemon/systemd-scope.ts` / `systemd-lifecycle.ts`: start and restart admission use the same rule (`assertNoSystemGatewayOwnershipForActivation`), so the updated service can start under exactly the condition that admitted the stop; a proven system owner still refuses.
- `src/daemon/systemd-definition-mutation.ts`: when the system-scope ownership probe is unverifiable (`SERVICE_DEFINITION_UNKNOWN [system-ownership-unverified]`, seen in the CI log) and the caller requires a loaded unit, a loaded user unit whose artifacts this account owns keeps its `writable` capability. The refusal is unchanged without `requireLoaded`, for a system-owned unit, and when the user unit is not loaded or not owned.
- `src/cli/update-cli/update-command-service-drain.ts`: a resident whose installation was already replaced closes every connection with `gateway install changed` (1011); the drain now warns and stops it directly instead of polling until the 30 min step deadline. The delegated Doctor stop is additionally bounded by the 330 s service stop budget. Found by the local lane rerun on the b2b8ada bytes, which reproduced the CI handoff (the 2026.9.5 updater skipped its own stop, the candidate `--doctor` hook fired) and then hung in the drain until the container timeout.
- Hard-link retention (openclaw#155977) and the lane are untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant