Skip to content

fix(gateway): restore Windows scheduled-task inspection - #148671

Merged
steipete merged 2 commits into
mainfrom
upd/schtasks-probe-148601
Sep 15, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/schtasks-probe-148601

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

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: true from that spawn, write HRESULTs through the PowerShell pipeline, and carry its bounded inspectionFailure.detail through 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 sets CREATE_NO_WINDOW for 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 /xml returns task definitions, not live numeric state; verbose text would introduce localization parsing. -WindowStyle Hidden can 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.ts reads service.ts → readScheduledTaskRuntime() → this probe; offline publication also uses it via isScheduledTaskDefinitelyNotRunning(). #148545's broad runtime-verification-failed could 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, reported missing for the random absent task, then found, state 3, enabled true for 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 returned missing for the absent task and found, state 3, enabled true for the registered task; cleanup succeeded. The test completed in 1555 ms. Both runs executed pnpm test:windows:ci:1, including the real powershell.exe invocation, using Node 24.21.0. The reporter used Node 24.19.0 on Windows 11; that exact OS/runtime combination was not tested.

                           Before (windowsHide: true)    After (windowsHide: false)
random absent task         missing                       missing
registered ONSTART task    found / state 3 / enabled     found / state 3 / enabled
native test                PASS                          PASS
reporter's exit-2          not reproduced                not reproduced

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 5bdd6856b0aa864a2824d1df99bd970d3c73d15e finished GREEN with no pending checks. No CI failure required a repair or rerun.

Local before/after, with production changes applied only after recording the failures:

node scripts/run-vitest.mjs src/daemon/schtasks-state-probe.test.ts
Before: 3 failed | 6 passed
  hidden-launch fixture: expected found, received unknown
  expected "...exit 2): no output from PowerShell."
  received "...exit 2): "
After: 9 passed

node scripts/run-vitest.mjs src/cli/update-cli/update-command-service-maintenance.test.ts
Before: 1 failed | 54 passed | 1 skipped
  update and Doctor refusal omitted the Scheduled Task failure detail
After: 55 passed | 1 skipped

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.mjs and git diff --check passed, including production/test typechecking, lint, formatting, and architecture guards.

Windows selection: scripts/lib/ci-node-test-plan.mts groups Node tests, while checks-windows-node-test-1 executes the separate test:windows:ci:1 list in package.json; this PR adds the native test there. scripts/ci-changed-scope.mjs includes all src/daemon/schtasks* paths in Windows scope.

Production delta: +8/-7 (net +1); no new dependencies or public contracts.

Production PowerShell call-site inventory

hidden means windowsHide: true, either explicit or inherited from the shared Windows command adapter; default means omitted. This inventory excludes test fixtures and platform test tooling.

Owner / call site Launch Output contract
src/daemon/schtasks-state-probe.ts:41 hidden → normal in this PR COM facts → JSON; HRESULT → Console.Out, changed to pipeline
src/daemon/schtasks-runtime.ts:177 hidden Startup script readability; output ignored
src/daemon/schtasks-process.ts:546 hidden CIM process JSON pipeline
src/infra/windows-port-pids.ts:31,117 hidden Listener PIDs / CIM command line pipeline
src/infra/windows-process-start.ts:92,140 hidden Console.Out start time / CIM ancestry JSON pipeline
src/infra/windows-encoding.ts:123 hidden Code-page expression pipeline
src/infra/update-managed-service-handoff-boot.ts:31 hidden CIM boot timestamp pipeline
src/cli/update-cli/update-finalization-processes.ts:33 hidden CIM process inventory pipeline
src/cli/update-cli/update-command-post-core.ts:156 hidden, shared adapter Console.Out process start time
src/infra/advertised-lan-host.ts:151 hidden, shared adapter Console.OutputEncoding, route JSON pipeline
src/infra/system-disks.ts:75 hidden, shared adapter Console.OutputEncoding, volume JSON pipeline
src/infra/ports-inspect.ts:396 hidden, shared adapter CIM command line pipeline
src/infra/windows-gateway-firewall-diagnostics.ts:652 hidden, shared adapter Firewall JSON pipeline
src/infra/clipboard.ts:9 hidden, shared adapter Console.In → clipboard
src/secrets/private-plan-file.ts:309 hidden, shared adapter Console.In payload → native ACL/file creation
src/snapshot/local-repository.ts:1566 hidden, shared adapter ACL metadata → base64 Console.Out
src/agents/date-time.ts:205 default Culture time-pattern pipeline
src/gateway/server-methods/open-path.ts:25,114 hidden, shared adapter Start-Process; no readback
extensions/browser/src/browser/chrome.executable-probe.ts:81 default PE version pipeline
extensions/browser/src/browser/chrome-mcp-process.ts:93 hidden, shared adapter CIM process inventory pipeline
extensions/qa-lab/src/process-tree-cpu.ts:175 default CIM CPU/RSS JSON pipeline
extensions/crabbox/src/crabbox-worker-node-enrollment.ts:123,360 hidden Remote process JSON / generated launcher with file logging
src/infra/windows-task-restart.ts:78,104 CMD wrapper hidden; PowerShell default Generated wait/verification script, Write-Output to log
src/cli/update-cli/restart-helper.ts:263,703,744 WScript hidden-console wrapper Script stdin; Console.Out completion record redirected to file

Dynamic user-command execution selects PowerShell in src/agents/shell-utils.ts; its non-PTY supervisor sets windowsHide: true. Task install/uninstall/start/stop themselves use schtasks.exe through schtasks-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 5bdd6856b0aa864a2824d1df99bd970d3c73d15e found 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.json only selects the native Windows test, with no dependency, schema, or migration change. No re-review was requested because this landing pass changed no code.

@clawsweeper

clawsweeper Bot commented Sep 15, 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 September 15, 2026 01:09
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Sep 15, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 14, 2026, 9:48 PM ET / September 15, 2026, 01:48 UTC (Revision 3).

ClawSweeper review

What this changes

The 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
Reviewed head: 5bdd6856b0aa864a2824d1df99bd970d3c73d15e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused patch with meaningful native controls and regression coverage; remaining uncertainty concerns affected-host recovery and upgrade validation.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The supplied maintainer identity exempts this PR from the external-contributor proof gate. Native Windows evidence exercises the real probe for absent and registered tasks on the repaired head; affected-host recovery and the separately required published-driver upgrade run remain unproven.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied maintainer identity exempts this PR from the external-contributor proof gate. Native Windows evidence exercises the real probe for absent and registered tasks on the repaired head; affected-host recovery and the separately required published-driver upgrade run remain unproven.
Evidence reviewed 9 items Introduced production changes: The pinned introduced diff changes the existing probe's console launch and error output, plus maintenance refusal text. Numeric state parsing, missing-task classification, ownership checks, and offline admission remain intact.
Still necessary on main and latest release: Fetched main retains windowsHide:true and the empty-output diagnostic. Independently inspected v2026.9.4 source also retains the hidden launch; no merged replacement was established.
Latest-release comparison: The latest supplied release still launches the task probe with windowsHide:true.
Findings None None.
Security None None.

How this fits together

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

Decision needed

Question Recommendation
Must the published-driver × candidate Windows run precede landing, or is an explicit exception justified for this narrow repair? Complete the upgrade evidence: Retain the required gate and record the published Windows driver's outcome against the candidate, including any refusal before installation.

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

  • Resolve merge risk (P1) - The repaired production probe has not been retested on the affected host; successful Windows controls do not establish recovery from its exit-2 failure.
  • Resolve merge risk (P1) - Processes without a parent console may briefly display a window; desktop and scheduled-parent visibility remain unmeasured.
  • Resolve merge risk (P1) - Published-driver upgrade compatibility remains unexecuted, and the old driver's pre-install refusal can prevent affected users from receiving this repair through openclaw update.
  • Complete next step (P2) - Supply the required published-driver × candidate Windows upgrade evidence, or obtain an explicit maintainer exception acknowledging pre-install refusal.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +1, Tests +125, Docs +7, Config 0. Total +133 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 8 7 +1
Tests 3 125 0 +125
Docs 1 7 0 +7
Config 1 1 1 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 141 8 +133

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: package.json. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #148601
Summary: This PR specifically addresses the reported hidden-console task-probe failure; the broader Windows update report lacks evidence of the same cause.

Members:

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    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.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

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

Labels

Label justifications:

  • P0: The linked report establishes blocked Doctor recovery on a default Windows Scheduled Task installation with no working in-product recovery path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied maintainer identity exempts this PR from the external-contributor proof gate. Native Windows evidence exercises the real probe for absent and registered tasks on the repaired head; affected-host recovery and the separately required published-driver upgrade run remain unproven.

Evidence

What I checked:

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Dallin Romney: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record published-driver × candidate Windows upgrade evidence, or obtain an explicit maintainer exception.
  • Confirm the repaired production probe restores Gateway status and Doctor maintenance on the affected host.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-15T01:15:11.997Z sha 0d989aa :: blocked before merge. :: none
  • reviewed 2026-09-15T01:31:24.564Z sha 5bdd685 :: blocked before merge. :: none

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).
@steipete steipete changed the title fix(gateway): restore Windows scheduled-task inspection without a no-console launch fix(gateway): restore Windows scheduled-task inspection Sep 15, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 15, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: S and removed size: XS labels Sep 15, 2026
@steipete
steipete merged commit 243f71c into main Sep 15, 2026
235 of 237 checks passed
@steipete
steipete deleted the upd/schtasks-probe-148601 branch September 15, 2026 02:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
)

* 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).
waterundman added a commit to waterundman/openclaw that referenced this pull request Oct 9, 2026
`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. 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

1 participant