Skip to content

fix(daemon): strip schtasks backslash prefix when matching gateway task name#91181

Open
425072024 wants to merge 5 commits into
openclaw:mainfrom
425072024:fix/win32-schtasks-backslash-false-positive-90494
Open

fix(daemon): strip schtasks backslash prefix when matching gateway task name#91181
425072024 wants to merge 5 commits into
openclaw:mainfrom
425072024:fix/win32-schtasks-backslash-false-positive-90494

Conversation

@425072024

@425072024 425072024 commented Jun 7, 2026

Copy link
Copy Markdown

Summary

  • Problem: On Windows, the live \OpenClaw Gateway Scheduled Task is falsely flagged as an extra gateway-like service with a schtasks /Delete cleanup hint. Following the hint removes the user's auto-start mechanism. Issue doctor/status: false positive 'Other gateway-like services detected' for active Windows Scheduled Task #90494.
  • Root Cause: schtasks /Query /FO LIST /V returns task names with a leading \ (e.g. TaskName:\OpenClaw Gateway). isOpenClawGatewayTaskName() compares the raw name against startsWith("openclaw gateway") — fails because \ comes first.
  • Fix: Strip leading backslash before comparison: normalized.replace(/^\\+/, "").
  • What changed: src/daemon/inspect.ts (+6/-1) and src/daemon/inspect.test.ts (+4/-1).

Real behavior proof

  • Behavior addressed: \OpenClaw Gateway Scheduled Task falsely flagged as extra gateway service with schtasks /Delete cleanup recommendation.
  • Real environment tested: Windows 11 Home China x64 (10.0.22631), Node 24.16.0. Two real Scheduled Tasks (\OpenClaw Gateway canonical, \Clawdbot Legacy legacy) created via schtasks /Create. Full schtasks /Query /FO LIST /V captured (257 tasks).
  • Exact steps or command run after this patch: Parsed all 257 real tasks from schtasks /Query /FO LIST /V via PowerShell, applied before/after detection logic to each task. Console output captured below.
  • Evidence after fix: Real console output from parsing 257 Windows Scheduled Tasks with before/after detection logic:
Total tasks parsed: 257

Task name: "\Clawdbot Legacy"
  Normalized:   "\clawdbot legacy"
  Stripped :    "clawdbot legacy"
  BEFORE fix: NOT SKIPPED -> correctly flagged as legacy extra service
  AFTER fix : NOT SKIPPED -> correctly flagged as legacy extra service

Task name: "\OpenClaw Gateway"
  Normalized:   "\openclaw gateway"
  Stripped :    "openclaw gateway"
  BEFORE fix: NOT SKIPPED -> flagged as extra service -> schtasks /Delete hint shown
  AFTER fix : SKIPPED (recognized as canonical gateway launcher)
  • Observed result after fix: \OpenClaw Gateway is correctly identified as the canonical task and excluded from the extra-services warning. \Clawdbot Legacy is still correctly detected as a legacy extra service. No regression for the other 255 system tasks.
  • What was not tested: Running a full live gateway process launched by the Scheduled Task. The fix is a single string-sanitization in a 7-line identity matcher; the before/after contract is fully verifiable from the real schtasks parse output above.

Fixes #90494

…sk name

Windows schtasks /Query /FO LIST /V returns task names with a leading
backslash prefix (e.g. \OpenClaw Gateway for root-folder tasks).
isOpenClawGatewayTaskName() compared the raw normalized name against
the configured task name, so \openclaw gateway never matched
openclaw gateway, causing the live gateway task to be flagged as an
extra gateway-like service and recommending schtasks /Delete cleanup.

Strip the leading backslash before comparison so the live launcher
task is correctly recognized and excluded from the warning.

Fixes openclaw#90494
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 7, 2026
@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 7, 2026, 10:46 AM ET / 14:46 UTC.

Summary
The PR strips leading backslashes from Windows schtasks task names before canonical gateway-task matching and updates the Windows daemon inspection fixture to use the backslashed schtasks form.

PR surface: Source +5, Tests +4. Total +9 across 2 files.

Reproducibility: yes. Source inspection shows current main preserves \OpenClaw Gateway, misses the canonical-task skip, and can flow into the status/doctor extra-service warning path; I did not run a live Windows OpenClaw command from this checkout.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
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:

  • none.

Risk before merge

  • [P1] The contributor proof exercises real Windows schtasks output and the exact matcher logic, but it does not include a full openclaw gateway status --deep or openclaw doctor --deep transcript from a running gateway.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow normalization fix with the focused regression test, then only pursue broader task-path or parent-process correlation if stale-task false positives remain after this fix.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No repair job is indicated; the PR is a narrow implementation candidate with no blocking code finding, so normal maintainer review and CI should decide landing.

Security
Cleared: The diff only changes Windows task-name normalization and a focused test fixture, with no dependency, CI, credential, permission, package, or script-execution surface changes.

Review details

Best possible solution:

Land the narrow normalization fix with the focused regression test, then only pursue broader task-path or parent-process correlation if stale-task false positives remain after this fix.

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

Yes. Source inspection shows current main preserves \OpenClaw Gateway, misses the canonical-task skip, and can flow into the status/doctor extra-service warning path; I did not run a live Windows OpenClaw command from this checkout.

Is this the best way to solve the issue?

Yes. Stripping schtasks root-folder backslashes at the Windows task-name matcher is the narrowest maintainable fix for the proven false positive, while broader launcher correlation can remain a follow-up if separate stale-task cases persist.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 66b91d78feb3.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes Windows terminal output from real schtasks data showing the after-fix matcher skips \OpenClaw Gateway while still flagging a legacy task.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes Windows terminal output from real schtasks data showing the after-fix matcher skips \OpenClaw Gateway while still flagging a legacy task.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a normal-priority Windows daemon/status false positive that can lead users to delete their intended gateway autostart task, with limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes Windows terminal output from real schtasks data showing the after-fix matcher skips \OpenClaw Gateway while still flagging a legacy task.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes Windows terminal output from real schtasks data showing the after-fix matcher skips \OpenClaw Gateway while still flagging a legacy task.
Evidence reviewed

PR surface:

Source +5, Tests +4. Total +9 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 1 +5
Tests 1 5 1 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 11 2 +9

What I checked:

  • Repository policy read: Root AGENTS.md was read fully and applied; no scoped AGENTS.md owns src/daemon, so the root OpenClaw review, proof, and history rules govern this PR. (AGENTS.md:1, 66b91d78feb3)
  • Current-main root cause: Current main normalizes the raw task name but compares it before removing a leading backslash, so \OpenClaw Gateway misses the canonical Windows task skip. (src/daemon/inspect.ts:201, 66b91d78feb3)
  • User-visible warning path: gateway status --deep loads findExtraGatewayServices, and the printer emits the extra-service warning plus cleanup hints when that list is nonempty. (src/cli/daemon-cli/status.gather.ts:560, 66b91d78feb3)
  • Doctor warning path: Doctor passes Windows extra services through because inactive-service filtering is Linux-only, so the same false positive can surface in openclaw doctor --deep. (src/commands/doctor-gateway-services.ts:215, 66b91d78feb3)
  • Focused test coverage: The existing Windows daemon inspection test covers canonical-task skipping and legacy-task reporting; the PR changes that fixture to the real backslashed schtasks root-task shape. (src/daemon/inspect.test.ts:358, 66b91d78feb3)
  • PR proof and discussion: The PR body supplies Windows 11 terminal output from real schtasks data with before/after matcher behavior, and the comments show the latest re-review was requested after proof updates. (4e5457db14e5)

Likely related people:

  • @vincentkoc: Current checkout blame attributes the Windows task-name matcher, daemon inspection test, and status warning path to commit 9fb8d87 in the daemon-service area. (role: recent area contributor; confidence: medium; commits: 9fb8d87f91f8; files: src/daemon/inspect.ts, src/daemon/inspect.test.ts, src/cli/daemon-cli/status.gather.ts)
  • steipete: The linked issue’s prior ClawSweeper source review attributes the earlier Windows extra-service scan and fixture lineage to commit c8665c6; the local checkout is grafted, so this remains useful routing context rather than fresh blame proof. (role: historical scan contributor; confidence: medium; commits: c8665c66ba96; 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jun 7, 2026
@425072024

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 7, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 7, 2026
@425072024

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

doctor/status: false positive 'Other gateway-like services detected' for active Windows Scheduled Task

1 participant