Skip to content

fix(update): preserve restart intent before macOS Gateway shutdown - #155433

Merged
fuller-stack-dev merged 4 commits into
mainfrom
openclaw/native-update-restart-intent-20260922
Sep 23, 2026
Merged

fuller-stack-dev merged 4 commits into
mainfrom
openclaw/native-update-restart-intent-20260922

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Authenticate managed-update restart intent before LaunchAgent shutdown. The native stop boundary resolves the selected service environment, revalidates live update authority and serving-process identity, and records process-targeted intent before bootout. Ordinary Stop remains terminal cancellation; a handoff tuple or inherited flag alone is not authority.

User Impact

Update-owned stops preserve the distinction between restart and cancellation. Preparation failure leaves the serving Gateway untouched. Failed native actions clear only their own intent, preserving successor writes even with identical payloads in the same millisecond. No configuration/schema migration, new marker, or native drain-budget change.

Scope

Three production files and three test/support files. The production change is unchanged from the earlier reviewed head. Native caller fixtures now use the actual service adapter and inherited update authority, a real disposable serving process, effective plist, live owner identity, and explicitly isolated handoff SQLite. All original caller scenarios remain; controls cover tuple-only refusal and ordinary external Stop.

Current main was integrated at 44559eb315e09528aa287878494583e32ad9582e, including reload expectation repair 3ff189887d035159bb3e609cead6f8b6719bd390. No unrelated assertion repair or supplier production seam is bundled.

Evidence

Candidate: 42c3a1dc6c46c4ae5ed941615212112d6bf1760c (published; exact-head CI green).

  • Actual composed candidate: 136 passed, 0 failed, 0 skipped across shared-helper consumers: maintenance 62, handoff 63, native caller 11. The 11 are included in 136, not additional. The original fixture reproduced the four CI failures before repair (5 passed / 4 failed).
  • Reused source-identical current-main proof: native intent 23 passed and 4 selected reload cases passed. Another 265 reload cases were name-filtered, not counted as passes.
  • Earlier unchanged affected behavior: restart-intent storage 9, explicit restart 20, published-legacy restart 15, launchd 194 passed. Existing regressions demonstrate missing intent, legacy identity replacement and same-timestamp successor cleanup failures before the fixes.
  • All three touched test/support files were audited in full, including imports, fixtures, hooks, skips and assertions. The obsolete mock adapter and fake PID were replaced with real authority and process behavior; no distinct regression was removed or assertion weakened. No retry/timeout increase. Private SQLite path and canonical parent are verified before access; children settle and mocks/environment restore.
  • Cost: composed native-caller file 4.24s, handoff 6.81s, maintenance 1.26s; cold affected launcher wall 56.79s, including worker preparation. Existing 23-case native-intent proof cost was 16.28s Vitest / 19.74s launcher wall. Per-case disposable children are required because successful bootout kills the selected identity while refusal must preserve it. No Gateway boots or added sleeps/polling. Resulting-head required CI completed successfully.
  • All selected static gates passed: node scripts/check-changed.mjs --base 44559eb315e09528aa287878494583e32ad9582e completed successfully in 649.86s, including core types, all 25 core-test typecheck shards, six-file typed lint, both dead-export scans, formatting, ratchets, schema/storage, and import/auth guards. API-direct final-composition review is scoped-clean through P2 with zero findings and whole-file test-quality review. Committed bytes match the tested/reviewed files exactly.

Installed macOS qualification

Exact-head package build and supported local packaging completed successfully. The candidate archive SHA-256 is c0c730a4af6ea7f14436d4839fedf1320c7221043ce3c4aa39cbf31b87ce5597. Installed native-controller module hashes match those emitted from the unchanged published head. The qualification imports installed emitted modules, not a TypeScript source loader, and uses real launchctl, process identities, service adapter, update lease and restart-intent storage.

Candidate controller × installed published 2026.9.4 Gateway: PASS. A unique task-private LaunchAgent and supported private profile were healthy before each stop. Both state and handoff SQLite files were physically pinned before execution and before opens in every product process; shared handoff paths were denied. No live user service or production database was used.

Native case Observed result
Effective-command inspection refusal Rejected before shutdown; the same serving PID remained running, with no signal or intent row.
Authenticated update-owned native stop Real serving Gateway logged received SIGTERM; restarting and completed clean shutdown; restart-intent row was consumed.
Native service-adapter recovery New real serving PID; HTTP /health returned 200.
Ordinary native Stop Real Gateway logged received SIGTERM; shutting down, never restart; no intent remained.
Settlement Exact private LaunchAgent absent and its plist removed.

Redacted observed sequence:

inspection: Effective LaunchAgent service command could not be inspected.
refusal: same serving PID, running; intent=[]
update stop: received SIGTERM; restarting
shutdown: completed cleanly
native recovery: running; /health=200
ordinary stop: received SIGTERM; shutting down
intent=[]; private job absent

Installed candidate controller × installed candidate Gateway: PASS for the same full native sequence: inspection refusal preserves the serving PID, update stop is classified restart and consumes intent, native recovery returns HTTP 200, ordinary Stop is terminal and the private job is absent. This second cell uses the repository-pinned pnpm 12.4 installation and the identical verified package artifact.

This closes the candidate-controlled native shutdown/refusal/recovery evidence gap. It does not change or prove the immutable published 9.4 updater's own first activation: that old writer still lacks this change. An old-to-candidate activation must not be represented as repaired by code that is not yet running. This PR also does not claim full no-loss/UNIQUE durability, automatic recovery, five-child durability or six-session recovery; those are separate successor/stack obligations, not bundled changes.

CI and landing gates

Exact public head 42c3a1dc6c46c4ae5ed941615212112d6bf1760c: required CI is green in both check-run and commit-status representations (openclaw/ci-gate). CI run 35691894743 completed with 119 successful and 17 unselected jobs; status publisher 35693640726 also completed. Earlier-head failures are superseded by the repaired and tested exact public head, not rerun as false proof.

ClawSweeper found no actionable patch findings; its installed-native qualification request is addressed above, with the immutable first-activation boundary expressly retained. No release artifact was published and no live Odin service was restarted or updated.

@clawsweeper

clawsweeper Bot commented Sep 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 22, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. labels Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 10:15 PM ET / September 23, 2026, 02:15 UTC (Revision 4).

ClawSweeper review

What this changes

The PR records authenticated restart intent before update-driven macOS Gateway shutdown and prevents failed-stop cleanup from deleting a newer restart request.

Merge readiness

✅ Ready for maintainer review

Keep open for landing: the change remains necessary, no actionable patch defect was found, and the installed macOS evidence resolves the earlier native-behavior proof gap. The published updater’s first activation remains explicitly outside this fix.

Priority: P2
Reviewed head: 42c3a1dc6c46c4ae5ed941615212112d6bf1760c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful installed-platform evidence, preserved regression coverage, and no remaining actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Installed macOS logs exercise the changed native controller against published and candidate Gateways, showing safe refusal, consumed restart intent, healthy recovery, and ordinary terminal Stop. This resolves the earlier candidate-controller proof gap; it does not prove or repair the immutable old updater's first activation. Existing-state compatibility is supported by the unchanged payload, published reader inspection, and published-Gateway consumption.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): Installed macOS logs exercise the changed native controller against published and candidate Gateways, showing safe refusal, consumed restart intent, healthy recovery, and ordinary terminal Stop. This resolves the earlier candidate-controller proof gap; it does not prove or repair the immutable old updater's first activation. Existing-state compatibility is supported by the unchanged payload, published reader inspection, and published-Gateway consumption.
Evidence reviewed 9 items Pinned change and review continuity: Reviewed the introduced delta from 44559eb to the exact original head. The production files are unchanged from the earlier reviewed head 9720415. The supplied test merge is stale and was not used to infer merge effects.
Current main still needs the fix: Current main's native stop owner proceeds to bootout without writing restart intent. The Gateway signal consumer distinguishes external restart from terminal Stop by consuming that intent, establishing the missing connection.
Authority and final native effects: The controller requires inherited live update ownership, checks transferred handoff identity, resolves the selected service environment, and revalidates serving ownership before intent storage and native mutation. Existing native dispatch also revalidates queued update authority. Tests cover tuple-only callers, revoked leases, replaced serving owners, preparation failure, and ordinary external Stop.
Findings None None.
Security None None.

How this fits together

The macOS service controller translates update and Stop requests into LaunchAgent operations. Restart intent tells the serving Gateway whether SIGTERM should drain work for a restart or perform terminal cancellation.

flowchart TD
  A[Update or ordinary Stop] --> B[Mac service controller]
  B --> C{Live update authority?}
  C -->|Yes| D[Verify serving process and record intent]
  C -->|Ordinary Stop| E[Unload LaunchAgent]
  D --> E
  E --> F[Gateway receives SIGTERM]
  F --> G[Restart drain or terminal shutdown]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +166, Tests +621. Total +787 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 199 33 +166
Tests 3 755 134 +621
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 954 167 +787

Review metrics

Metric Value Why it matters
Production versus regression coverage Net production +166 lines; tests/support +621 lines Production growth adds live authority, serving-identity checks, and owned cleanup; the larger test delta exercises refusal and successor-preservation cases.

Technical review

Best possible solution:

Keep restart classification in the existing native stop and intent owners, with live authorization, safe preparation refusal, and unchanged ordinary Stop semantics.

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

Yes, from source: current main's update stop reaches launchctl bootout without recording the intent required for SIGTERM restart classification. The reviewer did not execute a failing macOS run.

Is this the best way to solve the issue?

Yes. Extending the existing native boundary and intent store is a focused repair, and the installed evidence covers the changed controller behavior without claiming to repair an updater that is already published.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Installed macOS logs exercise the changed native controller against published and candidate Gateways, showing safe refusal, consumed restart intent, healthy recovery, and ordinary terminal Stop. This resolves the earlier candidate-controller proof gap; it does not prove or repair the immutable old updater's first activation. Existing-state compatibility is supported by the unchanged payload, published reader inspection, and published-Gateway consumption.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is a bounded macOS managed-update reliability fix; the related prolonged outage was subsequently traced to a different Doctor path.
  • 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 (logs): Installed macOS logs exercise the changed native controller against published and candidate Gateways, showing safe refusal, consumed restart intent, healthy recovery, and ordinary terminal Stop. This resolves the earlier candidate-controller proof gap; it does not prove or repair the immutable old updater's first activation. Existing-state compatibility is supported by the unchanged payload, published reader inspection, and published-Gateway consumption.
  • proof: sufficient: Contributor real behavior proof is sufficient. Installed macOS logs exercise the changed native controller against published and candidate Gateways, showing safe refusal, consumed restart intent, healthy recovery, and ordinary terminal Stop. This resolves the earlier candidate-controller proof gap; it does not prove or repair the immutable old updater's first activation. Existing-state compatibility is supported by the unchanged payload, published reader inspection, and published-Gateway consumption.

Evidence

What I checked:

  • Pinned change and review continuity: Reviewed the introduced delta from 44559eb to the exact original head. The production files are unchanged from the earlier reviewed head 9720415. The supplied test merge is stale and was not used to infer merge effects. (src/daemon/launchd-stop.ts:168, 42c3a1dc6c46)
  • Current main still needs the fix: Current main's native stop owner proceeds to bootout without writing restart intent. The Gateway signal consumer distinguishes external restart from terminal Stop by consuming that intent, establishing the missing connection. (src/daemon/launchd-stop.ts:151, 1dd82fa0d398)
  • Authority and final native effects: The controller requires inherited live update ownership, checks transferred handoff identity, resolves the selected service environment, and revalidates serving ownership before intent storage and native mutation. Existing native dispatch also revalidates queued update authority. Tests cover tuple-only callers, revoked leases, replaced serving owners, preparation failure, and ordinary external Stop. (src/daemon/launchd-stop.ts:168, 42c3a1dc6c46)
  • Installed macOS behavior proof: The complete supplied PR body, captured under sourceRevision 07f9978857f3301dd47ff8da8d3155de371ada143b824c5fd0b15ba300f5ba39, records installed candidate-controller runs against both published 2026.9.4 and candidate Gateways. Real launchctl and isolated LaunchAgents showed preparation refusal preserving the serving PID, restart-intent consumption, clean shutdown, recovery to HTTP 200, ordinary terminal Stop, and final job removal. The recorded package hash is c0c730a4af6ea7f14436d4839fedf1320c7221043ce3c4aa39cbf31b87ce5597. These are supplied observations, not reviewer-executed tests. (42c3a1dc6c46)
  • Stored-format compatibility: The patch preserves the existing intent table and consumer payload. Cleanup compares its recorded row, and updated_at_ms distinguishes successive candidate writes; consumption and expiry continue using created_at. The published v2026.9.5 consumer does not read updated_at_ms, and the supplied installed 2026.9.4 run demonstrates consumption of candidate-written intent. (src/infra/restart-intent.ts:373, 42c3a1dc6c46)
  • Release boundary: The latest supplied release, v2026.9.5, also lacks this update-owned intent preparation in native stop. Existing update documentation explicitly distinguishes repairs to future installed updaters from the immutable 2026.9.4 updater's first activation; the PR preserves that distinction rather than claiming an old-driver fix. (src/daemon/launchd-stop.ts:100, ec9c1a13db89)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • fuller-stack-dev: 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 (3 earlier review cycles)
  • reviewed 2026-09-22T04:49:12.889Z sha 9720415 :: blocked before merge. :: none
  • reviewed 2026-09-22T05:52:17.256Z sha 42c3a1d :: blocked before merge. :: none
  • reviewed 2026-09-22T06:17:32.343Z sha 42c3a1d :: blocked before merge. :: none

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

The unchanged published head now has real installed macOS qualification in the updated PR body: the installed candidate controller and a published 2026.9.4 Gateway, using an actual isolated LaunchAgent, prove safe preparation refusal, consumed restart intent, native recovery to healthy and ordinary terminal Stop. The immutable 9.4 updater first-activation limitation is explicitly separate and is not claimed fixed. Exact-head required CI is green; please refresh the existing review against this concrete evidence.

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 23, 2026
@fuller-stack-dev
fuller-stack-dev merged commit e0dc76b into main Sep 23, 2026
230 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/native-update-restart-intent-20260922 branch September 23, 2026 02:52
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
…penclaw#155433)

* fix(daemon): authenticate managed-update intent before launchd stop

* test(update): make native restart intent fixture portable

* test: exercise native update caller authority
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
roboclaw-bot added a commit that referenced this pull request Sep 26, 2026
Backport #155433: e0dc76b
Backport #149307: 8a53ee3
Adapted backport #156584: a1107a5

Preserve authenticated pre-stop restart intent and exact cleanup receipts.
Probe protected launchd plists through the existing runtime owner. Require
a helper cleanup receipt plus unsignalled closure before replacement; same-unit
dueling installs retain system restrictions without changing global user-first policy.

143 original focused passes and 50 review-repair passes retain their bindings.
Both findings are resolved. Composed native/CLI/restart checks and frozen
guards pass; 16 native macOS cases and live system-unit/driver proof remain open.
Report credit for the system-service issue: @ion-developing.

Co-authored-by: Jason (Json) <[email protected]>
Co-authored-by: PollyBot13 <[email protected]>
Co-authored-by: Patrick Erichsen <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: jalehman <[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 gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant