Skip to content

fix(update): refuse Gateway-started updates on Windows Scheduled Task installs - #199918

Merged
steipete merged 1 commit into
mainfrom
codex/issue-169844-windows-handoff-refusal
Nov 16, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/issue-169844-windows-handoff-refusal

Conversation

@steipete

@steipete steipete commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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 update keeps 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 set CREATE_BREAKAWAY_FROM_JOB. Both processes therefore stay in the Scheduled Task's kill-on-close Job: the launcher Job from bindWindowsTaskLauncher / proc-safe bindCurrentProcessLifetimeTo, 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).

Installed (updater) Lane Result
2026.11.5-beta.2 update.run → npm beta (beta.3) Validation passed, then stuck at activating. Task Disabled, 0 node processes, readyz down, CLI still beta.2.
2026.11.5-beta.2 Same, with a watcher outside the Job (IsProcessInJob) Helper (parent = Gateway) and updater both show job. Within 1.5 s of the task becoming Disabled, every task descendant, helper and updater included, is gone.
2026.11.3 (stable) update.run → npm beta (beta.3) Same stranding: task Disabled, 0 node processes, run stuck activating.
this branch update.run See "Proof on this head"

Terminal openclaw update runs outside the task's Job and passes. It is covered daily by the update matrix's Windows lanes.

What changed

admitManagedHandoffSupervisor (in update-managed-service-handoff-service.ts) now owns the admission of Gateway-started handoffs. It throws UpdatePreMutationError("managed-service-handoff-failed") for the schtasks supervisor, and keeps the existing systemd admission unchanged. startManagedServiceUpdateHandoff calls 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.run records managed-service-handoff-failed;
  • the in-Gateway openclaw update handoff reports it;
  • the startup auto-update 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:

  1. A proc-safe spawn with CREATE_BREAKAWAY_FROM_JOB. This also needs JOB_OBJECT_LIMIT_BREAKAWAY_OK on the launcher Job, and Task Scheduler's Job must allow breakaway.
  2. A one-shot Scheduled Task that launches the helper.
  3. A WMI Win32_Process.Create launch.

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 covers schtasks. The full file passes 71/71.
  • src/infra/update-managed-service-handoff-settlement-control.test.ts passes.
  • tsgo:core, oxfmt and oxlint pass.

Reviews

  • autoreview: scoped-clean at P2.
  • Independent codex exec read-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 AWS cbx_e08fe5efd047, Windows Server 2025, Node 24.22.1, Scheduled Task Gateway, package sha256 93de4bd8…, built on Linux from this branch.

Lane Result
Terminal openclaw update --tag <this package> from published 2026.11.3 rc=0 in 893 s. Task Running, readyz 200, version 2026.11.30 (ad95856).
Gateway update.run on the updated Scheduled Task Gateway Refused before any mutation: status: 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.

… 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
@clawsweeper

clawsweeper Bot commented Nov 16, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The update can reach activation, terminate its own updater, and leave the task disabled with the Gateway stopped.
  • After: The handoff is refused before helper launch, preserving the running Gateway and explaining how to update from an independent terminal.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is small, coherent, and has no identified correctness defect, but its required after-fix product proof is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Starting an update from a Windows Scheduled Task Gateway can stop the Gateway permanently while the update remains unfinished.
Reason: The maintainer-authored proposal explicitly accepts preserving availability through refusal as an interim measure and uses related references without claiming the full update capability is repaired.

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
Reviewed head: ad95856ffb6ca6c38a087351fc81f110751b0aac

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted Windows shipped-entry-point evidence that this head refuses update.run while preserving Gateway health, task enabled state, and package version, plus a latest-stable upgrade showing terminal updating and existing settings remain intact.
Agent review details

How this fits together

Gateway 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]
Loading

Technical review

Best 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

  • Supervisor admission and systemd operator restart keeps the original intent (a1107a5: Permit writable system-scope package updates while leaving native system-service control to the operator, as explained in fix(update): update system-scope services and hand the restart to the operator #156584.)
  • Windows handoff launch-metadata coverage changes intended behavior with a stated reason (676915d: Consolidate repeated infrastructure tests while retaining distinct lifecycle contracts; this PR replaces the now-obsolete Windows successful-launch row with a refusal-before-spawn regression.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • B.K.: Raw commit 22a0ca9 adds src/gateway/server-methods/update-managed-service-handoff.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 22a0ca9e3b22; files: src/gateway/server-methods/update-managed-service-handoff.ts)

PR surface

Source +18, Tests +13. Total +31 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 23 5 +18
Tests 1 17 4 +13
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 40 9 +31

Preflight source

Source 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 cluster

Relationship: partial_overlap
Canonical: #169844
Summary: This PR mitigates the documented Windows helper-lifetime outage; a separate draft attempts the full repair, while task-inspection failures remain distinct.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P0: The underlying community update flow leaves Windows Gateways offline with their startup task disabled and requires terminal intervention; the mitigation still requires an external terminal to update.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 15, 2026, 10:30 PM ET / November 16, 2026, 03:30 UTC.

@steipete
steipete marked this pull request as ready for review November 16, 2026 15:50
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T15:52:16.654715Z ad95856 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
… 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS 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