Repository navigation
fix(gateway): restore Windows scheduled-task inspection - #148671
Conversation
|
🦞👀 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: blocked before merge. Reviewed September 14, 2026, 9:48 PM ET / September 15, 2026, 01:48 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR allows Windows PowerShell console creation during Scheduled Task inspection, preserves probe errors in Doctor and update refusals, and adds Windows regression coverage and documentation. Merge readiness⛔ Blocked before merge - 6 items remain This remains a useful, focused repair: current main and v2026.9.4 retain the reported trigger. No introduced correctness defect was found; the published-driver upgrade requirement remains unresolved. Priority: P0 Review scores
Verification
How this fits togetherWindows service management reads Scheduled Task facts through a PowerShell probe. Gateway status displays those facts, while Doctor and update use them alongside ownership checks before maintenance. flowchart TD
A[Gateway status] --> C[Scheduled Task probe]
B[Doctor or update] --> C
C --> D[Windows PowerShell and Task Scheduler]
D --> E[Numeric state or inspection error]
E --> F[Status diagnostics]
E --> G[Existing maintenance admission checks]
Decision needed
Why: Repository policy requires that run, while the PR explicitly lacks it and documents an old-driver refusal that candidate code cannot repair retroactively. Before merge
Agent review detailsSecurityNone. PR surfaceSource +1, Tests +125, Docs +7, Config 0. Total +133 across 7 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the repair in the existing probe owner, establish the published-driver upgrade outcome, and provide a visible Doctor/Fix recovery route for users blocked before candidate installation. Do we have a high-confidence way to reproduce the issue? Unclear for the host-specific failure on current main: the reporter provides a controlled Windows reproduction and source confirms the failure cascade, but the native CI runner succeeds with both launch modes. Is this the best way to solve the issue? Yes, this is a narrow repair of the existing owner that preserves numeric state and maintenance checks; successful deployment through the published updater remains unverified. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 25155c466de2. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Allow the task probe to inherit or create a console and emit HRESULTs through the PowerShell pipeline. Preserve probe diagnostics in Doctor and update refusals without granting maintenance authority when inspection is unavailable. Reported by @westaicommerce (#148601).
|
Merged via squash.
|
) * test(gateway): exercise scheduled-task probes on Windows * fix(gateway): restore scheduled-task inspection on Windows Allow the task probe to inherit or create a console and emit HRESULTs through the PowerShell pipeline. Preserve probe diagnostics in Doctor and update refusals without granting maintenance authority when inspection is unavailable. Reported by @westaicommerce (openclaw#148601).
`powershell -EncodedCommand` trips Defender's obfuscation heuristic even though the probe only reads task state, so Windows users see AV alerts on OpenClaw's own scheduled-task health check during node-mode startup and status reporting (openclaw#138224). Keep the query body as a fixed literal string, spawn it with `-Command` directly, and carry the task name as base64 data on the child's stdin. The spawned command line is then a fixed, human-readable literal with no base64-encoded script and no task-name-specific content, so it stays auditable while non-ASCII task names keep working. An empty stdin selects the inventory path that `listScheduledTasks` uses, so one literal body covers both query shapes. The literal-command shape also matches the pattern this subsystem already uses for process inspection in `schtasks-process-snapshot.ts`, without adding a persistent .ps1 artifact or a new global `OPENCLAW_*` environment name. Scheduler fixtures identify the state probe by its command shape, so they follow the new transport: routing predicates in `schtasks.shutdown`, `schtasks.settlement`, `schtasks.stop`, `schtasks-runtime.deadline`, `schtasks.redirect-stop`, `schtasks.startup-fallback` and the `schtasks.stop` test support now recognize the literal body as well as the legacy encoded form, `inspect.windows.registered` reads the queried task name from stdin instead of decoding the command line, and `service-command-read` asserts the new argv shape. The two update-CLI fixtures that intercept the shared probe (`update-command-windows-preflight` test support and `update-command-service-windows-probe`) recognize it too, and the admission tests now count probe-shaped spawns rather than every literal `-Command` argv, which also matches the unrelated process-snapshot spawn. Rebased onto main at 8c22de3 so the branch keeps the task inspection contract introduced by current main: the `checkUpdateAccess` probe argument and `probeScheduledTaskUpdateAccess` export from openclaw#166695, the `probeTimeoutMs` cold-spawn budget, `resolveServiceManagerEnv()`, `windowsHide: false` (from openclaw#148671), the `enabled`/`actions` fields, and the diagnostic/timeout/failure-detail reporting from openclaw#155051 and openclaw#157719. Exit codes, the JSON contract, and missing-task HRESULT classification are unchanged.
Fixes #148601
Refs #148545
What Problem This Solves
Fixes unavailable Windows Scheduled Task runtime inspection that blocks Gateway status, Doctor maintenance, and managed update verification when Windows PowerShell exits without output under a no-console launch.
Reported by @westaicommerce (#148601).
User Impact
The task probe uses the reporter's working launch mode while retaining numeric task state and strict missing/unknown classification. Doctor and update refusals now include the native probe detail, including an explicit empty-output/exit-code diagnostic. Unverifiable ownership still refuses maintenance.
A process without a parent console can briefly display a console window. Interactive desktop and scheduled-parent window visibility have not been measured. The reporter's affected machine has not been retested.
Why This Change Was Made
The existing probe already owns task presence, runtime, enabled policy, and offline evidence. Remove
windowsHide: truefrom that spawn, write HRESULTs through the PowerShell pipeline, and carry its boundedinspectionFailure.detailthrough the shared maintenance refusal. No fallback stack, retry, configuration, or admission change is introduced.Node's synchronous spawn passes
UV_PROCESS_WINDOWS_HIDE; its bundled libuv setsCREATE_NO_WINDOWfor this piped invocation. Microsoft documents that this leaves the console handle unset. Node #29837 confirms the distinction between hiding and removing a console.The script's exit 2 path covers COM activation/connection errors before task lookup. Empty streams hide the HRESULT, so the exact host-specific exception remains unknown. No primary source establishes that
Schedule.Service.Connect()always needs a console; .NET can write redirected standard handles without one. The reporter's repeated A/B result, not a general COM claim, supports this fix. Successful-control CLIXML stderr does not establish a failure: PowerShell's open-source host selects XML error serialization for noninteractive encoded commands with redirected stderr; that source is PS6 lineage, not direct Windows PowerShell 5.1 internals.Alternatives:
schtasks /xmlreturns task definitions, not live numeric state; verbose text would introduce localization parsing.-WindowStyle Hiddencan still flash and can affect an inherited console. Normal console-parent launches inherit the existing console.Update consumers share this owner:
update-command-service-maintenance.tsreadsservice.ts→readScheduledTaskRuntime()→ this probe; offline publication also uses it viaisScheduledTaskDefinitelyNotRunning(). #148545's broadruntime-verification-failedcould have this cause, but that report supplies no task-probe evidence. The published 2026.9.3 driver performs this inspection before package mutation (update-command-execution.ts:564), so a candidate cannot retroactively repair an old driver that refuses before installing it. No published-driver × candidate execution was available here.Evidence
Native Windows before: CI job 104214198326, head
0d989aac56a9946db26cf8727c7add540db01724, passed against unchanged production code. The same test called the real inbox PowerShell, reportedmissingfor the random absent task, thenfound, state3, enabledtruefor the temporary registered task; cleanup succeeded. This runner did not reproduce the reporter's exit-2 failure. The test completed in 668 ms.Native Windows after: CI job 104217422394, head
5bdd6856b0aa864a2824d1df99bd970d3c73d15e, passed with the identical native test file. It again returnedmissingfor the absent task andfound, state3, enabledtruefor the registered task; cleanup succeeded. The test completed in 1555 ms. Both runs executedpnpm test:windows:ci:1, including the realpowershell.exeinvocation, using Node 24.21.0. The reporter used Node 24.19.0 on Windows 11; that exact OS/runtime combination was not tested.The baseline run was superseded after its Windows proof job completed. CI for the repaired head completed successfully, including both Windows partitions and
openclaw/ci-gate.node scripts/watch-pr-ci.mjs 148671 5bdd6856b0aa864a2824d1df99bd970d3c73d15efinishedGREENwith no pending checks. No CI failure required a repair or rerun.Local before/after, with production changes applied only after recording the failures:
The combined after run also covers
src/daemon/schtasks.test.ts,src/commands/doctor-maintenance.service-inspection.test.ts, and the new native test: 168 passed, two platform skips on macOS. Existing access-denied, failed COM connection, missing task, queued state, timeout, and native maintenance refusal coverage stays intact. The silent-failure regression asserts no stop/install and no offline authority.node scripts/check-changed.mjsandgit diff --checkpassed, including production/test typechecking, lint, formatting, and architecture guards.Windows selection:
scripts/lib/ci-node-test-plan.mtsgroups Node tests, whilechecks-windows-node-test-1executes the separatetest:windows:ci:1list inpackage.json; this PR adds the native test there.scripts/ci-changed-scope.mjsincludes allsrc/daemon/schtasks*paths in Windows scope.Production delta: +8/-7 (net +1); no new dependencies or public contracts.
Production PowerShell call-site inventory
hiddenmeanswindowsHide: true, either explicit or inherited from the shared Windows command adapter;defaultmeans omitted. This inventory excludes test fixtures and platform test tooling.src/daemon/schtasks-state-probe.ts:41src/daemon/schtasks-runtime.ts:177src/daemon/schtasks-process.ts:546src/infra/windows-port-pids.ts:31,117src/infra/windows-process-start.ts:92,140src/infra/windows-encoding.ts:123src/infra/update-managed-service-handoff-boot.ts:31src/cli/update-cli/update-finalization-processes.ts:33src/cli/update-cli/update-command-post-core.ts:156src/infra/advertised-lan-host.ts:151src/infra/system-disks.ts:75src/infra/ports-inspect.ts:396src/infra/windows-gateway-firewall-diagnostics.ts:652src/infra/clipboard.ts:9src/secrets/private-plan-file.ts:309src/snapshot/local-repository.ts:1566src/agents/date-time.ts:205src/gateway/server-methods/open-path.ts:25,114extensions/browser/src/browser/chrome.executable-probe.ts:81extensions/browser/src/browser/chrome-mcp-process.ts:93extensions/qa-lab/src/process-tree-cpu.ts:175extensions/crabbox/src/crabbox-worker-node-enrollment.ts:123,360src/infra/windows-task-restart.ts:78,104src/cli/update-cli/restart-helper.ts:263,703,744Dynamic user-command execution selects PowerShell in
src/agents/shell-utils.ts; its non-PTY supervisor setswindowsHide: true. Task install/uninstall/start/stop themselves useschtasks.exethroughschtasks-exec.ts, not PowerShell. Their state, enabled-policy, takeover, and update offline verification consume the repaired probe.Other hidden PowerShell helpers have no equivalent controlled failure evidence in this report and are unchanged. CLIXML or a use of Console.Out alone does not prove they share this defect.
ClawSweeper review
The completed review of
5bdd6856b0aa864a2824d1df99bd970d3c73d15efound no introduced correctness or security defects. No code fixups were needed. The maintainer decision is to land this narrow repair with the documented proof limits: affected-host recovery and console visibility remain unmeasured, and the published-driver × candidate Windows run is deferred. The installed driver's pre-install refusal cannot be repaired retroactively by candidate code. The console-flash tradeoff is accepted; follow-up affected-host and upgrade validation remain useful. The data-model compatibility item is inapplicable:package.jsononly selects the native Windows test, with no dependency, schema, or migration change. No re-review was requested because this landing pass changed no code.