Repository navigation
fix(windows): updates leave the Gateway stopped when the task logon account is machine-qualified - #169481
Conversation
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.
|
🦞👀 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 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +12, Tests +51, Docs +3. Total +66 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel 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 October 11, 2026, 8:39 PM ET / October 12, 2026, 00:39 UTC. |
|
Merged via squash.
|
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.
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)
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)
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.
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 whereUSERDOMAIN=WORKGROUP.User Impact
Windows updates complete and restart the Gateway on the new version instead of ending in
state-migrated-no-rollbackwith 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
USERDOMAINisWORKGROUP, that user is computed as a bare name (crabbox). Task Scheduler then exports the principal as a SID andLogonTrigger.UserIdasHOST\crabbox. The Windows definition audit accepted only an exact name or that SID, so it reported the installer's own trigger as anunknown-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 asUPDATE_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.Translatecall 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 runrefresh, 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
[email protected]ranopenclaw --profile <p> update --tag <candidate.tgz> --yes --json, with no--no-restartand no manual restart.9fec51a0: reproduced the outage. Post-update verification failed withUPDATE_NATIVE_AUTHORITY: exit 1, statusstate-migrated-no-rollback, task Disabled, port free.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 principalS-1-5-21-…-1000andLogonTrigger.UserIdEC2AMAZ-…\crabbox; both names translate to that same SID.gateway status --deep --require-rpchealthy on the new build.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:changedpassed. Surrounding service suites (Windows audit, definition facts, definition backup, CLI definition repair) passed: 127 tests.Follow-ups, not in this PR:
update-executor.tslabels every native refresh failureUPDATE_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.