Skip to content

improve: avoid Windows task imports during Linux service discovery - #206777

Merged
vincentkoc merged 2 commits into
mainfrom
perf/defer-windows-service-inventory-20261127
Nov 27, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
perf/defer-windows-service-inventory-20261127

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Linux and macOS service discovery loads Windows Scheduled Task inspection and launcher-encoding code before selecting its platform. Even shallow Windows discovery pays this cost without inspecting tasks.

User Impact

Service discovery avoids those unused Windows modules. Deep Windows inventory retains its existing task and Startup-folder inspection, errors, and native-operation deadline. No configuration or migration is required.

Why This Change Was Made

Keep the shared discovery owner and its public exports; load task modules only after the Windows/deep guard. Dependency loading still precedes the existing native inspection deadline. This is a small platform boundary change (+2 production lines, +29 test lines), with no additional cache or alternate discovery flow.

Evidence

  • The new public discovery regression failed on d41719aa71fb at the eager task-layout import, then passed on signed 03e1931ffcc6 for Linux, macOS, and shallow Windows.
  • 125 focused tests passed across seven files; one existing Linux-only test was skipped on the macOS ARM64 runner. Coverage includes deep Windows inventory, Startup launchers, stalled reads, shared/fractional deadlines, encoding, Linux scope identity, and updater bindings.
  • CI initially identified missing isolation explanations on the two intentional throwing mocks. The final two-comment correction passes pnpm check:test-mock-exports --base d41719aa71fb and all three boundary cases. Production and test assertions are unchanged, so the prior focused-suite/build proof is retained.
  • Targeted formatting/lint, pnpm tsgo:core, and ordinary pnpm build passed.
  • Matched baseline/head builds with the same frozen dependencies: the emitted discovery entry's static closure went from 196 modules / 891,975 bytes to 193 / 862,638 (−3 modules, −29,337 bytes). Actual Node imports evaluated five iconv-lite/safer-buffer files (13,145 bytes) before, zero afterward; codec tables were already lazy.
  • All 40 retained updater discovery exports resolve to the identical current findSystemGatewayServices function. The systemd-scope entry itself is unchanged; its dynamic discovery path benefits. Full service management still has independent Windows callers and grows by two small chunks / 684 bytes.
  • Local ClawSweeper completed against exact d41719aa71fb..03e1931ffcc6: no actionable findings; the requested execution and red→green proof is supplied above.

These are entry-specific module/file measurements, not latency or device-memory claims. Native Windows service operations and physical-device timings were not run.

@clawsweeper

clawsweeper Bot commented Nov 27, 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 the gateway Gateway runtime label Nov 27, 2026
@vincentkoc vincentkoc self-assigned this Nov 27, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 27, 2026 15:35
@clawsweeper clawsweeper Bot added the P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. label Nov 27, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) November 27, 2026 15:40
@vincentkoc
vincentkoc disabled auto-merge November 27, 2026 15:45
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

Defer Windows task-inspection imports until deep Windows service discovery needs them.

Example: Discover Gateway services on Linux with deep discovery enabled.

  • Before: Importing discovery also evaluates Windows launcher encoding and task-inspection modules.
  • After: Linux discovery runs without loading those Windows-only modules.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent; validation rests on the import-boundary harness and reported execution measurements rather than an independently inspected runtime artifact.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored internal loading optimization preserves user-visible behavior; the body supplies matched-build and actual Node-import measurements, while the committed regression exercises the production discovery functions.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Service discovery loads Windows inspection dependencies even when the selected platform or discovery depth cannot use them.
Reason: The maintainer-authored direction removes demonstrably unnecessary module evaluation with minimal production change and preserves discovery results.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR makes a focused, useful import-boundary improvement that current main still needs; no actionable code or security defects were found.

Reviewed head: 03e1931ffcc6bfd8431abf2cd4ea40b93828e817

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared daemon inventory serves Doctor, Gateway status, and managed-service discovery, translating platform service definitions into service findings and inspection errors.

flowchart TD
  A[Doctor and Gateway status] --> B[Shared service discovery]
  B --> C[Platform selection]
  C --> D[Linux systemd inventory]
  C --> E[macOS launchd inventory]
  C --> F[Deep Windows inventory]
  F --> G[Lazy task and Startup readers]
  D --> H[Services and inspection errors]
  E --> H
  G --> H
Loading

Technical review

Best possible solution:

Keep the existing discovery owner and load Windows dependencies only inside its deep-Windows branch.

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

Current-main static imports establish the unnecessary Windows dependency loading; the PR reports baseline failure and head success, but this read-only review ran no target code.

Is this the best way to solve the issue?

This is a small, complete improvement using existing owners, with no new cache, discovery path, configuration, or public contract.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Registered-task and Startup-entry discovery imports keeps the original intent (244d441: Registered-task inspection was centralized for accurate shared inventory, followed by Startup-entry support in 733ceac; neither recorded reason requires eager loading on other platforms.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 733ceac adds src/daemon/inspect.ts:288 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 733ceac1a7ea; files: src/daemon/inspect.ts)
  • Vincent Koc: Raw commit f2e7165 adds src/daemon/inspect.ts:215 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f2e71650245c; files: src/daemon/inspect.ts)

PR surface

Source +2, Tests +29. Total +31 across 2 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 10 8 +2
Tests 1 29 0 +29
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 39 8 +31

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 27, 2026, 11:05 AM ET / 16:05 UTC.

@vincentkoc
vincentkoc merged commit cee4bfb into main Nov 27, 2026
140 checks passed
@vincentkoc
vincentkoc deleted the perf/defer-windows-service-inventory-20261127 branch November 27, 2026 16:22
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…penclaw#206777)

* improve: avoid Windows task imports during Linux service discovery

* test: explain Windows discovery import isolation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant