Repository navigation
fix(update): refuse Gateway-started updates on Windows Scheduled Task installs - #199918
Conversation
… installs A Gateway started by the Windows Scheduled Task launches the managed update helper and updater inside the task's kill-on-close Job. Stopping the task during activation then ends the updater too, so the update never finishes: the task stays disabled, the Gateway stays stopped, and the package is unchanged (#169844). Refuse these handoffs before any mutation with a message that points to a terminal update, which runs outside the Job and works. Foreground (terminal) handoffs and other supervisors are unchanged. Refs #169844 Refs #199617
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR refuses Gateway-started Windows Scheduled Task update handoffs before helper launch and directs users to an independent terminal. Example: A Windows Scheduled Task Gateway running 2026.11.3 receives update.run.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR provides a focused, explicitly partial mitigation for a confirmed Windows update outage that current main still permits. Priority: P0 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway update RPCs and automatic campaigns enter the shared managed-service handoff owner, which admits the supervisor before preparing a helper that stages the update and coordinates service activation. flowchart TD
A[Gateway update request] --> B[Managed handoff owner]
B --> C[Supervisor admission]
C --> D[Windows task refusal]
D --> E[Independent terminal guidance]
C --> F[Other supervisor handoff]
F --> G[Updater and service activation]
Technical reviewBest possible solution: Retain the narrow mitigation while the existing full-repair effort restores Windows updating through the in-product update flow. Do we have a high-confidence way to reproduce the issue? Source confirms the detached helper and task-stop path, supported by native reproductions in the linked discussion and PR body; this read-only review did not reproduce the failure on current main. Is this the best way to solve the issue? The shared admission boundary is the smallest complete implementation of the accepted mitigation: reject the unsafe supervisor before helper preparation, preserve systemd admission, and leave unrelated launch paths intact. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8862ffc735fe. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +18, Tests +13. Total +31 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 15, 2026, 10:30 PM ET / November 16, 2026, 03:30 UTC. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Merged via squash.
|
… installs (openclaw#199918) A Gateway started by the Windows Scheduled Task launches the managed update helper and updater inside the task's kill-on-close Job. Stopping the task during activation then ends the updater too, so the update never finishes: the task stays disabled, the Gateway stays stopped, and the package is unchanged (openclaw#169844). Refuse these handoffs before any mutation with a message that points to a terminal update, which runs outside the Job and works. Foreground (terminal) handoffs and other supervisors are unchanged. Refs openclaw#169844 Refs openclaw#199617 Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Updates started from the Gateway (Control UI, chat, automatic updates) on a Windows Scheduled Task install never finish. The task ends up disabled, the Gateway stays stopped, and the package is unchanged. This PR refuses those handoffs before any mutation, with a message that points to a terminal update. Terminal
openclaw updatekeeps working.This is a mitigation, not the full fix. Gateway-started Windows updates are refused rather than repaired. See "Full fix needs a decision" below.
Refs #169844
Refs #199617
Refs #164639
Root cause
The Gateway spawns the managed update helper
detached, and the helper spawns the updater. On Windows, libuv's detached spawn does not setCREATE_BREAKAWAY_FROM_JOB. Both processes therefore stay in the Scheduled Task's kill-on-close Job: the launcher Job frombindWindowsTaskLauncher/ proc-safebindCurrentProcessLifetimeTo, plus Task Scheduler's own Job.During activation the updater disables the task and stops it (
schtasks /Change /DISABLE, then/End). Ending the task ends the Job, and that kills the helper and the updater. Nothing is left to swap the package or re-enable and restart the task.Evidence
Native lanes ran on Crabbox AWS (Windows Server 2025, Node 24.22.1, Scheduled Task Gateway).
update.run→ npm beta (beta.3)activating. Task Disabled, 0 node processes, readyz down, CLI still beta.2.IsProcessInJob)job. Within 1.5 s of the task becoming Disabled, every task descendant, helper and updater included, is gone.update.run→ npm beta (beta.3)activating.update.runTerminal
openclaw updateruns outside the task's Job and passes. It is covered daily by the update matrix's Windows lanes.What changed
admitManagedHandoffSupervisor(inupdate-managed-service-handoff-service.ts) now owns the admission of Gateway-started handoffs. It throwsUpdatePreMutationError("managed-service-handoff-failed")for theschtaskssupervisor, and keeps the existing systemd admission unchanged.startManagedServiceUpdateHandoffcalls it before any spawn, lease, or service mutation. Foreground (terminal-origin) handoffs skip it, as before.All three callers surface the refusal without stopping anything:
update.runrecordsmanaged-service-handoff-failed;openclaw updatehandoff reports it;Full fix needs a decision
Gateway-started updates can only work on Windows if the helper and updater run outside the task's Job. The options are:
CREATE_BREAKAWAY_FROM_JOB. This also needsJOB_OBJECT_LIMIT_BREAKAWAY_OKon the launcher Job, and Task Scheduler's Job must allow breakaway.Win32_Process.Createlaunch.Options 2 and 3 replace the helper's stdio control pipes, so the park handshake protocol has to change. Any of them touches the lifecycle authority boundary. Until one is chosen, the refusal turns a guaranteed outage into a visible, actionable message.
Tests
src/infra/update-managed-service-handoff-lifecycle.test.ts: the new test "refuses a Windows Scheduled Task handoff before spawning the updater" fails on base (the promise resolved with a started handoff) and passes with the fix. The launch-metadata case no longer coversschtasks. The full file passes 71/71.src/infra/update-managed-service-handoff-settlement-control.test.tspasses.tsgo:core, oxfmt and oxlint pass.Reviews
codex execread-only review: NO FINDINGS. It covered the gate placement, all three callers, foreground reachability and the message.Proof on this head
Native, on the exact head
ad95856ffb6. Crabbox AWScbx_e08fe5efd047, Windows Server 2025, Node 24.22.1, Scheduled Task Gateway, package sha25693de4bd8…, built on Linux from this branch.openclaw update --tag <this package>from published 2026.11.3update.runon the updated Scheduled Task Gatewaystatus: error,reason: managed-service-handoff-failed, with the Scheduled Task message. No handoff was spawned. 45 s later the task is still Running, readyz 200, and the version is unchanged.The stable 11.3 result is the third row of the Evidence table: a published 11.3 Gateway-started update strands the Gateway.