Repository navigation
Fix agent update.run managed-service handoff - #81945
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: yes. Source inspection shows current main sends supervised global Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Land the detached managed-service handoff after recording the final update sentinel into the Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main sends supervised global 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 Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 4505a88d882c. |
|
@clawsweeper re-review Real behavior proof is now attached here and in the PR body. Real Behavior Proof: PASSThis was a real disposable managed-service run, not only unit tests or mocked service boundaries. Environment:
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 30000Initial {
"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 {
"sentinel": {
"kind": "update",
"status": "skipped",
"stats": {
"mode": "npm",
"reason": "restart-health-pending",
"after": { "version": "2026.5.14" }
}
}
}Detached handoff log after CLI completion: Final managed-service proof: {
"service": { "label": "LaunchAgent", "loaded": true, "runtime": { "status": "running" } },
"rpc": { "ok": true, "server": { "version": "2026.5.14" } }
}Final {
"sentinel": {
"kind": "update",
"status": "ok",
"continuation": { "kind": "agentTurn" },
"stats": { "mode": "npm", "reason": null, "after": { "version": "2026.5.14" } }
}
}Additional validation: 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:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@codex any comments. please review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@openclaw-barnacle proof supplied in body and in comment |
There was a problem hiding this comment.
💡 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".
| void scheduleRestartSentinelWakeAttempt({ | ||
| deps: params.deps, | ||
| attempt: attempt + 1, |
There was a problem hiding this comment.
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 👍 / 👎.
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Verification for final head
Known gap: I did not run a destructive real package update against the live LaunchAgent install; the Crabbox proof used an isolated |
There was a problem hiding this comment.
💡 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".
| const child = spawn(params.execPath ?? process.execPath, [scriptPath, paramsPath], { | ||
| cwd: params.root, | ||
| env, | ||
| detached: true, | ||
| stdio: "ignore", | ||
| }); | ||
| child.unref(); |
There was a problem hiding this comment.
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 👍 / 👎.
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.
openclaw gateway call update.run --json ...against the live Gateway/control-plane path.ok: true,mode: "npm",reason: "managed-service-handoff-started",handoff.status: "started", restart scheduled withSIGUSR1.update.statusreportedreason: "restart-health-pending"and had no success continuation while restart health was still pending.loaded: true, runtimerunning,rpc.ok: true, gateway version2026.5.14, finalupdate.status.status: "ok", and the agent continuation present only after health passed.Redacted proof excerpts are in the
Real behavior proof,Repro + Verification, andEvidencesections below, and in PR comment #81945 (comment).Summary
update.runcould run package-manager updates inside the live Gateway process, unlike the safer shell CLI path.update.runnow hands supervised global package updates to a detached helper that runs the normalopenclaw update --yes --jsonCLI managed-service path after the Gateway exits; the CLI writes pending/final control-plane restart sentinels around restart health and preserves continuation metadata.update.run, change Lossless Claw behavior, or refactor the full updater.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
update.runon 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.Initial
update.runresponse 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.statuswhile 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:
Final managed-service health/status proof:
{ "service": { "label": "LaunchAgent", "loaded": true, "runtime": { "status": "running" } }, "rpc": { "ok": true, "server": { "version": "2026.5.14" } } }Final
update.statussentinel, after health passed:{ "sentinel": { "kind": "update", "status": "ok", "continuation": { "kind": "agentTurn" }, "stats": { "mode": "npm", "reason": null, "after": { "version": "2026.5.14" } } } }update.runreportsmanaged-service-handoff-startedwithok: 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.OPENCLAW_QA_ALLOW_UPDATE_RUN_SELF=1harness flag path on a production managed install was not used. The disposable LaunchAgent package-managed proof above exercised the same public control-planeupdate.runpath and managed CLI handoff.openclaw doctorinherited 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)
update.runpath 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.runGatewayUpdatein-process, and CLI sentinel tests did not require success continuations to wait for restart health.update.rundid not route package-managed self-updates through that abstraction.Regression Test Plan (if applicable)
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.update.runstarts a managed-service handoff instead of callingrunGatewayUpdate; git/devupdate.runstill 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.User-visible / Behavior Changes
For supervised package-managed installs, control-plane
update.runnow reports handoff initiation instead of package-swap completion from inside the old Gateway process. Handoff initiation isok: true;update.statuscan reportmanaged-service-handoff-startedorrestart-health-pendingbefore final success/failure. For package-managed installs without a detected supervisor,update.runreturns a structured safe-command response instead of attempting the risky in-process update.Diagram (if applicable)
Security Impact (required)
Yes/No): NoYes/No): NoYes/No): NoYes/No): YesYes/No): NoYes, explain risk + mitigation: The Gateway now spawns a narrow detached helper for supervised package-managed self-updates. The helper only runs the existingopenclaw update --yes --jsonCLI 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
OPENCLAW_UPDATE_PACKAGE_SPEC, loopback gateway port.Steps
update.runthroughopenclaw gateway call, not via the shellopenclaw updateentrypoint.gateway status --deep --require-rpc, andupdate.status.Expected
update.rundoes not callrunGatewayUpdatein-process.ok: true.Actual
loaded: true,rpc.ok: true, gateway version2026.5.14, and final update sentinelstatus: okwith continuation.Evidence
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-packResults:
Human Verification (required)
What I personally verified (not just CI), and how:
update.runfrom the live Gateway; handoff-start response; intermediaterestart-health-pendingstatus without continuation; final LaunchAgent loaded/RPC reachable/version proof; finalupdate.statusok sentinel with continuation; disposable LaunchAgent cleanup.managed-service-handoff-*/restart-health-pendingreasons.OPENCLAW_QA_ALLOW_UPDATE_RUN_SELF=1QA harness flag path on a production managed install. The disposable LaunchAgent package-managed proof above exercised the same public control-planeupdate.runpath and managed CLI handoff.Review Conversations
Compatibility / Migration
Yes/No): YesYes/No): NoYes/No): NoRisks and Mitigations
update.runreturns a structured safe command instead of doing the risky live package swap.runGatewayUpdatepath.