Skip to content

fix: update managed macOS Gateways from runtime snapshots#104946

Merged
steipete merged 2 commits into
mainfrom
codex/live-updater-runtime-snapshots
Jul 12, 2026
Merged

fix: update managed macOS Gateways from runtime snapshots#104946
steipete merged 2 commits into
mainfrom
codex/live-updater-runtime-snapshots

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #104945

What Problem This Solves

Fixes an issue where operators updating a managed macOS Gateway could fail to update or restart the intended service when its LaunchAgent was running a clean detached runtime snapshot.

Why This Change Was Made

The updater now validates snapshot provenance, the loaded LaunchAgent arguments, service wrappers, environment, ownership, modes, and listener identity before control or mutation. It drains through a trusted source build, stops the exact managed service, rebuilds and retargets its plist atomically, then proves the restarted source deployment owns the configured port; snapshot code is never executed.

User Impact

Managed macOS Gateways can be updated safely from validated runtime snapshots, including busy retry, custom state, direct-service environment, and wrapper-service configurations. Invalid, stale, or ambiguous service state continues to fail closed. No release or version change is included.

Evidence

  • node scripts/run-vitest.mjs test/scripts/openclaw-live-updater.test.ts — 43 passed
  • git diff --check — clean
  • targeted oxfmt — clean
  • fresh autoreview — no accepted or actionable findings
  • Live clawmac deployment proof will be posted after landing so the tested updater is the exact code on main.

Local focused-test fallback was used because the remote Testbox provider sync failed earlier in the session. The mandatory landing workflow will run with OPENCLAW_TESTBOX=1 against this exact PR head.

@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Jul 12, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8aad71f48

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +824 to +827
writeFileSync(temporaryPath, original, {
flag: "wx",
mode: statSync(deployment.plistPath).mode,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve LaunchAgent plist readability after rewrite

When the updater runs under a restrictive umask such as 077, this writeFileSync(..., { mode: stat.mode }) creates the temporary plist with the requested mode masked, so the existing 0644 LaunchAgent can be renamed back as 0600. The launchd installer explicitly chmods these plists back to world-readable because current macOS rejects unreadable user LaunchAgents; in that environment the subsequent bootstrap can fail after the old service has already been booted out. Chmod the temp file or final plist to the original readable mode before bootstrapping.

Useful? React with 👍 / 👎.

Comment on lines +1501 to 1504
verifyGatewayReadiness(runCommand, checkout, expectedSha, sleep, deployment);
} catch (error) {
verificationError = error;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Audit logs through the managed deployment

This path now verifies status/health through the selected managed deployment, but the restart-window log audit below still calls auditGatewayLogs(checkout, sinceMs) without the deployment's port/config/service environment. When the operator's normal CLI config points at a remote Gateway (the scenario the new overlay handling is meant to isolate), openclaw logs can audit the remote or unrelated local fallback instead of the just-restarted LaunchAgent, allowing post-restart errors from the managed Gateway to be missed.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head d8aad71f48f91df425cd22bf8ca737bdfd639726, but the PR head is now 006f94e49df34b7230d02d38b38498a05dae9b5b. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready at exact head 006f94e49df34b7230d02d38b38498a05dae9b5b.

Proof:

  • Exact-head CI run 29179382328: 50 successful jobs, none failing.
  • node scripts/run-vitest.mjs test/scripts/openclaw-live-updater.test.ts: 43 passed.
  • Testbox tbx_01kxa8b0001pj3gj9t6eyj4qyn: pnpm tsgo:test:root passed.
  • Targeted oxfmt and git diff --check passed.
  • Fresh autoreview after the CI type-contract fix: no accepted or actionable findings.
  • Repository review artifacts validated; OPENCLAW_TESTBOX=1 scripts/pr prepare-run 104946 passed on this exact head.

Live clawmac preflight confirms the managed Gateway is currently running the clean detached gateway-508f6a2 snapshot while the canonical source checkout is clean and current. After merge, the landed updater will migrate that exact service to the rebuilt source entrypoint and prove launchd argv, listener ownership, build stamps, health, and restart-window logs. No release.

@steipete
steipete merged commit f802a6f into main Jul 12, 2026
79 checks passed
@steipete
steipete deleted the codex/live-updater-runtime-snapshots branch July 12, 2026 04:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
…04946)

* fix(updater): migrate validated gateway snapshots

* test(updater): declare snapshot maintenance helpers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Updater can mis-handle managed Gateway runtime snapshots

1 participant