Skip to content

fix(windows): install an unattended-capable Gateway task and size readiness to cold boot - #165163

Merged
steipete merged 5 commits into
mainfrom
upd/upd-windows-scheduled-task-unattended
Oct 5, 2026
Merged

steipete merged 5 commits into
mainfrom
upd/upd-windows-scheduled-task-unattended

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #143757. Thanks @desksk for the detailed reproductions and corrected launcher analysis.

What Problem This Solves

Windows Gateway tasks can remain stopped after an unattended reboot because they require interactive logon, and short readiness windows report failure during cold starts that take tens of minutes.

Why This Change Was Made

The Windows task writer emits a password-free S4U principal, boot and logon triggers, and a direct CMD action. Doctor migrates recognized shipped logon-coupled definitions through the existing backup/rollback owner. The supervisor binds direct CMD launchers to their verified Windows Job Object owner so task termination contains the Gateway process tree.

resolveGatewayStartupTiming owns the Windows readiness budget used by wizard finalization (src/wizard/setup.finalize.ts), system-agent setup (src/system-agent/setup-apply.ts), and the update readiness verifier (src/cli/update-cli/update-command-readiness.ts). Setup reserves three default update steps (90 minutes). Implicit Windows update observation uses ten times measured canary startup, bounded between that floor and four steps (120 minutes). Explicit per-step --timeout values remain authoritative. The same owner returns the diagnostic derivation, so displayed bounds and computed deadlines agree. This removes the erroneous one-hour cap that always clipped the previous 90-minute floor.

User Impact

Installation reports its selected startup mode. openclaw doctor --fix repairs recognized older definitions with backup and rollback. Existing Password registrations retain their stored credentials, action, and triggers during launcher refresh; exported task XML cannot restore a password. Node hosts retain interactive desktop startup.

S4U cannot use Windows network credentials or encrypted files. Operators needing those capabilities can retain a configured Password task. Boot-task registration requires sufficient Windows permissions. A desktop/Startup-folder fallback is explicitly reported and still requires logon. Updates preserve their existing still-starting outcome while allowing slow cold boots time to become ready.

Evidence

  • rebased onto main 09242dc32ae1182f72856721170524882051f0f8 to resolve conflicts with config/test-mock-exports-baseline.txt, src/daemon/schtasks-install.ts, and src/system-agent/setup-apply.test.ts; no behavior change.
  • CI run https://github.com/openclaw/openclaw/actions/runs/37251272783 failed seven ordering cases because their fixture assumed every Gateway installation creates a VBS file and that the launcher is always in <Command>. Local reproduction matched all seven failures. This was stale test setup, not a production ordering defect: unattended tasks reference the existing CMD in <Arguments>. The fixture now reads that action, retains all six original retirement/interruption cases on the supported explicit desktop VBS path, and adds five unattended CMD rollback cases plus its compensation-warning case. Assertions verify original CMD bytes before re-registration, read-back of restored XML before VBS retirement, retained launchers and recovery instructions on failed compensation, and that the existing CMD is never deleted. Production backup/rollback ordering is unchanged.
  • Current correction proof: the nine-file set (the previous eight readiness suites plus service-definition-backup.ordering.test.ts) passed 247 tests ×3 locally in 268.58 / 205.54 / 155.62 seconds wall. The first full gate caught oxc(no-map-spread) in the new case table; replacing the spread with conditional arrays preserved every case and its order. The final ordering file then passed 24 cases ×3 with pnpm test src/daemon/service-definition-backup.ordering.test.ts --maxWorkers=1 in 36.34 / 28.23 / 34.14 seconds wall (6.400 / 8.348 / 7.103 seconds test time). No individual test in the three combined passes exceeded 11.679 seconds. Hosted timing for this new correction is not available yet.
  • Corrects the three failures reported in CI run https://github.com/openclaw/openclaw/actions/runs/37243965908: wizard finalize, system-agent setup, and Windows update-readiness expectations now use the canonical owner. The Windows verifier test exercises the real Windows budget on every host while preserving the host SQLite filesystem semantics. Owner tests independently cover 90-, 100-, and 120-minute results, diagnostic bounds, and explicit timeout precedence.
  • Negative proof: the new owner tests fail against the old owner, and the updated Windows verifier tests fail against the old verifier's short budgets. The corrected eight touched suites passed all 223 tests three times locally (183.35 / 68.78 / 84.33 seconds wall).
  • The final local node scripts/check-changed.mjs completed in full with exit 0 after the test-table lint correction. Both closure guards passed: 20 tests, 104.17 seconds wall. No production module was added or removed; the wrapper inventory remains closed without changes. All commands used isolated OPENCLAW_STATE_DIR. Remote check-changed was blocked by proof infrastructure during the original lane, so validation ran locally under the ruling; remote proof was off for this correction.
  • Required importer/readiness proof passed: 750 tests across 27 files (23 direct/one-barrel importers and four restart-health suites), retaining completed file results and resuming the remaining files in their recorded order after the additional lifecycle run below. The remaining 19-file continuation passed with exit 0 in 697.01 seconds wall.
  • An additional broad update-cli.windows-lifecycle.test.ts run hit 12 local 120-second test timeouts. Profiling found over 90% of samples blocked in synchronous SQLite snapshot subprocesses. The isolated-install case passed on unchanged HEAD in 58.932 seconds and on the corrected code in 50.994 seconds; these diagnostic passes do not erase the broad-run failures. The fixture performance issue is recorded without increasing timeouts, adding retry settings, weakening assertions, or claiming that it is fixed. The unchanged database-rollback package/git cases also took 51.126 / 45.186 seconds and perform real child-process, Doctor, SQLite recovery, and Git work.
  • Original service-definition/Doctor proof is retained: touched suites passed three times, backup/rollback passed 52 tests three times, and the earlier 67-file importer run passed 1,757 tests with six platform-gated skips. XML/schtasks assertions cover unattended definitions, legacy migration, rollback, and Password preservation.
  • No native Windows execution of this correction: unit/XML and simulated Windows proof only. Lane-side P1 review was unavailable (HTTP 401) and waived; the lead reviews the PR head. Fresh-head hosted CI timing is not yet available. Auto-merge remains off.

Latest ordering correction: production +0/−0, tests +93/−44 (one file). Full PR: production +255/−73, tests/support +882/−201, docs +30/−8, one removed mock-baseline entry, and one inherited stale max-lines allowance removed (42 files; +1167/−284).

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes commands Command implementations size: XL labels Oct 4, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 5, 2026, 3:35 AM ET / 07:35 UTC (Revision 9).

ClawSweeper review

What this changes

The branch adds unattended Windows Gateway tasks, preserves Password registrations, migrates recognized older task definitions, and extends cold-start readiness allowances.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

The work remains necessary on current main, but both previously reported correctness blockers remain unresolved. The merged reinstall repair addresses a different service-lifecycle problem.

Priority: P1
Reviewed head: 6f6de5a05eccf9b257eb4a06691b0cae6d26187c

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation has useful regression coverage and a coherent owner boundary, but two lifecycle defects and unverified native upgrade compatibility prevent readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER author classification exempts ordinary contributor proof. The captured evidence exercises task rendering, simulated migration, and readiness owners, but explicitly lacks native Windows execution; independent compatibility proof for persisted Scheduled Task migration and published-driver recovery remains insufficient.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER author classification exempts ordinary contributor proof. The captured evidence exercises task rendering, simulated migration, and readiness owners, but explicitly lacks native Windows execution; independent compatibility proof for persisted Scheduled Task migration and published-driver recovery remains insufficient.
Evidence reviewed 10 items Pinned introduction and merge ownership: Inspected the merge-base-to-head introduced changes. The raw test-merge record has the pinned main parent followed by the exact PR head; comparison against that main parent retains the readiness and Password-launcher changes underlying both findings.
Current main still needs the central change: Current main generates InteractiveToken with a LogonTrigger and retains a 90,000ms Windows setup deadline. It does not contain the unattended task contract or extended allowance proposed here. Direct inspection of the latest release tag was unavailable, so no new shipped-fix claim is made.
Terminal failure does not settle HTTP observation: The changed timing owner supplies a 5,400,000ms Windows deadline. Its start-readiness consumer awaits service health and HTTP readiness together, without passing HTTP polling a cancellation signal. Service health can return stopped-free, but unreachable HTTP continues until the long deadline.
Findings 2 actionable findings [P1] Stop HTTP readiness polling after terminal service failure
[P1] Refresh recognized VBS actions retained by Password tasks
Security None None.

How this fits together

Windows Task Scheduler launches and supervises the Gateway from generated launcher files. Installation, Doctor, and update flows manage those definitions, while readiness observers determine whether the Gateway started successfully.

flowchart TD
  A[Install Doctor or update] --> B[Inspect existing task]
  B --> C[Preserve or migrate task policy]
  C --> D[Publish launcher files]
  D --> E[Windows Task Scheduler]
  E --> F[Supervised Gateway]
  F --> G[Service and HTTP readiness]
  G --> H[Ready starting or failed result]
Loading

Before merge

  • Stop HTTP readiness polling after terminal service failure (P1) - The new Windows deadline becomes 5,400,000ms, but verifyGatewayStartReadiness awaits health and HTTP polling with Promise.all and gives HTTP polling no cancellation signal. If health returns stopped-free after the Gateway exits, unreachable HTTP continues for the entire 90 minutes before the CLI reports failure. Cancel and settle HTTP observation when service health establishes a terminal failure, while retaining the long allowance for a live startup. This prior blocker remains unresolved.
  • Refresh recognized VBS actions retained by Password tasks (P1) - For an identified Gateway user, this selection publishes only the CMD file, while the new Password-preservation branch keeps the existing task action. A Password task selecting a recognized older gateway.vbs therefore retains its old asynchronous or markerless wrapper. The updated CMD defaults launcher ownership to CMD, so it does not repair the retained WScript task's process-tree ownership; an asynchronous wrapper can finish while the Gateway continues running. Refresh the recognized selected VBS through the same backup/rollback publication path without re-registering credentials or changing operator policy. This prior blocker remains unresolved.
  • Resolve merge risk (P1) - Native Windows fresh-install and published v2026.9.8-to-candidate upgrade evidence is still missing for the new S4U/CMD task contract, including unattended startup, Task End process-tree settlement, Password-task preservation, and failed-migration recovery.
  • Complete next step (P2) - Resolve both retained findings and establish native Windows fresh-install and published-driver upgrade recovery for the changed task contract before merge.

Findings

  • [P1] Stop HTTP readiness polling after terminal service failure — src/commands/gateway-startup-timing.ts:24-26
  • [P1] Refresh recognized VBS actions retained by Password tasks — src/daemon/schtasks-install.ts:157-160
Agent review details

Security

None.

PR surface

Source +182, Tests +696, Docs +22, Other -1. Total +899 across 41 files.

View PR surface stats
Area Files Added Removed Net
Source 12 255 73 +182
Tests 26 901 205 +696
Docs 2 30 8 +22
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 41 1186 287 +899

Review metrics

Metric Value Why it matters
Readiness allowance Windows setup 90 seconds → 90 minutes; implicit update 90–120 minutes The larger budget makes prompt settlement of terminal failures essential.
Production versus test growth Production +255/−73; tests/support +901/−205 Production growth has a stated task-preservation and shared-readiness purpose, but the supplemental tests do not replace native upgrade evidence.

Merge-risk options

Maintainer options:

  1. Repair and verify the Windows transition (recommended)
    Resolve both source defects, then record native fresh-install and published-driver upgrade recovery for the changed task contract.
  2. Pause native policy migration
    Hold the unattended task migration until Windows upgrade evidence is available if that validation cannot be completed for this branch.

Technical review

Best possible solution:

Keep one task lifecycle owner that refreshes every retained generated launcher, settles failed readiness promptly, and preserves existing registrations through a verified Windows upgrade.

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

Yes, source establishes both introduced triggers: a stopped Gateway leaves uncancelled HTTP polling under the new 90-minute budget, and an identified-user Password task can retain an unrefreshed legacy VBS action. No runtime reproduction was executed.

Is this the best way to solve the issue?

Not yet: sharing the timing owner and preserving stored task credentials are sound directions, but failure settlement and retained-launcher publication must be completed before the implementation meets its lifecycle claims.

Full review comments:

  • [P1] Stop HTTP readiness polling after terminal service failure — src/commands/gateway-startup-timing.ts:24-26
    The new Windows deadline becomes 5,400,000ms, but verifyGatewayStartReadiness awaits health and HTTP polling with Promise.all and gives HTTP polling no cancellation signal. If health returns stopped-free after the Gateway exits, unreachable HTTP continues for the entire 90 minutes before the CLI reports failure. Cancel and settle HTTP observation when service health establishes a terminal failure, while retaining the long allowance for a live startup. This prior blocker remains unresolved.
    Confidence: 0.99
  • [P1] Refresh recognized VBS actions retained by Password tasks — src/daemon/schtasks-install.ts:157-160
    For an identified Gateway user, this selection publishes only the CMD file, while the new Password-preservation branch keeps the existing task action. A Password task selecting a recognized older gateway.vbs therefore retains its old asynchronous or markerless wrapper. The updated CMD defaults launcher ownership to CMD, so it does not repair the retained WScript task's process-tree ownership; an asynchronous wrapper can finish while the Gateway continues running. Refresh the recognized selected VBS through the same backup/rollback publication path without re-registering credentials or changing operator policy. This prior blocker remains unresolved.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 56bdfc723e0d.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: This addresses reported Windows Gateway availability failures and retains two blocking service-lifecycle defects.
  • merge-risk: 🚨 compatibility: The branch changes installed task policy and can preserve an obsolete VBS launcher under a Password registration.
  • merge-risk: 🚨 availability: A failed Gateway start can keep the CLI waiting for 90 minutes, and retained legacy launchers can lose task-owned process containment.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The supplied MEMBER author classification exempts ordinary contributor proof. The captured evidence exercises task rendering, simulated migration, and readiness owners, but explicitly lacks native Windows execution; independent compatibility proof for persisted Scheduled Task migration and published-driver recovery remains insufficient.

Evidence

Acceptance criteria:

  • [P1] pnpm test src/cli/daemon-cli/lifecycle-readiness.test.ts src/cli/daemon-cli/restart-health-probe.test.ts --maxWorkers=1.
  • [P1] pnpm test src/daemon/schtasks.install.test.ts src/daemon/schtasks-install-rollback.test.ts src/daemon/service-policy-preservation.test.ts src/daemon/service-definition-backup.ordering.test.ts --maxWorkers=1.
  • [P1] node scripts/check-changed.mjs.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: 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.

  • Cancel and settle HTTP readiness observation after terminal service failure.
  • Refresh retained recognized VBS launchers with credential-preserving rollback coverage.
  • Record native Windows fresh-install and published-driver upgrade recovery for the repaired task contract.

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 (8 earlier review cycles)
  • reviewed 2026-10-04T22:27:03.090Z sha 177943c :: blocked before merge. :: none
  • reviewed 2026-10-04T23:36:30.259Z sha 6cdb572 :: blocked before merge. :: [P1] [P1] Stop HTTP readiness polling after terminal service failure | [P1] [P1] Refresh recognized VBS actions retained by Password tasks
  • reviewed 2026-10-05T01:32:15.645Z sha f84fb71 :: blocked before merge. :: [P1] [P1] Stop HTTP readiness polling after terminal service failure | [P1] [P1] Refresh recognized VBS actions retained by Password tasks
  • reviewed 2026-10-05T03:06:12.643Z sha 903544c :: blocked before merge. :: [P1] Stop HTTP readiness polling after terminal service failure | [P1] Refresh recognized VBS actions retained by Password tasks
  • reviewed 2026-10-05T03:41:36.282Z sha 903544c :: blocked before merge. :: [P1] Stop HTTP readiness polling after terminal service failure | [P1] Refresh recognized VBS actions retained by Password tasks
  • reviewed 2026-10-05T04:41:11.155Z sha 903544c :: blocked before merge. :: [P1] Stop HTTP readiness polling after terminal service failure | [P1] Refresh recognized VBS actions retained by Password tasks
  • reviewed 2026-10-05T05:56:34.638Z sha cfe1463 :: blocked before merge. :: [P1] Stop HTTP readiness polling after terminal service failure | [P1] Refresh recognized VBS actions retained by Password tasks
  • reviewed 2026-10-05T07:05:01.677Z sha a5f537a9131de5a89ed4d582f17f91f246c9009b :: blocked before merge. :: [P1] Stop HTTP readiness polling after terminal service failure | [P1] Refresh recognized VBS actions retained by Password tasks

@steipete
steipete marked this pull request as ready for review October 4, 2026 23:29
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 5, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Oct 5, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 5, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 5, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Oct 5, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 5, 2026
@steipete
steipete force-pushed the upd/upd-windows-scheduled-task-unattended branch from 903544c to cfe1463 Compare October 5, 2026 05:49
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 5, 2026
@steipete
steipete force-pushed the upd/upd-windows-scheduled-task-unattended branch from cfe1463 to a5f537a Compare October 5, 2026 06:58
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 5, 2026
Install S4U boot/logon tasks with a direct CMD action and repair shipped
logon-coupled definitions through Doctor's backup and rollback owner.
Preserve operator-managed Password registrations and launcher ownership.
Share the existing update-step budget with Windows readiness observers.

Thanks @desksk for the detailed report and corrected launcher analysis.
@steipete
steipete force-pushed the upd/upd-windows-scheduled-task-unattended branch from a5f537a to 6f6de5a Compare October 5, 2026 07:29
@steipete
steipete merged commit eb893a8 into main Oct 5, 2026
117 of 120 checks passed
@steipete
steipete deleted the upd/upd-windows-scheduled-task-unattended branch October 5, 2026 07:42
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

1 participant