Skip to content

refactor(daemon): simplify platform path selection - #135646

Merged
vincentkoc merged 2 commits into
mainfrom
refactor/daemon-path-module
Sep 2, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
refactor/daemon-path-module

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Daemon PATH code repeated the same platform selector even where the surrounding owner already constrained the valid platform. Treating every copy as a shared abstraction added an unnecessary cross-module API and obscured the narrower contracts.

Why This Change Was Made

The service audit returns before PATH parsing on Windows, so its two splits now use path.posix.delimiter directly. Service PATH policy keeps its single cross-platform selector inline beside normalization. The earlier src/daemon/paths.ts export was removed, and runtime path discovery retains its existing private helper because it has several genuine cross-platform callers.

A focused regression test now supplies a semicolon-delimited Windows PATH plus a mismatched expected PATH and proves the audit emits none of gatewayPathMissing, gatewayPathMissingDirs, or gatewayPathNonMinimal. This protects the Windows early-return invariant that makes the POSIX-only parsing explicit and safe.

No public barrel, SDK seam, configuration, default, persistence, or fallback behavior changes.

User Impact

No user-visible behavior changes. POSIX service PATH auditing and Windows/POSIX service path normalization preserve their previous semantics with less production code and an explicit Windows regression boundary.

Production LOC: +3/-11 across two files, net -8. Tests: +18/-0.

Evidence

  • Final signed head: f20f51d1b013b70fae4587ddc4526b0c91c08f21.
  • node scripts/run-vitest.mjs run src/daemon/service-audit.test.ts src/daemon/service-env.test.ts src/daemon/schtasks.install.test.ts
    • Passed on the final head: 3 files, 166 tests.
  • node scripts/check-changed.mjs --dry-run -- src/daemon/service-audit.test.ts
    • Classified the change as the core-test lane.
  • node scripts/check-changed.mjs -- src/daemon/service-audit.test.ts
    • Passed conflict-marker, max-lines, assertion-safety, attribution, dependency, formatting, plugin-boundary, wrapper, package-patch, temp-directory, and core graph guards.
    • Its core-test typecheck initially exposed missing package-local links in the isolated worktree; gwt restored those links without installing dependencies or changing source.
  • pnpm tsgo:core:test
    • Passed after the worktree dependency links were restored.
  • pnpm check:coercion-helpers
  • pnpm check:deprecated-api-usage
  • node --import tsx scripts/check-deadcode-exports.mts
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/daemon/service-audit.test.ts
    • All passed.
  • git diff --check
    • Passed.
  • Exact Codex autoreview with gpt-5.6-sol at high reasoning:
    • Scoped clean, no accepted/actionable findings, correctness 0.99.
  • Independent frozen-head review:
    • Passed exact signed head f20f51d1b013b70fae4587ddc4526b0c91c08f21 at confidence 0.99.
    • Independently reproduced all 166 focused tests and confirmed the Windows fixture catches removal of the audit early return.
  • Codex gate inspected directly at ../codex/codex-rs/cli/src/main.rs:220-245 and :2840-2870; those ranges are unrelated to daemon PATH handling.
  • Hosted exact-head CI and native Testbox preparation are required before merge.

@vincentkoc vincentkoc self-assigned this Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Sep 1, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 7:32 PM ET / 23:32 UTC.

ClawSweeper review

What this changes

The branch removes duplicated platform-path selector helpers, uses POSIX PATH splitting in the Windows-bypassed service audit, and adds coverage for that bypass.

Merge readiness

✅ Ready for maintainer review

Keep open for normal maintainer handling: current main still uses the shared selector in this audit, while the branch safely makes the POSIX-only parsing boundary explicit after the Windows return. No introduced correctness or security defect was found.

Priority: P3
Reviewed head: f20f51d1b013b70fae4587ddc4526b0c91c08f21

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving cleanup with a useful boundary test and no actionable defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR is authored by a repository member, so the external-contributor proof gate does not apply; its body reports focused final-head validation, but this read-only review did not execute it.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR is authored by a repository member, so the external-contributor proof gate does not apply; its body reports focused final-head validation, but this read-only review did not execute it.
Evidence reviewed 5 items Introduced audit boundary: The introduced POSIX delimiter splits are reached only after the Windows early return, so semicolon-delimited Windows paths cannot be parsed by this code path.
Caller and sibling behavior: Doctor supplies an expected service PATH to the audit, while service environment generation intentionally omits frozen PATH values on Windows; scheduled-task coverage exercises the audit with platform win32.
Current-main comparison: Current main retains the local selector in the audit and retains the same Windows bypass, so it has not already absorbed this cleanup; the supplied GitHub state reports the PR as mergeable.
Findings None None.
Security None None.

How this fits together

The daemon service audit reads installed Gateway service commands and environment paths, then returns configuration findings to status and Doctor flows. Service-path policy normalizes paths and identifies unsuitable package-manager paths before those flows present repair guidance.

flowchart LR
A[Installed service command] --> B[Daemon service audit]
C[Expected service PATH] --> B
B --> D{Windows platform?}
D -->|Yes| E[Skip PATH drift audit]
D -->|No| F[Normalize and compare PATH entries]
F --> G[Status and Doctor findings]
H[Service path policy] --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -8, Tests +18. Total +10 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 3 11 -8
Tests 1 18 0 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 21 11 +10

Review metrics

Metric Value Why it matters
Production versus test delta production -8, tests +18 The refactor removes two single-use helpers while adding a focused platform-boundary regression test.

Technical review

Best possible solution:

Keep the Windows bypass before all PATH parsing and land this narrow helper-removal cleanup if maintainers want the simpler local ownership boundary.

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

Not applicable: this PR proposes an internal refactor rather than reporting a user-facing defect; source inspection confirms the relevant Windows bypass.

Is this the best way to solve the issue?

Yes. Inlining a one-use selector at each owner is the narrowest maintainable cleanup, and the POSIX-only audit parsing remains protected by the preceding Windows return.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a small internal cleanup with preserved service-audit behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 PR is authored by a repository member, so the external-contributor proof gate does not apply; its body reports focused final-head validation, but this read-only review did not execute it.

Evidence

What I checked:

  • Introduced audit boundary: The introduced POSIX delimiter splits are reached only after the Windows early return, so semicolon-delimited Windows paths cannot be parsed by this code path. (src/daemon/service-audit.ts:481, f20f51d1b013)
  • Caller and sibling behavior: Doctor supplies an expected service PATH to the audit, while service environment generation intentionally omits frozen PATH values on Windows; scheduled-task coverage exercises the audit with platform win32. (src/commands/doctor-gateway-services.ts:587, f20f51d1b013)
  • Current-main comparison: Current main retains the local selector in the audit and retains the same Windows bypass, so it has not already absorbed this cleanup; the supplied GitHub state reports the PR as mergeable. (src/daemon/service-audit.ts:564, e7951df4578b)
  • Regression-boundary test: The added fixture gives distinct Windows PATH values and asserts that none of the three PATH-drift findings are emitted, protecting the early-return invariant that makes POSIX splitting safe. (src/daemon/service-audit.test.ts:481, f20f51d1b013)
  • Current-main integration history: The current-main systemd hardening merge substantially changed the same audit after this PR's base; its author is a relevant routing candidate, while source inspection confirms the current bypass remains intact. (src/daemon/service-audit.ts:561, db907da599e3)

Likely related people:

  • vyctorbrzezowski: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-01T23:23:17.234Z sha b773cad :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T03:21:07.779Z sha 233e157 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T23:24:11.455Z sha f20f51d :: blocked before merge. :: none

@vincentkoc
vincentkoc force-pushed the refactor/daemon-path-module branch from b773cad to 233e157 Compare September 2, 2026 03:14
@vincentkoc vincentkoc changed the title refactor(daemon): share platform path module refactor(daemon): simplify platform path selection Sep 2, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 2, 2026 23:25
@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.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 2, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc merged commit 0e7c2ad into main Sep 2, 2026
267 checks passed
@vincentkoc
vincentkoc deleted the refactor/daemon-path-module branch September 2, 2026 23:41
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
* refactor(daemon): simplify platform path selection

* test(daemon): cover Windows PATH audit bypass
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 P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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.

1 participant