Skip to content

fix: unblock Windows Doctor and retained workspace recovery - #136578

Merged
steipete merged 3 commits into
mainfrom
steipete/issue-136203-root-cause-fixes-08e773
Sep 2, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/issue-136203-root-cause-fixes-08e773

Conversation

@steipete

@steipete steipete commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Related: #136203 — Windows upgrade recovery and retained workspace state.
Related: #136123 — non-English Windows Task Scheduler inspection blocks Doctor maintenance.
Maintainer replacement for #136170 — the numeric-state fallback contribution by @LiuwqGit. This repair makes numeric state canonical instead of retaining the locale-sensitive parser and a second classification path, and includes the connected workspace recovery boundaries. The lead will decide whether to close the contributor PR only after this replacement lands and exact-landed native verification proves coverage.

Additional instructions

Maintainers can update this same-repository branch.

What Problem This Solves

Fixes an issue where users recovering from an upgrade could not run Doctor on non-English Windows because an already-stopped Scheduled Task was reported as unknown. An explicit fleet could also leave retired setup files undiscovered in its configured shared workspace root. Pinning an agent back to that root while the Gateway was running could accept an unusable configuration and then repeatedly fail turns and heartbeats.

Why This Change Was Made

Task Scheduler's numeric current state now owns runtime classification, existence, offline checks, and takeover evidence. Historical LastTaskResult is retained as history, not current activity. The localized LIST parser and duplicate result-code inference are removed. Queued/unknown inspection remains conservative; failed COM activation/connection cannot prove absence or justify a second direct node launch. Exact persisted-argv process evidence is preserved without confusing a Startup process with Scheduler supervision, and Windows CIM ownership no longer loads Gateway bind-host configuration unnecessarily.

Doctor's existing source inventory now also examines the explicitly authored shared workspace root, reusing the existing verified SQLite import/archive/receipt/cleanup flow. Runtime readiness still considers only selected agent/sandbox workspaces. The existing workspace-readiness assertion runs at final reload-candidate preparation, before managed-write persistence or watcher publication. Rejected external file edits can remain on disk, but the last healthy runtime remains active.

No schema, dependency, protocol, configuration option, or ambient-owner inference is added. No memory/persona files are moved or merged. Existing main-only fixes already cover legacy-list workspace preservation, stale setup-state migration conflicts, and ownerless fleet status; this does not duplicate them or guess ownership for an already-keyed markerless roster.

User Impact

Operators can inspect running/stopped Scheduled Tasks without depending on Windows display language or console encoding. Doctor can find and retire both legacy setup markers in a retained shared root without assigning that root to an agent. Invalid live workspace changes fail immediately with the recovery hint instead of taking subsequent turns out of service. Recovery documentation distinguishes rejected managed writes from externally edited files and explains the existing Dreaming ambient-owner setting.

Reporter context: @hermannmetzker-ai and the Linux follow-up by @DasX in #136203. Related numeric-state contribution and native localized-host evidence: @LiuwqGit in #136170.

Evidence

Reproduction and owner-boundary regressions

Before the production repair, localized runtime cases returned unknown for ready/running tasks; queued/unknown tasks with historical success could trigger a direct node fallback; Doctor missed both reserved setup files in the explicit fleet's shared root; managed config writes and the file watcher accepted/published an unmigrated workspace.

After the repair, 262 distinct focused tests passed across the Windows runtime/control/install/stop/maintenance, workspace migration/sandbox/legacy-state, and Gateway candidate-admission suites. Gateway tests use the real core server entrypoint, WebSocket config.set, config writer, and file watcher; they verify last-good runtime preservation, unchanged source bytes, continued health, Doctor import, and successful post-repair activation.

Commands:

node scripts/run-vitest.mjs src/daemon/schtasks.test.ts src/daemon/schtasks.install.test.ts src/daemon/schtasks.startup-fallback.test.ts src/daemon/schtasks.stop.test.ts src/cli/update-cli/update-command-service-maintenance.test.ts
node scripts/run-vitest.mjs src/infra/state-migrations.workspace-setup.test.ts src/gateway/server-startup-workspace-readiness.test.ts src/infra/state-migrations.workspace-setup-sandbox.test.ts src/agents/workspace-legacy-state.test.ts

The shared-root table was subsequently extracted without assertion changes to satisfy the test-file size limit; the original and extracted suites passed together (34 + 2):

node scripts/run-vitest.mjs src/infra/state-migrations.workspace-setup.test.ts src/infra/state-migrations.workspace-setup-shared-root.test.ts

Built CLI and checks

  • Full pnpm build passed on a frozen tree, including runtime postbuild, SDK declarations, and Control UI budgets. An earlier build rejected a topology change while a test split was in flight; the frozen rerun passed without weakening the guard. No ineffective dynamic import warning.
  • node scripts/check-changed.mjs -- <all 18 changed source/test/docs paths> passed, including production/test typechecks, formatting/lint, dead exports, runtime cycles, storage and ownership guards.
  • An isolated synthetic HOME/profile using the freshly built node openclaw.mjs entrypoint passed doctor --fix --non-interactive, explicit workspace pinning, and status without an ambient owner. Assertions verified both legacy markers removed, canonical milestone imported, persona/memory bytes unchanged, and no inferred per-agent workspace. No operator Gateway/state was touched. This smoke did not start a Gateway or test memory embeddings.
  • Independent Codex P0–P2 review returned scoped-clean. Fresh pre-commit review is recorded in the landing proof.

Native Windows evidence and explicit remaining scope

A real Windows Server 2022 Schedule.Service lifecycle probe passed Ready → Running → Stopped → Disabled under en-US/de-DE/pt-BR process cultures: https://crabbox.openclaw.ai/portal/runs/run_fb086d4a400e . Provider: Azure; lease cbx_e6c67361b529, released. This proves the native API contract, not execution of the changed OpenClaw source or a complete German-OS/UAC upgrade replay. Earlier attempts to sync/run the complete source on that lease failed at SSH owner renewal/source transfer before tests.

The maintainer explicitly requested landing this repair first, then native Windows Crabbox testing of the landed code. That post-merge result will be appended with the exact source SHA and run link; it is not pre-merge proof. No new Control UI surface is introduced; the config-admission behavior is covered through actual RPC/watcher boundary tests, not a UI recording.

The stale Codex-binary selection comment remains unproven without failing-process command/source/environment evidence. A separate ancestor-shim/package-owner lookup weakness is recorded as follow-up; no Codex runtime source is changed or claimed repaired here. The issue references intentionally do not auto-close the broader report.

Original repair size and contracts

Production +94/-153 (net -59); tests +609/-358 (net +251), including the new focused shared-root test; docs +27/-5 (net +22). Test moves are distinguished from new cases. No changelog edit; this body retains behavior, surface, issue references, and contributor/reporter credit for release-note generation.

Maintainer review decision

The latest completed ClawSweeper review found no introduced correctness or security defect. The maintainer accepts its recommended retain last-good runtime admission option: rejecting an unready live workspace is intentional; managed writes reject before persistence, while externally edited config may remain on disk until the documented offline Doctor repair. This avoids replacing the working runtime with one that cannot execute turns. The RPC/watcher regression and recovery docs cover that distinction.

Rank-up move explicitly deferred: the redacted native Scheduled Task + Doctor recovery trace will be captured against the exact landed SHA after merge, following the maintainer's requested order. Both hosted Windows CI test jobs have passed on the PR head; they are not represented as a packaged German-OS/UAC recovery replay. No runtime changes were needed after review. The bounded test-only CI follow-up below preserves the reviewed runtime behavior; the fresh review remains applicable without a queued re-review.

CI cleanup-probe follow-up

The first exact-head run, 33678784467, passed both Windows jobs but failed one QA Lab cleanup test: a fresh source-transpiling child hit its existing 90-second execution deadline; 1,519 sibling tests in that shard passed. Substituting the ESM loader alone did not fix the timed cold import. The bounded follow-up extracts that same cleanup scenario into the existing invocation-owned compiled-subprocess system, compiling before the fresh child's execution deadline instead of inside it. The real SQLite/auth-store operations, natural process exit, sibling leases/profiles, isolated home, and all timeout limits remain unchanged. No new production seam or runtime behavior is added.

The final cleanup suite passed all 9 cases, with the critical child completing in 14.3 seconds; the unchanged source child had taken 55.7 seconds locally. The existing loader contract suite also passed 48 cases. Fresh independent Codex P0-P2 review of the full updated candidate returned scoped-clean; it was static review, not another test run. This follow-up touches five test/test-support/tooling paths, bringing the PR to 23 files. The original 18 reviewed files remain byte-for-byte unchanged.

Updated LOC: production +94/-153 (net -59); test-only compiler registration +4/-0; tests/test support +683/-399 (net +284); docs +27/-5 (net +22). The extracted fixture is mostly a move from the inline child program, not new runtime logic.

The five-path changed checker passed types, formatting/lint, dead exports, and ownership/contract guards. Its first attempt stopped on an inactive artifact lock; recorded owner/descendant/descriptor inspection established no remaining work before cleanup and a full successful retry.

A pinned-main rebase was required by an actual test-worker registry merge conflict, not behind-main drift. Both fixture registrations were preserved; range-diff shows the original repair patch unchanged. The cleanup suite passed again on fc1605cccc64afcfa6bae739d95f1c37b422885a (9 tests; critical child 6.7 seconds). The new exact-head hosted run is 33684143867.

The refreshed ClawSweeper cycle at 20:44:17 UTC retained no correctness/security finding and named the failed QA config shard plus unavailable current-main blobs as remaining proof gaps. The shard has the bounded repair above; current-main source comparison is now complete locally (no newer changes to the five runtime owners or worker registry through af9d82ad5a0). Its latest Rank-up move is to resolve that shard and obtain exact-head green CI; no CI gate is waived. Fresh independent Codex review of the exact rebased candidate also returned scoped-clean, no P0-P2, without executing project tests.

Audit-entry correction

The second run reported one further blocker in check-dependencies job 100427781474: the real compiled child was listed only in the root Knip workspace, so the plugin workspace classified it as unused. The existing canonical worker-entry derivation now runs relative to each owning workspace. This is entry modeling, not an ignore or baseline change. Both actual unused-file scans passed with zero entries; the 43 existing dead-code/config tests, formatting and lint passed, and fresh independent review found no P0-P2 issue. The zero-unused-file gate remains intact.

Final scope: 24 files. Runtime production remains +94/-153 (net -59); test-only compiler/audit tooling +10/-4 (net +6); tests/support +683/-399 (net +284); docs +27/-5 (net +22). Final source head: aedb525401f3d8ce8dfc31bb6ca8e159c6d57df8. Native Windows full-source verification remains pending after merge.

Windows CI timing follow-up

Final-head run33685130504 passed 189 checks, including the repaired QA and dependency jobs, but Windows shard2 job100431408810 timed out at120 seconds in the existing vitest-worker-artifacts.transforms.test.ts source-mode/single-layout case. Its compiled and source observations matched expectations before the final compiled launch; the project-layout sibling passed. The test and its support module are unchanged by this PR. A single targeted unchanged rerun passed as job100437719399. This does not claim that timing variance is fixed.

Named follow-up: investigate cold Windows compiled-worker transform test duration variance under the full shard workload. No timeout increase, assertion weakening, forced test environment, or CI bypass is part of this PR.

Final landing gate

Exact-head CI run33685130504 is successful. Required openclaw/ci-gate job100440731805 is green; final PR projection is MERGEABLE/CLEAN with194 successful,49 skipped and1 neutral checks, no pending/failing checks. Both Windows jobs 100437721050 and 100437719399 passed. QA 100437728172 and dependency 100437721646 are green.

The first Windows-shard2 attempt 100431408810 timed out at120s in the unchanged source-mode/single-layout compiled-worker transform test; its observed values were correct before the third launch. A single unchanged targeted rerun passed. This is not a claimed timing fix: follow-up: investigate cold Windows worker-transform fixture duration variance under full shard load. No timeout increase, weaker assertion, source edit, or gate bypass was used.

gh run rerun 33685130504 --job 100431408810
node scripts/watch-pr-ci.mjs 136578 aedb525401f3d8ce8dfc31bb6ca8e159c6d57df8 --completion ci-run

Live effective main rules require the GitHub Actions ci-gate and linear history, with no enforced independent approval rule. Native review artifacts validate for the exact head. Native prepare/merge follows this proof; no direct merge or bypass is authorized.

The latest completed ClawSweeper review is on this exact head (2026-09-02 21:34:24 UTC): no correctness/security finding, current-main comparison complete. Its exact-head green-CI Rank-up move is now satisfied; the maintainer retains the documented last-good-runtime admission behavior.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review September 2, 2026 20:21
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes size: XL maintainer Maintainer-authored PR labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. 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 Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 2, 2026, 6:01 PM ET / 22:01 UTC.

ClawSweeper review

What this changes

The PR replaces locale-sensitive Windows Scheduled Task inspection, expands Doctor’s retained-workspace discovery, rejects unready live workspace candidates, and moves a QA cleanup probe into the compiled-worker harness.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

No introduced P0–P2 correctness or security defect was found, and current main does not contain the repair. This maintainer-authored PR remains necessary; exact-head required-check completion is the remaining merge gate.

Priority: P0
Reviewed head: aedb525401f3d8ce8dfc31bb6ca8e159c6d57df8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is coherent, net-negative in runtime code, and backed by focused owner-boundary coverage; required-check completion remains to be confirmed for the exact head.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply. The supplied evidence remains useful: the changed service and Gateway owners have focused boundary coverage, while the referenced native Windows probe is explicitly limited to the platform contract rather than claimed as execution of this branch.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR, so the external-contributor proof gate does not apply. The supplied evidence remains useful: the changed service and Gateway owners have focused boundary coverage, while the referenced native Windows probe is explicitly limited to the platform contract rather than claimed as execution of this branch.
Evidence reviewed 8 items Windows runtime owner: The introduced implementation derives activity from Task Scheduler numeric state, treating only Running as running and Ready/Disabled as stopped while preserving unknown for queued or inconclusive state.
Safety consumers: Fallback launch requires a stopped task before interpreting historical result codes, and the existing process path continues to require persisted-argv ownership on Windows.
Workspace migration boundary: Doctor-only discovery adds the configured shared root without changing runtime readiness, which continues to enumerate only selected agent and sandbox workspaces.
Findings None None.
Security None None.

How this fits together

Windows service inspection determines whether Doctor may safely perform Gateway maintenance. Workspace migration and Gateway reload admission then prevent runtime activation of a selected workspace whose retired setup state still needs Doctor repair.

flowchart LR
A[Windows Task Scheduler] --> B[Numeric runtime inspection]
B --> C[Doctor maintenance gate]
D[Workspace configuration] --> E[Workspace readiness]
E --> F[Gateway candidate admission]
C --> G[Doctor repair]
G --> E
F --> H[Active Gateway runtime]
Loading

Before merge

  • Resolve merge risk (P1) - Existing installations that select an unmigrated workspace will reject that live configuration until Doctor repair completes; this is intentional and covered by the retained last-good-runtime tests, but it is upgrade-sensitive.
  • Resolve merge risk (P1) - The supplied exact-head check rollup is truncated/incomplete, so required-check completion cannot be confirmed from this review snapshot.
  • Complete next step (P2) - Confirm all required checks for aedb525 are complete and green before merge.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
Agent review details

Security

None.

PR surface

Source -59, Tests +284, Docs +22, Other +6. Total +253 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 5 94 153 -59
Tests 11 683 399 +284
Docs 5 27 5 +22
Config 0 0 0 0
Generated 0 0 0 0
Other 3 10 4 +6
Total 24 814 561 +253

Review metrics

Metric Value Why it matters
Production versus test delta runtime production +94/-153; tooling +6/-4; tests/test support +687/-399; docs +27/-5 The repair is net-negative in runtime code while adding focused regression and compiled-worker coverage for the changed upgrade boundaries.

Merge-risk options

Maintainer options:

  1. Confirm exact-head checks (recommended)
    Confirm all required checks for the reviewed head are green, then merge with the documented Doctor-repair upgrade behavior.
  2. Pause for additional platform proof
    Keep the PR open if maintainers require landed-code Windows recovery evidence beyond the focused native contract and regression coverage.

Technical review

Best possible solution:

Land the canonical numeric-state and candidate-admission repair only after exact-head required checks are confirmed green, retaining the documented offline Doctor recovery path and last-good runtime behavior.

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

Yes—source-reproducible with high confidence. The base implementation relied on localized task output, while the introduced tests and current owner paths cover numeric-state classification and live workspace-candidate rejection; this review did not execute the platform scenario.

Is this the best way to solve the issue?

Yes. Numeric Scheduler state is the authoritative current-activity signal, and checking workspace readiness at final candidate preparation protects both managed writes and watcher reloads without treating an unused shared root as active.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ca0982633103.

Labels

Label justifications:

  • P0: The repaired path can otherwise block Windows Doctor recovery and leave a Gateway unable to return to service.
  • merge-risk: 🚨 compatibility: A previously accepted live workspace selection now rejects until retained setup state is repaired, affecting upgrades and persisted configuration changes.
  • merge-risk: 🚨 availability: The Gateway deliberately retains the last-good runtime rather than activating an unready workspace candidate, so an incorrect boundary could affect service activation.
  • 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: This is a maintainer-authored PR, so the external-contributor proof gate does not apply. The supplied evidence remains useful: the changed service and Gateway owners have focused boundary coverage, while the referenced native Windows probe is explicitly limited to the platform contract rather than claimed as execution of this branch.

Evidence

What I checked:

Likely related people:

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

  • Confirm all required checks for aedb525 are complete and green before merge.

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 (3 earlier review cycles)
  • reviewed 2026-09-02T20:30:27.313Z sha ff7a9376d31b3b7569717999f603bbecd92dadf7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T20:44:17.010Z sha ff7a9376d31b3b7569717999f603bbecd92dadf7 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T21:34:24.597Z sha aedb525 :: blocked before merge. :: none

steipete and others added 2 commits September 2, 2026 14:14
Use Task Scheduler numeric current state instead of localized output and
historical task-result inference. Preserve queued/unknown safety and exact
process ownership. Include authored shared workspace roots in Doctor discovery
without assigning an owner, and reject unready live workspace candidates before
managed persistence or runtime publication.

Related: #136203, #136123, #136170
Credit LiuwqGit for the related numeric-state contribution; the canonical
refactor and connected workspace recovery changes are maintainer-owned.

Co-authored-by: LiuwqGit <[email protected]>
Keep the real SQLite cleanup, sibling ownership, and natural-exit assertions in the existing compiled runtime-worker harness. This removes cold source transpilation from the child deadline without increasing timeouts or weakening checks. Resolves the confirmed QA shard blocker in PR #136578.
@steipete
steipete force-pushed the steipete/issue-136203-root-cause-fixes-08e773 branch from ff7a937 to fc1605c Compare September 2, 2026 21:15
Keep plugin-owned compiled children reachable to Knip from their own workspace. Derive the same canonical entry map at each workspace boundary instead of only the repository root; preserve hard-zero unused-file enforcement.
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 2, 2026
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof for source commit aedb525.

The repair removes localized Task Scheduler LIST parsing and historical-result activity inference. Numeric current state is canonical; queued/unknown remain conservative, exact-argv PID evidence stays intact, and unavailable COM inspection cannot establish absence or justify a duplicate node launch. Doctor inventories the authored shared root without assigning it to an agent; final reload-candidate preparation rejects unready workspaces before managed persistence or watcher publication. Existing Doctor import/receipt/cleanup owns migration.

Owner decisions: no new schema, dependency, protocol, config option, guessed ambient owner, or persona/memory moves. The maintainer-owned branch preserves @LiuwqGit's related numeric-state contribution as a co-author without overwriting contributor ancestry. The broader issues and contributor PR remain open pending exact-landed native verification.

Verification

262 distinct focused tests passed: Windows runtime/control/install/stop/maintenance 195; workspace/Gateway/sandbox/legacy 67. The extracted shared-root rerun is included in that count. Commands executed on the frozen source by the repair lead, with final logs inspected by the landing worker:

node scripts/run-vitest.mjs src/daemon/schtasks.test.ts src/daemon/schtasks.install.test.ts src/daemon/schtasks.startup-fallback.test.ts src/daemon/schtasks.stop.test.ts src/cli/update-cli/update-command-service-maintenance.test.ts
node scripts/run-vitest.mjs src/infra/state-migrations.workspace-setup.test.ts src/gateway/server-startup-workspace-readiness.test.ts src/infra/state-migrations.workspace-setup-sandbox.test.ts src/agents/workspace-legacy-state.test.ts
node scripts/run-vitest.mjs src/infra/state-migrations.workspace-setup.test.ts src/infra/state-migrations.workspace-setup-shared-root.test.ts
pnpm build
node scripts/check-changed.mjs -- docs/cli/doctor.md docs/concepts/agent-workspace.md docs/concepts/dreaming.md docs/gateway/configuration.md docs/platforms/windows.md src/cli/update-cli/update-command-service-maintenance.test.ts src/daemon/schtasks-control.ts src/daemon/schtasks-process.ts src/daemon/schtasks-runtime.ts src/daemon/schtasks.install.test.ts src/daemon/schtasks.startup-fallback.test.ts src/daemon/schtasks.stop.test.ts src/daemon/schtasks.test.ts src/gateway/server-startup-bootstrap.ts src/gateway/server-startup-workspace-readiness.test.ts src/infra/state-migrations.workspace-setup.test.ts src/infra/state-migrations.workspace-setup.ts src/infra/state-migrations.workspace-setup-shared-root.test.ts
git diff --check

Full build passed in 16m17s without ineffective dynamic imports. An earlier build rejected concurrent test-file topology changes; the frozen rerun passed without weakening the guard. The isolated freshly built node openclaw.mjs Doctor/config/status smoke verified both setup markers removed, canonical state imported, retained corpus unchanged, no inferred per-agent workspace, explicit pinning, and ownerless status. It did not start a Gateway or call a model. Actual Gateway RPC/watcher regressions separately prove rejection, last-good runtime preservation, and successful activation after Doctor repair.

Fresh independent Codex precommit/preland review: scoped-clean, no P0-P2 findings; the reviewer did not independently run tests. All original runtime repair files match the frozen tested source. A conflict-only rebase preserves the original repair patch (range-diff verified) and retains both main and QA compiled-worker registrations. The new child fixture, not user runtime behavior, accounts for the five added paths. Native review-init, main/PR checkout guards, artifact initialization and review-validate-artifacts passed.

Runtime production +94/-153 (net -59); test-only compiler/audit tooling +10/-4 (net +6); tests/support +683/-399 (net +284); docs +27/-5 (net +22). No changelog edits.

The original exact-head CI run 33678784467 passed both Windows jobs (100410378760, 100410378908), but QA job 100410387618 failed one cold raw-tsx cleanup child at its 90-second deadline; 1,519 sibling tests passed. A loader-only attempt did not fix it. The existing compiled-worker owner now compiles that same real cleanup scenario before the fresh child starts, preserving natural exit, real stores/auth, sibling leases/profiles, isolated HOME and all deadlines. Nine cleanup cases passed before and after the conflict-only rebase; the final critical child took 6,687ms. The 48-case loader contract also passed. Five-path changed checks passed all lanes after inspection/removal of an inactive artifact lock; no active descendants were removed. Fresh exact-rebased-head independent review: scoped-clean, no P0-P2; static, not a claimed test execution.

node scripts/run-vitest.mjs extensions/qa-lab/src/gateway-child-artifacts.test.ts
# Loader-only experiment: 48 loader tests passed; cleanup timeout persisted and led to the compiled-child repair.
node scripts/run-vitest.mjs extensions/qa-lab/src/gateway-child-artifacts.test.ts test/scripts/direct-run-entrypoints.test.ts
node scripts/check-changed.mjs -- extensions/qa-lab/src/gateway-child-artifacts.test.ts extensions/qa-lab/src/gateway-child-artifacts-runtime.test-support.ts extensions/qa-lab/src/gateway-child-artifacts-child.test-support.ts scripts/lib/vitest-worker-build-entries.mts scripts/lib/vitest-worker-artifacts.mts
git range-diff 764ba7a9854e0b2347382e4c104aff42fdb95cf4..96d0f945e0cdf15666ebb60b673d9de924e15bf8 5b15291868b9d5e4566574cd04816541466e6144..fc1605cccc64afcfa6bae739d95f1c37b422885a

The second run 33684143867 exposed a missing audit entry in job100427781474: the new real compiled child was modeled only in root, not its Knip plugin workspace. The canonical entry map is now resolved relative to each workspace, matching Knip’s workspace contract, with no ignore or baseline changes. Production and full-tree unused-file scans both passed zero entries; 43 existing guard/config tests and format/lint passed. Fresh independent review of that final +6/-4 audit correction is scoped-clean, no P0-P2. Final scope is 24 files, and user runtime source is unchanged.

node --import ./scripts/tsx.mjs scripts/check-deadcode-unused-files.mts
node scripts/run-vitest.mjs test/scripts/check-deadcode-exports.test.ts test/scripts/check-deadcode-unused-files.test.ts
pnpm exec oxfmt --check config/knip.all-exports.config.ts
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.scripts.json config/knip.all-exports.config.ts

Exact-head CI run33685130504 is successful. Required openclaw/ci-gate job100440731805 is green; final PR projection is MERGEABLE/CLEAN with194 successful,49 skipped and1 neutral checks, no pending/failing checks. Both Windows jobs 100437721050 and 100437719399 passed. QA 100437728172 and dependency 100437721646 are green.

The first Windows-shard2 attempt 100431408810 timed out at120s in the unchanged source-mode/single-layout compiled-worker transform test; its observed values were correct before the third launch. A single unchanged targeted rerun passed. This is not a claimed timing fix: follow-up: investigate cold Windows worker-transform fixture duration variance under full shard load. No timeout increase, weaker assertion, source edit, or gate bypass was used.

gh run rerun 33685130504 --job 100431408810
node scripts/watch-pr-ci.mjs 136578 aedb525401f3d8ce8dfc31bb6ca8e159c6d57df8 --completion ci-run

Live effective main rules require the GitHub Actions ci-gate and linear history, with no enforced independent approval rule. Native review artifacts validate for the exact head. Native prepare/merge follows this proof; no direct merge or bypass is authorized.

Latest ClawSweeper review, completed 2026-09-02 21:34:24 UTC on this exact head, found no introduced correctness/security defect and independently completed current-main comparison. Maintainer compatibility decision: retain last-good runtime admission, with managed writes rejected before persistence and external file edits potentially remaining on disk until offline Doctor repair. No new config/default/schema surface is added. Its only current Rank-up move is successful exact-head required checks, addressed by the CI evidence above. The earlier optional native Scheduled Task + Doctor trace remains explicitly deferred to the operator-requested post-merge exact-landed Windows run. No code changed after this completed review.

Explicit native Windows proof gap

The prior Windows Task Scheduler lifecycle probe passed on Windows Server 2022 under en-US/de-DE/pt-BR process cultures. It proves the native TASK_STATE contract, not execution of this changed source or a complete German-OS/UAC upgrade replay. Full native Windows Crabbox testing of the exact landed source is deliberately next, as explicitly ordered by the maintainer: land first, then test Windows. This comment does not claim that post-merge result. No Codex runtime behavior is claimed repaired.

@steipete
steipete merged commit 145d243 into main Sep 2, 2026
429 of 431 checks passed
@steipete
steipete deleted the steipete/issue-136203-root-cause-fixes-08e773 branch September 2, 2026 22:08
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Post-merge native Windows verification

Verified the exact landed commit 145d243d6b6dca809e8dfd9c9a34308b506943b1 on native Windows Server 2022 (10.0.20348.5499), Node 24.20.0, and repository-pinned pnpm 12.1.0. Provider: Azure through Crabbox, Standard_D4ads_v6. These were real Windows tasks and actual OpenClaw source/CLI execution, not mocked Task Scheduler responses.

Results

  • Real task lifecycle through the landed readScheduledTaskRuntime: Ready → stopped, Running → running, stopped → stopped, Disabled → stopped, deleted → stopped / missingUnit. Offline checks agreed. Historical results were retained as history (267011, 267009, 267014), not used to override current state.
  • Full native pnpm build passed in 8m 4s.
  • Final Doctor proof used the OS account home with a unique canonical profile and asserted isDefaultInstallIdentity=true, service.targetRole=target, and service ownership owned before running Doctor. This is important: an earlier temporary-HOME attempt was diagnostic-only and is not counted as managed-maintenance proof.
  • With a real Ready Scheduled Task and the generated OpenClaw launcher present, the built CLI's gateway status --deep --json reported stopped / Ready. doctor --fix --non-interactive completed; both retired setup markers were removed after verified SQLite import; the task remained Ready/stopped after repair.
  • The canonical workspace milestone was verified by workspace key (Windows workspace identities fold path case). Persona and memory bytes were unchanged, Doctor did not assign the shared root to either agent, explicit workspace pinning persisted, and status succeeded after removing the ambient system-agent owner.
  • Test tasks and the canonical profile state were removed. No operator Gateway/state or live credentials were used.

Final managed-profile verdict excerpt:

{
  "result": "pass",
  "sourceHead": "145d243d6b6dca809e8dfd9c9a34308b506943b1",
  "canonicalInstallIdentity": true,
  "serviceTargetRole": "target",
  "serviceOwnership": "owned",
  "stoppedScheduledTaskBeforeAndAfterDoctor": true,
  "doctorRemovedBothLegacyMarkers": true,
  "canonicalMilestoneImported": true,
  "doctorDidNotAssignSharedWorkspace": true,
  "explicitWorkspacePinPersisted": true,
  "statusWithoutAmbientOwnerSucceeded": true
}

Observed Doctor output:

Migrated workspace setup state to SQLite.
Verified canonical SQLite workspace setup state.
Removed retired workspace state after verified SQLite import.
Doctor complete.

The actual CLI sequence, with isolated fixture environment/profile and assertions between commands, was:

node openclaw.mjs gateway status --deep --json
node openclaw.mjs doctor --fix --non-interactive
node openclaw.mjs config set agents.entries.alpha.workspace <retained-workspace>
node openclaw.mjs config unset agents.defaults.systemAgent.agentId
node openclaw.mjs status

Scope and infrastructure notes

Both Windows VMs used en-US system/user/UI culture and an administrator SSH context. The headless task fixtures used the SYSTEM principal; the Doctor task had no triggers and was never started. This proves the stopped-task maintenance path, native runtime classification, and workspace recovery—not a full Windows 11 German/Portuguese UI installation, an interactive-login/UAC comparison, a running Gateway restart, or memory embedding/model execution. The pre-fix localized regression tests and Microsoft numeric-state contract remain the locale-specific evidence.

The automated crabbox run path lost its SSH/ownership heartbeat during setup (run_c1594f5d1f22, run_808d5e676b0d). After verifying expired ownership and no remaining run child, testing used Crabbox's documented connect path with captured logs and explicit exit/JSON checks. The successful connect-session results above are not represented as signed crabbox run receipts. First lease: cbx_e7238bf9cc1e; final canonical-profile lease: cbx_f6e97ca115e2.

A fresh VM also lacked the Microsoft VC++ runtime DLLs needed by pnpm's native Windows executable (exit STATUS_DLL_NOT_FOUND). Installing the Authenticode-verified Microsoft runtime restored pnpm; no OpenClaw dependency/config change was made. Separate follow-ups were recorded for that image prerequisite and the automated-run transport failure.

The broader Codex-selection and already-keyed-roster questions in the upgrade report remain separate; this proof does not claim to resolve them. The original repair and its conservative maintenance/reload ownership boundaries are unchanged by the post-merge testing.

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

Use numeric Task Scheduler current state instead of localized LIST output and historical-result inference. Preserve queued/unknown safety, exact persisted-argv process evidence, and the existing Startup fallback contract.

Have Doctor inventory an authored retained shared workspace root without assigning it to an agent or making an unused root a runtime blocker. Reuse the readiness assertion before managed-write persistence and watcher publication; retain the last-good runtime until Doctor repairs the selected workspace. No schema, config option, dependency, persona/memory move, or inferred owner is added.

Compile the real QA cleanup child through the existing worker harness before its execution deadline, and model compiled child entries in their owning Knip workspace. Preserve deadlines, real-store/lease assertions, and zero-unused-file enforcement.

Related: openclaw#136203, openclaw#136123, openclaw#136170
Reporter: @hermannmetzker-ai; Linux follow-up: @DasX.
Credit @LiuwqGit for the related numeric-state contribution. The canonical refactor and connected workspace repairs are maintainer-owned. Full native Windows proof is explicitly scheduled after landing; broader issues are not auto-closed.

Co-authored-by: LiuwqGit <[email protected]>
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 extensions: qa-lab gateway Gateway runtime maintainer Maintainer-authored PR 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. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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