Skip to content

fix(daemon): clean stale Windows startup fallback#88361

Closed
vincentkoc wants to merge 1 commit into
mainfrom
fix/windows-fallback-task-status-20260530
Closed

fix(daemon): clean stale Windows startup fallback#88361
vincentkoc wants to merge 1 commit into
mainfrom
fix/windows-fallback-task-status-20260530

Conversation

@vincentkoc

@vincentkoc vincentkoc commented May 30, 2026

Copy link
Copy Markdown
Member

Summary

  • Remove stale Windows Startup-folder fallback launchers after a Scheduled Task install/update is confirmed running.
  • Preserve the fallback when Task Scheduler only gets a one-shot fallback launch instead of a real running task.
  • Normalize root schtasks names like \OpenClaw Gateway so the active task is not reported as another gateway-like service.

Refs #87156. This is the native-Windows daemon cleanup slice; the broader doctor/update migration from existing fallback installs to Scheduled Task is tracked in #88311.

Verification

  • node scripts/run-vitest.mjs src/daemon/schtasks.startup-fallback.test.ts src/daemon/inspect.test.ts
  • node_modules/.bin/oxfmt --check src/daemon/schtasks.ts src/daemon/schtasks.startup-fallback.test.ts src/daemon/inspect.ts src/daemon/inspect.test.ts
  • node_modules/.bin/oxlint src/daemon/schtasks.ts src/daemon/schtasks.startup-fallback.test.ts src/daemon/inspect.ts src/daemon/inspect.test.ts
  • git diff --check origin/main...HEAD
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main
  • AWS Crabbox pnpm check:changed: provider=aws, lease=cbx_5e61cd2ed565, run=run_7f8dc0bf445a
  • AWS Crabbox native Windows SYSTEM schtasks/Startup-folder contract proof: provider=aws, lease=cbx_070e47559279, run=run_b633192f400e
  • Native Windows CI checks-windows-node-test: https://github.com/openclaw/openclaw/actions/runs/26687401081/job/78657871243

Behavior addressed: Windows fallback installs that later migrate to a healthy Scheduled Task no longer keep stale Startup-folder launchers, and gateway status --deep no longer treats \OpenClaw Gateway as an extra service.
Real environment tested: focused unit coverage in a Codex worktree, AWS Crabbox native Windows SYSTEM scheduled-task proof, AWS Crabbox changed gate, plus the existing native Windows GitHub Actions runner proof.
Exact steps or command run after this patch: the Verification commands and Crabbox runs above.
Evidence after fix: targeted schtasks fallback tests pass, win32 extra-service parsing test passes, formatter/lint/diff checks pass, autoreview is clean, pnpm check:changed passed remotely, and native Windows proof observed Status: Running with Last Result: 267009 before cleanup.
Observed result after fix: cleanup removes both .cmd and .vbs Startup entries only after Task Scheduler reports a running task result; the fallback is preserved when schtasks /Run falls back to direct launch.
What was not tested: live elevated manual install/update on an interactive Windows desktop and Windows WSL; this patch touches native-Windows service metadata/runtime cleanup, not WSL behavior.

@vincentkoc vincentkoc self-assigned this May 30, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels May 30, 2026
@clawsweeper

clawsweeper Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 21, 2026, 4:59 AM ET / 08:59 UTC.

Summary
The branch changes Windows daemon Scheduled Task install/update handling to remove stale Startup-folder launchers after confirmed task startup and updates related status/task-name coverage.

PR surface: Source +35, Tests +39. Total +74 across 4 files.

Reproducibility: yes. Current main and v2026.6.9 still run the Scheduled Task install/update path without removing Startup-folder entries, and the linked Windows issue contains live stale-fallback evidence; I did not run a fresh native Windows repro in this read-only review.

Review metrics: 3 noteworthy metrics.

  • Fallback cleanup targets: 2 launcher extensions: .cmd and .vbs. These are existing Windows Startup-folder artifacts that the PR may delete during upgrade, so the compatibility surface is concrete.
  • Cleanup activation gates: 2 guarded paths: existing-task update and fresh install. Both deletion call sites are intended to run only after Scheduled Task running evidence, which is the main availability safety condition.
  • Already-merged overlap: 1 inspect matcher overlap. The branch must preserve the current-main matcher from the merged status false-positive fix when it is refreshed.

Stored data model
Persistent data-model change detected: serialized state: src/daemon/schtasks.startup-fallback.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: partial_overlap
Canonical: #87156
Summary: The canonical user problem is the Windows doctor/update fallback migration and stale runtime issue; this PR covers the narrow stale Startup-folder cleanup slice, while a broader open PR owns the full repair.

Members:

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Refresh against current main and preserve the merged inspect matcher.
  • Confirm maintainer acceptance of deleting .cmd and .vbs Startup-folder fallbacks only after running-task evidence.

Risk before merge

Maintainer options:

  1. Refresh The Narrow Cleanup (recommended)
    Rebase or recreate the branch on current main, keep the fallback cleanup tests, and preserve the already-merged inspect matcher before merge.
  2. Accept Scoped Startup Risk
    Maintainers can land the refreshed cleanup if they explicitly accept deleting .cmd and .vbs fallbacks only after Scheduled Task running evidence.
  3. Fold Into The Broader Migration
    Pause or close this branch if maintainers prefer the fallback cleanup to land only with the broader Windows doctor/update migration PR.

Next step before merge

  • [P2] Protected maintainer PR with a live dirty merge state and compatibility/availability risk; the next action is maintainer refresh and scope decision, not an autonomous repair job.

Security
Cleared: No concrete security or supply-chain regression was found; the diff adds no dependencies, workflows, permissions, or new secret handling.

Review details

Best possible solution:

Refresh this narrow daemon cleanup against current main, keep fallback deletion gated on confirmed Scheduled Task running evidence, preserve the merged inspect matcher, and let the broader doctor/update migration stay owned by the linked repair PR.

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

Yes. Current main and v2026.6.9 still run the Scheduled Task install/update path without removing Startup-folder entries, and the linked Windows issue contains live stale-fallback evidence; I did not run a fresh native Windows repro in this read-only review.

Is this the best way to solve the issue?

Mostly yes. The narrow cleanup belongs in src/daemon/schtasks.ts and is gated on confirmed running-task evidence, but the PR needs a current-main refresh and should remain scoped below the broader doctor/update migration PR.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded Windows daemon startup cleanup with meaningful upgrade/startup impact but limited platform scope.
  • merge-risk: 🚨 compatibility: The PR can remove existing Windows Startup-folder fallback launchers during upgrade based on Scheduled Task runtime detection.
  • merge-risk: 🚨 availability: If the running-task evidence is wrong, removing the fallback could leave an existing Windows gateway without its previous autostart path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 external-contributor proof gate does not apply to this MEMBER/maintainer-labeled PR, though the PR body reports native Windows Crabbox, changed-gate, focused tests, and Windows CI proof.
Evidence reviewed

PR surface:

Source +35, Tests +39. Total +74 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 58 23 +35
Tests 2 40 1 +39
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 98 24 +74

What I checked:

  • Repository policy applied: Root AGENTS.md was read fully; its ClawSweeper policy treats setup, startup checks, fallback behavior, and upgrade behavior as compatibility-sensitive review surfaces. (AGENTS.md:28, e9b694ef9cd8)
  • Current main still lacks the cleanup: On origin/main, Scheduled Task update and fresh activation run the task and then write success output without removing existing Startup-folder fallback entries; resolveStartupEntryPaths only covers the current default and legacy .cmd path. (src/daemon/schtasks.ts:1005, e9b694ef9cd8)
  • Latest release still lacks the cleanup: Tag v2026.6.9 has the same install/update flow without post-run Startup-folder removal, so the useful cleanup is not shipped in the latest release. (src/daemon/schtasks.ts:1004, c645ec4555c0)
  • PR adds gated fallback removal: The PR adds removeStartupEntries, includes both .cmd and .vbs startup paths, and calls cleanup only when runScheduledTaskOrThrow reports taskStarted after confirmed running evidence. (src/daemon/schtasks.ts:466, 0faa38b31290)
  • PR covers removal and preservation cases: The branch tests removal of stale .cmd and .vbs Startup-folder entries after a running task result and preserves the fallback when schtasks /Run is accepted but never starts the task. (src/daemon/schtasks.startup-fallback.test.ts:332, 0faa38b31290)
  • Inspect overlap is already merged on main: Current main already has the root-task backslash normalization with a stricter exact/default-or-suffixed matcher; the PR branch still carries the older startsWith matcher shape and must be reconciled during refresh. (src/daemon/inspect.ts:201, e9b694ef9cd8)

Likely related people:

  • vincentkoc: Vincent authored this narrow PR, owns the broader linked Windows doctor/update migration PR, merged the overlapping inspect normalization PR, and current blame in this checkout points to recent Windows daemon work by Vincent. (role: current fix owner and recent area contributor; confidence: high; commits: 0faa38b31290, 11f564ede1ba, 273eb888749f; files: src/daemon/schtasks.ts, src/daemon/schtasks.startup-fallback.test.ts, src/daemon/inspect.ts)
  • 425072024: This contributor authored the merged PR that already fixed the root schtasks backslash false-positive status behavior overlapping this branch's inspect hunk. (role: adjacent inspect normalization contributor; confidence: high; commits: 1d8a74021df8, edd76238feda; files: src/daemon/inspect.ts, src/daemon/inspect.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 30, 2026
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Closing this as fully consolidated; there is no remaining unique change to land from this branch.

  • The Startup-folder cleanup is carried forward in fix(windows): repair doctor update fallback migration #88311 with the stronger shape: both .cmd and hidden .vbs launchers, install and restart paths, and removal only after Task Scheduler itself reports running evidence. Its native Windows proof also exercises the dual-extension cleanup.
  • The other unique slice here—normalizing root Task Scheduler names such as \\OpenClaw Gateway—is already on current main in edd76238fed, with focused coverage in src/daemon/inspect.test.ts.

Keeping this conflicting four-file branch open would split the same Windows migration invariant across two PRs. #88311 remains the canonical doctor/update migration candidate. Thanks @vincentkoc for the original focused proof and Windows coverage.

@steipete steipete closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. P2 Normal backlog priority with limited blast radius. 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

Development

Successfully merging this pull request may close these issues.

2 participants