Skip to content

refactor(rocm-core): one PATH lookup for the summary and the examination stacks - #953

Merged
jussielo-amd merged 16 commits into
mainfrom
refactor-one-path-lookup-for-host-probing
Nov 9, 2026
Merged

jussielo-amd merged 16 commits into
mainfrom
refactor-one-path-lookup-for-host-probing

Conversation

@jussielo-amd

@jussielo-amd jussielo-amd commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Closes ROCMAI-905.

Summary

rocm-core had two PATH lookups that answer the same question, "is this program installed": tool_on_path in host_gpu/capture.rs (the summary stack, which feeds the text of rocm examine and the summary object of its JSON) and which in probe_exec.rs (the examination stack, about fifteen capability checks in examine/ and fix/runners.rs). On WSL both ask about rocminfo in one rocm examine --json run, as summary.wsl.rocminfo and wsl.rocminfo, and they could disagree. This is pair 1 of 6 in docs/host-probing.md: the survivor is the behaviour of tool_on_path (it follows PATHEXT), housed in probe_exec.rs under the existing name which, so the call sites do not change. tool_path_candidates moved there with it because the capture runner and the Windows diagnostics capture start each spelling in turn. detect_wsl_summary now asks the shared which for rocminfo and cargo, and tool_on_path is gone. There is no third copy.

The empty-entry question the note left open is decided as skip: an empty PATH entry is not read as the current directory. That keeps the examination's answer, which the fifteen or so checks (including sudo and usermod) already relied on, so a file called sudo in the directory the CLI was started from never reads as installed. It changes only the summary's answer on WSL. The cost is that a program the CLI later starts by bare name can still resolve from the current directory through the operating system when PATH has an empty entry, and the lookup, which starts nothing, no longer agrees with that. The doc comment on which says so. Reading the code gave no concrete reason to take the other branch: following PATH semantics would widen what the examination calls installed in all fifteen checks. Skipping also makes the open question of how Windows split_paths treats an empty entry moot, because the entry is dropped either way.

The answers that move, each with the test that pins it (the characterisation commit pins both old answers, the convergence commit flips them):

  • An empty PATH entry with a file of the program's name in the current directory: the summary used to say found, the examination not found; now both say not found. Pinned by which_does_not_read_an_empty_path_entry_as_the_current_directory (leading, middle, trailing and whole-PATH shapes, plus the control that the same file counts once a real entry names its directory), path_dirs_drop_every_empty_entry and scenario examine-36.
  • A PATH that is not valid Unicode: the summary searched it, the examination found nothing for every program; now both search it, split as an OsString. Pinned by which_searches_a_path_that_is_not_unicode, path_dirs_keep_an_entry_that_is_not_unicode and scenario examine-37.
  • Windows PATHEXT entries outside .exe, .bat and .cmd, in both cases: the examination now tries them. Pinned by candidates_on_windows_try_every_pathext_entry_in_both_cases, candidates_on_windows_fall_back_to_the_default_pathext_when_it_is_unset and candidates_on_windows_trim_pathext_entries_and_skip_empty_ones (all hosts) and which_tries_a_pathext_extension_outside_exe_bat_and_cmd (Windows job).
  • A quoted Windows PATH entry holding a ;: the examination used to split on every ;; now std::env::split_paths keeps it whole. Pinned by which_searches_a_quoted_path_entry_that_holds_a_semicolon (Windows job; the splitting is std's, so it can only be tested where it runs).
  • A Windows name that already has an extension (python3.11, tool.py, wsl.exe): the examination's old copy also tried .exe, .bat and .cmd after it (as read from the deleted function: it appended each of those and the bare name to whatever it was given); the summary's copy and the shared lookup try it as given only. No which call site passes such a name except wsl.exe, which is found as given, so no answer moves today; every call site passes a bare name (python, python3, mokutil, lspci, rocminfo, dpkg, rpm, usermod, sudo, cargo, llama-cli, llama-server, main). Pinned by candidates_on_windows_for_a_name_with_an_extension_are_the_name_alone.
  • The System32 locations of cmd, pnputil and powershell (pwsh has no fixed location; its only extra candidate is the bare pwsh.exe): the examination now finds them. No which call site asks for those four today (checked with grep), so nothing visible changes; they stay in the shared candidate list because the capture runner needs them to start those tools at all, and one list read by both the runner and the lookup cannot drift. A future caller of which("powershell") gets "would the runner find it", not "is it on PATH". An absolute candidate is tested once as it is, not joined onto each PATH directory, so it is found even when PATH is unset or all empty, which is what the capture runner can start (tool_on_path only found it when PATH listed a directory; review pointed out the lookup and the runner disagreed in that corner). Pinned by candidates_on_windows_add_the_fixed_system32_locations, found_in_asks_about_an_absolute_candidate_once_as_it_is_whatever_the_directories, found_in_still_tries_relative_candidates_in_directories_beside_an_absolute_one and which_finds_cmd_at_its_system32_location_without_it_being_on_path (Windows job).
  • Unchanged on purpose, and pinned: a program with an extension is tried as given (candidates_on_windows_for_a_name_with_an_extension_are_the_name_alone, which also records that the cmd.exe arm of the System32 list is unreachable through the early return, as before), off Windows only the bare name is tried, and a directory named like the program is not the program.

The near copy of tool_path_candidates in apps/rocm (program_path_candidates) did not join; the note keeps it on its open list.

What moved

Before After
tool_on_path in host_gpu/capture.rs deleted; which in probe_exec.rs has its behaviour
tool_path_candidates, windows_absolute_tool_candidates in host_gpu/capture.rs probe_exec.rs, as tool_path_candidates over a pure path_candidates(program, windows, pathext, system_root)
the directory walk inside tool_on_path / which probe_exec.rs: path_dirs (split, drop empty entries) and found_in(dirs, candidates, is_file), both pure
capture.rs and diagnostics.rs imports crate::probe_exec::tool_path_candidates
detect_wsl_summary calls which("rocminfo"), which("cargo")

The Windows spellings take the platform, PATHEXT and the system root as arguments, and the search takes the directories and an existence test, so the logic that only matters on Windows is unit-tested on every host and the Windows job exercises it. The directory split itself is std::env::split_paths, which cannot be injected, so the ; and quote behaviour is covered by the two cfg(windows) tests.

Test plan

Commit order: (1) characterisation tests, green against the unchanged code, pinning what both copies return for the same input and each copy's own answer where they differ; (2) the convergence, which moves the tests into probe_exec.rs and flips exactly the assertions meant to change; (3) the scenarios and the harness change they need, with the working-directory control added after review; (4) the note records the decision (the analysis of the two old copies stays as the record of what changed).

Because neither lookup can be pointed elsewhere on a test thread without disturbing every test that spawns a program by name, and one case needs a different working directory, the cases that read the real PATH run in a child copy of the test binary started with the PATH, PATHEXT and working directory the case needs. No test mutates the process environment.

Run locally on Linux, in a dedicated target dir: cargo test -p rocm-core --no-fail-fast (1057 passed, 3 ignored, exit 0); cargo test -p rocm --bin rocm examine (25 passed) and system_packages (1 passed); cargo test -p e2e-cucumber --test feature_naming (4 passed); cargo fmt --all --check; cargo clippy --locked -p rocm-core --all-targets -- -D warnings and cargo clippy --locked -p e2e-cucumber --test e2e -- -D warnings; the same two clippy runs for --target x86_64-pc-windows-msvc (checked, not run; this compiles and lints the cfg(windows) tests); cargo xtask manifest --check; cargo xtask check-crate-edges; lychee --offline on the three docs; the leak scan against the merge base (the only hits are the word "private" in text that was already there) and a conflict-marker grep. The leaf test-name list of cargo test -p rocm-core --lib -- --list went from 1043 to 1060 names: no test disappeared, 17 were added (the characterisation tests of the first commit are replaced inside this PR, so they do not appear in the comparison).

Also run locally: the four new scenarios through the real harness, cargo test -p e2e-cucumber --test e2e -- -n 'examine-3[5-8] ' with ROCM_CLI_BINARY pointing at a debug rocm built with --features rocm/e2e-test-hooks (4 scenarios, 12 steps, all passed on this WSL box). Not run: the Windows job (the four cfg(windows) tests and every Windows spelling are exercised only there; the pure path_candidates and found_in tests run on every host) and the rest of the e2e suite. examine-35 to examine-38 run on the Linux lanes only, because they plant a simulated host root; the ids follow examine-34, and several open PRs that also add examine-NN scenarios will need renumbering by whichever merges second. No Windows-gated scenario drives rocm examine's framework selection with PATHEXT or quoted-entry fixtures: .ps1 is not something the probe could then run (Rust starts only .exe by bare name), such a scenario cannot be validated without a Windows lane, and the Windows behaviour is covered by the pure path_candidates and found_in tests plus the three cfg(windows) lookup tests, which the Windows job runs. What the Windows lane alone can confirm is the real PATHEXT and split_paths behaviour of those three tests.

Scenario answer. rocm examine --json on a simulated WSL host (the machine examine-32 uses) is drivable from the Linux lane, so the observable answer is covered: examine-35 (control: rocminfo in a PATH directory, both reports true), examine-36 (only in the working directory behind an empty entry, both false), examine-37 (in a directory whose name is not valid Unicode, both true) and examine-38 (the control for 36: the same machine with . as the first entry, both true, which can only happen if rocm really runs from that directory). They assert summary.wsl.rocminfo and wsl.rocminfo together. The planted PATH leaves out the runner's own entries that hold a rocminfo, so a runner with ROCm installed cannot be the reason a tool reads as found. The Windows rows cannot run on the Linux lane and are covered by the unit tests above. The harness gains command_dir, consumed like command_env. Through the harness the answers are true/true, false/false, true/true and true/true for 35 to 38, both with the runner's own PATH and with . first on the harness's PATH (the runner's relative entries are resolved against the harness directory before they are filtered, by planted_path_entries in the harness library, which has a unit test per case). With the harness ignoring command_dir, examine-38 fails with false/false where true/true is expected, so examine-36's answer cannot come from a harness that did not apply the working directory. With the lookup keeping empty entries, examine-36 fails with true/true and 35, 37 and 38 stay green; by hand, putting back both old behaviours (empty entries kept, PATH read as a String) fails 36 and 37 and leaves the control alone.

Mutation evidence. After review: deleting the pwsh arm or the bare powershell.exe candidate turns candidates_on_windows_add_the_fixed_system32_locations red (it now uses a PATHEXT without .EXE, so those spellings can only come from the fixed list; with .EXE in it the assertion was vacuous), trying PATHEXT after a dotted name turns candidates_on_windows_for_a_name_with_an_extension_are_the_name_alone red. The test names the note cites were checked against the sources by hand (a doc-reading test inside rocm-core was tried and removed, because the pre-push narrowing rule rejects a rocm-core test that reads docs/). For the scenarios: ignoring command_dir in run_rocm_with_scenario_env turned examine-38 red; keeping empty entries in path_dirs turned examine-36 red. For the characterisation commit, against the old code: keeping empty entries out of which turned the empty-entry test red; making tool_on_path read PATH with env::var turned the non-Unicode test red; exists() for is_file() in tool_on_path turned the directory test red; making which find nothing turned the shared-answer test red. For the survivor's tests, one mutation at a time, each restored by a targeted edit and the file hash compared at the end: path_dirs keeping empty entries (path_dirs_drop_every_empty_entry and which_does_not_read_an_empty_path_entry_as_the_current_directory red); which reading PATH as Unicode (which_searches_a_path_that_is_not_unicode red); dropping the lower-case spelling, removing the sort, removing the trim, losing .BAT from the default PATHEXT, dropping the cmd System32 arm, applying PATHEXT to a name with an extension, applying it off Windows (each red in the matching candidates_* tests); found_in trying only the first candidate or only the first directory (found_in_asks_each_candidate_in_each_directory_in_order_and_stops_at_the_first_file red); path_dirs mangling a non-Unicode entry (path_dirs_keep_an_entry_that_is_not_unicode red); exists() for is_file() in which (which_does_not_take_a_directory_named_like_the_program_for_the_program red); and stripping the root off every candidate before the join (found_in_asks_about_an_absolute_candidate_once_as_it_is_whatever_the_directories red); and, after review, putting found_in back to joining every candidate onto each directory (the same test red) and skipping relative candidates (found_in_still_tries_relative_candidates_in_directories_beside_an_absolute_one and the lookup tests red).

The summary stack's tool_on_path and the examination stack's `which` answer the same question, is this program installed, and are about to become one. Pin what each returns for the same input first, so the change that merges them shows exactly which answers it moves.

They agree on a PATH of plain directories, on an unset PATH and on a directory that has the program's name. They differ on an empty PATH entry (tool_on_path reads it as the current directory, `which` skips it) and on a PATH that is not valid Unicode (tool_on_path still searches it, `which` reads PATH with env::var and finds nothing). On Windows they also differ on PATHEXT spellings outside .exe, .bat and .cmd, on a quoted PATH entry holding a semicolon, and on the System32 location of cmd.

Each case runs in a child copy of the test binary with its own PATH, PATHEXT and working directory, because neither lookup can be pointed elsewhere on a test thread without disturbing the tests that spawn programs by name. The Windows cases run only on the Windows job.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
…ion stacks

The summary stack's tool_on_path (host_gpu/capture.rs) and the examination stack's `which` (probe_exec.rs) answered the same question and disagreed on an empty PATH entry, on a PATH that is not valid Unicode and, on Windows, on PATHEXT spellings, quoted PATH entries and the System32 locations. `which` now has the behaviour tool_on_path had, and tool_on_path is gone. tool_path_candidates moved to probe_exec.rs with it, because the capture runner and the Windows diagnostics capture start each spelling in turn; they import it from there. detect_wsl_summary asks `which` for rocminfo and cargo.

An empty PATH entry is skipped rather than read as the current directory. That keeps the examination's answer, so a file named sudo or usermod in the directory the CLI runs from still does not read as installed, and moves only the summary's WSL answer. A program the CLI later starts by bare name can still resolve from the current directory through the operating system; the lookup no longer agrees with that, and its doc comment says so.

Moves relative to the two old copies: the examination now searches a PATH that is not valid Unicode (it used to find nothing in any directory), follows every PATHEXT entry in both cases, keeps a quoted PATH entry holding a semicolon whole, and finds cmd, pnputil, powershell and pwsh at their System32 locations (no `which` caller asks for those four). The summary stops finding a file in the current directory through an empty entry. The Windows spellings are computed by path_candidates, which takes the platform, PATHEXT and the system root as arguments, and the search by found_in, which takes the directories and an existence test, so both are unit-tested on every host; the cases that need the real PATH, PATHEXT and working directory run in a child copy of the test binary.

The characterisation tests of the previous commit move to probe_exec.rs and now assert the one answer: the cases that differed flip to the survivor's.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
… rocminfo is installed

`rocm examine --json` on WSL reports whether rocminfo is installed twice, as summary.wsl.rocminfo and as wsl.rocminfo, and the two used to come from different PATH lookups. They share one now, so three scenarios on the simulated WSL host that examine-32 uses hold the two answers level: a rocminfo in a PATH directory is found by both (examine-35), a rocminfo only in the directory the command runs from, behind an empty PATH entry, is found by neither (examine-36), and a rocminfo in a PATH directory whose name is not valid Unicode is found by both (examine-37).

The runner's own PATH entries that hold a rocminfo are left out of the planted PATH, so a runner with ROCm installed cannot be why the tool reads as found. The scenario with the empty entry first shows that the stand-in rocminfo does resolve through that entry from the working directory, so its "not installed" cannot come from a fixture that never reached it. The harness gains command_dir, the working directory for the next rocm run, consumed like command_env.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
The PATH lookup is the first pair of the host-probing note to converge. Record what was decided: which survived, that an empty PATH entry is skipped and what that costs, every answer that moved with the test or scenario that pins it, and that the System32 candidates stay in the shared list. The analysis of the two old copies stays as the record of what the change moved; the entry for the empty-entry question leaves the open list, and the near copy in apps/rocm stays on it.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
@jussielo-amd
jussielo-amd marked this pull request as ready for review November 6, 2026 16:06
@jussielo-amd
jussielo-amd requested a review from a team as a code owner November 6, 2026 16:06
@jussielo-amd
jussielo-amd requested review from fredespi and a balanced review from Copilot November 6, 2026 16:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Windows lookup changes lack CLI-level Gherkin coverage, and the working-directory regression scenario needs a positive control to detect an ignored override.

2 open issues
What changed in this PR

Consolidates rocm-core’s PATH lookups so the host summary and examination stacks use the same tool-detection logic.

Changes:

  • Moves lookup and Windows candidate generation into probe_exec.rs, removing the duplicate implementation.
  • Standardizes empty-entry handling and non-Unicode PATH support, with unit tests and Linux scenarios.
  • Adds scenario-specific working directories and documents the convergence decisions.

Verification was limited to source inspection; tests were not run.

File Description
tests/​e2e-cucumber/​tests/​e2e/​examine_steps.rs Adds WSL PATH fixtures and paired report assertions.
tests/​e2e-cucumber/​tests/​e2e.rs Supports scenario-specific working directories.
tests/​e2e-cucumber/​features/​examine.feature Adds three tool-detection scenarios.
docs/​testing.md Documents scenarios and their invocation.
docs/​host-probing.md Records lookup convergence and behavior decisions.
docs/​architecture.md Updates helper ownership and module descriptions.
crates/​rocm-core/​src/​probe_exec.rs Centralizes lookup logic and adds regression tests.
crates/​rocm-core/​src/​host_gpu/​wsl.rs Uses the shared lookup for WSL facts.
crates/​rocm-core/​src/​host_gpu/​diagnostics.rs Imports shared Windows candidates.
crates/​rocm-core/​src/​host_gpu/​capture.rs Removes duplicate helpers and imports shared candidates.
crates/​rocm-core/​src/​host_gpu.rs Updates module documentation to reflect ownership.

Review effort: Balanced

Comment thread crates/rocm-core/src/probe_exec.rs Resolved

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the diff at head 502ef7f against ROCMAI-905. No blocking correctness problems found; the points below are what I'd like addressed or consciously acknowledged before merge.

Should address

  • Scenario examine-36 (false/false for the empty PATH entry) would also pass if the new command_dir harness plumbing were not applied: the Given step shows the stand-in resolves through the empty entry, but nothing shows the rocm child actually runs from that directory. The PR says the live e2e harness was only exercised by hand, not via cargo xtask e2e. Please add a control that distinguishes the two cases, or confirm from the Linux e2e lane that the control and examine-36 differ for the right reason (inline comment).

Nit

  • The edited module-doc line in host_gpu.rs is about 140 characters; re-wrap it to match the neighbouring //! lines (inline comment).

For a maintainer's conscious ack

  • On Windows, which("cmd" | "pnputil" | "powershell" | "pwsh") now returns true when the System32 file exists, regardless of PATH. It is documented in the PR and docs, and the PR states no current caller asks for these four; worth a quick grep confirmation.

Verified from the diff

  • Duplicate tool_on_path/old which removed and call sites in wsl.rs, diagnostics.rs and capture.rs rewired; scenarios examine-35/36/37 and the docs/testing.md entry added; Windows logic split into pure path_candidates/found_in helpers tested on every host; docs consistent with the code; no internal names in the diff.

Not verified by me

  • I did not re-run tests, clippy or the mutation checks (author-reported). At review time CI had 0 failures, with build-and-test, clippy, Windows build/test, coverage and the e2e lanes still pending; those need to go green before merge.

Comment thread crates/rocm-core/src/host_gpu.rs Outdated
//!
//! The probes live in child modules: `capture` (optional-command capture and the
//! tool-on-`PATH` lookup), `os_facts` (kernel, distro, CPU and RAM), `linux`
//! The probes live in child modules: `capture` (optional-command capture), `os_facts` (kernel, distro, CPU and RAM), `linux`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the edit left this module-doc line at about 140 characters, where the surrounding //! lines wrap near 80. Please re-wrap it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-wrapped to match the neighbouring //! lines in 03bee1c; no wording change.

.status()
.expect("the stand-in must resolve through the empty PATH entry");
assert!(reached.success(), "the stand-in rocminfo failed: {reached}");
world.command_dir = Some(work);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

examine-36 (false/false) would also pass if command_dir were not applied by the harness: the Given step checks the stand-in resolves through the empty entry, but not that the rocm child really runs from work. Consider a control that fails when the cwd is not work, or confirm from the e2e lane that the control and examine-36 differ for the right reason.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and fixed in b6a3346. The Given step only proved the stand-in resolves from work through a separate Command, not that the rocm child runs there. I added examine-38, the same machine with . as the first PATH entry instead of an empty one, asserting both reports find the stand-in; the two Given steps now share one planting helper, so 36 and 38 differ in nothing but that entry. I ran 35 to 38 through the real harness (debug rocm built with e2e-test-hooks, ROCM_CLI_BINARY, -n 'examine-3[5-8] '): all four pass. With command_dir ignored in run_rocm_with_scenario_env, examine-38 fails with false/false where true/true is expected; with path_dirs keeping empty entries, examine-36 fails with true/true. Both mutations were restored by targeted edit.

… working directory

examine-36 expects both reports to say rocminfo is not installed when the only copy is in the directory the command runs from and PATH has an empty entry. That answer would also come out if the harness ignored command_dir and started rocm somewhere else, so nothing showed the working directory was applied.

examine-38 is the same machine with `.` as the first PATH entry instead of an empty one. A `.` entry is an ordinary directory, so both reports find the stand-in, and only if rocm really runs from that directory. The two scenarios now differ in nothing but that entry. With command_dir ignored in the harness, examine-38 fails with false/false where true/true is expected; with the lookup keeping empty entries, examine-36 fails with true/true.

The planting is shared between the two Given steps, and the testing guide and the host-probing note list the new scenario.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
The line that named the child modules had grown to about 140 characters when capture lost its mention of the PATH lookup. Wrap it like the neighbouring lines.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
@jussielo-amd

Copy link
Copy Markdown
Collaborator Author

Should address: done in b6a3346, see the inline replies. examine-38 is the control, and I ran 35 to 38 through the real harness locally (all pass) and mutated command_dir out to see 38 fail. The lane still has the final say on its own hosts. Nit: re-wrapped in 03bee1c. Conscious ack: I grepped which("cmd, which("pnputil, which("powershell, which("pwsh and which(& across crates, apps and engines. No call site passes any of the four. The literal callers are python, python3, mokutil, lspci, rocminfo, dpkg, rpm, wsl.exe, usermod, sudo and cargo, and the one indirect call, probe_llama_cpp, iterates a fixed list (llama-cli, llama-server, main); the only other non-literal use is the test child. So the System32 candidates are reachable by the capture runner but not by any which caller. Not verified: the Windows job and the rest of the e2e suite; what I ran is cargo test -p rocm-core --lib probe_exec, cargo test -p e2e-cucumber --test feature_naming, fmt, the two clippy runs, manifest --check and check-crate-edges, all green locally.

@jussielo-amd
jussielo-amd requested a balanced review from Copilot November 6, 2026 16:35
@jussielo-amd
jussielo-amd dismissed juhovainio’s stale review November 6, 2026 16:35

Fixed: the examine-36 control (examine-38) is added in b6a3346 and shown red when the harness ignores the working directory, the module-doc line is re-wrapped in 03bee1c, and the System32 grep and the Windows-coverage decision are answered on the PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Inherited relative PATH entries can resolve to the planted rocminfo after the child changes directories, causing examine-36 to fail even when empty entries are correctly skipped.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Resolve relative PATH entries before filtering

tests/​e2e-cucumber/​tests/​e2e/​examine_steps.rs:2400

If the runner's PATH includes . and its working directory contains no rocminfo, this filter retains that relative entry. examine-36 then changes the child's working directory to work, where ./rocminfo is the planted executable, so both lookups return true and the scenario fails despite correctly skipping the empty entry. Resolve inherited relative entries against the runner's working directory before filtering and appending them, so they cannot become additional routes to the planted executable.

2 resolved since last review

Review effort: Balanced

Signed-off-by: Jussi Elo <jussi.elo@amd.com>

# Conflicts:
#	docs/architecture.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Inherited relative PATH entries are filtered from the harness directory but interpreted from work, allowing the planted rocminfo to cause false failures in examine-36.

1 open issue

Review effort: Balanced

…s directory before filtering them

The scenarios that plant a rocminfo leave out the runner's own PATH entries that hold one, but they checked an inherited relative entry from the harness's directory while the rocm child runs from the scenario's command_dir. A runner whose PATH contains `.` and whose harness directory has no rocminfo kept that entry, and the child then read it as the planted work directory and found the stand-in, so examine-36 failed with true/true despite a correct lookup.

planted_path_entries now makes each non-empty inherited entry absolute against the harness's own working directory, checks it there and keeps it in that resolved form, drops inherited empty entries, and leaves the fixture's own entries exactly as written, since the empty entry and `.` are what two scenarios are about. It is a pure function in the harness library with a row per case, so it runs on every host. With the old filter and `.` first on the harness PATH, examine-36 fails with true/true; with this change examine-35 to examine-38 pass both with and without it.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because working-directory contents can cause the test harness to select an unintended executable or attempt to execute a directory.

1 open issue

Review effort: Balanced

Signed-off-by: Jussi Elo <jussi.elo@amd.com>

# Conflicts:
#	docs/architecture.md

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread tests/e2e-cucumber/tests/e2e.rs Resolved
…e, as the lookup does

The harness leaves out the runner's PATH entries that hold a rocminfo, so a runner with ROCm installed cannot be why the tool reads as found. It tested that with exists(), which a directory named rocminfo also satisfies, while the shared lookup in rocm-core requires a regular file. Such an entry would have been dropped without ever making rocminfo resolve.

dir_holds_tool now uses is_file(), in the harness library next to planted_path_entries, and the step uses it. A test plants a directory called rocminfo in one entry and a file in another and checks the first is kept and the second dropped; going back to exists() turns it red. No other exists() or is_dir() check was added by the harness changes of this branch.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because PATH filtering can also hide the CLI when specified by a bare name, causing the new scenarios to fail before reaching their assertions.

3 open issues

Review effort: Balanced

@juhovainio juhovainio left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The PR merges the two PATH lookups in rocm-core into one. tool_on_path (summary stack) is deleted, and which in probe_exec.rs takes over its behaviour: it follows PATHEXT, splits PATH as an OsString, and skips empty entries. tool_path_candidates moves into probe_exec.rs as a pure path_candidates(program, windows, pathext, system_root). The capture runner and the Windows diagnostics import it from there, and detect_wsl_summary now calls which("rocminfo") and which("cargo"). Four Linux e2e scenarios (examine-35 to 38) are added. The harness gains command_dir and two helper modules, planted_path and binary_path. I read the whole diff and found no correctness or security defect. The logic is small and well factored: pure path_candidates, path_dirs and found_in. The behavioural differences are documented and pinned by tests. All earlier review threads have been answered or fixed in later commits; I did not re-check the three that remain open on GitHub (host_gpu.rs:15, outdated; examine_steps.rs:2464, answered; e2e.rs:1036, answered). Confidence is high for Linux. It is lower for the Windows spellings, which only the Windows job exercises. CI on the head commit is green, including Windows build-and-test and the Windows, WSL2, MI300X and Strix Halo e2e jobs, except the W7900 e2e job, which was still queued when I looked.

Author: jussielo-amd. Commit reviewed: 0c85d5f (base 3dc4a31).

Blocking

None.

Non-blocking

  • crates/rocm-core/src/probe_exec.rs:183 (found_in): an absolute candidate such as the System32 cmd.exe is only tried inside the loop over directories. which("cmd") is therefore false when PATH is unset or all-empty, even though the capture runner would start cmd at its fixed location. The doc comment says "found whenever PATH lists at least one directory", so this is known. It still means the lookup and the runner disagree in that corner. Suggested fix: test absolute candidates once outside the directory loop, or filter them out of which if "on PATH" is the intended meaning.
  • crates/rocm-core/src/probe_exec.rs:147: the doc comment says a file named like the tool in the starting directory "never reads as the tool being installed". That holds only for an empty PATH entry. An explicit . or other relative entry is still searched, which examine-38 relies on. Suggested fix: say "through an empty entry".
  • tests/e2e-cucumber/features/examine.feature:555: the comment says "these three scenarios", but four were added (examine-35 to 38). Suggested fix: say "these scenarios" or "four".
  • crates/rocm-core/src/probe_exec.rs (path_candidates, around lines 223-240): on Windows which("python") now returns true for any PATHEXT spelling, such as python.PY or .PS1. The probe starts python by bare name through Command, and that can only run an .exe. The framework probe in examine/framework.rs:227 can therefore report a tool as installed that it cannot run. The author acknowledged this in the thread and chose not to add a Windows scenario. The risk is small, but a comment at the framework.rs call site, or restricting which to runnable extensions for that caller, would stop it being a surprise later.
  • tests/e2e-cucumber/tests/e2e/examine_steps.rs:2392 and probe_exec.rs (which_child_reports_its_answer): the child-process technique depends on module_path!() and --exact naming. It fails loudly with the child's stdout and stderr if the name stops matching, which is good. The no-op test that passes in a normal run does inflate the test count slightly. This is acceptable.

Questions for the author

  • Is it intended that which("cmd"), pnputil and similar report true without being on PATH, even though no caller asks for them today? Would you prefer which to stay "on PATH" and have only the runner use the System32 spellings?
  • Skipping empty entries means the examination can say a tool is absent while capture_optional_command still starts a same-named file from the current directory through the OS. This is documented. Is there a reason not to also guard the runner, or is it left to a later pair?
  • The PR notes that examine-35 to 38 may collide with other open PRs' examine-NN ids. Is there a plan for who renumbers?

What I could not verify

  • The sandbox has no cargo, so I ran no builds, tests, clippy or e2e scenarios. I relied on the CI check runs, which were green except the queued W7900 job.
  • I did not run the cfg(windows) tests or inspect Windows behaviour of split_paths with quoted entries.
  • I did not confirm the author's claims of 1043 to 1060 test names or the mutation results.
  • I did not trace every one of the roughly fifteen which call sites beyond confirming, by grep, that none asks for cmd, pnputil, powershell or pwsh.

Comment thread crates/rocm-core/src/probe_exec.rs Outdated
///
/// - An empty `PATH` entry is skipped, not read as the current directory as a
/// shell or `execvp` would. A file named like the tool in the directory the
/// CLI was started from therefore never reads as the tool being installed,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "never reads as the tool being installed" holds only for an empty PATH entry; an explicit . or other relative entry is still searched (examine-38 relies on it). Suggest saying "through an empty entry".

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and fixed in 5e5946d: the doc comment now says a file named like the tool in the starting directory does not read as installed through an empty entry, and that an explicit . or other relative entry is an ordinary directory and is searched (examine-38 relies on it). The Q2 answer lives here too: the runners (capture_optional_command* and run) start a bare name through Command, so the operating system resolves an empty entry for them, and I see no reason the lookup and the runners should not eventually agree, but guarding the runner is a property of how they spawn, not of the lookup. It belongs to the subprocess-runners pair (item 6 in the note's proposed order), which the note did not say until now; 5e5946d adds that sentence to docs/host-probing.md and lists the question among the open ones, and I did not touch the runner here. Q3: a grep of origin/main and every origin/* branch finds examine-34 as the highest id on main and examine-35 to examine-38 on two branches only: this one, and fix-examine-kfd-builtin (#694, open), which uses the same four numbers for different scenarios. The feature_naming test enforces sequential unique ids, so whichever of the two merges second renumbers its scenarios (and the ids in docs/testing.md; for this PR also the note and the step comments).

/// to `is_file`. Directories are tried in order, and within a directory the
/// candidates in order. `is_file` is injected so a test can say which files
/// exist without a file system.
fn found_in(dirs: &[PathBuf], candidates: &[String], is_file: impl Fn(&Path) -> bool) -> bool {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An absolute candidate (System32 cmd.exe etc.) is only tried inside the directory loop, so which("cmd") is false when PATH is unset or all-empty while the capture runner would still start it. Documented, but consider checking absolute candidates once outside the loop or excluding them from which.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and I took the first option in 5e5946d: found_in now tests an absolute candidate once as it is, after the directories, and which no longer returns early when PATH is unset, so which("cmd") agrees with what the capture runner can start (Q1: yes, intended, and now also with PATH unset or all empty; the doc comment, docs/host-probing.md and the PR body say so). Two pure tests that run on every platform pin it: found_in_asks_about_an_absolute_candidate_once_as_it_is_whatever_the_directories (no, one or two directories, asked exactly once) and found_in_still_tries_relative_candidates_in_directories_beside_an_absolute_one; putting the per-directory join back turns the first red, and skipping relative candidates turns the second and the lookup tests red. The Windows-only test also asserts cmd with no PATH at all; only the Windows job can confirm that. I re-grepped every which call site: all pass a literal bare name (python, python3, mokutil, lspci, rocminfo, dpkg, rpm, wsl.exe, usermod, sudo, cargo) or the fixed llama.cpp names, none is absolute and none is cmd, pnputil, powershell or pwsh, so on Linux nothing changes.

# `rocm examine --json` asks twice whether `rocminfo` is installed on WSL: the
# host summary (`summary.wsl.rocminfo`) and the examination (`wsl.rocminfo`).
# They used to use two different PATH lookups and could disagree; they now use
# one, and these three scenarios hold the two answers level on the cases where

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment says "these three scenarios" but four are added (examine-35 to 38).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2a7a2e3: the comment now says "these scenarios", since four were added. The same commit adds the comment you suggested at the framework.rs call sites: probe_llama_cpp and probe_pytorch_on_path now say that on Windows which follows PATHEXT, so python or llama-cli can read as found through a spelling like .PS1 or .PY that the probe, which starts the bare name through Command, cannot run. I preferred the comment to restricting which, since a few exact extensions would not stay in step with the runner's candidate list. Verified locally: cargo test -p rocm-core and the other checks listed in the PR, and examine-35 to examine-38 through the real harness on a debug rocm built with e2e-test-hooks; not run: the Windows job.

@r0x0r r0x0r left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving this — the refactor holds up, and the two things I left inline are nits rather than anything I'd block on.

I went in sceptical because this isn't a behaviour-preserving move: the output genuinely changes. But every moved behaviour is enumerated, each one is pinned by either a scenario or a unit test, the branches are mutation-tested one at a time, and the design note records the reasoning. That's the bar I'd want for a refactor that admits it changes output.

The central safety claim is the one I most wanted to check, and it checks out: no which caller asks for cmd, pnputil, powershell or pwsh, which I confirmed by grepping the tree rather than taking the comment's word for it. The dir-outer / candidate-inner search order is preserved from both of the old copies, and every caller of the removed tool_on_path / tool_path_candidates is migrated with nothing stale left pointing at them. I also reverted the change locally to see whether the tests actually bite — examine-36, examine-37 and the new empty-entry and non-Unicode unit tests all fail on the revert, so they're real tests and not decoration. docs/architecture.md, docs/host-probing.md and docs/testing.md were all updated in the same change, per AGENTS.md §5/§6.

One note on CI rather than on the code: 30 checks are green on this head, but E2E tests (W7900, current) is still queued, so that lane isn't evidence in either direction yet. Worth a glance before merge.

Neither inline comment needs to hold up the merge — fix them here or in a follow-up, whichever you prefer.

.contains(&r"C:\Win\System32\WindowsPowerShell\v1.0\powershell.exe".to_owned())
);
assert!(powershell.contains(&"powershell.exe".to_owned()));
assert!(with("pwsh").contains(&"pwsh.exe".to_owned()));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this assertion is vacuous, and it's guarding a match arm that's effectively dead.

With any PATHEXT that contains .EXE — including the hard-coded default — path_candidates has already pushed pwsh.exe before the match is consulted, and the result is then sorted and deduped. So deleting the "pwsh" | "pwsh.exe" arm (line 251) changes the output not at all, and this assertion still passes either way. The same holds for the bare "powershell.exe" entry at line 249 and its assertion on line 418.

What makes it worth mentioning is the test's name: candidates_on_windows_add_the_fixed_system32_locations. A reader takes that to mean the arm is what puts pwsh.exe in the list, when PATHEXT expansion would have done it regardless — so if the arm were ever dropped by accident, nothing here would notice.

The arm itself is pre-existing (moved verbatim from capture.rs), so this isn't something the PR introduced; the assertion is new, which is why I'm raising it here. Either assert something the arm uniquely provides, or drop the pwsh line and let the cmd / pnputil cases — which do have real absolute paths — carry the test.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, the assertion was vacuous: with .EXE in PATHEXT the expansion already pushes pwsh.exe and powershell.exe, so deleting the arm or the bare candidate changed nothing. Fixed in c50c6ba: candidates_on_windows_add_the_fixed_system32_locations now uses a PATHEXT without .EXE, so those two spellings can only come from the fixed list, and the cmd and pnputil assertions still carry the real absolute paths. I proved it by mutation: deleting the pwsh arm, and separately deleting the bare powershell.exe candidate, each turns that test red (it stayed green before).

Comment thread crates/rocm-core/src/probe_exec.rs Outdated
@@ -135,26 +135,122 @@ pub(crate) fn read_host_text(path: &str) -> String {
}

/// Whether `program` resolves on `PATH` (best-effort, no execution).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the summary line of which now contradicts its own body.

This line still reads "Whether program resolves on PATH", which is no longer accurate for cmd, pnputil and powershell — those are found at absolute System32 paths whether or not they're on PATH. The bullet further down explains that correctly, but the one-line summary is what a caller actually sees in the hover or the generated docs, and it's the part most likely to be trusted without reading on.

Relatedly, line 157 lumps pwsh in with the other three as "also found at their fixed System32 locations" — pwsh has no fixed location at all; its only candidate is the bare pwsh.exe name.

Something like "Whether program is installed, by PATH lookup plus a few fixed Windows locations" would keep the summary honest, and splitting pwsh out of that sentence would fix the second half.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on both halves, fixed in c50c6ba. The summary line now reads "Whether program is installed, by PATH lookup plus a few fixed Windows locations (best-effort, no execution)", and the doc splits pwsh out: cmd, pnputil and powershell have System32 locations, while pwsh has none and its only extra candidate is the bare pwsh.exe. The note's System32 row (2208f53) says the same.

…grees with what the runner can start

found_in joined every candidate onto each PATH directory, so an absolute candidate (the System32 location of cmd, pnputil or powershell on Windows) was only tried inside the loop over directories. which("cmd") was therefore false when PATH was unset or all empty, while the capture runner would still start cmd at its fixed location.

An absolute candidate names its own location, so found_in now tests it once as it is, after the directories, whatever dirs holds, and which no longer returns early when PATH is unset. A pure test pins that an absolute candidate is asked about once, with no directories, one or two, and another that a relative candidate beside an absolute one is still joined onto the directories. On Linux no candidate is absolute unless the caller passes an absolute path, and every which call site passes a literal bare name, so nothing changes there.

The doc comment on which also says that a file in the starting directory does not read as installed through an empty entry, which is what the lookup does; an explicit `.` or other relative entry is an ordinary directory and is searched. The host-probing note states the new System32 behaviour, says that guarding the runners against an empty PATH entry (they start a bare name through Command, so the operating system resolves it) belongs to the subprocess-runners pair and is not changed with the lookup, and lists that among the open questions.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
…fix a scenario comment

framework.rs: which follows PATHEXT on Windows, so python or llama-cli can read as found through a spelling such as .PS1 or .PY that the probe, which starts the bare name through Command, cannot run. Name that at the two probes that call which for those programs.

examine.feature: the comment above examine-35 said three scenarios and four were added.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
@jussielo-amd
jussielo-amd requested a balanced review from Copilot November 9, 2026 13:02
@jussielo-amd
jussielo-amd dismissed juhovainio’s stale review November 9, 2026 13:02

The review listed no blocking items. Its non-blocking points and questions are fixed and answered in 5e5946d and 2a7a2e3.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because PATH filtering can also hide the CLI executable, causing the four new scenarios to fail at launch rather than exercise lookup behavior.

3 open issues

Review effort: Balanced

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through the whole diff. I found no code defects, but I'm requesting changes for one stale doc reference and a few questions I'd like answered before this merges.

To fix

  • docs/host-probing.md (row at line 172) cites a test name that doesn't exist (details inline). Bare backtick names aren't link-checked, so CI won't catch it.

Questions

  • Windows, names with an extension: which returns only the bare name for anything with an extension (probe_exec.rs, the extension().is_some() early return), so python3.11 no longer tries .exe/.bat/.cmd. The old examination lookup did. Can you confirm no which("...") caller passes a dotted name, or list it under the answers that move?
  • which now answers true for an absolute program path even when PATH is unset; before, an unset PATH always gave false. Please confirm no caller relied on that.
  • Wider PATHEXT matches (e.g. python.PS1 reads as found while Command only starts .exe) are explained in comments, but no test pins the consequence.

What I liked: the pure, injectable path_candidates/found_in let the Windows spellings run on every host, and examine-36 has a matching control in examine-38 so "not installed" can't come from a harness that ignored the working directory.

I did not build or run the tests; several CI jobs (including the Windows debug job that runs the Windows-gated tests) were still pending when I looked.

Comment thread docs/host-probing.md Outdated
| `PATH` that is not valid Unicode | summary: searched; examination: not found for every program | searched | `which_searches_a_path_that_is_not_unicode`, `path_dirs_keep_an_entry_that_is_not_unicode`, scenario `examine-37` |
| Windows `PATHEXT` entries outside `.exe`, `.bat`, `.cmd`, in both cases | summary: tried; examination: not tried | tried | `which_tries_a_pathext_extension_outside_exe_bat_and_cmd` (Windows job), `candidates_on_windows_try_every_pathext_entry_in_both_cases`, `candidates_on_windows_fall_back_to_the_default_pathext_when_it_is_unset` |
| Windows `PATH` entry in quotes holding a `;` | summary: kept whole; examination: split | kept whole | `which_searches_a_quoted_path_entry_that_holds_a_semicolon` (Windows job) |
| System32 locations of `cmd`, `pnputil`, `powershell`, `pwsh` | summary: found; examination: not found | found | `which_finds_cmd_at_its_system32_location_without_it_being_on_path` (Windows job), `candidates_on_windows_add_the_fixed_system32_locations`, `found_in_asks_about_an_absolute_candidate_as_it_is_whatever_the_directory` |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cited test name doesn't exist. In probe_exec.rs it is found_in_asks_about_an_absolute_candidate_once_as_it_is_whatever_the_directories (adds once, directories is plural). The PR body spells it correctly; bare backtick names aren't link-checked, so please fix it here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2208f53: the note now cites found_in_asks_about_an_absolute_candidate_once_as_it_is_whatever_the_directories (the PR body already had it right). Since a bare backtick name is not link-checked, c50c6ba adds the_host_probing_note_cites_only_tests_that_exist, which reads the note and requires every cited which_, candidates_, found_in_ or path_dirs_ name to be a function in probe_exec.rs; misspelling a cited name turns it red. I also grepped every backticked snake_case name in docs/host-probing.md, docs/testing.md and docs/architecture.md against the Rust sources: the only other name not found is tool_on_path, which the note cites on purpose as the deleted function.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A correction to my earlier reply: the doc-reading test I mentioned, the_host_probing_note_cites_only_tests_that_exist, is removed in f4659ff, because the pre-push narrowing rule in xtask rejects a rocm-core test that reads a file under docs/ (it failed every_cross_crate_read_is_covered_by_the_widening_rule) and widening the rule for a citation tripwire is not worth it. The corrected test name in the note stays, and every test name the note cites was checked against the Rust sources by hand with a grep, which found no other name that does not exist apart from tool_on_path, cited on purpose as the deleted function.

pathext: Option<&str>,
system_root: &str,
) -> Vec<String> {
if Path::new(program).extension().is_some() || !windows {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows a name with any extension (e.g. python3.11) returns only itself, so PATHEXT is never tried. The old examination which tried .exe/.bat/.cmd for it. Please confirm no which("...") caller passes a dotted name, or list it among the answers that move.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, and I read the old code rather than assuming it. The examination's old which (the function deleted in this PR, from the base commit) appended .exe, .bat, .cmd and the empty extension to whatever name it was given on Windows, so python3.11 was also looked for as python3.11.exe, .bat and .cmd; the summary's old tool_path_candidates and the shared lookup return a name that already has an extension as given only, so that is a real difference for dotted names. No call site relies on it: every which call passes a bare literal (python, python3, mokutil, lspci, rocminfo, dpkg, rpm, usermod, sudo, cargo, and the llama.cpp names llama-cli, llama-server and main), apart from wsl.exe, which is found as given in both versions. So no answer moves today, and I documented it instead of restoring the old behaviour: 2208f53 adds a row to the note's table of moved answers, and c50c6ba adds it to the which doc comment and pins it in candidates_on_windows_for_a_name_with_an_extension_are_the_name_alone (python3.11 yields only python3.11; trying PATHEXT after a dotted name turns it red). A future caller that needs python3.11.exe found would have to ask for it by that name.

…otted names are looked up on Windows

The note cited found_in_asks_about_an_absolute_candidate_as_it_is_whatever_the_directory, which does not exist; the test is found_in_asks_about_an_absolute_candidate_once_as_it_is_whatever_the_directories. Fix the name.

Add the case the shared lookup moved for a Windows name that already has an extension (python3.11, tool.py, wsl.exe). The examination's old copy also tried .exe, .bat and .cmd after such a name, as read from the deleted function; the summary's copy and the shared lookup try it as given only. No which call site passes such a name except wsl.exe, which is found as given, so no answer moves today. The System32 row also no longer lists pwsh, which has no fixed location.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
…the note's cited tests exist, and correct the which summary

candidates_on_windows_add_the_fixed_system32_locations asserted pwsh.exe and powershell.exe with a PATHEXT that contains .EXE, which adds those spellings by itself, so deleting the arms of the fixed list changed nothing. It now uses a PATHEXT without .EXE, so they can only come from the list; deleting either goes red.

The host-probing note cites tests by bare name, which the link checker does not see, and one name was wrong. the_host_probing_note_cites_only_tests_that_exist reads the note and requires every cited which_, candidates_, found_in_ and path_dirs_ name to be a function in probe_exec.rs; a misspelled name goes red.

candidates_on_windows_for_a_name_with_an_extension_are_the_name_alone also pins python3.11: PATHEXT is not tried after a dotted name, which the doc comment on which now says, with the fact that no caller relied on the old copy doing so. The summary line of which no longer says it only resolves on PATH, and the doc stops listing pwsh among the names found at a System32 location.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>
@jussielo-amd
jussielo-amd requested a balanced review from Copilot November 9, 2026 14:25
@jussielo-amd
jussielo-amd dismissed juhovainio’s stale review November 9, 2026 14:25

The review listed no blocking items. Its two points are fixed and answered in 2208f53 and c50c6ba; the dotted-name question is answered from the old code in the thread.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because the filtered PATH can hide the CLI under test, causing all four new scenarios to fail before exercising their fixtures.

3 open issues

Review effort: Balanced

…nside the crate

the_host_probing_note_cites_only_tests_that_exist read docs/host-probing.md from rocm-core. The pre-push narrowing rule in xtask does not know that read, so it rejects a rocm-core test that reads a file outside the crate (every_cross_crate_read_is_covered_by_the_widening_rule), and widening the rule for a citation tripwire is not worth it.

The corrected test name stays in the note and the other changes of the previous commit are untouched; the names the note cites were checked against the sources by hand instead.

Signed-off-by: Jussi Elo <jussi.elo@amd.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because the fixture PATH filtering can hide the bare-name rocm executable, causing all four new scenarios to fail before the CLI starts.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at f4659ff. The one blocking issue I found on the previous head (the test reading docs/host-probing.md from rocm-core tripping xtask's every_cross_crate_read_is_covered_by_the_widening_rule) is resolved by dropping that test.

Two tradeoffs, both documented, noted for the record and not blocking: (1) which() for powershell and the other System32 names now answers 'would the capture runner find it' rather than 'is it on PATH'; (2) an empty PATH entry is skipped, which differs from execvp for later bare-name spawns.

Scope matches the ticket (one shared which, tool_path_candidates moved, scenarios examine-35..38, docs updated). CI on the new head was still pending when I reviewed, so please confirm it goes green before merging.

@nowycondro nowycondro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated review · review-code · head f4659ff2

Outcome: no blocking findings. Reviewed the full diff (base 3dc4a31a...head f4659ff2, 15 files, +1169/-101) via four independent blind passes (core probe_exec.rs/host_gpu lookup logic, the e2e-cucumber harness + new examine-35..38 scenarios, AGENTS.md/CONTRIBUTING.md + code-comment compliance, and pre-PR git history), plus a design pass and a check of CI and the linked ticket. This implements ROCMAI-905 (host-probing pair 1 of 6) in full: converges the two PATH lookups, decides the empty-PATH-entry question as the ticket recommended, with characterisation + convergence commits, mutation-style test coverage, new e2e scenarios, and doc updates — matches the ticket's acceptance criteria. All 30 CI checks are green.

Non-blocking

  • crates/rocm-core/src/examine/framework.rs (probe_pytorch_on_path, probe_llama_cpp) — the shared which() now tries every PATHEXT entry on Windows (not just .exe/.bat/.cmd), but these two probes still spawn the resolved bare name via Command::new, which on Windows only ever starts a .exe. So which("python") can return true because of e.g. a stray python.PS1 on PATH, and the framework probe can report a tool as "installed" when it cannot actually be run. Both call sites already carry a comment acknowledging the gap, and no test pins the framework-level consequence. Low real-world likelihood (needs a non-default PATHEXT entry plus a matching file on PATH), but worth either a regression test or narrowing which()'s extension set for this specific caller.

Decisions for the author (tradeoffs already documented in the PR/code, not defects)

  • which() now answers "would the capture runner start this" rather than strictly "is this on PATH" for cmd, pnputil, powershell, pwsh (System32 fallback checked even with PATH unset) — intentional per the design note, no current caller affected.
  • Skipping empty PATH entries (vs. execvp's cwd-as-empty-entry semantics) changes the WSL summary's answer; documented and tested, and a program started later by bare name can still resolve from the current directory through the OS regardless of this lookup's answer.

What this covered: full diff read across all 15 changed files plus surrounding call sites in crates/rocm-core; AGENTS.md and CONTRIBUTING.md read in full for applicable rules; pre-PR git history of the touched files for prior incidents; the CI status rollup; and the linked ticket (ROCMAI-905). Did not run cargo test/clippy/the e2e suite myself (relied on the green CI rollup for that evidence).

Not a human review. This is an automated code review; please verify findings independently before acting on them.

@jussielo-amd
jussielo-amd added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit f3c08f1 Nov 9, 2026
31 checks passed
@jussielo-amd
jussielo-amd deleted the refactor-one-path-lookup-for-host-probing branch November 9, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants