fix(model): discover Windows npm CLI installs (BRNS-DESK-069) - #92
Conversation
nir-ssvlabs
left a comment
There was a problem hiding this comment.
The property worth proving here is that no candidate can come out relative, since these are prepended to PATH — a .codex/bin formed from an absent root would resolve against the CWD and let anything sitting there shadow the real CLI. It's structurally impossible as written: every candidate is built inside a map/if let on its Option<&Path>, the Nones are dropped by flatten, and the home-relative entries sit behind let Some(home) = home else { return dirs; }. That early return is also what delivers the "keep known-folder candidates when the profile home is unavailable" requirement rather than falling back to an empty list.
Unix is genuinely untouched: #[cfg(not(windows))] starts from an empty vec and the same .extend([...]) list follows in the same order, so both the populated and the home == None cases produce exactly what they did before. The dirs mapping is right too — data_dir() is %APPDATA% and data_local_dir() is %LOCALAPPDATA% on Windows, which is what the roaming/local npm paths need.
Checked: candidate construction against a missing root, the prepend order and that explicit binary overrides are untouched, the Unix path's before/after equivalence including the None home case, and the Known Folder mapping. Not read: nothing material — this is small and the risk is concentrated in one function.
Merge: ✅ into dev once Rust (Windows) lands green — it was still pending, and since no Windows hardware run was possible, that job is the only proof the new gated test actually passes.
stefan-ssv-labs
left a comment
There was a problem hiding this comment.
✅ review-pr (self-review, cannot approve own PR): clean — no blocker or critical issue found.\n\n
Summary
Fixes the remaining Windows CLI-discovery gap for GUI-launched desktop sessions with a stale inherited
PATH.Ticket: BRNS-DESK-069
Requirements → changes
dirsKnown Folder APIs: roaming npm, local npm, the default Codex installer bin, and~/.codex/bin..cmdshims proving bothclaudeandcodexresolve when inheritedPATHis empty.Regression provenance
Reproduction / current gap
Source-derived; no Windows hardware run was performed on this macOS host.
%APPDATA%\\npmor%LOCALAPPDATA%\\npm, or use the default Codex installer bin.PATHpredates that installation, with no explicit binary override.PATHbecause it did not prepend those deterministic locations.Validation
Passed on the rebased branch:
cargo fmt --all --checknpm run lint:sizecargo test -p brains-model— 182 passed, 2 ignoredcargo check -p brains-model --tests --target x86_64-pc-windows-msvccargo clippy --workspace --all-targets -- -D warningscargo check -p brains-browser --features chromium(three existing browser warnings only)cargo test --workspaceran through the affected model and desktop suites, but remains non-green on this macOS host because twoheadless_sandboxintegration tests cannot access local Keychain services (SecKeychainCopySearchList/KEYCHAIN-DENIED). The exact two failures reproduce unchanged in a clean detached worktree at unmodifiedorigin/dev26d5c7694ede7aadf326f1f54b0d433a7d072285; they are not introduced by this change. CI remains the actual Windows execution lane.Risk, scope, and rollout
CODEX_INSTALL_DIRand arbitrary npm prefixes are deliberately deferred; inheritedPATHand explicit binary overrides still cover custom installations.Merge method: squash (do not merge-commit or rebase-merge).