Repository navigation
Conversation
Localized `schtasks /FO LIST` field labels leave the Scheduled Task's Last Run Result unparsed, so the runtime status degrades to "unknown" (more often under UAC elevation, where the console encoding also changes). The managed-service maintenance gate only accepts running or stopped, so `doctor --fix` could never enter maintenance on affected installs — a hard deadlock while a legacy workspace migration is pending. Fall back to the Task Scheduler COM object's numeric state (already used for locale-independent task-existence checks) whenever LIST output cannot be classified. TASK_STATE_RUNNING maps to running; TASK_STATE_DISABLED/TASK_STATE_READY map to stopped. A failed or inconclusive probe keeps the previous "unknown" status so an unavailable native probe is never treated as stopped. Fixes openclaw#136123
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 7:15 AM ET / 11:15 UTC. ClawSweeper reviewWhat this changesThe PR adds a locale-independent Task Scheduler COM-state fallback so Doctor can classify stopped or running scheduled tasks when localized Merge readinessThe PR remains necessary: current main still lacks the numeric fallback, and the patch correctly restores the Doctor maintenance path while retaining fail-closed handling for ambiguous Task Scheduler states. Priority: P1 Review scores
Verification
How this fits togetherWindows gateway installs use Scheduled Task status to determine whether Doctor may enter maintenance. The daemon normalizes task output and native state into a runtime status consumed by the maintenance gate. flowchart LR
A[Windows Scheduled Task] --> B[Localized task query]
A --> C[COM numeric task state]
B --> D[Runtime status classifier]
C --> D
D --> E[Maintenance gate]
E --> F[Doctor repair]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +55, Tests +71. Total +126 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the owner-boundary fallback with its conservative numeric mapping so localized task output no longer blocks Doctor while inconclusive states remain unavailable. Do we have a high-confidence way to reproduce the issue? Yes, with high confidence: current main lacks the fallback, the localized fixture reaches unknown in source, and the PR body supplies a native Windows RED-to-GREEN trace for the same runtime boundary. This reviewer could not independently run the Windows path. Is this the best way to solve the issue? Yes. The fallback sits in the runtime-status owner after stronger listener detection, reuses the existing numeric COM probe, and preserves unknown for every state that cannot safely establish stopped or running. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against dd7c84a2d964. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
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]>
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: #136203, #136123, #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]>
|
Superseded by the landed canonical Windows Doctor/workspace repair, commit 145d243d6b6dca809e8dfd9c9a34308b506943b1. Thank you @LiuwqGit for the numeric-state contribution and localized-host evidence. Your co-author credit is preserved in the landed commit. The maintainer replacement makes the existing numeric COM probe canonical for every locale, removes the old LIST/result-history classification paths, and repairs the connected workspace discovery/admission failures; it does not leave the English path dependent on historical results. The original PR diff, shared runtime/maintenance callers, and current main were checked for coverage. The landed repair has focused before/after regressions, green exact-head CI, independent review, and post-merge native Windows runtime plus canonical-profile Doctor proof, with the locale/interactive-install limitations stated there. Closing this overlapping PR now that the replacement is on main; no changes were pushed to your branch. |
…#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]>
What Problem This Solves
openclaw doctor --fixis permanently blocked for gateway installs that run as a Scheduled Task.schtasks /Query /V /FO LISTlocalizes its field labels (Last Run Result→ e.g.Último Resultado/上次结果), so the English-only key lookup inparseSchtasksQuerynever extractslastRunResult, andreadScheduledTaskRuntimedegrades tostatus: "unknown". Under UAC elevation the situation is worse becauseschtasksalso emits OEM-codepage bytes.inspectManagedGatewayServiceBeforeUpdate) only acceptsrunningorstoppedruntime statuses, so Doctor can never enter maintenance — a hard deadlock: the gateway cannot start untildoctor --fixmigrates the legacy workspace, anddoctor --fixrefuses to run until it can verify the already-stopped service is stopped (issue Windows (pt-BR): doctor --fix permanently blocked — schtasks runtime status parsing breaks on non-English locale, worse under UAC elevation #136123).stoppedvia the locale-independent numeric Task Scheduler state, letting the maintenance gate proceed anddoctor --fixcomplete.readScheduledTaskRuntimereturnsstoppedfor a real Ready/Disabled task whose localized LIST output cannot be parsed, and keepsunknownonly when the numeric probe itself cannot establish state.src/daemon/schtasks-runtime.ts(numeric fallback insertion after the listener-backed probe) andsrc/daemon/schtasks-task-state.ts(extracted COM probe; reuse of the state mapping already trusted byisScheduledTaskDefinitelyNotRunning).Linked context
clawsweeper:source-repro,clawsweeper:fix-shape-clear,clawsweeper:queueable-fix, andimpact:ux-release-blocker; the issue itself is a P0 user-facing release blocker.Evidence
Behavior or issue addressed: Non-English Windows locales cannot run
openclaw doctor --fixbecause a stopped Scheduled Task reads back asunknown(localized LIST labels defeat the English-only parser), which the maintenance gate rejects.Real environment tested: Yes — a real native Windows host:
WIN-MDN8MTKGLPT, Windows NT 10.0.17763 (Windows Server 2019), zh-CN UI locale (non-English, same localization-failure class as pt-BR; rawschtasksLIST output confirmed localized Chinese/GBK on this host). Real Scheduled Task created viaschtasks /Createunder an interactive user session; real task execution verified (/Run→ result 0). The repository's ownreadScheduledTaskRuntimewas invoked against the real Task Scheduler COM object — no mocks, no stubs.Exact steps or command run after this patch:
Evidence after fix: On the real zh-CN Windows host with the real Ready Scheduled Task,
readScheduledTaskRuntimeat PR head returns:{"status":"stopped","detail":"Task Scheduler numeric state=3; locale-independent probe found no queued or running instance."}The maintenance gate (
update-command-service-maintenance.ts, rejects anything other thanrunning/stopped) therefore accepts the state and Doctor can proceed. Unit-level RED→GREEN on the same logic:src/daemon/schtasks.test.ts— 3 new pt-BR-localized cases fail on main (unknown) and pass on PR head; 37/37 green including fail-closed cases (probe unknown/queued stayunknown). Related suites green:update-command-service-maintenance.test.ts+doctor-health.update.test.ts13/13,doctor-health.test.ts76/76.Observed result after fix: A stopped task that previously read as
unknown(blocking the maintenance gate) now readsstoppedfrom the numeric COM state on a real non-English Windows host; English-locale behavior is unchanged (LIST classification still matches first), and fail-closedunknownis preserved when the native probe cannot establish state.What was not tested: the exact pt-BR byte sequences (host locale is zh-CN — same localized-label failure class, verified by raw output), UAC-elevated OEM-codepage output (process was not elevated), and a full
openclaw doctor --fixend-to-end run against a real gateway install. The repo's wholetest:windows:schtasks:integrationlifecycle lane could not complete on this host: its startup-fallback harness step timed out spawning a detachedtsxprocess (environment limitation, unrelated to this change); the focused real-task runtime read above exercises the exact code path the maintenance gate consumes.Before evidence (optional but encouraged): Pre-fix on the same real host/task,
readScheduledTaskRuntime(origin/main) returned{"status":"unknown"}— the maintenance gate's rejection branch, i.e. the Windows (pt-BR): doctor --fix permanently blocked — schtasks runtime status parsing breaks on non-English locale, worse under UAC elevation #136123 deadlock, reproduced against a real Scheduled Task on a real non-English Windows host.Tests and validation
node --import ./scripts/tsx.mjs .../step2.mtsagainst the real task at origin/main →{"status":"unknown"}(RED)30d6044d→{"status":"stopped", ...numeric state=3...}(GREEN)node scripts/run-vitest.mjs run src/daemon/schtasks.test.ts→ 37/37node scripts/run-vitest.mjs run src/cli/update-cli/update-command-service-maintenance.test.ts src/flows/doctor-health.update.test.ts→ 13/13node scripts/run-vitest.mjs run src/flows/doctor-health.test.ts→ 76/76skills/fix-pr/scripts/validate.shon the three changed files (oxfmt, oxlint, same-directory tests,tsgo:core) — greenschtasks.test.ts— pt-BR localized LIST output with numeric COM state 3/4/1 expectsstopped/running/stopped; fail-closed cases (probe unknown, queued state 2) keepunknown.unknown(Task status is locale-dependent and no numeric Last Run Result was available.); the 3 new unit cases failed and the real zh-CN host returned{"status":"unknown"}.Risk checklist
doctor --fixmaintenance is no longer permanently blocked when the stopped task's numeric state can establish it is stopped.probeScheduledTaskState) already trusted on main; no new privileges or execution scopes.stoppedwould let Doctor enter maintenance when it should not.TASK_STATE_DISABLED(1) andTASK_STATE_READY(3) yieldstopped— both prove no queued/running instance;UNKNOWN(0),QUEUED(2), probe failure, and missing task keepunknown(or the existing missing-unit path). This reuses the mapping already used byisScheduledTaskDefinitelyNotRunningon main.Current review state