Repository navigation
refactor(daemon): simplify platform path selection - #135646
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 7:32 PM ET / 23:32 UTC. ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherThe 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
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -8, Tests +18. Total +10 across 3 files. View PR surface stats
Review metrics
Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
b773cad to
233e157
Compare
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* refactor(daemon): simplify platform path selection * test(daemon): cover Windows PATH audit bypass
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.delimiterdirectly. Service PATH policy keeps its single cross-platform selector inline beside normalization. The earliersrc/daemon/paths.tsexport 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, orgatewayPathNonMinimal. 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/-11across two files, net-8. Tests:+18/-0.Evidence
f20f51d1b013b70fae4587ddc4526b0c91c08f21.node scripts/run-vitest.mjs run src/daemon/service-audit.test.ts src/daemon/service-env.test.ts src/daemon/schtasks.install.test.tsnode scripts/check-changed.mjs --dry-run -- src/daemon/service-audit.test.tsnode scripts/check-changed.mjs -- src/daemon/service-audit.test.tsgwtrestored those links without installing dependencies or changing source.pnpm tsgo:core:testpnpm check:coercion-helperspnpm check:deprecated-api-usagenode --import tsx scripts/check-deadcode-exports.mtsnode scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/daemon/service-audit.test.tsgit diff --checkgpt-5.6-solat high reasoning:0.99.f20f51d1b013b70fae4587ddc4526b0c91c08f21at confidence0.99.../codex/codex-rs/cli/src/main.rs:220-245and:2840-2870; those ranges are unrelated to daemon PATH handling.