Repository navigation
refactor(rocm-core): one CPU model-and-vendor read for the summary and the examination stacks - #998
Conversation
…hat read through it live_rocm_repo_paths_in_dir_skips_a_real_bak_file_on_disk and merge_live_repo_paths_scans_every_family_dir_including_zypp scan temp directories through host_path, which a test holding a simulated host root re-roots, and neither takes HOST_ROOT_TEST_LOCK as every test that sets the root does. They pass while the tests that set the root are short, and fail in most full runs with the e2e-test-hooks feature once one of those tests runs a whole examination under the root, which holds it for much longer. They take the lock now, ahead of the test that does. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
…rged The summary stack (detect_cpu_model and the Windows inventory's CPU row) and the examination stack (probe_cpu_linux and probe_cpu_windows) both read the CPU, and are about to become one reader. Pin what each returns for the same input first, so the change that merges them shows exactly which answers it moves. They agree on an ordinary model name, on a model name with no vendor_id, on a blank model name line followed by a real one, on a cpuinfo with no CPU in it, and on Windows on a name the query returns. They differ on four Linux inputs (repeated spaces in the model name, which only the summary collapses; a Hardware line with no model name, which only the summary reads; Hardware before model name; an empty vendor_id value) and on Windows on whitespace, on the first line of several, and on the time allowed: 8 s for the examination, 1.5 s for both the summary's system query and its own fallback query. The summary asks its own fallback query only when there is no inventory at all, even when the inventory has no CPU row. On WSL the summary reads the CPU and the examination returns before it does, so cpu_model is empty and cpu_vendor is unknown; that is pinned as an existing difference from a simulated host root. The Windows logic runs on any host through injected queries: probe_cpu_windows_with, detect_cpu_model_windows and windows_system_inventory_with take the query as a closure, and windows_cpu_model makes the summary's inventory-or-fallback choice. Nothing else changes; the live queries are the same commands as before. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
…and the examination The summary's detect_cpu_model and the examination's probe_cpu_linux and probe_cpu_windows each read the CPU their own way, so one rocm examine --json could show the model spelled two ways, a CPU in the summary and none in the examination, or a Windows CPU read three times. os_facts now has one reader that returns the model and the vendor together: on Linux from /proc/cpuinfo through host_path (the first model name or Hardware line with a value, and the first vendor_id with a value), on Windows from the CPU row of the system inventory query, with the vendor derived from the model string. probe_cpu_linux and probe_cpu_windows record its answer, detect_cpu_model returns its model, and the separate Win32_Processor query behind each Windows copy is gone. WSL is unchanged (option (a)): the examination still returns before the CPU probe, so cpu_model stays empty and cpu_vendor unknown there while the summary shows the CPU. Decided here. Whitespace: the collapse reaches cpu_model, so the model is one string in both forms; nothing reads cpu_model or cpu_vendor to diagnose, they reach the JSON and Doctor reports only. Hardware-only: the Hardware value is the model, the vendor stays unknown. Empty versus unknown: a CPU that could not be read is an absent model in the summary and an empty cpu_model with vendor unknown in the examination, as before; on Windows the examination still records a probe failure for it. Timeout: one limit of 5 s, the inventory's, for the one query; the summary's system query was 1.5 s and the examination's was 8 s, so the summary waits longer and the examination gives up 3 s sooner. Inventory fallback: dropped. With no inventory the summary used to ask for the CPU again with a query of its own, but the inventory run had just asked the same question, so a second try only repeated a failed query; the summary now reads no CPU there. User-visible differences: on Linux cpu_model has its whitespace collapsed; a Hardware-only cpuinfo now gives cpu_model the Hardware value; with Hardware before model name the examination reports the Hardware value; an empty vendor_id value no longer becomes the vendor, the next one is read, else unknown. On Windows cpu_model has its whitespace collapsed; the examination asks the system inventory query, which also asks for RAM, instead of Win32_Processor alone; that query is read as strict UTF-8 and runs through the optional-command helper, which tries each spelling of powershell after a timeout where run started it once, so a hung PowerShell can cost the examination more than one limit; the summary's system query, and so its RAM row too, waits 5 s instead of 1.5 s; and with no inventory the summary shows no CPU instead of retrying. The characterisation tests of the previous commit change only on those inputs. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
rocm examine --json reads the CPU in the host summary (summary.cpu, shown as cpu: in the text) and in the examination (cpu_model and cpu_vendor), which now share one reader. examine-39 plants a /proc/cpuinfo under a simulated host root that names an AMD CPU with runs of spaces in its model, on a machine that is not WSL, and asserts both reports carry the same collapsed model and the examination reports the vendor as amd. examine-40 plants an Arm-style cpuinfo with only a Hardware line and asserts both reports name that value and the vendor stays unknown. examine-41 plants the same CPU on a WSL machine and pins the difference this change leaves as it is: the summary reports the CPU, the examination reports no model and an unknown vendor. The comparison is scoped to hosts where is_wsl is false, and each scenario asserts the specific values and the is_wsl flag it is scoped by. Against the code before the reader was merged, examine-39 fails on the examination's spaces and examine-40 on its empty model; examine-41 passes before and after. Native Windows reads the CPU through the system inventory and cannot run on this lane, so its cases are the unit tests next to the reader. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
The CPU model is the third pair of the note to converge. Record what survived (one reader returning model and vendor, called by both probe functions and read by the summary), WSL option (a), the five decisions (the whitespace collapse reaches cpu_model, a Hardware line is the model when no model name comes first, a CPU that could not be read stays an absent model in the summary and an empty one in the examination, one 5 s limit for the Windows query, and the summary's own Windows fallback query dropped), the answers that moved with the test or scenario that pins each, the two differences that come with the optional-command helper and cannot be pinned off Windows, and what stays untested. The analysis of the old copies stays as the record of what changed; the timeout question leaves the open list for the CPU and two new questions join it. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The Windows CPU probe’s changed subprocess runner and timeout/retry behavior lack Windows compilation and live PowerShell validation, and injected-query tests do not exercise that path.
No open issues 🎉
What changed in this PR
Consolidates CPU model and vendor detection in rocm-core so the host summary and examination use shared parsing and query logic, while preserving the existing WSL behavior.
Changes:
- Unifies CPU normalization and Linux
Hardwarefallback handling. - Reuses the Windows system-inventory query with a shared five-second timeout and removes the summary’s separate CPU fallback query.
- Adds regression tests and Linux scenarios, protects host-root-sensitive tests, and documents behavior changes.
Live Windows execution remains unverified, as noted in the PR. No additional tests were run for this review.
| File | Description |
|---|---|
tests/e2e-cucumber/tests/e2e/examine_steps.rs |
Adds simulated CPU fixtures and exact report assertions. |
tests/e2e-cucumber/features/examine.feature |
Adds CPU consistency, Hardware-only, and WSL scenarios. |
docs/host-probing.md |
Records convergence decisions, behavior differences, and verification gaps. |
docs/architecture.md |
Updates ownership descriptions for shared CPU detection. |
crates/rocm-core/src/host_gpu/windows_inventory.rs |
Extracts an injectable system query and shares its timeout. |
crates/rocm-core/src/host_gpu/os_facts.rs |
Implements shared CPU facts and parsing regression tests. |
crates/rocm-core/src/host_gpu.rs |
Sources the Windows summary CPU exclusively from its inventory. |
crates/rocm-core/src/examine/rocm_install_probe.rs |
Locks repository-scan tests against simulated host-root changes. |
crates/rocm-core/src/examine/host_env.rs |
Records shared CPU facts and tests host-root and WSL behavior. |
crates/rocm-core/src/examine.rs |
Exposes CPU recording helpers for cross-module tests. |
Review effort: Balanced
Security scan found no critical or high findings on lines changed by this pull requestView the security scan run for complete reports. “New” means the finding is located in a changed file on an added or modified line; it is not a base-versus-head findings delta. |
nowycondro
left a comment
There was a problem hiding this comment.
🤖 Automated review · review-code · head 66c80ffb
Review — needs work
Full review of the whole change (10 files, +870/-105). Closes ROCMAI-924 (an internal tracker reference; not retrieved here to keep internal ticket content out of a public review — the relationship is stated from the PR description alone, which was checked against the diff and found accurate throughout).
Blocking
- CI: the Security scan jobs (
gitleaks,Security scan / Security scanners) are red on this head commit, but the finding is not attributable to this PR's own diff — the posted security-scan comment flags 3 "generic-api-key" hits inapps/rocm/src/runtime_install_finalize.rsandapps/rocm/src/serve_summary.rsat commitf3c08f12df1398ac51e0ec2784bac9987d34b. Neither file is among this PR's 10 changed files, andf3c08f12is a separate, already-merged commit ("one PATH lookup for the summary and the examination stacks (#953)"), not a commit on this branch. So this looks like a pre-existing/stale scan result surfaced on this PR's check run rather than something introduced here.
Confidence 85 · architectural · Fix: nothing to change in this PR's files; ask a maintainer to re-run the job or confirm the finding is already tracked/allowlisted, so the PR isn't blocked on an unrelated red check.
Non-blocking
None. Five independent file-coupling passes (the shared Linux/Windows CPU-facts reader in os_facts.rs; the Windows system-inventory query and summary plumbing in windows_inventory.rs/host_gpu.rs; the examination stack and host-root test-lock fix in examine.rs/host_env.rs/rocm_install_probe.rs; the new e2e scenarios and step definitions; and a docs-accuracy-plus-history pass) plus direct spot-checks of the parsing loop, the dropped Windows fallback, WSL scoping, and e2e scenario isolation found no surviving candidate at confidence ≥ 70.
Decisions for the author
- The Windows examination's CPU read now goes through strict UTF-8 decoding and a multi-spelling PowerShell retry it didn't use before, unverified on a real Windows host — answered-by-intent
PR body: "it reads the output as strict UTF-8 whererundecoded lossily, so a CPU name that is not valid UTF-8 reads as no CPU, and it tries each spelling ofpowershellafter a timeout whererunstarted it once, so a hung PowerShell can cost the examination more than one limit... neither is pinned because the helper is not injectable and needs a Windows host." Would otherwise have been a non-blocking correctness/robustness finding (a non-UTF-8 CPU name silently regresses to "no CPU" instead of a lossily-decoded string). Confirm this is still the acceptable tradeoff given it can't be verified without Windows hardware. - Unifying the timeout to 5 s widens the "hung PowerShell" worst case beyond
rocm examine— answered-by-intent
PR body: "8 s was not taken for the shared query because it would also be the worst case of every startup path that gathers the summary on a host whose PowerShell hangs. Neither number was measured." Confirmed call sites ofExamineSummary::gather/gather_without_driver_factsbeyondexamineitself:driver_install.rs,freeform_answer.rs,chat/mcp_bridge.rs,runtime_install_finalize.rs, androcmd'shost_snapshot.rs/mcp.rs/sandbox.rs. Would otherwise have been a tradeoff finding (consistency/correctness vs. worst-case latency on a slow Windows host across several command paths, not just one). Confirm the 5 s choice is deliberate for all of them.
Positive signals
- The characterisation → convergence test sequence is unusually rigorous: every new test is reported mutation-tested (shown red by breaking its target, restored by the fix) and the new e2e assertions compare exact tuples (
summary.cpu,cpu_model,cpu_vendor,is_wsl) rather than loosecontainschecks. cpu_facts_from_cpuinfo's single-pass parser (first matchingmodel name/Hardwareline wins regardless of which label appears first; a blankvendor_idis skipped rather than locked in) is correct by direct trace and is exercised by tests for exactly the edge cases that used to make the two old readers disagree.- The
HOST_ROOT_TEST_LOCKfix inrocm_install_probe.rsis a precisely diagnosed, narrowly-scoped fix for a real race the new host-root-simulating tests would otherwise introduce.
Deployment notes
- On Windows, every path that gathers the host summary now waits up to 5 s (previously 1.5 s) before concluding there's no CPU/inventory on a host where PowerShell is slow or unresponsive — see the second "Decisions for the author" item above.
- No Windows host was available to the author or to this review; the
cfg(windows)production path (run_windows_system_query/detect_windows_system_inventory_from_cim) is verified only by hand-reading and by unit tests against injected closures, not by a live run.
What this covered
Full diff, 227968dc…66c80ffb (merge-base with main…PR head), all 10 changed files read completely by independent passes, plus the surrounding code each pass needed (callers of the changed CPU functions repo-wide, confirmed to have no callers outside the reviewed files; the pre-existing, untouched capture.rs subprocess helper now reached by the examination's Windows path for the first time; the e2e harness's scenario-isolation and concurrency model). Design-review questions on timeout blast radius, the newly-reached UTF-8/retry behavior, and WSL scoping were investigated directly and resolved via the PR's own stated intent (Step 9) or direct code tracing.
Did not run: cargo test/cargo clippy/any build (no local toolchain available); no Windows host (matching the PR's own disclosed gap). Did not retrieve the linked Jira ticket ROCMAI-924, deliberately, to keep internal tracker content out of this public review. Not reconciled against any prior review thread on this PR; the existing Copilot bot review was noted only to avoid duplicating it, not used to anchor any finding here.
Not a human review. This is an automated code review; please verify findings independently before acting on them.
juhovainio
left a comment
There was a problem hiding this comment.
I read through this diff and found nothing that should block the merge. The change itself does what the description says: one shared CPU model-and-vendor reader for the summary and examination stacks, with the Windows logic behind an injectable runner and the new e2e scenarios asserting exact values.
Two small non-blocking notes are left inline. In short:
- The Windows failure message still names
Get-CimInstance Win32_Processor, though the query is now the combined CPU+RAM script. - The call-site wiring (
probe_cpu_windowsandsummary_cpu(runtime_is_windows(), ..)) is covered only by the Windows job compiling. The PR anddocs/host-probing.mdalready acknowledge this.
Open questions you already list (shared 5 s timeout, running the Windows query twice per --json run) are fine to settle as you see fit.
This reflects a read of the diff only. I did not build or run the tests locally, and the two Security scan checks were red when I looked, so please confirm those are unrelated before merging.
| pub(crate) fn record_cpu_windows(e: &mut Examination, facts: CpuFacts) { | ||
| if facts.model.is_none() { | ||
| e.probe_failures | ||
| .push("Get-CimInstance Win32_Processor failed; cannot identify CPU.".to_owned()); |
There was a problem hiding this comment.
The failure text still names Get-CimInstance Win32_Processor, but the query is now the CPU+RAM inventory script and this entry also fires when the query succeeds without a CPU row. Consider wording that names the inventory query so the remediation points at what ran.
There was a problem hiding this comment.
Fixed in aac07b4. The entry now reads "The Windows system inventory query (CPU and RAM) reported no CPU; cannot identify CPU.", which names the query that runs and is accurate for both cases that fire it: the query failing or timing out, and the query succeeding with no CPU row. It is a shared constant (WINDOWS_CPU_NOT_FOUND). The characterisation test asserts the message together with the state in one test: for a failed query, a timeout, empty output, a RAM-only answer and a blank CPU row it expects exactly that single entry, an empty cpu_model and a vendor of unknown. Putting the old wording back turns that test red.
| /// 8 s for the examination, 1.5 s for the summary's system query and for its | ||
| /// own CPU query. | ||
| #[test] | ||
| fn windows_both_reads_are_given_the_same_time() { |
There was a problem hiding this comment.
This pins the shared 5 s limit, but nothing ties probe_cpu_windows and summary_cpu(runtime_is_windows(), ..) themselves to these readers; the call-site wiring is only covered by the Windows job compiling. Worth stating in the PR as the untested path (it is in the docs already).
There was a problem hiding this comment.
Partly closed in aac07b4. For the examination, probe_cpu_windows now passes the real runner to a new probe_cpu_windows_with, which takes the query as an argument, so the whole Windows read including the failure entry is driven by an injected query on Linux and on the Windows job. Off Windows a test also runs probe_cpu_windows itself, where the real runner finds no PowerShell, and pins that it reports no CPU with the new entry; replacing the runner it passes with a canned answer turns that test red. For the summary, summary_cpu already takes the Windows flag and the inventory as arguments and is tested for every combination, but I could not find a seam that ties its caller to runtime_is_windows() without starting the live host summary, so that one-argument call and the live PowerShell runner argument remain covered only by the Windows job compiling (the workspace clippy for the Windows target now passes with stand-in build tools). The PR text and docs/host-probing.md say so.
…ure and inject the examination's runner The probe_failures entry for a Windows read that finds no CPU still named a Win32_Processor query, though the examination now runs the system inventory's CPU and RAM script, and the entry also fires when that query succeeds with no CPU row. It now says the Windows system inventory query reported no CPU, as a shared constant, and the characterisation test asserts the message together with the empty model, the unknown vendor and the single entry. probe_cpu_windows now passes the real PowerShell runner to probe_cpu_windows_with, so the whole examination read, failure entry included, is driven by an injected query on every host and the Windows job. A test off Windows runs probe_cpu_windows itself, where the real runner finds no PowerShell, and pins that it reports no CPU with the new entry; replacing the runner or the entry turns it red. What no test reaches is the live runner argument itself and the runtime_is_windows() argument summary_cpu is called with; the host-probing note says so. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Native Windows validation is still needed for the combined CPU/RAM PowerShell runner’s decoding, timeout, and retry behavior, as supplied checks cover only injected queries and cross-compilation.
No open issues 🎉
Review effort: Balanced
r0x0r
left a comment
There was a problem hiding this comment.
Approving this. I spent a while on it because the whole family of changes rests on one claim — that collapsing three CPU readers into one moves nothing a user sees except what the note already lists — and I wanted that checked rather than argued. Three small things are left inline; none of them need to hold up the merge, but I'd like an answer on the first two.
Instead of reasoning about the parsing, I ran it. I built a small differential harness over the old summary reader, the old examination reader and the new shared one, and fed all three the same 13 real /proc/cpuinfo layouts: a two-socket EPYC, an aarch64 file with neither model name nor vendor_id, an armv7 one with Hardware last, s390x, POWER9, Hygon, files with interior padding and trailing whitespace, and lines with no colon at all. The summary output came back identical on all 13. The examination output moved on exactly 4 of them, and every one of those 4 is already on the disclosed list in docs/host-probing.md. Nothing moved that this PR doesn't say moves.
The supporting claims hold up too: grep agrees that nothing diagnoses off cpu_model or cpu_vendor — the only consumers are the JSON output and the report fixtures — and every backticked test name the note cites resolves to a real test.
On CI: the build, test, clippy, Windows and E2E lanes were green on this branch. A fresh run started on the current head a few minutes ago and most of it is still in flight, so it's worth a glance before you merge. The gitleaks failure I saw earlier is a pre-existing false positive that is already on main (runtime_key: "wheel-gfx942-7.13.0", which came in with #953), not anything this PR introduced — and it's green on the current head regardless. E2E tests (W7900) hadn't reported yet when I looked.
Two things I'd rather have confirmed than changed. First, ExamineSummary::gather* on Windows now waits up to 5 s instead of 1.5 s on every startup path that builds a summary (windows_inventory.rs:28), and the note is honest that the number is unmeasured — so the cost of that is genuinely unknown, including for callers that never wanted the examination. Second, the strict-UTF-8 decoding and the powershell-candidate retry that come with the examination's new Windows read aren't pinned by anything. The note says so, which I appreciate; I'm just flagging that the untested surface sits on the one platform this change moves the most.
| /// The CPU facts of the host this process runs on. | ||
| pub(crate) fn read_cpu_facts() -> CpuFacts { | ||
| if runtime_is_windows() { | ||
| let script = | ||
| "Get-CimInstance Win32_Processor | Select-Object -First 1 -ExpandProperty Name"; | ||
| return capture_optional_command_with_timeout( | ||
| "powershell", | ||
| &["-NoProfile", "-Command", script], | ||
| OPTIONAL_COMMAND_TIMEOUT, | ||
| ) | ||
| .map(|value| normalize_cpu_model(&value)) | ||
| .filter(|value| !value.is_empty()); | ||
| read_windows_cpu_facts() | ||
| } else if runtime_is_linux() { | ||
| read_linux_cpu_facts() | ||
| } else { | ||
| CpuFacts::unknown() | ||
| } | ||
| } |
There was a problem hiding this comment.
The Windows arm here looks unreachable in practice. detect_cpu_model is now reached only through detect_cpu_model_with_windows_inventory in crates/rocm-core/src/host_gpu.rs (around line 274), which hands it to summary_cpu as the non-Windows reader — when windows is true, summary_cpu takes the inventory row instead and never calls it. And runtime_is_windows() is a const fn over compile-time cfg, so there's no target on which production code can enter read_windows_cpu_facts() from this function.
Dead code is usually a shrug, but not this particular branch: it is exactly the path that would silently re-introduce the second PowerShell query this PR exists to remove. Either drop the arm, or leave a comment saying it's kept only for a future caller — otherwise the next person wires something into read_cpu_facts() and quietly gets the duplicate query back.
There was a problem hiding this comment.
You are right, and I checked it before changing anything. detect_cpu_model had exactly one production caller, detect_cpu_model_with_windows_inventory, which hands it to summary_cpu as the non-Windows reader, and read_cpu_facts and read_windows_cpu_facts had no other callers, so no target could enter the Windows arm. Fixed in the next commit by taking the second option from your note in its stronger form: the Windows arm, read_cpu_facts and read_windows_cpu_facts are gone, and detect_cpu_model is a Linux-only reader that answers None off Linux, so a future caller on Windows gets no CPU rather than a second PowerShell query. The host check is an argument of a small helper, so detect_cpu_model_reads_nothing_off_linux runs on any host and shows the reader is never called when the check is false; dropping the check turns it red. That the summary starts only one Windows query is the existing windows_an_answer_with_no_cpu_is_no_cpu_in_both_reads, which counts the queries behind the inventory.
| /// query. Elsewhere it is `read`, the Linux reader. | ||
| fn summary_cpu( | ||
| windows: bool, | ||
| windows_inventory: Option<&WindowsExamineInventory>, | ||
| read: impl FnOnce() -> Option<String>, | ||
| ) -> Option<String> { | ||
| if windows { | ||
| os_facts::cpu_facts_from_windows_inventory(windows_inventory).model | ||
| } else { | ||
| read() |
There was a problem hiding this comment.
CPU and RAM now disagree about what an absent inventory means. summary_cpu here drops the CPU's second query on the reasoning that no inventory implies the system query already failed, so asking again just repeats a failed query. But detect_system_ram_gib_with_windows_inventory immediately below (roughly lines 294-305) still falls back to its own query for the RAM row — the same row set, from the same query. If a repeat is pointless for the CPU it should be pointless for the RAM, and if it isn't pointless the CPU shouldn't have dropped it.
The RAM fallback predates this PR, so this isn't a regression you caused — it just became inconsistent here. A sentence in the note saying why RAM keeps its fallback (or a follow-up to drop it) would close the gap.
There was a problem hiding this comment.
I kept the RAM fallback and said why in docs/host-probing.md. The reason is not that a repeat is useful for RAM: detect_system_ram_gib is a public reader that model_fit calls with no inventory at all, so its Windows query has to exist, and removing the summary's fallback would change what the summary shows for RAM when the inventory is absent, a behaviour change for a fact this PR does not touch and would want its own test. So the two disagree on purpose, for now, and dropping the RAM fallback to follow the CPU is recorded as a follow-up in the note and the PR text.
| - Whitespace: the collapse reaches `cpu_model`, so the model is one string in both forms. Nothing diagnoses from `cpu_model` or `cpu_vendor` (grep of the crates), so the only places that see the change are the JSON and the Doctor reports; a consumer that matched the old padded spelling is the one that sees it. | ||
| - The `Hardware`-only case: the `Hardware` value is the model and the vendor stays `unknown`, because such a file names none. The model is the first line of either kind, as the summary always had it, so with `Hardware` before `model name` the examination now reads the `Hardware` value where it read the `model name`; real cpuinfo prints `Hardware` after the per-core blocks, so that order is a fixture, not a host this note knows of. | ||
| - Empty versus unknown: a CPU that could not be read is no model (shown `<unknown>` in the text, `null` in `summary.cpu`) in the summary and an empty `cpu_model` with `cpu_vendor` `unknown` in the examination, as before, and a vendor line with no value names no vendor. On Linux that is not a `probe_failures` entry, as before. On Windows the examination still records a `probe_failures` entry, now worded for the query that runs (`The Windows system inventory query (CPU and RAM) reported no CPU; cannot identify CPU.`, where it named a `Win32_Processor` query that no longer runs), now for any read that gives no CPU (a query that failed, timed out, printed nothing or printed no CPU row), where it recorded it for a non-zero exit or blank output. | ||
| - The Windows timeout: one limit of 5 s, the inventory's own for every other query, for the one query both stacks run. The summary's system query was 1.5 s (and its own CPU query too) and the examination's was 8 s, so the summary now waits longer, for its RAM row as well, and the examination gives up 3 s sooner. The reason is that the examination runs the query first in a `--json` run, on a PowerShell that has not started yet, where 1.5 s may not be enough and a spurious empty `cpu_model` with a `probe_failures` entry costs more than waiting; 8 s was not taken for the shared query because it would also be the worst case of every startup path that gathers the summary on a host whose PowerShell hangs. Neither number was measured: UNCONFIRMED on a real Windows host. |
There was a problem hiding this comment.
Worth pinning down the number in the PR description. Windows still runs this system query twice for a single rocm examine --json: once in the summary's assemble_windows_inventory, and once in probe_cpu_windows. The note is straight about that, which is good — but the PR body says the old state was "up to three queries for one fact" and then never says what it is now. Someone reading only the description will reasonably conclude it's one.
A clause saying it's two, and why the two runs aren't shared within a single --json run, would stop that misreading — especially since the open-questions list already carries "whether one rocm examine --json run shares answers between the stacks".
There was a problem hiding this comment.
Added to both. The PR text and the note now say that native Windows runs the system query twice in one rocm examine --json (the summary's assemble_windows_inventory and probe_cpu_windows), down from two or three, and that this change does not claim one. They are not shared within a run because the examination is built first and the summary after it by separate calls that pass nothing between them, and sharing means choosing which stack owns the answer, which stays in the open-questions list.
nowycondro
left a comment
There was a problem hiding this comment.
🤖 Automated review · review-code · head aac07b4
Review — needs work
Full review of the whole change (10 files, +923/-107), 227968dc…aac07b4. Closes ROCMAI-924 (an internal tracker reference; not retrieved here to keep internal ticket content out of a public review — the relationship is stated from the PR description alone, checked against the diff and found accurate).
This is a re-review: the head advanced from 66c80ffb (reviewed earlier today) to aac07b4 with one further commit, so the whole diff was re-read rather than narrowed. That turned out to matter: the last commit itself introduces the finding below.
Blocking
read_windows_cpu_facts()— and the Windows arm ofread_cpu_facts()/detect_cpu_model()— is dead code, introduced by this PR's own final commit —crates/rocm-core/src/host_gpu/os_facts.rs:100-109,165-167,crates/rocm-core/src/host_gpu.rs:272-289,crates/rocm-core/src/examine/host_env.rs:136-150
An exhaustivegit grepfordetect_cpu_model,read_cpu_factsandread_windows_cpu_factsacross the whole repository at HEAD showsdetect_cpu_model()'s only callers are (a)host_gpu.rs'ssummary_cpu(windows, windows_inventory, read), whose body isif windows { cpu_facts_from_windows_inventory(...).model } else { read() }— i.e.read(detect_cpu_model) is invoked only in the non-Windows branch — and (b) two#[cfg(target_os = "linux")]-gated tests inhost_env.rsexercising the Linux path. So on an actual Windows runtime,detect_cpu_model()'s Windows branch, henceread_cpu_facts()'sif runtime_is_windows()arm, henceread_windows_cpu_facts()itself, never executes — andread_windows_cpu_facts()has no caller at all, production or test.
This is a regression the final commit (aac07b4, "name the inventory query in the Windows CPU failure and inject the examination's runner") introduced: before it,probe_cpu_windowscalledrecord_cpu_windows(e, read_windows_cpu_facts()), so the function was live. That commit rewiredprobe_cpu_windowsto the injectableprobe_cpu_windows_with(e, run_windows_system_query)(a sound improvement for testability) but leftread_windows_cpu_facts()behind, now orphaned. TheCpuFactsdoc comment (os_facts.rs:70-73) still claims the model is "read together by the one reader both stacks use: the summary'scputhroughdetect_cpu_model... the examination'scpu_model... throughprobe_cpu_linuxandprobe_cpu_windows" — which overstates the Windows half: the Windows summary reads throughcpu_facts_from_windows_inventorydirectly off the cached inventory (not throughdetect_cpu_model), and the Windows examination reads throughwindows_cpu_facts_with(run_windows_system_query)directly (not throughread_windows_cpu_facts). Only the Linux side, and the underlying parsing function, are genuinely shared by both stacks.
Confidence 90 · logic · Fix: deleteread_windows_cpu_facts()(and reconsider whetherread_cpu_facts()needs a Windows arm at all, since nothing reaches it), and tighten theCpuFactsdoc comment to say precisely what Windows shares (the parsing function, reached via two separate call sites) rather than implying one call path.
Non-blocking
None. Several lower-confidence observations from the fan-out passes (whether the rocm_install_probe.rs lock fix is itself proven by a concurrency-forcing test rather than by code inspection only; a state-matrix cell with e2e coverage only at the unit-test level) scored below the confidence bar and are not included.
Decisions for the author
- Unifying the Windows system-inventory timeout to 5 s (from the summary's previous 1.5 s) widens the "hung PowerShell" worst case to every command path that builds a host summary, not just
rocm examine— answered-by-intent
docs/host-probing.md: "8 s was not taken for the shared query because it would also be the worst case of every startup path that gathers the summary on a host whose PowerShell hangs. Neither number was measured: UNCONFIRMED on a real Windows host." Confirmed call sites ofExamineSummary::gather/gather_without_driver_factsbeyondrocm examine:driver_install.rs,freeform_answer.rs,chat/mcp_bridge.rs,runtime_install_finalize.rs, androcmd'shost_snapshot.rs/mcp.rs/sandbox.rs. Worth weighing when confirming: the repo has an existing convention of choosing subprocess timeouts by call-site latency sensitivity (host_snapshot.rs'sAMD_SMI_PROBE_TIMEOUTdoc comment;chat_host_facts.rs's own doc comment explicitly avoidingExamineSummary::gather()on a latency-sensitive path because of its "several process-spawning inventory queries"), which this unification trades away for one shared number. - The examination's Windows CPU read now goes through strict UTF-8 decoding and a multi-spelling PowerShell retry it didn't use before, unverified on real Windows hardware — answered-by-intent
docs/host-probing.md: "it reads the output as strict UTF-8 whererundecoded lossily, so a CPU name that is not valid UTF-8 reads as no CPU, and it tries each spelling ofpowershellafter a timeout whererunstarted it once ... neither is pinned because the helper is not injectable and needs a Windows host." Would otherwise be a non-blocking correctness/robustness finding (a non-UTF-8 CPU name silently regresses to "no CPU"). Confirm this is still acceptable given it can't be verified without Windows hardware.
Positive signals
- The parsing consolidation is genuinely clean on the side that matters most:
cpu_facts_from_cpuinfo's single-pass parser (first matchingmodel name/Hardwareline wins regardless of order, a blankvendor_idis skipped rather than locked in) is correct by direct trace and the Windows query-wiring now sits behind an injectable closure (windows_cpu_facts_with,probe_cpu_windows_with) exactly per this repo's own "platform-gated code needs an injectable helper" convention, giving the Windows failure-message and timeout logic real unit-test coverage from the Linux job. docs/host-probing.mdis unusually accurate: every specific claim checked (timeout values, cited test names, scenario ids, the exactprobe_failureswording) matched the code at HEAD exactly, including a sentence ("the summary ... reads the CPU row of the inventory it already holds ... which is the same row through the same function") that is more careful than the top-of-fileCpuFactsdoc comment about exactly the Windows-bypass this review's blocking finding is about.- The new e2e scenarios (
examine-39/40/41) assert exact tuples rather than loose substring checks, and the WSL scenario was confirmed to exercise the realis_wsldetection mechanism via a planted/dev/dxgrather than a mocked shortcut — a genuine regression guard, not a rubber-stamp test. - The
HOST_ROOT_TEST_LOCKfix inrocm_install_probe.rsis a precisely-diagnosed, narrowly-scoped fix for a real shared-fixture race the new host-root-simulating tests would otherwise introduce.
Deployment notes
- On Windows, every path that gathers the host summary (not only
rocm examine) now waits up to 5 s instead of 1.5 s before concluding there's no CPU/RAM data on a host where PowerShell is slow or unresponsive — see the first "Decisions for the author" item. - No Windows host was available to this review (matching the PR's own disclosed gap); the
cfg(windows)production path is verified only by reading and by unit tests against injected closures. read_windows_cpu_facts()carries no functional risk as-is (nothing calls it), but should be removed before or shortly after merge so it doesn't mislead a future maintainer into thinking it's part of the live Windows path.
What this covered
Full diff, 227968dc…aac07b4, all 10 changed files read completely across six independent fan-out passes (the shared CPU-facts reader and Windows query in os_facts.rs/windows_inventory.rs; the host-summary and examination orchestration in host_gpu.rs/examine.rs; the examine/host_env.rs + rocm_install_probe.rs host-root-lock pair; the e2e feature and step definitions; a docs-accuracy pass cross-checking every factual claim in docs/host-probing.md/docs/architecture.md against the code; and an agent-instruction/history/prior-changes pass against this repo's AGENTS.md), plus direct driver-level verification (repository-wide git grep, and reading the final commit's own diff in isolation) that produced the blocking finding above. CI: 39 of 40 reported check runs green on this exact head (build/test/clippy, Windows build+test+release lifecycle, all E2E lanes shown, all Security-scan sub-jobs including gitleaks, coverage-ratchet, architecture-doc/module-size/link-check hooks); the one-check discrepancy between total_count and the returned list showed no failing job. No module-size, architecture-doc-sync, markdown-link, or public-content-leak violations found.
Did not run cargo build/test/clippy locally (no toolchain in this environment); relied on CI's green result for that. Declined to retrieve the internal Jira ticket ROCMAI-924, to keep internal tracker content out of a public review. Not reconciled against the discussion on this PR; existing review threads were read only for the required duplicate-review and CI-status claim-check, never used to anchor a finding — all findings above were reached blind by independent fan-out workers or by this driver's own direct verification.
Not a human review. This is an automated code review; please verify findings independently before acting on them.
…art a second Windows query detect_cpu_model had a Windows arm that no production path reached: its only caller hands it to summary_cpu as the non-Windows reader, and on Windows the summary reads the CPU row of the inventory it already holds. It was also the path that would have brought the duplicate PowerShell query back for whoever called it next. The arm, read_cpu_facts and read_windows_cpu_facts are gone, and detect_cpu_model answers None off Linux; the host check is an argument of a small helper, so detect_cpu_model_reads_nothing_off_linux shows on any host that the reader is never called when it is false, and goes red when the check is dropped. The host-probing note now says that native Windows runs the system query twice in one rocm examine --json (the summary's inventory and probe_cpu_windows) and why the two are not shared within a run, and why the summary's RAM keeps its own fallback query while the CPU dropped it: detect_system_ram_gib is a public reader that model_fit calls with no inventory, and changing the summary's RAM is a behaviour change for a fact this change does not touch. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The changed PowerShell runner and timeout behavior require native Windows validation, since injected-output tests and cross-compilation do not cover real execution or slow and hung queries.
No open issues 🎉
Review effort: Balanced
…t-probing Conflicts, all of the kind where both sides added next to each other: the examine scenarios (main now ends at examine-44 with the kfd and kernel-release scenarios, so this change's three are examine-45 to examine-47), the examine step definitions, the test modules of host_env.rs and os_facts.rs, the imports of host_gpu.rs (detect_kernel_version is crate-visible on main) and the host-probing and architecture notes, which now record three delivered pairs. The two repo-scan tests keep main's host-root locks and drop this branch's duplicates, which deadlocked against them. Signed-off-by: Jussi Elo <jussi.elo@amd.com>
nowycondro
left a comment
There was a problem hiding this comment.
🤖 Automated review · review-code · head 27a5d64
Review — needs work
Full review of the whole change (10 files, +936/-108), 227968dc…27a5d64. Closes ROCMAI-924 (an internal tracker reference; not retrieved here to keep internal ticket content out of a public review — the relationship is stated from the PR description alone, which was cross-checked against the diff by an independent fan-out pass and found accurate throughout, including every timeout value, test name and scenario id it cites).
This is a re-review: the head advanced from aac07b4 (reviewed earlier today) to 27a5d64 with one further commit ("make detect_cpu_model Linux-only so it cannot start a second Windows query"), so the whole diff was re-read rather than narrowed. That commit is the fix for the previous round's blocking finding (read_windows_cpu_facts() was dead code). Verified directly: an exhaustive repo-wide search confirms read_windows_cpu_facts no longer exists anywhere, detect_cpu_model() is now Linux-only (linux_cpu_model(runtime_is_linux(), read_linux_cpu_facts)), and its only production caller (summary_cpu in host_gpu.rs) never invokes it on the Windows branch — the finding is resolved, cleanly, with no new regression introduced by the fix.
Blocking
- The PR currently has merge conflicts with
mainand cannot be merged as-is — verified live:gh pr view 998 --json mergeable,mergeStateStatusreturns"mergeable":"CONFLICTING","mergeStateStatus":"DIRTY"against the current head.mainhas advanced 22 commits past this PR's merge-base (227968dc→cf20ee10) since this branch was cut, including a sibling convergence change already merged tomain("one kernel-release read for the summary and the examination stacks (#990)") that is the next item in this PR's owndocs/host-probing.mdtask list and very plausibly touches the same regions ofos_facts.rs/host_env.rs/docs/host-probing.md/docs/architecture.mdthis PR also edits.
Confidence 100 · architectural · Fix: rebase onto currentmainand resolve the conflicts (most likely concentrated inos_facts.rs,host_env.rs, and the twodocs/files, given the overlapping convergence work in #990).
Non-blocking
- New prose in
docs/host-probing.md's "Decided and delivered" section cites real tracked files with bare backtick mentions instead of the relative markdown links this repo'sAGENTS.md§5 requires (e.g. "the unit tests are inos_facts.rs,host_gpu.rsandhost_env.rs", "separate calls inexamine_cmd.rs") — each of these files is linked properly elsewhere in the very same document, so the convention is known and simply not applied to this new text. Mitigating: the same style already exists, pre-PR, in the doc's earlier "PATH lookup" section, so this mirrors an existing pattern rather than inventing a new deviation — butAGENTS.md's own "does not inherit bad patterns" standard says new text should still use the correct form.
Confidence 85 · mechanical · Fix: convert the four bare mentions to[text](relative/path)links, consistent with the rest of the file. - One combinatorial state of the new shared Linux parser (
cpu_facts_from_cpuinfo) has no test: avendor_idline present with nomodel name/Hardwareline at all (vendor known, model never found). All 13 fixture cases across the two test functions pair "model found" with either vendor outcome, or pair "nothing found" with both absent, but none isolates "vendor found, model absent." Practical risk is low — real/proc/cpuinfoalways carries amodel nameorHardwareline on every architecture this parser handles — and the function's two per-fieldifblocks are independent and already individually exercised, so this is a coverage gap rather than a likely latent bug.
Confidence 70 · logic · Fix: add one moreCpuinfoCasewith avendor_idline and no model line, assertingmodel: Nonealongside the known vendor.
Decisions for the author
- Unifying the Windows system-inventory timeout to 5 s (from the summary's previous 1.5 s) widens the "hung PowerShell" worst case to every command path that builds a host summary, not just
rocm examine— answered-by-intent
docs/host-probing.md: "8 s was not taken for the shared query because it would also be the worst case of every startup path that gathers the summary on a host whose PowerShell hangs. Neither number was measured: UNCONFIRMED on a real Windows host." Confirmed call sites ofExamineSummary::gather/gather_without_driver_factsbeyondrocm examine:driver_install.rs,freeform_answer.rs,chat/mcp_bridge.rs,runtime_install_finalize.rs, androcmd'shost_snapshot.rs/mcp.rs/sandbox.rs. Would otherwise have been a tradeoff finding (consistency/correctness vs. worst-case latency on a slow Windows host across several command paths). Confirm the 5 s choice is still deliberate for all of them. - The examination's Windows CPU read now goes through strict UTF-8 decoding and a multi-spelling PowerShell retry it didn't use before, unverified on real Windows hardware — answered-by-intent
docs/host-probing.md: "it reads the output as strict UTF-8 whererundecoded lossily, so a CPU name that is not valid UTF-8 reads as no CPU, and it tries each spelling ofpowershellafter a timeout whererunstarted it once ... neither is pinned because the helper is not injectable and needs a Windows host." Would otherwise be a non-blocking correctness/robustness finding (a non-UTF-8 CPU name silently regresses to "no CPU"). Confirm this is still acceptable given it can't be verified without Windows hardware.
Positive signals
- The previous round's dead-code finding is resolved precisely and minimally: the final commit removes exactly the orphaned Windows arm and nothing else, with its own regression test (
detect_cpu_model_reads_nothing_off_linux) that would go red if the host check were ever dropped again. - The Windows system-inventory output (
CPU\t.../RAM\t...) is parsed by matching each line against its own key, never by pairing two independently-ordered lists by position — correctly following this repo's ownAGENTS.mdrule against positional pairing. docs/host-probing.mdis unusually accurate: an independent pass checked every concrete claim in the new "CPU model"/"Decided and delivered" section (symbol names, timeout before/after values, the WSL-unchanged claim, every cited test and scenario name) against the code at head and found no mismatches.- The
HOST_ROOT_TEST_LOCKfix inrocm_install_probe.rsacquires the lock before the race-prone temp-directory work in both modified tests, is held through the scan under test, and carries no deadlock risk (the lock is never taken from production code, only from independent#[test]bodies). - The new e2e scenarios (
examine-39/40) are genuine convergence tests, verified to fail against the pre-PR per-stack readers (traced through the actual diff rather than taken on faith);examine-41is an honest, explicitly-labelled pin of unchanged WSL behaviour, not a disguised regression test.
Deployment notes
- On Windows, every path that gathers the host summary (not only
rocm examine) now waits up to 5 s instead of 1.5 s before concluding there's no CPU/RAM data on a host where PowerShell is slow or unresponsive — see the first "Decisions for the author" item. - No Windows host was available to this review (matching the PR's own disclosed gap); the
cfg(windows)production path is verified only by reading and by unit tests against injected closures. - CI is fully green on this exact head (
27a5d64f): all 38 reported check runs succeeded (build/test/clippy, Windows build+test+release lifecycle, all E2E lanes, all Security-scan sub-jobs includinggitleaks), plus 2 skipped (not applicable) and 1 additional status context (readthedocs) green — confirmed against the liveheadRefOid, which matches the commit reviewed. The merge-conflict finding above is a live-git-state fact, separate from CI.
What this covered
Full diff, 227968dc…27a5d64, all 10 changed files read completely across five independent fan-out passes (the shared CpuFacts reader and Windows system-inventory query in os_facts.rs/windows_inventory.rs/host_gpu.rs/examine.rs; the examination stack and host-root test-lock pair in host_env.rs/rocm_install_probe.rs; the e2e feature and step definitions; a docs-accuracy pass cross-checking every factual claim in docs/host-probing.md/docs/architecture.md against the code; and an AGENTS.md-adherence-plus-history pass), plus this driver's own direct verification (repository-wide call-graph tracing for the previous round's dead-code finding, live CI-status query, live mergeability query, and a full read of the diff and the repo's AGENTS.md).
Did not run cargo build/test/clippy locally (no toolchain in this environment); relied on CI's green result for that, confirmed against the live head commit. Declined to retrieve the internal Jira ticket ROCMAI-924, to keep internal tracker content out of a public review. Not reconciled against the discussion on this PR; prior review threads were read only for the required duplicate-review claim-check (confirming no review already existed at this exact head), never used to anchor a finding — every finding above was reached blind by independent fan-out workers or by this driver's own direct verification.
Not a human review. This is an automated code review; please verify findings independently before acting on them.
There was a problem hiding this comment.
🔵 Needs a closer look
Native Windows validation is needed to confirm live PowerShell CPU/RAM reporting and startup latency under slow or failing queries, since injected-query tests and cross-compilation do not exercise the changed subprocess and timeout behavior.
No open issues 🎉
Review effort: Balanced
nowycondro
left a comment
There was a problem hiding this comment.
🤖 Automated review · review-code · head e480a32
Review — no blocking findings
Full review of the whole change (9 files, +923/-110), cf20ee10…e480a326 (merge-base is current main's tip, since this head is itself a merge of origin/main). Closes ROCMAI-924 (an internal tracker reference; not retrieved here to keep internal ticket content out of a public review — the relationship is stated from the PR description alone: this implements pair 3 of 6 in the host-probing convergence note, one shared CPU model-and-vendor reader for the summary and examination stacks).
This is a re-review: the head advanced from 27a5d64 via a merge commit ("Merge origin/main into refactor-one-cpu-model-and-vendor-read-for-host-probing"). The previous round's reported blocking finding was a live merge conflict with main. Verified directly rather than assumed: a read-only git merge-tree --write-tree between the current main tip and this PR's head completes cleanly (no conflict markers, exit 0), and GitHub's own gh pr view --json mergeable had not finished recomputing at review time (UNKNOWN) — the local merge-tree check is the authoritative result here and shows the conflict is resolved.
Blocking
None.
Non-blocking
- New prose added by this PR in
docs/host-probing.mdcites a real tracked file (examine_cmd.rs) with a bare backtick mention instead of the relative markdown linkAGENTS.md§5 requires for "citations you add or edit" —docs/host-probing.md:135: "...by separate calls inexamine_cmd.rsthat pass nothing between them...". The same file is correctly linked elsewhere in this exact document (docs/host-probing.md:37:[examine_cmd.rs](../apps/rocm/src/examine_cmd.rs)), so the convention is known and simply wasn't applied to this new sentence.AGENTS.md's stated reason is thatlychee/docs-linkscan catch a moved or deleted link target but cannot see a bare path go stale.
Confidence 85 · mechanical · Fix: convert the bare mention to a relative markdown link, consistent with the rest of the file.
Decisions for the author
- Unifying the Windows system-inventory timeout to 5 s (from the summary's previous 1.5 s) widens the "hung PowerShell" worst case to every command path that builds a host summary, not just
rocm examine— tradeoff
The PR body states this directly and explains why 8 s wasn't taken either ("it would also be the worst case of every startup path that gathers the summary on a host whose PowerShell hangs. Neither number was measured."). This affects every caller ofExamineSummary::gather/gather_without_driver_facts, not onlyexamineitself. Reasonable either way; worth confirming the 5 s choice is still deliberate for all call sites now that it's landing. - On native Windows, one
rocm examine --jsonrun still queries the system inventory twice (once for the summary, once for the examination) rather than sharing one answer — tradeoff
Explicitly called out as an open question in the PR's own host-probing note ("sharing the answer means choosing which stack owns it"), deferred rather than solved here. Reasonable scope boundary for this PR; flagging only so it isn't lost as a follow-up.
Positive signals
- The WSL early-return path in
Examination::probe_with_interpreteris verified byte-identical to before the refactor (confirmed directly against the diff — the only change toexamine.rsitself is two added#[cfg(test)]re-export lines), so the one behavior explicitly meant to stay untouched demonstrably did. HOST_ROOT_TEST_LOCKis correctly and non-reentrantly reused by the new host-root-simulating tests (traced every lock site repo-wide): no production code path takes it, and env-var restoration happens before the lock is released, closing the race the new longer-running CPU tests would otherwise introduce.cpu_facts_from_cpuinfo's single-pass Linux parser (first matchingmodel name/Hardwareline wins regardless of order; a blankvendor_idis skipped rather than locked in) is correct by direct trace and is the one piece of logic genuinely shared, unit-tested, and now also exercised end-to-end by three new Gherkin scenarios that plant a real/proc/cpuinfoand assert exact output tuples rather than loose substring checks.- The Windows query-wiring sits behind injectable closures (
windows_cpu_facts_with,probe_cpu_windows_with) exactly per this repo's own "platform-gated code needs an injectable helper" convention, and a dedicated test (windows_both_reads_are_given_the_same_time) ties both call sites to one shared timeout constant so they can't silently drift apart again. docs/host-probing.md's new section is unusually accurate: an independent pass cross-checked every specific claim in it (function names, before/after timeout values, cited test names, scenario ids, the exactprobe_failureswording) against the code at this head and found no mismatches.
Deployment notes
- On Windows, every path that gathers the host summary (not only
rocm examine) now waits up to 5 s instead of 1.5 s before concluding there's no CPU/RAM data on a host where PowerShell is slow or unresponsive — see the first "Decisions for the author" item. - No Windows host was available to this review (matching the PR's own disclosed gap); the
cfg(windows)production path is verified only by reading and by unit tests against injected closures. - CI is fully green on this exact head (
e480a326): all 40 reported check runs succeeded or were appropriately skipped (build/test/clippy, Windows build+test+release lifecycle, all E2E lanes, all Security-scan sub-jobs includinggitleaks). The PR's merge-conflict status (see opening note) is a separate, live-git-state fact from CI, and was independently verified to be resolved.
What this covered
Full diff, cf20ee10…e480a326, all 9 changed files read completely across four independent fan-out passes (the shared CpuFacts reader, Windows system-inventory query and summary plumbing in os_facts.rs/windows_inventory.rs/host_gpu.rs; the examination stack in examine.rs/examine/host_env.rs; the e2e feature and step definitions; a docs-accuracy-plus-AGENTS.md-adherence-plus-history pass over docs/host-probing.md/docs/architecture.md), plus this driver's own direct verification: a read-only git merge-tree mergeability check against the current main tip, a live CI check-run query, and direct cross-checks of the one surviving finding and the two tradeoff items against AGENTS.md and the PR body respectively.
Did not run cargo build/test/clippy locally (no toolchain in this environment); relied on CI's green result for that. Declined to retrieve the internal Jira ticket ROCMAI-924, to keep internal tracker content out of a public review. Not reconciled against the discussion on this PR; prior review threads were read only for the required duplicate-review claim-check (confirming no automated review already existed at this exact head) and to know what the previous round's blocking finding had been, so that this round could independently verify its resolution rather than assume it — never used to anchor any finding above; every finding was reached blind by independent fan-out workers or by this driver's own direct verification.
Not a human review. This is an automated code review; please verify findings independently before acting on them.
Closes ROCMAI-924.
What and why
rocm examine --jsonread the CPU twice, through two separate implementations: the host summary (summary.cpu, thecpu:line of the text) throughdetect_cpu_modeland the Windows inventory's CPU row, and the examination (cpu_model,cpu_vendor) throughprobe_cpu_linuxandprobe_cpu_windows. On Windows that was two or three PowerShell queries for one fact in one--jsonrun. It is two now: the system query runs once in the summary's inventory and once inprobe_cpu_windows, and the two are not shared within a run because the examination is built first and the summary after it by separate calls that pass nothing between them, and sharing means choosing which stack owns the answer, which is left open in the note ("Whether onerocm examine --jsonrun shares answers between the stacks"). This change removes the third read and the second implementation; it does not claim one query. The two could spell the same model differently, and a board whose cpuinfo has aHardwareline and nomodel nameshowed a CPU in the text and an emptycpu_modelin the JSON. This is pair 3 of 6 in the host-probing note (docs/host-probing.md): one reader returns the model and the vendor together, and both stacks call it.read_cpu_factsinhost_gpu/os_facts.rsreturns aCpuFacts(the model, or none, and the vendor). On Linux it reads/proc/cpuinfothroughhost_path(firstmodel nameorHardwareline with a value, firstvendor_idwith a value). On Windows it runs the CPU-and-RAM query of the system inventory and takes its CPU row, deriving the vendor from the model string asprobe_cpu_windowsdid.probe_cpu_linuxandprobe_cpu_windowsrecord its answer,detect_cpu_modelis its model, and the summary on Windows reads the CPU row of the inventory it already holds. Both separateWin32_ProcessorPowerShell queries are gone.WSL: option (a)
The WSL early return in
Examination::probe_with_interpreterstays, so on WSLcpu_modelis still empty andcpu_vendorstillunknownwhile the summary shows the CPU. Thesummary.cpuversuscpu_modelcomparison is scoped to hosts whereis_wslis false, and the empty WSL fields are pinned as an existing difference (see below), so collecting CPU facts on WSL (option (b)) is a visible change of its own that turns the pins.Decisions
cpu_model, so the model is one string in both forms. Nothing diagnoses fromcpu_modelorcpu_vendor(grep of the crates); they reach the JSON and Doctor reports only.Hardwarevalue is the model and the vendor staysunknown, since such a file names none. The model is the first line of either kind, as the summary always had it.<unknown>in the text,nullinsummary.cpu) and an emptycpu_modelwithcpu_vendorunknownin the examination, as before. Avendor_idline with no value names no vendor. On Linux a cpuinfo with no CPU is not aprobe_failuresentry, as before. On Windows the examination still records aprobe_failuresentry for a read that gives no CPU, now worded for the query that runs (The Windows system inventory query (CPU and RAM) reported no CPU; cannot identify CPU., where it named aWin32_Processorquery that no longer runs) and fired for any read with no CPU.--jsonrun, on a PowerShell that has not started yet, so a spurious emptycpu_modelwith aprobe_failuresentry costs more than waiting, and 8 s was not taken for the shared query because it would also be the worst case of every startup path that gathers the summary on a host whose PowerShell hangs. Neither number was measured.detect_system_ram_gibis a public reader thatmodel_fitcalls with no inventory at all, so its Windows query must exist, and changing what the summary shows for RAM is a behaviour change for a fact this PR does not touch; dropping that fallback is a follow-up.Win32_Processorquery of its own, but an absent inventory means every source, the system query included, had just failed, so the second try repeated a failed query. Keeping it would have kept a second Windows implementation.User-visible differences, each with the test that pins it
cpu_modelwith repeated spaces inside the model: the summary collapsed and the examination trimmed only; both collapse now (Linux and Windows).linux_cpuinfo_the_inputs_the_two_reads_used_to_disagree_on,windows_both_reads_collapse_whitespace_inside_the_name,cpu_reads_follow_the_simulated_host_root, scenarioexamine-45.Hardwareline and nomodel name: the summary read it and the examination had an emptycpu_model; both read it now, vendorunknown.linux_cpuinfo_the_inputs_the_two_reads_used_to_disagree_on, scenarioexamine-46.Hardwarebeforemodel name(a fixture; real cpuinfo printsHardwareafter the per-core blocks): the examination read themodel name, now it reads theHardwarevalue like the summary.linux_cpuinfo_the_inputs_the_two_reads_used_to_disagree_on.vendor_idvalue: the examination took""as the vendor and stopped looking; it is not a vendor now, the nextvendor_idis read, elseunknown.linux_cpuinfo_the_inputs_the_two_reads_used_to_disagree_on.Win32_Processoralone throughrunwith 8 s; now the system inventory query (CPU and RAM) with 5 s.windows_both_reads_are_given_the_same_time.windows_both_reads_are_given_the_same_time.<unknown>now and starts no second query.windows_an_answer_with_no_cpu_is_no_cpu_in_both_reads,the_summary_cpu_comes_from_the_windows_inventory_or_not_at_all.Win32_Processor) only for a non-zero exit or blank output before; an entry naming the inventory query, for any read with no CPU, now.windows_an_answer_with_no_cpu_is_no_cpu_in_both_readsasserts the message together with the empty model, the unknown vendor and the single entry, andprobe_cpu_windows_runs_the_inventory_query_and_reports_no_cpu_without_oneasserts it fromprobe_cpu_windowsitself.rundecoded lossily, so a CPU name that is not valid UTF-8 reads as no CPU, and it tries each spelling ofpowershellafter a timeout whererunstarted it once, so a hung PowerShell can cost the examination more than one limit. The candidate loop belongs to the subprocess-runners pair and the summary's inventory already had it.on_wsl_the_summary_reads_the_cpu_and_the_examination_does_not, scenarioexamine-47.Scenarios and lanes
New scenarios in
examine.feature:examine-45(idexamine-reports-one-cpu-in-both-forms),examine-46(idexamine-reports-a-hardware-line-cpu-in-both-forms) andexamine-47(idexamine-reports-no-cpu-model-on-wsl-where-the-summary-has-one). Each plants a/proc/cpuinfounder a simulated host root in ane2e-test-hooksbuild and asserts the specific values ofsummary.cpu,cpu_model,cpu_vendorandis_wslfrom one--jsonrun. They are@requires-os:linuxand run on every Linux lane, native or WSL, since the planted root decides whether the machine reads as WSL. Native Windows reads the CPU through the inventory and cannot run them; its cases are unit tests behind an injectable query (windows_cpu_facts_with), which are not platform-gated and so run on the Windows job too. The scenario numbers follow the last scenario on main (examine-44: the kfd and amdgpu scenarios 39 to 42 and the kernel-release scenarios 43 and 44), so these areexamine-45toexamine-47, in sequence asfeature_namingrequires. The bounded-subprocess PR follows and takes the next numbers after these; whichever of the two merges second renumbers with a one-linesedoverexamine.featureanddocs/host-probing.md(and this body) plus afeature_namingrun. The ids are slugs, so they do not collide.README,
docs/testing.mdanddocs/manual-testing.mdneeded no change: no flag, default or command changed, and nothing outsidedocs/host-probing.mdstates a claim aboutcpu_modelor the CPU reads.docs/host-probing.mdrecords the decisions and the table above, anddocs/architecture.mdhas the entries foros_facts.rs,windows_inventory.rsandhost_env.rsupdated.Commits
The branch has seven commits and a merge of
origin/main. The first takes the host-root lock in two existing repo-scan tests that read throughhost_path: they race with any test that sets the simulated root and failed in most full runs with thee2e-test-hooksfeature once the WSL test below ran a whole examination under the root (4 of 4 full runs red before, 4 of 4 green after). The second adds the characterisation tests, green against the unchanged behaviour, pinning what each copy returns for the same input and each copy's own answer where they differ; it adds only injectable seams (a pure function over cpuinfo text, injected Windows queries). The third is the convergence and flips exactly the assertions in the list above. The fourth adds the scenarios, the fifth the note, the sixth is a review fix: it renames the Windows failure entry after the query that runs and passes the examination's PowerShell runner through an injectableprobe_cpu_windows_with, and the seventh removes the Windows armdetect_cpu_modelhad, which nothing reached in production and which would have brought the second query back (detect_cpu_modelanswersNoneoff Linux now;detect_cpu_model_reads_nothing_off_linuxgoes red if the host check is dropped).Mutation checks
Each new test was shown red by breaking the code it covers, then restored by a targeted edit. Removing the
Hardwarefallback, trimming instead of collapsing, and not skipping an emptyvendor_idturnedlinux_cpuinfo_the_inputs_the_two_reads_used_to_disagree_onred (the trim also turnedcpu_reads_follow_the_simulated_host_rootred). Changing the shared Windows timeout to 1.5 s turnedwindows_both_reads_are_given_the_same_timered. Swapping the Windows vendor test turned three Windows tests red. Inverting the failure entry turnedwindows_both_reads_report_the_name_the_query_returnsandwindows_an_answer_with_no_cpu_is_no_cpu_in_both_readsred. Reverting the failure message to the old wording turnedwindows_an_answer_with_no_cpu_is_no_cpu_in_both_readsred, and replacing the runnerprobe_cpu_windowspasses with a canned answer turnedprobe_cpu_windows_runs_the_inventory_query_and_reports_no_cpu_without_onered. Reintroducing the summary's fallback turnedthe_summary_cpu_comes_from_the_windows_inventory_or_not_at_allred. Reading cpuinfo withouthost_pathturned both host-root tests red. Emptyingprobe_cpu_linuxturnedcpu_reads_follow_the_simulated_host_rootred and, with a rebuilt binary, scenarios 45 and 46 red (47 stayed green). Callingprobe_cpu_linuxfrom the WSL branch turnedon_wsl_the_summary_reads_the_cpu_and_the_examination_does_notand scenario 45 red (43 and 44 stayed green). Restoring the examination's file from the characterisation commit turned scenarios 45 and 46 red with the old values (AMD Ryzen 9 9950X 16-Core Processorand an empty model) and left 45 green.Not run
No Windows host was available, so nothing here ran on Windows.
cargo clippy --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warningstype-checks clean with stand-in C compiler and archiver scripts for the build scripts, so thecfg(windows)code compiles and lints; nothing was linked or run. What no test reaches is the live PowerShell runnerprobe_cpu_windowspasses and theruntime_is_windows()argumentsummary_cpuis called with: the logic behind both is driven by injected queries on every host and on the Windows job, and only the one-argument wiring is covered by the Windows job compiling (off Windows a test runsprobe_cpu_windowsitself and pins that it reports no CPU). The live PowerShell command line, the timing claims and the real behaviour of the Windows reads on a slow host are UNCONFIRMED. The workspace-wide test run,scripts/smoke_local.pyand the coverage floors were not run locally; the crates and targets touched were (rocm-corewith and withoute2e-test-hooks, the e2e crate, xtaskprepush,feature_naming, the architecture-doc, crate-edge and manifest checks, and the new scenarios through the real harness against a debugrocmbuilt withrocm/e2e-test-hooks).Renumbering note: this PR's three scenarios were
examine-39,examine-40andexamine-41when first opened and areexamine-45,examine-46andexamine-47now, because main tookexamine-39toexamine-44in the meantime (the kfd and amdgpu scenarios, then the kernel-release ones). Only the numbers in the scenario titles and indocs/host-probing.mdand the feature comments changed; the@id:slugs, the step definitions and the behaviour are unchanged. The numbers stay provisional until the bounded-subprocess PR lands.The first commit (a host-root lock in two repo-scan tests) was independently made by the merged kfd change; merging both would deadlock those tests (the lock is not reentrant), so the merge keeps main's copies and those tests equal
origin/main. The first commit is therefore a no-op against main; it is left in history rather than rewriting reviewed commits. The branch also mergesorigin/mainafter the kernel-release PR landed: the host-probing note now records three delivered pairs.