Skip to content

Fix agent update.run managed-service handoff - #81945

Merged
steipete merged 7 commits into
openclaw:mainfrom
BKF-Gitty:codex/fix-agent-update-run-handoff-81894
May 15, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
BKF-Gitty:codex/fix-agent-update-run-handoff-81894

Conversation

@BKF-Gitty

@BKF-Gitty BKF-Gitty commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Managed-service proof summary

This PR now includes real managed-service proof in both the body and a top-level PR comment. The proof was run on a disposable macOS LaunchAgent-backed OpenClaw package install, not only Vitest/mocked service boundaries.

  • Real environment: macOS LaunchAgent-backed package install, isolated temp profile/state/config, temp npm global prefix, local package tarball built from this PR, loopback gateway RPC.
  • Real command path: openclaw gateway call update.run --json ... against the live Gateway/control-plane path.
  • Observed handoff start: ok: true, mode: "npm", reason: "managed-service-handoff-started", handoff.status: "started", restart scheduled with SIGUSR1.
  • Observed pending state: update.status reported reason: "restart-health-pending" and had no success continuation while restart health was still pending.
  • Observed final state: LaunchAgent loaded: true, runtime running, rpc.ok: true, gateway version 2026.5.14, final update.status.status: "ok", and the agent continuation present only after health passed.
  • Cleanup: disposable LaunchAgent was stopped and uninstalled after proof collection.

Redacted proof excerpts are in the Real behavior proof, Repro + Verification, and Evidence sections below, and in PR comment #81945 (comment).

Summary

  • Problem: Agent update.run could run package-manager updates inside the live Gateway process, unlike the safer shell CLI path.
  • Why it matters: A live Gateway package swap can strand managed services, including macOS LaunchAgent installs, and can produce misleading update completion state while the service is unloaded or unreachable.
  • What changed: Gateway update.run now hands supervised global package updates to a detached helper that runs the normal openclaw update --yes --json CLI managed-service path after the Gateway exits; the CLI writes pending/final control-plane restart sentinels around restart health and preserves continuation metadata.
  • What did NOT change (scope boundary): Git/dev installs still use the existing in-process gateway update path; this PR does not remove update.run, change Lossless Claw behavior, or refactor the full updater.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: Agent/control-plane update.run on a package-managed install no longer calls the risky in-process package update path from the live Gateway. It creates a managed-service handoff and relies on the CLI path for service stop/swap/restart/health verification.
  • Real environment tested: Disposable macOS LaunchAgent-backed OpenClaw install from a local package tarball, using an isolated temp profile/state/config, temp npm global prefix, loopback gateway port, and redacted terminal/log output.
  • Exact steps or command run after this patch:
pnpm pack --pack-destination .artifacts/openclaw-update-run-81894-pack

openclaw gateway call update.run --json --timeout 30000 --params '{
  "sessionKey":"agent:main:qa:update-run-81894-final",
  "deliveryContext":{"channel":"webchat","to":"qa-update-run-81894","accountId":"qa"},
  "note":"QA update.run handoff proof after doctor-cwd fix.",
  "continuationMessage":"Verify the updated gateway is reachable and report update status.",
  "restartDelayMs":1000,
  "timeoutMs":1800000
}'

openclaw gateway status --deep --require-rpc --json
openclaw gateway call update.status --json --timeout 30000
  • Evidence after fix:

Initial update.run response from the live Gateway:

{
  "ok": true,
  "result": {
    "status": "skipped",
    "mode": "npm",
    "reason": "managed-service-handoff-started",
    "before": { "version": "2026.5.14" }
  },
  "handoff": { "status": "started", "command": "openclaw update --yes --timeout 1800" },
  "restart": { "ok": true, "signal": "SIGUSR1", "reason": "update.run" }
}

Intermediate update.status while restart health was still pending. This intentionally had no success continuation:

{
  "sentinel": {
    "kind": "update",
    "status": "skipped",
    "stats": {
      "mode": "npm",
      "reason": "restart-health-pending",
      "after": { "version": "2026.5.14" }
    }
  }
}

Detached handoff log after CLI completion:

starting managed update command: openclaw update --yes --timeout 1800
Stopped LaunchAgent: gui/<uid>/<qa-label>
{
  "status": "ok",
  "mode": "npm",
  "steps": [
    { "name": "global update", "exitCode": 0 },
    { "name": "global install swap", "exitCode": 0 },
    { "name": "openclaw doctor", "cwd": "<prefix>/lib/node_modules/openclaw", "exitCode": 0 }
  ],
  "postUpdate": { "plugins": { "status": "ok", "changed": false } }
}
managed update command exited code=0 signal=null

Final managed-service health/status proof:

{
  "service": { "label": "LaunchAgent", "loaded": true, "runtime": { "status": "running" } },
  "rpc": { "ok": true, "server": { "version": "2026.5.14" } }
}

Final update.status sentinel, after health passed:

{
  "sentinel": {
    "kind": "update",
    "status": "ok",
    "continuation": { "kind": "agentTurn" },
    "stats": { "mode": "npm", "reason": null, "after": { "version": "2026.5.14" } }
  }
}
  • Observed result after fix: Gateway package-managed update.run reports managed-service-handoff-started with ok: true, the detached CLI performs global update + staged swap + doctor, the LaunchAgent is stopped and loaded again, RPC is reachable, the gateway version is reported, and the success continuation appears only after restart health passes.
  • What was not tested: The exact OPENCLAW_QA_ALLOW_UPDATE_RUN_SELF=1 harness flag path on a production managed install was not used. The disposable LaunchAgent package-managed proof above exercised the same public control-plane update.run path and managed CLI handoff.
  • Before evidence: Issue v2026.5.12 agent-invoked self-update can leave macOS LaunchAgent unloaded or fail before package swap #81894 reports real LaunchAgent-backed instances where agent-initiated updates left services unloaded or not updated. While proving this PR, an earlier run reproduced a post-swap updater failure where openclaw doctor inherited a removed package cwd; this PR now runs post-swap doctor from the verified package root and the final proof above exits 0.

Root Cause (if applicable)

  • Root cause: The documented control-plane update.run path still allowed the Gateway process to invoke package updates from inside the live Gateway, while the shell CLI path had the safer managed-service stop/restart/recovery flow.
  • Missing detection / guardrail: Gateway tests covered restart sentinel/session behavior but did not assert that package-managed control-plane updates avoid runGatewayUpdate in-process, and CLI sentinel tests did not require success continuations to wait for restart health.
  • Contributing context (if known): The CLI managed-service safeguards and LaunchAgent recovery logic existed, but update.run did not route package-managed self-updates through that abstraction.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/gateway/server-methods/update.test.ts, src/gateway/server-methods/update-managed-service-handoff.test.ts, src/cli/update-cli.test.ts, src/cli/update-cli/update-command.test.ts, src/daemon/launchd.test.ts, src/infra/restart-sentinel.test.ts.
  • Scenario the test should lock in: Package-managed update.run starts a managed-service handoff instead of calling runGatewayUpdate; git/dev update.run still uses the existing in-process update path; service identity env vars survive the supervisor-hint strip; control-plane success continuation is delayed until restart health passes; staged package swap runs doctor from the verified package root.
  • Why this is the smallest reliable guardrail: These tests sit at the Gateway/CLI boundary where the bug lived, while reusing existing CLI LaunchAgent recovery coverage instead of duplicating service-manager internals.
  • Existing test that already covers this (if any): Existing CLI/daemon tests cover LaunchAgent restart/re-bootstrap and health verification; new tests cover the Gateway handoff branch and sentinel timing.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

For supervised package-managed installs, control-plane update.run now reports handoff initiation instead of package-swap completion from inside the old Gateway process. Handoff initiation is ok: true; update.status can report managed-service-handoff-started or restart-health-pending before final success/failure. For package-managed installs without a detected supervisor, update.run returns a structured safe-command response instead of attempting the risky in-process update.

Diagram (if applicable)

Before:
agent update.run -> live Gateway -> package-manager update in same process -> restart attempt -> possible unloaded/unreachable service

After:
agent update.run -> live Gateway writes sentinel + starts handoff -> Gateway exits -> detached helper runs openclaw update --yes --json -> CLI managed-service stop/swap/restart/health verify -> final status/continuation sentinel

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): No
  • New/changed network calls? (Yes/No): No
  • Command/tool execution surface changed? (Yes/No): Yes
  • Data access scope changed? (Yes/No): No
  • If any Yes, explain risk + mitigation: The Gateway now spawns a narrow detached helper for supervised package-managed self-updates. The helper only runs the existing openclaw update --yes --json CLI path, strips supervisor runtime hint env vars while preserving explicit service identity vars, stores sentinel metadata in owner-only temp files, removes sensitive helper/meta files after the CLI exits, and stale handoff directories are swept on CLI update startup.

Repro + Verification

Environment

  • OS: macOS for disposable LaunchAgent proof; OpenClaw PR container for repo tests/build.
  • Runtime/container: Node/Vitest through the OpenClaw PR container; real LaunchAgent proof used the local packaged CLI tarball.
  • Model/provider: N/A.
  • Integration/channel (if any): Gateway control-plane updater path.
  • Relevant config (redacted): Isolated temp OpenClaw profile/state/config, temp npm global prefix, local package tarball via OPENCLAW_UPDATE_PACKAGE_SPEC, loopback gateway port.

Steps

  1. Build/package this PR into a local tarball.
  2. Install/start a disposable macOS LaunchAgent-backed OpenClaw package install from the tarball.
  3. Invoke update.run through openclaw gateway call, not via the shell openclaw update entrypoint.
  4. Poll handoff log, gateway status --deep --require-rpc, and update.status.
  5. Stop/uninstall the disposable LaunchAgent.

Expected

  • Package-managed Gateway update.run does not call runGatewayUpdate in-process.
  • A managed-service handoff is reported as started with ok: true.
  • A durable update sentinel exists before Gateway exit.
  • Pending/restart-health status does not include a success continuation.
  • Final success sentinel is written only after service health passes.
  • Git/dev update mode still uses the existing in-process update runner.

Actual

  • Real disposable LaunchAgent proof passed with final service loaded: true, rpc.ok: true, gateway version 2026.5.14, and final update sentinel status: ok with continuation.
  • All targeted and acceptance tests passed on the pushed commit.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Commands run:

node scripts/run-vitest.mjs src/gateway/server-methods/update.test.ts src/agents/openclaw-gateway-tool.test.ts src/cli/update-cli.test.ts src/cli/update-cli/update-command.test.ts src/daemon/launchd.test.ts
pnpm exec oxfmt --check --threads=1 src/cli/update-cli.test.ts src/cli/update-cli/update-command.ts docs/cli/update.md docs/gateway/protocol.md src/gateway/server-methods/update-managed-service-handoff.test.ts src/gateway/server-methods/update-managed-service-handoff.ts src/gateway/server-methods/update.ts src/gateway/server-restart-sentinel.ts src/infra/restart-sentinel.test.ts src/infra/update-control-plane-sentinel.ts
git diff --check
pnpm pack --pack-destination .artifacts/openclaw-update-run-81894-pack

Results:

acceptance: Test Files 7 passed (7), Tests 264 passed (264), Duration 99.17s
format check: All matched files use the correct format
diff check: passed
pack/build: package tarball created; build-smoke bundled channel entry smoke passed

Human Verification (required)

What I personally verified (not just CI), and how:

  • Verified scenarios: Real macOS LaunchAgent-backed package install invoked update.run from the live Gateway; handoff-start response; intermediate restart-health-pending status without continuation; final LaunchAgent loaded/RPC reachable/version proof; final update.status ok sentinel with continuation; disposable LaunchAgent cleanup.
  • Edge cases checked: Full supervisor runtime hint env stripping while preserving service identity vars, stale handoff temp cleanup, restart health mismatch marking the sentinel failed and removing continuation, post-swap doctor cwd after staged npm swap, and response-shape docs for managed-service-handoff-* / restart-health-pending reasons.
  • Remaining unverified item: The exact OPENCLAW_QA_ALLOW_UPDATE_RUN_SELF=1 QA harness flag path on a production managed install. The disposable LaunchAgent package-managed proof above exercised the same public control-plane update.run path and managed CLI handoff.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: Update flow changes can leave package-managed installs in a bad state if the handoff or restart health reporting is wrong.
    • Mitigation: The Gateway writes a durable sentinel before exit, the CLI overwrites/marks it after managed-service restart verification, and failed health checks remove the success continuation.
  • Risk: Non-supervised global installs lose the old in-process package update behavior.
    • Mitigation: update.run returns a structured safe command instead of doing the risky live package swap.
  • Risk: Git/dev installs could regress if the branch is too broad.
    • Mitigation: A test locks git/dev installs to the existing runGatewayUpdate path.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes size: XL labels May 14, 2026
@clawsweeper

clawsweeper Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

Summary
The PR reroutes supervised package-managed Gateway update.run calls through a detached CLI managed-service handoff and updates restart sentinels, tests, and updater docs.

Reproducibility: yes. Source inspection shows current main sends supervised global update.run through runGatewayUpdate in the live Gateway process, and the linked issue plus PR proof describe the LaunchAgent-backed failure mode; I did not run the destructive self-update locally.

Real behavior proof
Sufficient (logs): The PR body and comment include after-fix redacted logs from a real disposable macOS LaunchAgent package install showing live update.run, pending/final update.status, service health, and RPC reachability.

Next step before merge
The remaining blocker is a narrow, source-local regression in the restart-sentinel status cache that an automated repair can attempt on the PR branch.

Security
Cleared: No concrete security or supply-chain regression found; the new command execution path uses a fixed argv-based helper, owner-only temp metadata/log files, and the existing updater CLI path.

Review findings

  • [P2] Refresh final update status before consuming it — src/gateway/server-restart-sentinel.ts:517-529
Review details

Best possible solution:

Land the detached managed-service handoff after recording the final update sentinel into the update.status cache before consuming it, with a focused regression test for the pending-to-final retry path.

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

Yes. Source inspection shows current main sends supervised global update.run through runGatewayUpdate in the live Gateway process, and the linked issue plus PR proof describe the LaunchAgent-backed failure mode; I did not run the destructive self-update locally.

Is this the best way to solve the issue?

Mostly yes, but not complete. Reusing the existing CLI managed-service updater is the narrow maintainable fix, while the final status sentinel still needs to refresh the cached update.status value before merge.

Full review comments:

  • [P2] Refresh final update status before consuming it — src/gateway/server-restart-sentinel.ts:517-529
    When a managed-service handoff is pending, startup can cache the pending sentinel, then this retry path later re-reads the final ok or error sentinel after the CLI finishes. The final path removes the sentinel without recording that payload, while update.status only returns the in-memory cache, so callers can keep seeing restart-health-pending after health succeeds. Record or refresh the final update payload before removing it.
    Confidence: 0.92

Overall correctness: patch is incorrect
Overall confidence: 0.88

Acceptance criteria:

  • node scripts/run-vitest.mjs src/gateway/server-restart-sentinel.test.ts src/gateway/server-methods/update.test.ts
  • node scripts/run-vitest.mjs src/gateway/server-methods/update-managed-service-handoff.test.ts src/cli/update-cli.test.ts src/cli/update-cli/update-command.test.ts src/daemon/launchd.test.ts
  • git diff --check

What I checked:

  • Current main bug path: Current main resolves the install surface and, when a respawn supervisor is detected, still reaches runGatewayUpdate from inside the live update.run Gateway handler for global package installs. (src/gateway/server-methods/update.ts:72, 4505a88d882c)
  • Current docs describe the unsafe control-plane behavior: Current docs say package-manager updates requested through the live Gateway control-plane handler force a restart after package swap, while shell openclaw update remains preferred for supervised installs because it can stop and restart the service around the update. Public docs: docs/install/updating.md. (docs/install/updating.md:171, 4505a88d882c)
  • PR handoff branch: The PR changes global package installs with a detected supervisor to create a handoff id, call startManagedServiceUpdateHandoff, return managed-service-handoff-started, and avoid the in-process runGatewayUpdate branch. (src/gateway/server-methods/update.ts:110, 1aa510d7a4d3)
  • Blocking PR regression: The new pending-sentinel retry path re-reads the restart sentinel until it is no longer pending, but the final path removes the final ok or error sentinel without updating the in-memory value returned by update.status. (src/gateway/server-restart-sentinel.ts:517, 1aa510d7a4d3)
  • Real behavior proof supplied: The PR body and top-level comment include redacted after-fix logs from a disposable macOS LaunchAgent-backed package install exercising openclaw gateway call update.run, pending and final update.status, service health, and RPC reachability. (1aa510d7a4d3)
  • Feature history provenance: Local blame attributes the current update.run handler and restart-sentinel path in this checkout to commit 9cfb4c747a035e00dfd2f1ba1ff448d984e744d4; recent updater finalization work is in 4199034de2417a5c25d6825aa01e4755c4cb4453 and 92f8c1edac78d092bd0cc0cb904bb7e806234bf7. (src/gateway/server-methods/update.ts:34, 9cfb4c747a03)

Likely related people:

  • Josh Lehman: git blame attributes the current update.run handler and restart-sentinel code in this checkout to commit 9cfb4c747a035e00dfd2f1ba1ff448d984e744d4. (role: introduced current control-plane update/restart-sentinel surface in checkout; confidence: medium; commits: 9cfb4c747a03; files: src/gateway/server-methods/update.ts, src/gateway/server-restart-sentinel.ts)
  • @shakkernerd: Recent history for src/cli/update-cli/update-command.ts shows updater finalization commits adjacent to the CLI sentinel and doctor paths touched by this PR. (role: recent updater finalization contributor; confidence: high; commits: 4199034de241, 92f8c1edac78; files: src/cli/update-cli/update-command.ts)
  • @obviyus: GitHub path history for src/gateway/server-restart-sentinel.ts includes restart continuation retry-budget work, which is adjacent to the retry/status-cache behavior reviewed here. (role: adjacent restart-continuation contributor; confidence: medium; commits: 0b8857d65366; files: src/gateway/server-restart-sentinel.ts)

Remaining risk / open question:

  • The PR is still draft, and I did not run the contributor's test commands in this read-only review.
  • Until the status-cache issue is fixed, callers can see a stale pending update.status after the managed-service handoff has actually finished.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 4505a88d882c.

@openclaw-barnacle openclaw-barnacle Bot added the proof: supplied External PR includes structured after-fix real behavior proof. label May 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: supplied External PR includes structured after-fix real behavior proof. labels May 15, 2026

BKF-Gitty commented May 15, 2026 •

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Real behavior proof is now attached here and in the PR body.

Real Behavior Proof: PASS

This was a real disposable managed-service run, not only unit tests or mocked service boundaries.

Environment:

  • macOS LaunchAgent-backed OpenClaw package install
  • isolated temp profile/state/config
  • temp npm global prefix
  • local package tarball built from this PR
  • loopback gateway RPC
  • host/user/token/path details redacted

Commands exercised:

pnpm pack --pack-destination .artifacts/openclaw-update-run-81894-pack
openclaw gateway call update.run --json --timeout 30000 --params '{"sessionKey":"agent:main:qa:update-run-81894-final","deliveryContext":{"channel":"webchat","to":"qa-update-run-81894","accountId":"qa"},"note":"QA update.run handoff proof after doctor-cwd fix.","continuationMessage":"Verify the updated gateway is reachable and report update status.","restartDelayMs":1000,"timeoutMs":1800000}'
openclaw gateway status --deep --require-rpc --json
openclaw gateway call update.status --json --timeout 30000

Initial update.run response from the live Gateway:

{
  "ok": true,
  "result": {
    "status": "skipped",
    "mode": "npm",
    "reason": "managed-service-handoff-started",
    "before": { "version": "2026.5.14" }
  },
  "handoff": { "status": "started", "command": "openclaw update --yes --timeout 1800" },
  "restart": { "ok": true, "signal": "SIGUSR1", "reason": "update.run" }
}

Intermediate update.status while restart health was still pending, with no success continuation:

{
  "sentinel": {
    "kind": "update",
    "status": "skipped",
    "stats": {
      "mode": "npm",
      "reason": "restart-health-pending",
      "after": { "version": "2026.5.14" }
    }
  }
}

Detached handoff log after CLI completion:

starting managed update command: openclaw update --yes --timeout 1800
Stopped LaunchAgent: gui/<uid>/<qa-label>
{
  "status": "ok",
  "mode": "npm",
  "steps": [
    { "name": "global update", "exitCode": 0 },
    { "name": "global install swap", "exitCode": 0 },
    { "name": "openclaw doctor", "cwd": "<prefix>/lib/node_modules/openclaw", "exitCode": 0 }
  ],
  "postUpdate": { "plugins": { "status": "ok", "changed": false } }
}
managed update command exited code=0 signal=null

Final managed-service proof:

{
  "service": { "label": "LaunchAgent", "loaded": true, "runtime": { "status": "running" } },
  "rpc": { "ok": true, "server": { "version": "2026.5.14" } }
}

Final update.status after restart health passed:

{
  "sentinel": {
    "kind": "update",
    "status": "ok",
    "continuation": { "kind": "agentTurn" },
    "stats": { "mode": "npm", "reason": null, "after": { "version": "2026.5.14" } }
  }
}

Additional validation:

node scripts/run-vitest.mjs src/gateway/server-methods/update.test.ts src/agents/openclaw-gateway-tool.test.ts src/cli/update-cli.test.ts src/cli/update-cli/update-command.test.ts src/daemon/launchd.test.ts
Test Files 7 passed (7), Tests 264 passed (264), Duration 99.17s

pnpm exec oxfmt --check --threads=1 ...changed files...
All matched files use the correct format

git diff --check
passed

Result: updating from inside the active Gateway/agent control-plane path worked on a disposable macOS LaunchAgent package-managed install, the service came back loaded and reachable, and the agent continuation was delayed until final health success.

Re-review progress:

@clawsweeper

clawsweeper Bot commented May 15, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@BKF-Gitty
BKF-Gitty marked this pull request as draft May 15, 2026 01:13
@BKF-Gitty
BKF-Gitty marked this pull request as ready for review May 15, 2026 01:14
@BKF-Gitty

Copy link
Copy Markdown
Contributor Author

@codex any comments. please review

@clawsweeper

clawsweeper Bot commented May 15, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@BKF-Gitty

Copy link
Copy Markdown
Contributor Author

@openclaw-barnacle proof supplied in body and in comment

@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: 1556fc4d10

ℹ️ 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 +521 to +523
void scheduleRestartSentinelWakeAttempt({
deps: params.deps,
attempt: attempt + 1,

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 Update the cached status when the final sentinel arrives

When a managed-service handoff is pending, the restarted gateway caches the pending sentinel during startup, then this retry path later re-reads the sentinel file after the CLI writes the final ok/error result. That final payload is consumed and removed without calling recordLatestUpdateRestartSentinel, while update.status only returns the in-memory getLatestUpdateRestartSentinel(), so after a successful handoff callers can keep seeing restart-health-pending indefinitely even though the continuation has run. Refresh or record the latest update sentinel before consuming it on the retry path.

Useful? React with 👍 / 👎.

@BKF-Gitty
BKF-Gitty marked this pull request as draft May 15, 2026 01:20
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 15, 2026
@clawsweeper

clawsweeper Bot commented May 15, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 15, 2026
@steipete
steipete marked this pull request as ready for review May 15, 2026 05:05
@clawsweeper

clawsweeper Bot commented May 15, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

Copy link
Copy Markdown
Contributor

Verification for final head 6e25d05cfd68e7f5d2300335213b6fecf63253c7:

  • node scripts/run-vitest.mjs src/gateway/server-methods/update-managed-service-handoff.test.ts src/gateway/server-methods/update.test.ts src/infra/restart-sentinel.test.ts
  • pnpm check:test-types
  • pnpm exec oxfmt --check --threads=1 src/gateway/server-methods/update-managed-service-handoff.ts src/gateway/server-methods/update-managed-service-handoff.test.ts src/gateway/server-methods/update.test.ts src/gateway/server-methods/update.ts src/infra/restart-sentinel.ts src/infra/update-restart-sentinel-payload.ts src/infra/update-control-plane-sentinel.ts
  • git diff --check
  • codex-review --mode local clean after accepted findings were fixed.
  • Crabbox macOS proof on static_clawmac (clawmac.local, macOS 26.5, arm64, LaunchAgent ai.openclaw.gateway present): before ref 1556fc4d10 left managed-service-handoff-started pending after helper parent-timeout; final ref 1aa510d7a4 changed the same case to status=error, reason=managed-service-handoff-parent-timeout, and preserved both unrelated config sentinels and newer pending handoff sentinels.

Known gap: I did not run a destructive real package update against the live LaunchAgent install; the Crabbox proof used an isolated /tmp harness extracting the actual inline helper from before/after refs.

@steipete
steipete merged commit 22a0ca9 into openclaw:main May 15, 2026
162 of 164 checks passed

@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: 6e25d05cfd

ℹ️ 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 +324 to +330
const child = spawn(params.execPath ?? process.execPath, [scriptPath, paramsPath], {
cwd: params.root,
env,
detached: true,
stdio: "ignore",
});
child.unref();

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.

P1 Badge Handle handoff helper spawn errors explicitly

startManagedServiceUpdateHandoff returns status: "started" immediately after spawn(...) without attaching an error listener to the returned ChildProcess. If the helper cannot spawn (for example due to an invalid/missing cwd or runtime path), Node emits an unhandled error event, which can terminate the gateway process instead of returning a structured managed-service-handoff-failed response; even if process-level handlers keep it alive, this path can still misreport a started handoff and leave the update sentinel stuck in a pending state.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime proof: supplied External PR includes structured after-fix real behavior proof. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2026.5.12 agent-invoked self-update can leave macOS LaunchAgent unloaded or fail before package swap

2 participants