Skip to content

fix(windows): updates leave the Gateway stopped when the task logon account is machine-qualified - #169481

Merged
steipete merged 1 commit into
mainfrom
steipete/windows-task-account-alias
Oct 12, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/windows-task-account-alias

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: on Windows, updating from 2026.10.1 leaves the Gateway stopped (Scheduled Task disabled, UPDATE_NATIVE_AUTHORITY: exit 1) when the task's logon trigger account is exported as a machine-qualified name, such as installs made over SSH where USERDOMAIN=WORKGROUP.

User Impact

Windows updates complete and restart the Gateway on the new version instead of ending in state-migrated-no-rollback with the service stopped. Task definitions that point at a genuinely different account, or at an account Windows cannot resolve, are still treated as operator edits and left untouched.

Why This Change Was Made

The installer writes the task for the current user. When USERDOMAIN is WORKGROUP, that user is computed as a bare name (crabbox). Task Scheduler then exports the principal as a SID and LogonTrigger.UserId as HOST\crabbox. The Windows definition audit accepted only an exact name or that SID, so it reported the installer's own trigger as an unknown-edit. During the post-update service refresh, reconciliation therefore refused to rewrite the task (SERVICE_DEFINITION_UNKNOWN: ... Triggers.LogonTrigger.UserId). The candidate re-labels any refresh failure as UPDATE_NATIVE_AUTHORITY, so finalization treated the refusal as unverified recovery and left the task disabled.

The audit now resolves an otherwise-unmatched account name to its SID, through the same base64-encoded PowerShell NTAccount.Translate call it already used for the installer account, and accepts it only when it equals the verified expected SID. Different SIDs and failed lookups still refuse. Original-definition custody, rebind fingerprints and update authority are unchanged.

Update behavior: the published 2026.10.1 driver runs first and cannot be patched. After its state migration it hands post-swap finalization, including the gateway install --force --update-executor run refresh, to the candidate. The fix is candidate-side, so it repairs updates from shipped drivers without any marker or schema change. Rollback is unaffected.

Evidence

  • Published-driver × candidate, native Windows x64. Crabbox AWS, Windows Server 2025, Node 24.18.0, Scheduled Task with the Node runtime, unique canonical named profile. The unmodified published [email protected] ran openclaw --profile <p> update --tag <candidate.tgz> --yes --json, with no --no-restart and no manual restart.
    • Candidate built from main 9fec51a0: reproduced the outage. Post-update verification failed with UPDATE_NATIVE_AUTHORITY: exit 1, status state-migrated-no-rollback, task Disabled, port free.
    • A diagnostic-only candidate (instrumented, not proof) captured the child's real error: SERVICE_DEFINITION_UNKNOWN: Service definition inspection or backup failed; the definition was preserved: Error: Triggers.LogonTrigger.UserId: Scheduled Task Triggers.LogonTrigger.UserId contains an unrecognized setting. The pre-update task XML had principal S-1-5-21-…-1000 and LogonTrigger.UserId EC2AMAZ-…\crabbox; both names translate to that same SID.
    • Candidate built from this commit (verified build-info commit, no instrumentation in any packaged JS): update exit 0, status ok, task Enabled and Running, gateway status --deep --require-rpc healthy on the new build.
  • Regression test in src/daemon/service-audit-schtasks.windows.test.ts: three cases (same SID / different SID / unresolvable) feed the real installer XML through the real auditor, mocking only the native SID lookup. The same-SID case failed before the fix (1 failed / 13 passed) and passes after (14/14). pnpm test src/daemon/service-audit-schtasks.windows.test.ts --maxWorkers=1: 83 s wall on a loaded host, almost all transform; the new cases add about 1 s of assertions to an existing file, with no new fixtures, timers or processes.
  • pnpm check:changed passed. Surrounding service suites (Windows audit, definition facts, definition backup, CLI definition repair) passed: 127 tests.

Follow-ups, not in this PR: update-executor.ts labels every native refresh failure UPDATE_NATIVE_AUTHORITY, even a pre-write refusal that preserved the definition, and that label turns any refusal into a stopped Gateway. Separately, the published 2026.9.3 driver times out at 30 s on Windows global-install swap rollback verification.

Compare otherwise-unmatched task account names with the expected Windows
SID so a qualified local name is not mistaken for an operator edit during
service refresh. Distinct SIDs and unresolved names still refuse repair;
original-definition custody and update authority checks are unchanged.

Cover the published 2026.10.1 task shape with a focused audit regression
and document the update behavior. This fixes updates that stopped the
Gateway after rejecting an equivalent LogonTrigger.UserId spelling.
@clawsweeper

clawsweeper Bot commented Oct 12, 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.

@steipete
steipete marked this pull request as ready for review October 12, 2026 00:33
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR recognizes Windows Scheduled Task account aliases that resolve to the expected SID.

Example: A Windows task uses operator as its installer account and WIN-TEST\operator as its logon-trigger account, both resolving to S-1-5-21-1-2-3-1001.

  • Before: The audit reports an unknown edit, preventing service refresh and leaving the Gateway stopped after updating.
  • After: The audit accepts the equivalent account spelling, allowing service refresh and restart.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and correct, with meaningful negative coverage and a documented native upgrade result; proof confidence is limited by the absence of an attached runtime trace.
Proof confidence 🐚 platinum hermit (4/6) The supplied maintainer-authored classification places this PR outside the ordinary contributor proof gate; its complete body documents the published-driver Windows update scenario and successful task restart, although no attached raw runtime trace was available for independent inspection.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A Windows update can leave the Gateway stopped because Task Scheduler exports the installer's account using an equivalent machine-qualified spelling.
Reason: The fix restores intended update behavior, preserves existing account boundaries, and comes from the established feature owner without new configuration or public contracts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for landing: current main still has the reported defect, and the focused fix preserves account identity and operator edits without introducing an actionable bug.

Priority: P1
Reviewed head: 86a8bdb096e664bfd52e25d8da6847eb2c01cfe9

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared Windows service auditor compares exported Task Scheduler XML with installer expectations and supplies drift facts to Doctor, update reconciliation, and publication verification.

flowchart TD
  A[Windows update] --> B[Candidate service refresh]
  B --> C[Scheduled Task audit]
  D[Exported task XML] --> C
  C --> E[Windows SID lookup]
  C --> F[Definition reconciliation]
  F --> G[Task publication and Gateway restart]
Loading

Technical review

Best possible solution:

Land the SID-equivalence fix at the shared auditor while retaining rejection of different or unresolved accounts.

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

Current-main comparison and reconciliation source establish the failure path for equivalent qualified account names; the PR additionally records a native failing run, but this read-only review ran no target code.

Is this the best way to solve the issue?

Resolving unmatched names through the existing Windows SID mechanism fixes identity comparison at its shared owner without weakening operator-edit preservation or adding another repair path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 81a4679dec8b.

Provenance checked

  • Windows Scheduled Task identity comparison keeps the original intent (5e59120: The original audit recognized installer policy while preserving unknown operator edits; merged history and the original PR establish that intent. Local content-history searching encountered the documented missing-object limit at the creation boundary.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +12, Tests +51, Docs +3. Total +66 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 28 16 +12
Tests 1 51 0 +51
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 82 16 +66

Labels

Label changes:

  • add P1: The reported Windows upgrade failure leaves an existing Gateway stopped after updating from an official release.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The reported Windows upgrade failure leaves an existing Gateway stopped after updating from an official release.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • 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 October 11, 2026, 8:39 PM ET / October 12, 2026, 00:39 UTC.

@steipete steipete self-assigned this Oct 12, 2026
@steipete
steipete merged commit 751fa4f into main Oct 12, 2026
199 of 200 checks passed
@steipete
steipete deleted the steipete/windows-task-account-alias branch October 12, 2026 01:16
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
Compare otherwise-unmatched task account names with the expected Windows
SID so a qualified local name is not mistaken for an operator edit during
service refresh. Distinct SIDs and unresolved names still refuse repair;
original-definition custody and update authority checks are unchanged.

Cover the published 2026.10.1 task shape with a focused audit regression
and document the update behavior. This fixes updates that stopped the
Gateway after rejecting an equivalent LogonTrigger.UserId spelling.
RomneyDa pushed a commit that referenced this pull request Oct 13, 2026
Compare otherwise-unmatched task account names with the expected Windows
SID so a qualified local name is not mistaken for an operator edit during
service refresh. Distinct SIDs and unresolved names still refuse repair;
original-definition custody and update authority checks are unchanged.

Cover the published 2026.10.1 task shape with a focused audit regression
and document the update behavior. This fixes updates that stopped the
Gateway after rejecting an equivalent LogonTrigger.UserId spelling.

(cherry picked from commit 751fa4f)
RomneyDa pushed a commit that referenced this pull request Oct 13, 2026
Backport of 751fa4f (#169481) adapted for 2026.10.3.

Code applied cleanly. Docs keep only the alias paragraph (the surrounding Windows
principal/system-package text belongs to PRs not on 10.3); the test file drops main's
unrelated task-policy audit cases and keeps the qualified-account regression.

(cherry picked from commit 751fa4f)
xydigitLybnnnn added a commit to xydigitLybnnnn/openclaw that referenced this pull request Oct 13, 2026
Upstream openclaw#169481 ("recognize Scheduled Task account aliases") already owns the
Task Scheduler run-as account normalization (SID resolution), so the conflict in
src/daemon/service-audit-schtasks.ts is resolved by keeping upstream's version and
retaining only this branch's still-unique change: treating
Settings.UseUnifiedSchedulingEngine as a scheduler-managed field.

The now-redundant account-name comparison and its two mock tests are dropped;
upstream's service-audit-schtasks.windows.test.ts covers the run-as account cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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