Repository navigation
Conversation
b639c54 to
454ceb3
Compare
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. |
454ceb3 to
64ee7cb
Compare
nowycondro
left a comment
There was a problem hiding this comment.
🤖 Automated review · review-code · head bdfea70
Review — needs work
Full review of the whole change (two commits, b839fa8…bdfea70).
Fixes #531 in full (protected-location refusal + loud shared-cache warning) and goes further (home reached via a symlinked parent, ./..-relative spellings, an ownership-marker requirement) than the issue's bare ask; also tracked under ROCMAI-465.
Blocking
-
Windows protected-root list is stale vs. its own new sibling, leaving
runtimes uninstall/storage remove-old-installsunder-protected on non-C:systems —crates/rocm-core/src/runtime.rs:830-839,crates/rocm-core/src/runtime.rs:923-933
system_roots()backsruntime_protected_location/runtime_protected_location_for_home, which gates the realfs::remove_dir_allinapps/rocm/src/runtime_uninstall.rs:445(ensure_runtime_install_root_is_safe_to_remove_for_home) andapps/rocm/src/storage.rs:896(build_prune_plan) — i.e.rocm runtimes uninstallandrocm storage remove-old-installs. It hardcodes["C:/Windows", "C:/Program Files", "C:/Program Files (x86)"]and ignores the system drive. Its sibling,uninstall_system_roots_on(), added in this same commit to gate the newrocm uninstallconfig/data/cache check, takes asystem_driveparameter and adds"ProgramData". Confirmed via diff/blame: this PR touchedsystem_roots()itself (refactored from an inlineletinto aconst fn(platform)) without carrying over either fix, while adding a dedicated test (windows_roots_follow_the_system_drive) proving the drive/ProgramDatagap mattered enough to close in the sibling function. On a Windows host whose system drive isn'tC:(not unusual on managed/imaged machines), or forC:\ProgramDataon any host,rocm runtimes uninstall/rocm storage remove-old-installswill fail to recognize a real system folder as protected.
Confidence 95 · architectural · Fix: threadsystem_drivethroughsystem_roots()(or have its Windows arm calluninstall_system_roots_on), and add"ProgramData". -
uninstall_root_verdict's doc comment states a check order that contradicts the code, and omits a whole refusal category —crates/rocm-core/src/runtime.rs:985-990(doc) vs:1013-1034(code)
The doc says: "In order:/... is refused; the user's own home is refused ...; the [uninstall_system_roots] ... are refused ...; another user's home ... is refused; anything else needs the marker" — home before system-roots. The code checks system roots first (lines 1019-1026), with its own comment explaining why:// Before the home allowance, so a home inside a system location (an odd HOME such as /usr/sbin) does not open that location up.The doc's ordered list also never mentionsProtectedLocation::SharedTopLevel, a real branch at lines 1032-1034.
Confidence 90 · mechanical · Fix: rewrite the doc to the real order (filesystem-root → system-roots → home → SharedTopLevel → other-users'-home → marker) and add the missingSharedTopLevelstep.
Non-blocking
- Two sibling protected-location predicates in the same file now deliberately disagree on system-root-vs-home precedence (
protected_location_on, used byruntimes uninstall/storageprune, checks home first;uninstall_root_verdict_on, used by the newrocm uninstallguard, checks system-roots first), with nothing cross-referencing why only one was hardened —crates/rocm-core/src/runtime.rs:869-887vs:1005-1043. Confidence 70 · architectural. judge_uninstall_root's ownership-marker check usesPath::is_file(), which follows symlinks, so a symlinked.rocm-cli-rootpointing at any existing regular file elsewhere would satisfy "this folder is ROCm CLI's own" without ROCm CLI having written it there —apps/rocm/src/uninstall_plan.rs:346-347. Narrow (needs pre-existing write access inside the target folder) and untested either way. Confidence 70 · logic.homes_parents_onresolves paths via plainPath::parent()rather than the lexically-resolved text (comparable_runtime_path_text) used elsewhere in the same file for comparisons —crates/rocm-core/src/runtime.rs:963-981. The identified worst case is under-, not over-, protection (falling toNeedsMarkerinstead of a refusal). Confidence 70 · logic.- The
--keep-binaries/--keep-config/--keep-data/--keep-cache/--force-dev-binariesflag spellings are duplicated as literal strings betweencrates/rocm-dash-tui/src/app/slash.rs:244-251andapps/rocm/src/cli.rs/apps/rocm/src/uninstall_plan.rs, with no shared constant tying them together — a future--keep-<newkind>flag could silently fail to reach the dashboard. Confidence 75 · mechanical. - An existing (not just new) e2e scenario's
config_gonestep was weakened fromsymlink_metadata(&config).is_err()to!config.exists()as a side effect of this PR's refactor —exists()follows symlinks and reportsfalsefor a dangling symlink too, so a bug that left the config folder as a dangling symlink rather than truly removing it would no longer be caught here —tests/e2e-cucumber/tests/e2e/uninstall_steps.rs:747-756. Confidence 70 · logic (test coverage). uninstall-18's "WILL BE DELETED" claim is only ever exercised with--dry-run; nothing in the e2e suite performs a real removal and then confirms the shared cache is actually gone —tests/e2e-cucumber/features/uninstall.feature:219-224,tests/e2e-cucumber/tests/e2e/uninstall_steps.rs:758-806. Per this repo's own AGENTS.md rule, an outcome claim needs the message and the resulting state asserted together. Confidence 70 · logic (test coverage).
Decisions for the author
- Unify the two protected-location predicates, or keep them deliberately separate? — tradeoff
protected_location_on/runtime_protected_location(home-before-system-roots) anduninstall_root_verdict_on(system-roots-before-home) now live side by side with different precedence and, until the Blocking finding above is fixed, different Windows coverage. Unifying would prevent this exact kind of drift from recurring; keeping them separate may still reflect a genuine semantic difference between a runtime install root and a config/data/cache root. Worth confirming which is intended. - Non-directory (file/symlink) roots skip the resolved-location check that real directories get — non-blocking-improvement
judge_uninstall_rootonly resolves and re-judges a root's real location when it is a directory ("the only kind removed recursively," per its own doc comment); a file or symlink root is judged solely by its spelling. The blast-radius argument for that scoping is reasonable, but it is untested and the asymmetry isn't called out as prominently as the directory case — consider a regression test for the file/symlink path too.
Positive signals
- The anti-spoofing check for the forwarded
ROCM_CLI_APP_PATH_SOURCESvalue validates it against the current value of its ownROCM_CLI_*_DIRvariable before trusting it, with a dedicated forged/stale-value test (crates/rocm-core/src/paths.rs, exercised fromapps/rocm/src/uninstall_plan.rs'sdiscover_with_sources_reads_the_real_environment_and_config). - The two-phase
recheck/execute_plandesign inapps/rocm/src/uninstall.rscorrectly handles nested roots (a cache folder inside a data folder) and a link/file swapped for a folder mid-prompt, each pinned by its own targeted regression test. - Refusal messages consistently derive from one shared
ProtectedLocation::describe()acrossrocm runtimes uninstall,rocm storage remove-old-installs, androcm uninstall, so the wording a user sees doesn't drift between commands. - Windows-specific logic is exercised via an injectable
RuntimePlatform/system_driveparameter rather thancfg(windows), so the Windows path is unit-tested on every CI host, not just the Windows lane. - SDK
--prefixmarking order is correct for both the tarball and uv-venv install paths, with a snapshot test proving a previously-marked prefix stays marked across a rebuild.
Deployment notes
This is an intentionally breaking safety change: a rocm uninstall that previously succeeded (silently emptying /, the home folder, or an unmarked folder outside home) will now be refused. Anyone with ROCM_CLI_DATA_DIR/ROCM_CLI_CACHE_DIR/setup.therock_venv pointed at such a location will see their next uninstall stop with a refusal and advice rather than complete — the PR body already calls this out, but it's worth carrying into release notes.
What this covered
Full review of the whole change: both commits, fanned out across coupled-file groups — crates/rocm-core/src/runtime.rs; crates/rocm-core/src/{paths,lib,config,confirm}.rs; apps/rocm/src/uninstall_plan.rs; apps/rocm/src/{uninstall,deletion_properties,runtime_uninstall,storage}.rs; apps/rocm/src/therock.rs+therock/fetch.rs+therock/python.rs+engines/vllm/src/install.rs; the dashboard/assistant pass-through plus README.md/docs/architecture.md/docs/manual-testing.md/docs/testing.md; and the e2e cucumber tests — plus a dedicated AGENTS.md mechanical-compliance pass. Each group was read completely (not just its diff hunks) along with the surrounding/calling code it needed. All 39 CI checks on this commit are green, including the module-size and architecture-doc gates. Both Blocking findings were independently re-verified by the consolidating reviewer directly against the current source (exact lines and git-blame/diff evidence cited above), not taken only on a sub-reviewer's word.
Did not run: a dedicated "prior changes" pass (whether review comments on earlier PRs touching these files apply here) — out of scope for this review, which was restricted to this single pull request. The "history" pass was done directly by the consolidating reviewer via git log/git blame on the most safety-critical files rather than as an independent fan-out worker; it found no sign that this exact protection was attempted and reverted before. Not reconciled against any PR discussion or review thread — there were none on this PR as of this review.
Not a human review. This is an automated code review; please verify findings independently before acting on them.
tomastola
left a comment
There was a problem hiding this comment.
Review: needs work
Full review of the whole change at bdfea70 (two commits). Implements #531 (protected-location refusal and the shared-cache warning) and goes further with resolved-location judging and the ownership marker. Two blocking findings, both about text that contradicts the code. The guard logic itself held up: I found no bypass of the new directory-root check, and the policy tests and the 117 rocm uninstall tests pass locally (see the end).
Blocking
-
Comments and docs this change wrote contradict the code beside them (mechanical, confidence 90). Each site, with the side that governs and why:
crates/rocm-core/src/runtime.rs:985-990documentsuninstall_root_verdictas:/, then the user's home, then system roots, then other users' homes, then marker. The code (runtime.rs:1013-1043) checks system roots before the home allowance, on purpose (its own comment at:1019-1020says why), and has aSharedTopLevelstep the doc never mentions. The code governs; the doc is the safety contract of a delete guard and should state the real order.crates/rocm-core/src/config.rs:1150-1166: the doc fora_config_save_that_cannot_publish_cleans_up_its_temp_fileis now glued onto the newthe_config_folder_a_save_creates_is_marked_and_an_existing_one_is_nottest, so the new test carries two docs and the real cleanup test has none. Move the new test above the old doc block.crates/rocm-core/src/runtime.rs:2022-2037: the "Properties: the recursive-delete guard" header now sits above the newcreate_marked_root_marks_only_what_it_creates...test instead of abovemod delete_guard_properties.apps/rocm/src/uninstall_plan.rs:14-22saysuninstall.rs"owns only" the PATH undo and the Windows self-delete, whileapps/rocm/src/uninstall.rs:16-17saysapply_uninstall_planlives there as "the one step that deletes".uninstall.rsgoverns: it is where the deletion is.tests/e2e-cucumber/features/uninstall.feature:148-150anduninstall_steps.rs:1221say the assistant's preview "takes no flags", butREADME.md:1790says the flags work in the assistant's preview, andrender_uninstall_dry_run_with(apps/rocm/src/uninstall_plan.rs:655-667) reads--keep-*and--force-dev-binaries. The code governs: the preview reads flags but its footer has no command to offer. Fix the feature and step comments (anddocs/testing.md's "no flag to offer" wording).docs/testing.md(theuninstall-16to-21paragraph) says each scenario asserts the message together with the resulting state.uninstall-16and-20are dry runs that assert no folder state, and-21plants a config folder it never checks. Narrow the claim or add the assertions (the latter also closes a coverage gap, see below).
Fix: correct each site as stated; none needs a code change.
-
The refusal message says ROCm CLI "never removes such a folder" for a folder it will remove once the marker exists (mechanical, confidence 80).
apps/rocm/src/uninstall_plan.rs:262and:743("Refused (ROCm CLI never removes these folders)") are printed for every refusal kind, includingNotMarked, whose own advice (:154-160) says to create.rocm-cli-rootand re-run, andcreating_the_advised_marker_clears_the_refusalshows that then removes it. The same sentence promises and withdraws. The advice and the test are the behaviour, so the message should derive its "never" clause from the protected kinds only (system, home, root) and say "not marked as ROCm CLI's own" forNotMarked. Note:186already words the home case well.
Non-blocking
Several are inline on the diff; the rest are here.
runtime_protected_location_for_home(used byrocm runtimes uninstallandrocm storage remove-old-installs) is still lexical, so$HOME/link -> /etcmakes$HOME/link/xremovable on those paths. Pre-existing and documented in the code, but this change splits the guard in two and leaves the weaker half on a recursive delete.crates/rocm-core/src/runtime.rs:809-860. Confidence 70 · architectural.- The runtime-folder rule and the new uninstall rule disagree about system roots, and a comment says they share a predicate. See the inline comment on
system_roots.apps/rocm/src/runtime_uninstall.rsdoc onensure_runtime_install_root_refuses_the_home_folder_by_nameis the comment to fix. Confidence 75 · architectural. - Windows verbatim paths (
\\?\C:\Windows,\\?\UNC\...) are not stripped bycomparable_runtime_path_text, so the runtime rule does not recognise them; onlyuninstall_plan.rs'scanonicalize_for_comparestrips the prefix.crates/rocm-core/src/runtime.rs:538-545,:1402. Pre-existing for the runtime rule. Confidence 60 · logic. - Several deletion property tests never run the changed execution path:
apps/rocm/src/deletion_properties.rs:976,:1011,:1070build a plan and loopremove_paththemselves, skippingrecheckand the binary partition;:1009,:1040,:1069,:1168use the process's real home. Onlyuninstall_case(:777) switched toapply_uninstall_plan. Confidence 65 · logic (test coverage). uninstall-21plants a config folder to show a refusal removes nothing else, but never asserts it survived; only the home file is checked.tests/e2e-cucumber/tests/e2e/uninstall_steps.rs(venv_is_home/dashboard_refusal_names_venv). Confidence 65 · logic (test coverage).uninstall-18anduninstall-20prove "WILL BE DELETED" and the marker only on a dry run; no e2e run deletes the shared cache or keeps it with--keep-cache. The AGENTS.md rule is message plus state; unit and property tests do cover warned-iff-deleted. See the inline comment. Confidence 55 · logic (test coverage).- A homed service account (
HOME=/var/lib/svc) makes a marked, legitimate/var/lib/rocm-clirefuse as "another user's home", because home's parent is treated as a folder of homes.crates/rocm-core/src/runtime.rs:1009-1018,:1043-1051. Confidence 45 · logic. - Behaviour is chosen by a display string:
entry.kind == SHELL_COMPLETIONS_KIND(apps/rocm/src/uninstall.rs:187), with"binary"a bare literal atuninstall.rs:180anduninstall_plan.rs:604;PlannedAs::Unchecked's doc (uninstall_plan.rs:95-97) says it is only forstorage, but fish completions and an unreadable binary use it too. Confidence 60 · mechanical. uninstall.rs:211-216,:257: a root renamed away during the prompt is still reported "removed". Confidence 45 · logic.apps/rocm/src/cli.rsandcrates/rocm-core/src/runtime.rssit at the module-size limit (production code ends at exactly 1,500 and 1,472 lines against a 1,500 cap), so the next addition fails the clippy gate. Consider moving the protected-location code out ofruntime.rsand theafter_helptext out ofcli.rs. Confidence 80 · architectural.cli.rs:700-705hand-lists the refused folders; only the EXAMPLES order is tested, so it can drift fromuninstall_system_roots. README's list also omits/mnt/wsl,/mnt/wslgand the unresolvable-folder refusal. Confidence 50 · mechanical.windows_system_driveispub used atcrates/rocm-core/src/lib.rs:237but nothing outsideruntime.rsuses it. Confidence 70 · mechanical.crates/rocm-dash-tui/src/app/slash.rs:236-258: an unrecognised--flag on/uninstallis dropped silently, so a typo such as--keep-datturns an intended keep into a full removal request (approval-gated, but the argv label is the only hint). See the inline comment. Confidence 60 · logic.- The PR currently conflicts with
main(apps/rocm/src/therock/python.rs,crates/rocm-core/config.rs,crates/rocm-core/paths.rs); thepython.rsone is two sides each appending tests, so keep both. The description's note about #568 and #299 already says merge order matters. discover_with_sources(crates/rocm-core/src/paths.rs:177-230) re-implements the override and venv decision thatdiscovermakes; the two can drift. Confidence 40 · architectural.
Decisions for the author
- Roots inside home never need the marker (
ROCM_CLI_DATA_DIR=~/Documentsis allowed and removed) and file/symlink roots are judged by spelling only (uninstall_plan.rs:313-317). The first is the documented design and keeps the common case frictionless; the second skips the resolved-parent check that directories get, so a file root reached through a symlinked parent is unlinked wherever it really is, but only that one file. Please confirm both are intended — tradeoff. - Unify the two protected-location predicates, or keep them separate? They now differ in precedence (home first vs system first) and in coverage. Unifying prevents drift; separate may reflect a real semantic difference between a runtime install root and a config/data/cache root — tradeoff.
Positive signals
create_marked_rootmakes the leaf withcreate_dirrather thancreate_dir_all, so a folder somebody else created a moment earlier is never marked, and a failed marker write degrades to a warning that fails safe.uninstall_root_verdict_onchecks system roots before the home allowance, so an oddHOMEsuch as/usr/sbincannot open a system location, and the caller judges resolved spellings too.ROCM_CLI_APP_PATH_SOURCESentries are honoured only while the matchingROCM_CLI_*_DIRstill names the same folder, which limits spoofing and stale values, with a forged-value test.- Refusal advice is built from the refused roots themselves and each piece of advice is followed in a test to prove it clears the refusal.
- The refusal runs before the prompt and again in
execute_plan, with the confirm closure injected to prove the order.
Deployment notes
Intentionally breaking safety change: a rocm uninstall that used to succeed on /, the home folder, or an unmarked folder outside home is now refused, with advice. Folders from earlier releases are unmarked, so anyone with ROCM_CLI_DATA_DIR, ROCM_CLI_CACHE_DIR or setup.therock_venv outside home must create the marker or pass --keep-<kind>. Worth carrying into release notes.
What this covered
Every changed file, read completely, split across four coupled-file groups (rocm-core policy; uninstall plan and execution; marker writers and plumbing; e2e tests and docs), reviewed from a local checkout of refs/pull/569/head at bdfea70 against b839fa8 (the merge base). The description and issue #531 were read after the findings were settled. Verified by reading: the order and wording findings above against the cited lines, and the marker and refusal behaviour against creating_the_advised_marker_clears_the_refusal.
Ran locally against bdfea70: cargo test -p rocm-core --lib (1361 passed, 0 failed) and cargo test -p rocm uninstall (117 passed, 0 failed). Not run: the e2e cucumber suite, rocm storage and runtimes uninstall tests, anything Windows. Every CI check reported on this commit is green (the skill-checks job was skipped). Test verdicts were by reading, not by mutation runs, so "each test was shown red with its guard removed" from the description is not independently confirmed.
Did not run: a prior-changes pass. This review was written with the existing review thread in view (an earlier automated review of the same head); its findings were not used to scope the workers.
| ] | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Non-blocking: system_roots() still hardcodes C:/Windows, C:/Program Files* and has no ProgramData, while its new sibling uninstall_system_roots_on follows the system drive and adds ProgramData, /run, /media, /snap and the WSL roots. rocm runtimes uninstall and rocm storage remove-old-installs therefore stay under-protected on a non-C: Windows host, and the comment in runtime_uninstall.rs that says the two share a predicate is not true. Either make both consult one table, or say why they differ.
There was a problem hiding this comment.
Fixed in e7472d4. On Windows the runtime-folder rule now uses rocm uninstall's own list on the system drive (Windows, Program Files, Program Files (x86), ProgramData), so a non-C: system is covered; the_runtime_rule_refuses_the_windows_system_folders_on_the_system_drive pins it and fails with the old list. The Unix lists still differ, on purpose: the runtime rule refuses all of /opt and /var (a runtime prefix there is the system's), while rocm uninstall refuses only their top level and lets a marked folder below them go. That is now said beside system_roots, and the test comment in runtime_uninstall.rs no longer claims the two share one predicate.
| return RootJudgment::Remove { | ||
| planned: PlannedAs::non_dir(path, metadata, canonicalize), | ||
| }; | ||
| } |
There was a problem hiding this comment.
Non-blocking: a file or symlink root is judged by its spelling only. If ~/x is a link to /etc and the root is ~/x/config.json, the spelling check passes as "inside home" and only that file is unlinked, wherever it really is. The --help text in cli.rs also says outside home only a marked folder is removed, which this branch does not do. Either judge the resolved parent for non-directories too, or narrow the help text.
There was a problem hiding this comment.
Not changed in e7472d4, and I'd like your call on it. A non-directory root is unlinked, never walked, so the most a link-reached file root can cost is that one entry; judging the resolved parent would also refuse a cache root that is itself a link the user made on purpose (uninstall-01/-02 unlink exactly that). The help text speaks of folders, which a file or link root is not, so I left it; cli.rs is at the 1,500-line limit, which is why I did not add a sentence there. If you prefer resolving the parent for non-directories, I'll do that in a follow-up.
There was a problem hiding this comment.
Changed in 15b6bd8 after all: the newer automated review raised the same case as blocking. A file or link root is now judged by where its folder really is, under its own name. So ~/x/config.json with ~/x -> /etc is refused as /etc/config.json.
A root that is itself a link is still only unlinked: only its folder is resolved, so uninstall-01/-02 are unchanged. a_link_root_pointing_at_a_system_location_is_planned_as_the_link pins that.
uninstall-22 (Linux) refuses a data setting naming a file through a home-folder link to /proc and leaves everything in place. The --help text needed no change.
| ) { | ||
| UninstallRootVerdict::Refused(why) => refuse(why), | ||
| UninstallRootVerdict::NeedsMarker | ||
| if !resolved.join(rocm_core::ROCM_CLI_ROOT_MARKER).is_file() => |
There was a problem hiding this comment.
Non-blocking: .is_file() follows symlinks, so a symlinked .rocm-cli-root pointing at any regular file counts as ROCm CLI's marker. Needs write access inside the folder already, so low impact, but symlink_metadata().is_file() costs nothing.
There was a problem hiding this comment.
Fixed in e7472d4: the marker counts only when symlink_metadata says it is a plain file (is_root_marker). a_linked_marker_does_not_mark_a_folder plants a link named like the marker and fails if the check follows it.
| if !real { | ||
| argv.push("--dry-run"); | ||
| } | ||
| let label = argv.join(" "); |
There was a problem hiding this comment.
Non-blocking: the flag passthrough is an exact-match allowlist, so a typo such as --keep-dat or --Keep-data is dropped without a word and the approved command is a full uninstall. Reject any unrecognised -- token with the same guided error the conflicting-flags branch gives, dedupe repeats, and add an unknown-flag case to the test.
There was a problem hiding this comment.
Fixed in e7472d4: any flag other than --dry-run, --apply and the five passed through is refused with a guided error naming the flags it takes, so --keep-dat raises no request; a repeated flag is passed once. Both cases are in slash_uninstall_passes_keep_flags_through, and each goes red with its guard removed.
| Given the cache folder is set to the user's own cache folder, which holds the uv and model caches | ||
| When the user previews an uninstall | ||
| Then the review warns that the uv and model caches will be deleted with the cache folder | ||
| And the uv cache is still there after the preview |
There was a problem hiding this comment.
Non-blocking: this scenario proves "WILL BE DELETED" only on a preview, so nothing at e2e level shows the cache actually deleted, or kept with --keep-cache. AGENTS.md asks for the message and the resulting state together; add a real run (and one with --keep-cache). uninstall-20 has the same shape for the marker.
There was a problem hiding this comment.
Fixed for uninstall-18 in e7472d4: after the preview it runs the uninstall with --keep-cache (the uv cache is still there) and then without it (the cache folder is gone). uninstall-20 still stops at the preview; the marker clearing a real removal is covered at unit level by creating_the_advised_marker_clears_the_refusal, not end to end.
| async fn config_gone(world: &mut E2eWorld) { | ||
| let config = config_dir(world); | ||
| assert!( | ||
| !config.exists(), |
There was a problem hiding this comment.
Non-blocking: main used symlink_metadata(&config).is_err() here. !config.exists() follows symlinks and reads a dangling link as gone, so a bug that leaves the config folder as a dangling symlink would no longer fail this step. Restoring symlink_metadata keeps the old strength.
There was a problem hiding this comment.
Fixed in e7472d4: config_gone uses symlink_metadata(..).is_err() again.
bdfea70 to
036ae53
Compare
…arker elsewhere `rocm uninstall` had no protected-location check: ROCM_CLI_DATA_DIR=/ or an SDK installed with `--prefix ~` could make it remove `/` or the home folder, and so could a home folder spelled as `.` or reached through a symlinked parent. Each config, data and cache root is now judged both as written and by where it really is. The filesystem root, system folders, folders other programs share, the home folder, anything containing it and other users' homes are refused; anything inside the user's own home is allowed; any other folder is removed only if it carries `.rocm-cli-root`, which ROCm CLI writes only into folders it creates itself (its setup, the first log line, the first config save, the download-metadata and vLLM cache writes, and an SDK `--prefix`). A refusal stops the whole command before the prompt, names the folder, the reason and the setting it came from (a cache folder that follows the data folder names the data folder's setting), and says what clears it. A refused dry run says so and exits non-zero. Every entry is re-checked just before removal, an entry already removed with an earlier one is still reported, and a shared cache inside a folder being removed is listed as WILL BE DELETED before confirmation. Confirmation goes through rocm-core's shared yes/terminal guard. The dashboard's /uninstall now passes --keep-* and --force-dev-binaries through, the assistant's preview honours them, and `rocm` children run for the dashboard and assistant receive ROCM_CLI_APP_PATH_SOURCES so their refusals name the setting the user actually made. The assistant refuses an SDK --prefix by the runtime-folder rule and says why, and the runtime and prune refusals now name the reason. Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
… a test A root spelled beside home but really inside it is judged by where it really is. That allowance now also covers a folder that resolves to home itself, so it is refused as the home folder rather than as another user's, and it no longer applies when home resolves to the top of the filesystem, where every folder is inside it. The tests now cover each condition that bounds it: a link spelled beside home stays another user's, a folder that is home itself is refused as home, home reached through a link still counts, a folder spelled under the users folder that really lives elsewhere keeps its refusal, a spelled system location stays refused whatever it resolves to, and a top-of-filesystem home grants nothing. Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
…cter marker and flags The runtime-folder rule now refuses the same Windows system folders as `rocm uninstall`, ProgramData included, on the system drive instead of a fixed C:, so `rocm runtimes uninstall` and `rocm storage remove-old-installs` are protected on a non-C: system too. Its Unix list stays different on purpose, and the comment now says why. The marker counts only as a plain file of the folder's own: a link named like it no longer marks a folder. The dashboard's /uninstall refuses a flag it does not pass through, with the flags it takes, instead of dropping it into a full removal, and passes a repeated flag once. The review's "Refused" heading no longer claims ROCm CLI never removes a listed folder, which was false for one cleared by the marker. Docs and comments that contradicted the code are corrected: the verdict's check order and its shared-folder step, a test doc attached to the wrong test, the properties header, the module's ownership note, the assistant preview's flags, and the scenario summary. uninstall-18 now also runs the uninstall with --keep-cache (the cache stays) and without it (the cache is gone), uninstall-21 checks the config folder survives, and the config-gone step no longer reads a dangling link as removed. Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
036ae53 to
e7472d4
Compare
|
@tomastola thanks for the review. All of it is answered in e7472d4, on top of a rebase onto current Blocking
Non-blocking, fixed
Non-blocking, not changed here (each is a separate change or needs your call)
Decisions for you
|
nowycondro
left a comment
There was a problem hiding this comment.
🤖 Automated review · review-code · head 036ae53
Review — needs work
Full review of the whole change (two commits, f7c5fef7…036ae531, merge base f7c5fef7a7cd2e477ebc655c7f879fe040820cc6).
Fixes #531 in full (protected-location refusal + an explicit shared-cache "WILL BE DELETED" warning in place of the old silent filter) and goes further than the issue's bare ask (resolved-location judging through symlinks/8.3 short names, an ownership-marker requirement for folders outside home); also tracked under ROCMAI-465, an internal AMD Jira ticket ID this review has no access to.
Blocking
-
The older protected-location predicate — gating
rocm runtimes uninstall,rocm storage remove-old-installs, and the chat assistant's SDK--prefixguard — was not brought up to the strength of the new one this same PR added forrocm uninstall—crates/rocm-core/src/runtime.rs(system_roots()~830-839,protected_location_on~869-887, feedingruntime_protected_location/runtime_protected_location_for_home) vs. (uninstall_system_roots_on()~923-958,uninstall_root_verdict_on~1005-1043); callersapps/rocm/src/storage.rs:896,apps/rocm/src/runtime_uninstall.rs:445,apps/rocm/src/tool_policy.rs:964-971.
system_roots()hardcodes["C:/Windows", "C:/Program Files", "C:/Program Files (x86)"]with no system-drive parameter and noProgramData; its new siblinguninstall_system_roots_on()takes asystem_driveparameter and addsProgramData. The same PR also gave the new functionOtherUsersHome/SharedTopLevelcategories the old one still lacks, and made it check system-roots before the home allowance (the old one checks home first, soHOME=/usr/sbinmakes/usr/sbin/xlook safe to the old predicate). A comment intool_policy.rs:964-969claims the chat install-prefix guard uses "the same protected-location rule every recursive delete uses" — it does not. This isn't a fresh oversight: a commit already onmainbefore this PR (ce7d0269) named the 3-entry Windows list as an incomplete policy that "deserves its own change," and this PR's own commit touchessystem_roots()itself (refactoring it into aconst fn(platform)) without carrying that fix over, while adding a dedicated test (windows_roots_follow_the_system_drive) proving the gap mattered enough to close in the new function. On a Windows host whose system drive isn'tC:, or forC:\ProgramDataon any host, or for/home/bob//tmp//srv,rocm runtimes uninstall/rocm storage remove-old-installs/the chat SDK-install guard will not recognize a real protected folder. The PR body does say these commands "keep their existing rule," but doesn't flag that the existing rule is now measurably weaker than the new one.
Confidence 90 · architectural · Fix: threadsystem_drivethroughsystem_roots()(or have it calluninstall_system_roots_on), add the missing categories, and align the check order — or explain in the PR why the split is intentional. -
uninstall_root_verdict's doc comment states a check order that contradicts its own code, and omits a real branch —crates/rocm-core/src/runtime.rs:985-990(doc) vs:1013-1043(code).
The doc says:/, then home, then system-roots, then other users' homes, then marker. The code checks system-roots before the home allowance — deliberately, per its own comment ("so a home inside a system location... does not open that location up") — and has aSharedTopLevelbranch the doc never mentions. The code governs (it's the one actually gating deletion); the doc is a delete guard's safety contract and should say what the guard really does.
Confidence 85 · mechanical · Fix: rewrite the doc to the real order (root → system-roots → home → SharedTopLevel → other-users'-home → marker) and add the missing step. -
The ownership-marker check, and the resolved-location re-judgment generally, are skipped entirely for a config/data/cache root that is a file or symlink rather than a directory — contradicting the PR's own description of the policy —
apps/rocm/src/uninstall_plan.rs:293-355(judge_uninstall_root), specifically the!metadata.is_dir()branch at 313-317, which returnsRemovebefore the function ever computes a resolved path or checks.rocm-cli-root.
The PR description states the policy plainly: "Anywhere else: removed only if the folder carries.rocm-cli-root." That promise is directory-only in the actual code: a config/data/cache root that happens to be a bare file or a symlink, spelled outside home and not matching any named system/shared/other-home pattern, is removed unconditionally — no marker, no refusal, nothing. (judge_uninstall_root's own doc comment does flag that the resolved-location recheck is directory-only "the only kind removed recursively" — but that doesn't extend to justify skipping the marker/ownership check too, and no test exercises this case either way.)ROCM_CLI_CACHE_DIR/ROCM_CLI_DATA_DIRetc. are user-settable, so pointing one at a symlink is a plausible real configuration, not a contrived edge case — and it's exactly the kind of odd-path-type escape issue #531 and this PR are about closing.
Confidence 78 · logic · Fix: extend the marker requirement to non-directory roots outside home too, or narrow the PR's "anywhere else" claim to say "any directory" and add a regression test proving the current, narrower scope is intentional. -
Several of this PR's own new "what will/won't happen" promises are only ever exercised with
--dry-run, never against a real removal —apps/rocm/src/uninstall_plan.rs:788-855(shared_cache_notes_for) and its tests;tests/e2e-cucumber/features/uninstall.feature:198-260(scenariosuninstall-16,-18,-20);tests/e2e-cucumber/tests/e2e/uninstall_steps.rs:758-806(warns_shared_caches_deleted/uv_cache_intact);docs/testing.md's claim thatuninstall-16..-21"each" assert message together with resulting state.
The "WILL BE DELETED" shared-cache warning is asserted only via plan-building/dry-run; nothing runs a real--yesuninstall and confirms the cache is actually gone afterward (or survives with--keep-cache). The unmarked-folder-then-marked scenario (uninstall-20) likewise only ever previews, never actually removes after marking. The filesystem-root-refused scenario (uninstall-16) is dry-run only too, sodocs/testing.md's blanket "each" overstates what's covered. This is a direct instance of this repo's ownAGENTS.mdrule: "a message about the CLI's own behavior is asserted together with the resulting state."
Confidence 80 · logic (test coverage) · Fix: add a real (non-dry-run) run for at least the shared-cache case asserting the cache is gone, and a real run after marking foruninstall-20; narrowdocs/testing.md's "each" claim to match. -
The dashboard's
/uninstallslash command silently drops any--keep-*/--force-dev-binariestoken it doesn't recognize, instead of erroring — so a typo silently turns "preserve this" into "remove everything," and there is no shared constant tying the flag spellings tocli.rs's clap definitions to catch a future rename —crates/rocm-dash-tui/src/app/slash.rs:225-260, specifically theflags.iter().copied().filter(...)at 244-253, vs.apps/rocm/src/cli.rs:720-737(clap fields) andapps/rocm/src/uninstall_plan.rs:662-669(chat_cli_has_flagliteral-scanning, a third independent spelling of the same five flags).
Every token afteruninstallthat isn't--apply/--dry-runis filtered down to the five known literals; anything else (e.g.--keep-dat) vanishes with no error — unlike the sibling"comfyui"/"setup"slash branches, which push aChatTurn::errorfor an unknown sub-arg and have a test proving it. Because this is approval-gated but still destructive, a user typing/uninstall --apply --keep-datmeaning to preserve data gets a full uninstall with no warning. The real CLI's own clap parser has a dedicated typo guard for exactly this shape of mistake (a_mistyped_force_never_reaches_the_dev_binaries_flagincli.rs) that never gets a chance to fire here, because slash.rs drops the token before it would ever reach clap. Three independent spellings of the same five flags (clap fields, this filter, anduninstall_plan.rs's own literal scan) with nothing tying them together compounds the risk of silent drift.
Confidence 85 · logic · Fix: partition tokens into recognized/unrecognized and error on any unrecognized one (mirroring the comfyui/setup pattern), and share a single constant/table for the flag list across all three sites. -
Three of the four distinct failure branches in
recheck()— the TOCTOU safety net this PR's two-phase design relies on — have zero test coverage —apps/rocm/src/uninstall.rs:242-320.
Of thebail!branches — (a) aDirnow resolving somewhere else, (b) aLinkno longer a symlink, (c) aFileno longer a regular file, (d) the holding folder of aLink/Filenow resolving elsewhere — only (c) is exercised, bya_binary_that_became_a_folder_stops_before_the_path_change. The PR body is candid that "the second, per-removal re-check has no test that fails without it, since the race it guards cannot be staged deterministically" — but that disclosure doesn't fit branches (a), (b) and (d): the one branch that is tested is staged by directly arranging a specific filesystem state before callingrecheck(), not by winning an actual race, and the same technique applies equally to the other three (arrange a symlink, then swap it; arrange a parent folder, then move it).
Confidence 75 · logic (test coverage) · Fix: add a test per remaining branch using the same directly-staged-state technique as the existing one, each asserting both the bail message and that nothing was removed.
Non-blocking
- The
.rocm-cli-rootownership-marker check usesPath::is_file(), which follows symlinks, while every other ownership-sensitive check in the same file deliberately usessymlink_metadata(per an explicit comment two lines above it) — a symlink named.rocm-cli-rootpointing at any existing regular file elsewhere would satisfy "this folder is ROCm CLI's own."apps/rocm/src/uninstall_plan.rs:347. Narrow (needs pre-existing write access to the folder already) but inconsistent with the module's own stated discipline, and untested either way. Confidence 70 · logic. - This PR's own refactor weakened the e2e
config_gonestep fromsymlink_metadata(&config).is_err()(pre-PR) to!config.exists()(now) —.exists()follows symlinks, so a regression leaving a dangling symlink instead of truly removing the config folder would no longer be caught; this step backs both the newuninstall-17and the pre-existinguninstall-07scenarios. The new siblingdata_cache_gone(uninstall_steps.rs:534-543) has the identical follow-symlinks pattern, freshly introduced rather than weakened.tests/e2e-cucumber/tests/e2e/uninstall_steps.rs:534-543,748-756. Confidence 85 · logic (test coverage). cli.rs's newafter_helpprose foruninstallhand-lists the refused folders in plain English, but no test ties that text to the actualuninstall_system_roots/system_rootslists it's describing — only theEXAMPLESordering is tested — so the two can silently drift.apps/rocm/src/cli.rs:699-709. Confidence 80 · mechanical.- The
.rocm-cli-rootmarker filename is hardcoded as a literal in three places in the e2e step file instead of referencing thepubrocm_core::runtime::ROCM_CLI_ROOT_MARKERconstant, and nothing ties the duplicate to the real constant.tests/e2e-cucumber/tests/e2e/uninstall_steps.rs:75,480,869. Confidence 70 · architectural. - A feature-file comment cites a unit test function name,
a_windows_drive_root_is_the_filesystem_root, that does not exist anywhere in the repo (the real covering test iswindows_roots_follow_the_system_drive).tests/e2e-cucumber/features/uninstall.feature:193-196. Confidence 80 · mechanical.
Decisions for the author
- Unify the two protected-location predicates, or keep them deliberately separate? — tradeoff. They now differ in Windows coverage (see Blocking #1), in precedence order, and in which
ProtectedLocationcategories they can produce. Unifying prevents this exact class of drift from recurring; keeping them separate may reflect a genuine semantic difference between a runtime install root and a config/data/cache root. Worth stating which, in a comment both functions point at. - Module-size headroom is nearly gone on two files this PR touches — non-blocking-improvement.
cli.rssits at exactly 1,500/1,500 production lines after this PR's own +7 (it was already at 1,493 before);runtime.rsgrew by roughly 395 production lines in this PR alone, landing at ~1,472/1,500 — the largest growth of any touched file. Neither fails the gate today, but the next change to either file very likely will. Worth splitting proactively rather than under pressure later. docs/architecture.md's entries forruntime.rsandpaths.rswere not updated despite this PR adding substantial new public surface to both (ProtectedLocation,create_marked_root,mark_root,runtime_protected_location[_for_home],uninstall_root_verdict,uninstall_system_roots,windows_system_drive,ROCM_CLI_ROOT_MARKERon the one side;AppPathSource,ForwardedAppPathSources,APP_PATH_SOURCES_ENVon the other) — non-blocking-improvement, since neither file is new/renamed so the hard CI gate doesn't fire, butAGENTS.mdis explicit that an entry's description staying true "is still on you."own_home_decides_on's exact-match home protection is a real behavior change riding along with what reads like a pure rename — non-blocking-improvement. The pre-PRruntime_install_root_is_protecteddid not refuseinstall_root == $HOMEexactly (it fell through to "not protected" for a non-system home); the new code explicitly does. Likely a deliberate improvement, worth calling out as such rather than leaving it implicit in a rename-shaped diff.- Windows
\\?\-verbatim paths may not be stripped by the lexical comparison pipeline backing the older predicate (comparable_runtime_path_text/split_runtime_path_anchor), unlikecanonicalize_for_comparewhich the neweruninstall_plan.rspath uses — non-blocking-improvement. Pre-existing, and only verified by manual trace (no Rust toolchain was available to compile a check), so treat as worth auditing rather than confirmed. - Other folder-creators outside this diff may not participate in the new marking discipline — non-blocking-improvement.
apps/rocm/src/comfyui/install.rshas roughly 15fs::create_dir_allcall sites and nocreate_marked_root/mark_rootcalls; since this PR's new policy now refuses an unmarked folder outside home where it previously allowed removal unconditionally, worth confirming comfyui's cache/model folders are always nested inside an already-marked root rather than ever being the first creator of one. - README's and
cli.rs's hand-listed refused-folder prose omits/mnt/wsl//mnt/wslg(which the code does protect), anddocs/manual-testing.md's new "Uninstall Safety" section has no native-Windows steps despite real Windows-specific logic (system drive,ProgramData) — non-blocking-improvement, low impact.
Positive signals
- Property-based tests for the protected-location policy use oracles written independently of the implementation (with an explicit comment on why), and Windows system-drive logic is exercised via an injectable parameter tested against a non-
C:drive rather than hardcoded. create_marked_root/mark_rootfail safe: a folder is only ever marked viacreate_dir(nevercreate_dir_all), so a folder that already existed a moment earlier is never falsely claimed, and a failed marker write degrades to a warning rather than blocking the operation or silently succeeding as "marked."- The forwarded
ROCM_CLI_APP_PATH_SOURCESmechanism is confirmed display/advice-only:judge_uninstall_rootnever consults it, so a forged or stale value can mislabel which setting a refusal names but cannot weaken the actual delete decision — verified directly, and backed by a dedicated forged-value test. - The two-phase
recheck/execute_plandesign correctly handles a cache folder nested inside a data folder (removed incidentally, still reported) and a link/file swapped for a folder mid-prompt, each pinned by its own targeted regression test, and the refusal gate is checked unconditionally before any removal — including the fish-completions cleanup, proven by a test that plants a completions entry inside a refused plan and asserts it survives. - The main deletion property test (
uninstall_case) was upgraded to drive the real production path end-to-end (build_uninstall_plan_for_home+apply_uninstall_plan) instead of looping a lower-level removal helper directly, so it now exercises the realrecheck()and binary/non-binary partitioning rather than bypassing them. - Refusal messages consistently derive from one shared
ProtectedLocation::describe()across all three affected commands, so wording can't drift between them; DCO sign-off is present on both commits, and a leak scan across the whole diff found no real internal-reference leaks.
Deployment notes
This is an intentionally breaking safety change: a rocm uninstall that previously succeeded silently on /, the home folder, or an unmarked folder outside home will now be refused with advice, and folders created by earlier ROCm CLI releases are unmarked until the user creates the marker or passes --keep-<kind> — the PR body already calls this out. Two gaps are worth carrying into release notes specifically: Windows hosts whose system drive isn't C:, or with data under C:\ProgramData, remain unprotected by rocm runtimes uninstall/rocm storage remove-old-installs/the chat assistant's SDK-prefix guard until Blocking finding #1 is fixed (issue #189 flagged this same list's incompleteness once before); and the dashboard's /uninstall currently performs a full uninstall, with no warning, if a --keep-* flag is mistyped (Blocking finding #5).
What this covered
Full review of the whole change: both commits (8e3adc5b, 036ae531), all 30 changed files (4,655 insertions / 452 deletions), fanned out across 11 independent workers — 9 coupled-file groups (crates/rocm-core/src/runtime.rs; crates/rocm-core/src/{paths,lib,confirm,config}.rs; apps/rocm/src/uninstall_plan.rs; apps/rocm/src/{uninstall,runtime_uninstall}.rs; apps/rocm/src/{storage,deletion_properties}.rs; apps/rocm/src/cli.rs + crates/rocm-dash-tui/src/app/slash.rs; the marker-writing and forwarded-path-sources plumbing across logging.rs/therock.rs/therock/fetch.rs/therock/python.rs/engines/vllm/src/install.rs/engine_ipc.rs/engine_runtime_select.rs/chat.rs/chat/mcp_bridge.rs/tool_policy.rs; README.md and docs/{architecture,manual-testing,testing}.md; the e2e cucumber uninstall suite) plus a dedicated AGENTS.md-adherence pass and a dedicated git-history pass. Each group was read completely, and several of the highest-stakes claims above (the two predicates' Windows-list and precedence divergence, the symlink-following marker check, the config_gone regression, the exact module-size line counts) were independently re-verified by the consolidating reviewer directly against the source rather than taken on a worker's word alone.
Did not run: any compiled check. No Rust toolchain was available in this review's sandbox, so no cargo test/clippy/xtask check-module-size/check-architecture-doc could be run; all test-coverage and module-size findings above are from static reading and manual line-counting, scored accordingly (none claims a "ran it" confidence). No CI has executed yet for this exact head commit (036ae531) at review time — no GitHub Actions workflow run and no check-run exists for this SHA, only an unrelated Read-the-Docs status — so this review is the only verification this commit has had so far; it is not itself a finding against the change, but a reader should not assume CI has passed it. A prior-changes pass (whether review comments on earlier PRs touching these files apply here) was not run, out of scope for a single-PR review. This PR has had earlier review rounds at a previous head commit; per this review's method, their contents were not read before these findings were reached — only commit metadata, to confirm no review already existed at this exact head — and nothing from them was given to the fan-out workers, who worked from the code alone. Not reconciled against any PR discussion.
Not a human review. This is an automated code review; please verify findings independently before acting on them.
nowycondro
left a comment
There was a problem hiding this comment.
🤖 Automated review · review-code · head e7472d4b
Review — needs work
Full review of the whole change (3 commits, merge-base eb2a8194…tip e7472d4b), fanned out across 9 coupled-file groups (crates/rocm-core/src/runtime.rs; crates/rocm-core/src/{paths,lib,confirm,config}.rs; apps/rocm/src/uninstall_plan.rs; apps/rocm/src/{uninstall,runtime_uninstall}.rs; apps/rocm/src/{storage,deletion_properties}.rs; apps/rocm/src/cli.rs + crates/rocm-dash-tui/src/app/slash.rs; the marker-writing/path-forwarding plumbing across logging.rs/therock.rs/therock/fetch.rs/therock/python.rs/engines/vllm/src/install.rs/engine_ipc.rs/engine_runtime_select.rs/chat.rs/chat/mcp_bridge.rs/tool_policy.rs; README.md+docs/{architecture,manual-testing,testing}.md; the e2e cucumber uninstall suite). Fixes #531 (no protected-location guard on config/data/cache roots; shared-cache warning disappearing) in full, and goes further: resolved-location judging through symlinks/8.3 short names, an ownership-marker requirement for folders outside home, and Windows system-drive/ProgramData handling. Also tracked under ROCMAI-465.
Blocking
-
A refusal's own error text contradicts its own advice for
NotMarkedfolders —apps/rocm/src/uninstall_plan.rs:254-266(refusal_error),:149-193(RefusedRoot::advice)
refusal_error()appends, unconditionally over every refused root, "ROCm CLI never removes such a folder." For aProtectedLocation::NotMarkedrefusal, the very next sentence (fromadvice()) tells the user "if this folder belongs to ROCm CLI, create {marker}" — andcreating_the_advised_marker_clears_the_refusalproves that doing so and re-running does remove the folder. So a real refusedrocm uninstallcan print, in one message, both "never removes" and "do this and it will be removed." Confirmed via diff that both sentences are new in this PR. The per-category "never removes" sentence insideadvice()itself is correctly scoped toSharedTopLevel/OtherUsersHome/Systemonly (:178-189) — it's only the generic wrapper inrefusal_error()that over-applies the claim to every kind, includingNotMarked.
Confidence 90 · logic · Fix: scoperefusal_error()'s "never removes" clause to the same protected kindsadvice()uses for it, or drop it from the generic wrapper. -
docs/architecture.md's entries forruntime.rsandpaths.rsdescribe only the pre-PR surface, omitting this PR's entire new deletion-guard mechanism —docs/architecture.md:252(runtime.rs),:212(paths.rs)
Read directly: theruntime.rsentry coversRuntimePlatform, OS-specific names, default directories andinstall_root_has_payload— nothing aboutProtectedLocation,runtime_protected_location[_for_home],uninstall_root_verdict/uninstall_system_roots,ROCM_CLI_ROOT_MARKER, orcreate_marked_root/mark_root, all added or substantially grown by this PR (+960 lines). Thepaths.rsentry covers onlyAppPaths/env_vars/theROCM_CLI_*_DIRconstants — nothing aboutAppPathSource,AppPathSources,ForwardedAppPathSources,PinnedAppPathSource,APP_PATH_SOURCES_ENV, ordiscover_with_sources(+236 lines).AGENTS.md§5/§6 names this exact gap:cargo xtask check-architecture-docfails on a file with no entry, "but not on an entry whose description went stale... keeping an entry's description true is still on you." (By contrast, the PR'suninstall.rs/uninstall_plan.rsentries were correctly extended — the gap is specific to these tworocm-corefiles.)
Confidence 90 · mechanical · Fix: extend both entries with the new public surface. -
system_roots()'s doc comment understates how far it now diverges fromuninstall_system_roots(), leavingrocm runtimes uninstall/rocm storage remove-old-installsunprotected against several real system paths —crates/rocm-core/src/runtime.rs:830-834(doc) vs:845-852and:929-964(the two lists)
The doc says the Unix lists differ "on purpose:/optand/varare refused [bysystem_roots]... whilerocm uninstallrefuses only their top level." That's true as far as it goes, butuninstall_system_roots_on's Unix list also contains/lib32,/libx32,/run,/media,/snap,/mnt/wsl,/mnt/wslg— none of which are insystem_roots()'s 13-entry list, and none of which the "top-level only" explanation covers (they're just absent). Soruntime_protected_location/_for_home— the predicate backingrocm runtimes uninstallandrocm storage remove-old-installs— does not recognize an install root at, e.g.,/run,/media,/mnt/wsl, or anything under/lib32, as protected at all. The underlying 13-entry list is pre-existing and unchanged by this PR, but this PR adds the doc text claiming the divergence is limited to/opt//var, which is not accurate.
Confidence 90 · architectural · Fix: either broadensystem_roots()'s list to match, or correct the comment to say the two lists are not fully reconciled and name the gap. -
A feature-file comment cites a unit test that does not exist —
tests/e2e-cucumber/features/uninstall.feature:195
New comment: "covered only by rocm-core'sa_windows_drive_root_is_the_filesystem_rootunit test." A repo-wide search finds no such function anywhere. The real covering test iswindows_roots_follow_the_system_drive(crates/rocm-core/src/runtime.rs:2100), confirmed to exist and to assert the Windows drive-root refusal unconditionally (not platform-gated).
Confidence 90 · mechanical · Fix: correct the cited name. -
Hand-written protected-folder prose in
README.mdandcli.rs'safter_helpis untested against the real protected-root lists, and both currently omit entries those lists contain —README.md:1792-1797,apps/rocm/src/cli.rs:700-709
README's bullet list names/usr /etc /boot /bin /sbin /lib /lib32 /lib64 /libx32 /sys /proc /dev /run /media /snapplus "the same folders on a drive WSL mounts at/mnt/<drive>" — but never names/mnt/wslor/mnt/wslgthemselves, whichuninstall_system_roots_onprotects unconditionally (separate from the drive-letter rule).cli.rs'safter_helpseparately hand-lists "Windows, Program Files, ProgramData" for the Windows case, omitting "Program Files (x86)", which is the fourth entry in the real Windows list. The only test touchingafter_help(uninstall_help_shows_a_dry_run_before_the_real_run,cli.rs:2438) asserts only theEXAMPLES:ordering — confirmed by reading it — never the "Never removes..." paragraph; a repo-wide search for that paragraph's wording finds only its own definition site. Nothing would catch either list drifting further fromuninstall_system_roots()/is_shared_top_level.
Confidence 85 · mechanical · Fix: add the missing entries to both, and add a test (incli.rsand/ordeletion_properties.rs) asserting every folder named in the prose is actually covered by the real protected-root lists.
Non-blocking
protected_location_on(home-before-system, backing the runtime-folder rule) anduninstall_root_verdict_on(system-before-home, deliberately, per its own comment) disagree on precedence for an edge case likeHOME=/usr/sbin; nothing cross-references why the two chose opposite orders. Pre-existing for the runtime side, undocumented as a disagreement.crates/rocm-core/src/runtime.rs:869-887vs:1013-1043. Confidence 70 · architectural./rootisn't blanket-protected byuninstall_root_verdictthe way it is bysystem_roots(); it's only refused when the acting process's own$HOMEresolves to/root. Confidence 60 · logic.AppPaths::discover_with_sources(crates/rocm-core/src/paths.rs) re-readsconfig.jsona second time and hand-duplicates the override-precedence chain (discover_from_pathsderives it once already), with no property test tying the two together — a future precedence change could drift the display-only "sources" silently. Confidence 70 · architectural.windows_system_driveispub used fromlib.rsbut has no consumer outsiderocm-coreitself. Confidence 65 · mechanical.storage.rs's new regression test for the home-equality fix (prune_plan_leaves_a_protected_install_folder_and_says_why,storage.rs:1635) uses/etc/C:\Windowsas the "protected" path — both already caught by the old, pre-PR predicate, so the test proves message-forwarding but not that the newHome/ContainsHomelogic (the actual bug class storage.rs:896's switch fixes) is exercised. Confidence 65 · logic (test coverage).- Two marker-plumbing gaps, both narrow:
therock.rs's tarball install path has an unmarkedcreate_dir_allfor a cache subdir that currently never races only because another call happens to run first in the same function (an unenforced ordering invariant, not a structural guarantee); andpython.rs'sensure_uv_venvrebuild branch (pre-existing, not touched by this diff) doesremove_dir_allon a user-supplied--prefixwith no marker check. Confidence 60 · logic. - TOCTOU
recheck()branch coverage is good but incomplete: theFile-variant of "parent moved" and the non-NotFoundI/O-error branch forDirentries are untested. Confidence 60 · logic (test coverage). - A root renamed away (not deleted) during the confirmation prompt is still reported "removed" — pre-existing behavior (the old
execute_planalready treated a missing path as silent success), not a regression. But this PR's own new doc comment on the two-phase design asserts a stronger guarantee than this case actually gets, and no test distinguishes "truly gone" from "moved intact elsewhere."apps/rocm/src/uninstall.rs:211-266. Confidence 60 · logic. data_cache_gone(e2e step helper, pre-existing, serving old scenariouninstall-05) usesPath::exists()rather thansymlink_metadata(...).is_err(), inconsistent with the stronger idiom this PR establishes everywhere else it touches (config_gone,cache_link_gone,uv_cache_gone). Confidence 70 · logic (test coverage).- Scenario
uninstall-20never performs a real (non-dry-run) removal after the marker is created — "marking makes it genuinely removable" is asserted only via dry-run text in this feature file. Not a violation of the message+state rule (the scenario never claims a real-removal outcome), but a coverage gap. Confidence 55 · logic (test coverage). docs/architecture.md'sconfirm.rsentry doesn't mentionrequire_yes_or_interactive_withbecomingpub; itsruntime_uninstall.rsentry doesn't mention the new_for_homevariant or that refusal wording now comes fromProtectedLocation::describe(). Smaller than the main staleness above; underlying claims remain true. Confidence 55 · mechanical.docs/manual-testing.md's new "Uninstall Safety" section is scoped to "a throwaway home on Linux or WSL," with no manual steps for the genuinely Windows-specific protected roots (Windows,Program Files*,ProgramDataon the system drive), breaking from this doc's own convention elsewhere of flagging untested Windows paths with a manual recipe. Confidence 55 · mechanical.
Decisions for the author
- Unify the two protected-location predicates, or keep them deliberately separate? — tradeoff
protected_location_on/runtime_protected_location(home-before-system, backing the runtime-install-root rule) anduninstall_root_verdict_on(system-before-home, backing the new config/data/cache-root rule) now differ in precedence and in exact coverage (see Blocking above). Unifying would prevent this class of drift from recurring; keeping them separate may reflect a genuine semantic difference between a runtime install root and a config/data/cache root. Worth stating which, in a comment both functions point at. - Non-directory (file/symlink) roots skip the resolved-location recheck and the marker requirement once the literal-spelling verdict passes — non-blocking-improvement
judge_uninstall_root's own doc comment explains this is bounded (only a directory is walked recursively, so the blast radius of a file/symlink root is smaller) and it is a deliberate, reasoned choice, not an oversight. No dedicated test pins this exact boundary either way — worth adding one so the scope stays what's documented. --keep-binaries/--keep-config/--keep-data/--keep-cache/--force-dev-binariesare spelled as independent literals in three places (cli.rs's clap fields,crates/rocm-dash-tui/src/app/slash.rs'sPASSED_THROUGH, anduninstall_plan.rs'srender_uninstall_dry_run_with) — non-blocking-improvement. All three currently agree, and the drift direction is fail-safe (an out-of-sync flag gets refused rather than mis-passed), but nothing enforces it; a shared constant or a test diffingCli::command()'s flags against the other two would close the gap cheaply.
Positive signals
- The refusal gate (
plan.refusal_error()) runs unconditionally before every removal, including the fish-completion-script cleanup that otherwise has its own "softer" check — proven by a test that plants a completions entry ahead of a refused root and asserts it survives. ROCM_CLI_APP_PATH_SOURCES/AppPathSourceforwarding is genuinely display-only: traced to its one production consumer,judge_uninstall_root, which decidesRemove/Refusepurely fromuninstall_root_verdictagainst real path/metadata and never reads the forwarded sources; it's also spoofing-guarded (an entry is honoured only while the live env var still names the same path).create_marked_root/mark_rootmark a folder withcreate_dir(nevercreate_dir_all), so a folder that already existed a moment earlier is never falsely claimed as ROCm CLI's own; every touched folder-creation call site (log dir, download-metadata cache, tarball install root, uv-venv install root, vLLM cache) creates then marks in the correct order, including correctly handling the case where a venv rebuild loses and needs to re-apply the marker.deletion_properties.rs's main property test (uninstall_case) now drives the real production path end-to-end (apply_uninstall_plan) instead of looping a lower-level removal helper directly, so it genuinely exercisesrecheck()and the refusal gate rather than bypassing them; its oracles are independent filesystem-diffing, not reimplementations of the code under test.runtime_uninstall.rs's refusals now derive their wording fromProtectedLocation::describe(), so the message genuinely names the specific reason ("...because it is your home folder") instead of a generic string, proven by a dedicated test.- The dashboard's
/uninstallslash command correctly refuses an unrecognized---prefixed flag by name (a typo cannot silently turn into a full removal), with thorough test coverage (dry-run/apply, order-preservation, de-duplication, and the typo-refusal path itself).
Deployment notes
This is an intentionally breaking safety change: a rocm uninstall that previously succeeded silently on /, the home folder, or an unmarked folder outside home will now be refused with advice, and folders created by earlier ROCm CLI releases are unmarked until the user creates the marker or passes --keep-<kind> — the PR body already calls this out. Worth also carrying into release notes: rocm runtimes uninstall/rocm storage remove-old-installs remain less protective than the new rocm uninstall guard for several real Unix paths (see the system_roots() finding above), and the user-facing "never removes" text in README/--help isn't exhaustive of what the code actually protects.
All 39 CI checks reported for this exact head commit (e7472d4b) are green (one, Skill checks (skillscope), is skipped, matching AGENTS.md's note that it's advisory-only and not yet a required gate). The PR's mergeable_state is reported as blocked by the GitHub API, but a local git merge-tree of this head against the current tip of main produced no conflicts — blocked most likely reflects a pending required-review/approval gate rather than a merge conflict.
What this covered
Every changed file read completely at the tip (eb2a8194…e7472d4b), fanned out across 9 independent workers grouped by file coupling (listed in the opening line above), each instructed to read its whole group and flag if it could not. The highest-stakes claims above (the refusal_error() self-contradiction, the system_roots()/uninstall_system_roots() divergence, both docs/architecture.md staleness findings, the stale test citation, and the after_help/README gaps) were independently re-verified by the consolidating reviewer directly against the source via git show/git grep on the pr-569 tip, not taken on a worker's word alone.
Did not run: any compiled check (no Rust toolchain in this sandbox) — all test-coverage and logic findings above are from static reading, scored accordingly (capped well below "ran it" confidence). CI's own 39 checks were read via the GitHub API rather than re-derived, per method. A "prior changes" pass (whether review comments on earlier PRs touching these files apply here) was not run, out of scope for a single-PR review. This PR has had earlier review rounds at prior head commits (including automated ones); per method, their contents were not read before these findings were reached — only commit-id metadata, to confirm no review already existed at this exact head — and nothing from them was given to the fan-out workers. Not reconciled against any PR discussion or review thread.
Fixes #531 in full and goes beyond its literal ask (resolved-location judging, the ownership marker, Windows handling) — confirmed by reading the issue directly; no scope overclaim found.
Not a human review. This is an automated code review; please verify findings independently before acting on them.
…ed-roots Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
|
Merged main (79c1fd6) to resolve conflicts with #1016:
No behaviour change beyond the port. |
nowycondro
left a comment
There was a problem hiding this comment.
🤖 Automated review · head 79c1fd6
This automation never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer.
Review — needs work
Full review of the whole change (30 files, base 8f086ad9…head 79c1fd6). Implements protected-location refusal for rocm uninstall described in the PR body as fixing #531 and referencing ticket ROCMAI-465; the ticket itself is not retrievable from this review (no issue-tracker tool available here), so it was judged only against the PR's own description, which matches the diff's scope well — no overclaim or undisclosed work found.
Blocking
-
A required E2E check is failing at this exact head commit —
tests/e2e-cucumber/tests/e2e/uninstall_steps.rs(scenariouninstall-moved-data-folder-keeps-its-own-cachehelpers, e.g.data_cache_holds_file/uninstall_without_cache_setting), vs.tests/e2e-cucumber/tests/e2e/lifecycle_steps.rs:691-700.
gh pr view 569 --json statusCheckRollupshowsE2E tests (Strix Halo, Windows, current)= FAILURE, completed at the reviewed head; the job's own reconciliation line readsFAIL: 'uninstall-moved-data-folder-keeps-its-own-cache' was expected to pass on this host but FAILED — a regression.Likely root cause: every other uninstall scenario touched by this PR was restructured to nest its config/data folders under the scenario's synthetic HOME (to dodge the new "folder beside HOME counts as another user's home" rule — see the comment atuninstall_steps.rs:47-49and the sibling fix inlifecycle_steps.rs:691-700), but this one scenario's helpers still resolve config/data through the flat, un-nestedworld.app_paths()layout. On the Windows self-hosted runner, the harness'sTempDirlands inside the runner's own profile tree, so the flat layout now gets misclassified under the new home-folder protection. Confidence 100 (a failing required check at the reviewed commit, with the workflow's own log naming this exact scenario as a regression).
Fix: nest this scenario's config/data folders under the scenario's home the same way the others were restructured, or tag/skip it on Windows with a stated reason until fixed. Confidence 100 · logic · Fix: see above. -
Fail-open gap: a non-directory root reached through a symlinked ancestor directory is judged only by its as-spelled path, never resolved —
apps/rocm/src/uninstall_plan.rs:301-318(judge_uninstall_root).
The first check (rocm_core::uninstall_root_verdict(path, home, &[]), line 301) runs on the unresolved, as-writtenpath. If that doesn't refuse, and!metadata.is_dir()(line 314), the function returnsRemoveimmediately — it never reaches thecanonicalize(path)call at line 321 that directories get, which is what actually re-judges the entry against the resolved home/system roots. Concrete case:home = /home/alice,ROCM_CLI_DATA_DIR = /home/alice/mnt-etc/secret.confwheremnt-etcis a symlink to/etcandsecret.confis a plain file. Lexically this spells "inside home" so it passes the first check; because the entry isn't a directory it skips resolution entirely and is planned forRemove, even though removing that path actually deletes/etc/secret.conf(intermediate symlink components are always followed by the OS). The in-code comment justifying this ("a symlinked root is unlinked, never walked, and a file is just a file") only covers the root itself being a symlink, not an ancestor of the root being one — this is precisely the class of bypass the PR's own tests cover for directories (a_system_root_reached_through_its_link_target_is_refused) but not for non-directory entries. No test exercises this case.
Confidence 80 · architectural · Fix: resolve the real location of non-directory entries too (e.g. canonicalize the parent chain) before decidingRemove, or fail closed (Unresolvable) when that resolution isn't attempted. -
Silent failure: a resolved system root that fails to canonicalize for a reason other than "not found" is dropped from the comparison set with no warning —
apps/rocm/src/uninstall_plan.rs:331-334.let resolved_system_roots = rocm_core::uninstall_system_roots() .iter() .filter_map(|root| canonicalize(root).ok()) .collect::<Vec<_>>();
.ok()swallows everycanonicalizeerror alike, not justNotFound. This is exactly the defense layer meant to catch a symlinked system root (the PR's own example:/usr/libwhere/lib -> usr/lib); if canonicalizing one of those aliases errors for a transient or permissions reason, that alias silently stops being protected for this run, with nothing surfaced.
Confidence 70 · logic · Fix: distinguishNotFound(fine to drop) from other I/O errors, and surface the latter as a plan warning or refusal rather than silently omitting the root. -
Missing test for new behavior: the local assistant refusing an SDK
--prefixinstall at the user's own home folder —apps/rocm/src/tool_policy.rs(testthe_assistant_cannot_name_a_system_install_folder_by_respelling_it, ~2639-2661; call sites ~357, ~948),apps/rocm/src/chat/mcp_bridge.rs(~691).
chat_install_prefix_protectionnow delegates torocm_core::runtime_protected_location, which refusesprefix == home(ProtectedLocation::Home) — behavior the oldchat_install_prefix_is_systemdid not have (basemain's version only refused paths outside home, i.e.prefix == homepreviously validated). This is new, PR-introduced behavior ("now also covers the home folder, not just system folders"), but no test anywhere in this group passes the home directory itself as--prefix; the only respelling test tries only system paths (/usr/,/opt/, etc.).
Confidence 80 · logic · Fix: add a test assertingchat_install_prefix_protection(home)(and ideallyvalidate_chat_install_sdk_tool_call/validate_chat_rocm_command_safetyfor a real call) refuses the home directory, naming the reason. -
Missing tests for the marker-on-creation invariant at 3 of its 4 call sites —
apps/rocm/src/therock.rs:957,apps/rocm/src/therock/fetch.rs:420,engines/vllm/src/install.rs:528.
Each now callsrocm_core::create_marked_root(...)instead of plainfs::create_dir_all(...), sorocm uninstallcan later tell these folders are ROCm CLI's own. Onlyapps/rocm/src/logging.rsships a test asserting the marker actually lands on the right folder (the_data_folder_logging_creates_is_marked_and_an_existing_one_is_not); the other three have no equivalent — e.g. the existing vLLM test touching this function only asserts the written config contents, neverpaths.cache_dir.join(ROCM_CLI_ROOT_MARKER), andtherock/fetch.rshas zero references to the marker anywhere. Since the entire marker-based refusal scheme (the PR's central new safety mechanism) depends on every creation call site remembering to mark the right folder, an unverified call site is a systemic risk, not just a nice-to-have.
Confidence 80 · logic · Fix: add a unit test per site asserting the marker file exists at the correct root after the call, and is absent for a pre-existing folder (mirroringlogging.rs's test). -
Missing test coverage for the dashboard
/uninstallunknown-flag check's interaction with other checks —crates/rocm-dash-tui/src/app/slash.rs(unknown-flag logic ~226-280; test module ~1185).
No test covers an unknown flag combined with the pre-existing--apply+--dry-runconflict (unclear which error wins), nor a bare unknown flag with no mode flag at all — both are states this new refusal logic can be observed in.
Confidence 70 · logic · Fix: add tests for both states.
Non-blocking
uninstall_plan.rs'sa_refusal_names_the_setting_the_folder_came_fromtest (~1541-1560) pins only the refusal/advice string, with no cross-reference comment to the test that proves the named remediation actually clears the refusal — non-blocking-improvement. Its siblinguninstall_plan_refuses_the_filesystem_rootcarries exactly this kind of comment pointing at the proving test; this one doesn't point atpointing_the_named_variable_elsewhere_clears_the_refusal, which is the test that actually proves it. Low risk since the proving test does exist, just not linked.AppPathSources/AppPathSource::for_paths(paths.rs) compares paths with plain equality rather than canonicalized comparison, and falls back to blanket-labeling all three folders as environment-overridden when fresh discovery errors — non-blocking. Traced to its only consumer (uninstall_plan.rs's refusal advice text): this only affects the wording of a remediation suggestion, never theProtectedLocation/UninstallRootVerdictvalue that actually gates deletion, so a defect here produces misleading advice text at worst, not a wrongful delete.
Decisions for the author
- The e2e harness nests scenario folders under HOME per-scenario rather than through one shared constructor — non-blocking-improvement. The Windows regression above happened because one scenario (out of ~20) was missed when this nesting convention was introduced; a single shared "give me an already-correctly-nested AppPaths for this scenario" helper would make this class of omission structurally harder to repeat as new scenarios are added.
Positive signals
- The property-based tests in
apps/rocm/src/deletion_properties.rsrun their randomized scenarios through the realapply_uninstall_planproduction entry point (not a hand-rolled stand-in), and the safety assertion is unconditioned on whether the plan was refused — a meaningful, non-vacuous check of the refusal guarantee across a wide randomized input space, not just the hand-picked unit-test cases. - Refusal reasons are threaded through a single
why: ProtectedLocationvalue from the gate to the printed message in bothruntime_uninstall.rsandstorage.rs, so the displayed reason can't drift from the rule that actually fired — and this is pinned by tests that would fail if the wrong variant were substituted. uninstall.rs's per-entry TOCTOU re-check immediately before removal, and the "already-gone-but-still-reported-as-removed" accounting, were both traced end-to-end and found correct — a genuinely easy place to get subtly wrong.
Deployment notes
- This PR changes previously-succeeding behavior: uninstalls whose data/config/cache folder sits inside or beside the user's home, or outside the home without ROCm CLI's marker file, will now be refused where they previously weren't. Existing users/scripts relying on the old lenient behavior will need
--keep-<kind>or to let ROCm CLI (re-)create and mark the folder. - Windows: the system-folder refusal (ProgramData included) now follows the live system drive instead of a hardcoded
C:— relevant for anyone running off a non-default system drive.
What this covered
Full diff 8f086ad9c0fe85e7bab2bd8272dc88638938e4fe…79c1fd63030ed51830b3dbc44296d50125833336, all 30 changed files read completely by ten independent fan-out workers grouped by coupling (rocm-core primitives; the runtime-folder rule and its consumers; uninstall_plan.rs alone; uninstall.rs + deletion_properties.rs; therock/python.rs alone; the marker-on-creation call sites; assistant-side prefix protection; CLI/dashboard pass-through; the e2e cucumber suite; docs + agent-instruction adherence), each also reading the relevant surrounding/caller code and existing tests.
Did not run as dedicated standalone sweeps, given this PR's scale (~5,300 changed lines): a repo-wide history/git blame pass and a prior-changes-on-these-files pass — each worker reasoned about its own files' surrounding code and tests instead. Agent-instruction adherence (this repo's AGENTS.md) was checked across the whole diff by a dedicated worker: module-size limits (all touched files well under 1,500 production lines), markdown-link conventions (no violations), docs/architecture.md entries (not triggered — every changed file was modified, none added/renamed/removed), and the subprocess/FFI checklist (not triggered — no new tokio::process/spawn_blocking in the diff).
CI was read live via gh pr view --json statusCheckRollup at the reviewed commit: E2E tests (Strix Halo, Windows, current) is failing (see Blocking above); E2E tests (MI300X, current) was still queued and had not completed as of this review — an unresolved, not a failing, check. Everything else reported passing.
Not reconciled against any prior review discussion or comments on this PR.
Not a human review. This is an automated code review; please verify findings independently before acting on them.
…ed-roots Both sides added a section 13 to docs/manual-testing.md: main's "Pasting An Error Into `rocm diagnose`" keeps 13 and this branch's "Uninstall Safety" becomes 14. Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
… keep uninstall-05 inside the scenario home A refusal ended "ROCm CLI never removes such a folder" for every kind, while an unmarked folder's own advice says creating the marker makes it removable. The claim now comes from the per-kind advice only, for the kinds no marker or setting can clear (the filesystem root, a home folder or one containing it, system and shared folders, other users' homes). uninstall-17 and uninstall-20 assert it with the resulting state, and uninstall-20 now removes the folder for real once it is marked. On native Windows the harness's own config and data folders sit inside C:\Users\<runner>, outside the scenario's home, so uninstall-05 was refused as another user's home. It and uninstall-06 now keep their isolated folders inside the scenario home, as the other scenarios do. README names /mnt/wsl and /mnt/wslg, and tests now hold README's list and `rocm uninstall --help` to the real system roots. The system_roots and assistant install-prefix comments state how the runtime rule differs from uninstall's; the architecture entries cover the deletion guards and path sources; a feature comment names the test that exists. Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
A config, data or cache setting naming a file or a link was judged by its spelling alone: with ~/x a link to /etc, ~/x/config.json passed as inside home and the uninstall unlinked /etc/config.json. A non-directory root is now judged by its resolved folder under its own name, so that one is refused as the system file it is, while a root that is itself a link is still only unlinked, never followed (uninstall-22, and unit tests for a file through a linked folder and a link pointing at a system location). A system location that exists but cannot be resolved used to drop out of the comparison silently, leaving its real place unprotected; the root is now refused as unresolvable instead. Each place that creates and marks a folder ROCm CLI owns (the tarball --prefix, the metadata cache, the vLLM cache) now has a test that a folder it creates is marked and an existing one is not; the tarball and metadata steps move into small helpers for that. Also tested: the assistant refusing the home folder as an SDK --prefix, and the dashboard's /uninstall naming an unknown flag on its own and ahead of the --apply/--dry-run conflict. Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
…ed-roots Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
…ed-roots Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com> # Conflicts: # docs/manual-testing.md
…s reader readme_names_every_uninstall_system_root embedded README.md with include_str!, which the ASCII output contract counts as data compiled into a binary, and which the pre-push hook's widening rule did not list for rocm-core. The test now reads README at run time, and CROSS_CRATE_READS names rocm-core as a README reader so the narrowed hook runs it when README changes; docs_and_skills_select_the_crates_whose_tests_read_them now expects rocm-core for README only, not for docs or skills. Also drops a redundant clone clippy flags in the new link test. Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
|
This answers both automated reviews: the one of e7472d4, and the one of 79c1fd6. The fixes are in 4ab285e and 15b6bd8 (plus acc80d1, which reads README at run time in Review of e7472d4Blocking
Non-blocking, fixed
The Strix Halo Windows e2e failure (blocking in the 79c1fd6 review too): fixed. Non-blocking, not changed here
Review of 79c1fd6Blocking
Non-blocking
|
juhovainio
left a comment
There was a problem hiding this comment.
Review — needs work
Full review of the whole change (merge-base ee605065…head acc80d1e), reviewed as 4 independent fan-out passes grouped by coupling (core protected-root policy in crates/rocm-core; uninstall_plan.rs; uninstall.rs + deletion_properties.rs; CLI/runtime-uninstall/storage wiring) plus my own direct verification of the remaining areas (marker-writer call sites, dashboard/assistant pass-through, the e2e Gherkin scenarios, and docs/xtask) after a background-agent concurrency limit prevented launching independent workers for those last four.
Implements the fix for #531 (rocm uninstall could delete / or the user's home directory) in full — every reproduction scenario in #531 (ROCM_CLI_DATA_DIR=/, setup.therock_venv=$HOME, the shared-cache-inside-a-removed-root case) is directly covered by a corresponding e2e scenario in this PR.
Blocking
resolved_home's canonicalize fallback is not fail-closed, unlike every other resolution step in the same function —apps/rocm/src/uninstall_plan.rs:325-327.Every otherlet resolved_home = home.map(|home| { canonicalize(home).unwrap_or_else(|_| rocm_core::resolve_path_through_symlinks(home)) });
canonicalizefailure injudge_uninstall_rootrefuses the root asUnresolvable. This one instead falls back to a weaker, non-canonical resolution on any canonicalize error for the home path itself. If home's resolution degrades this way while a candidate root canonicalizes fully to that same real location via a different symlink chain, the equality check used to detect "this root is home" can miss the match — i.e. a root that genuinely is the user's home could fail to be flagged asHomeand become removable, which is the exact property this PR exists to guarantee.
Confidence 70 · logic · Fix: make this arm refuse (Unresolvable) on failure too, matching the rest of the function, or explicitly document why home resolution alone gets a non-full fallback.
Non-blocking
- TOCTOU window in
create_marked_root_with—crates/rocm-core/src/runtime.rs:758-777. Betweencreate_dirsucceeding and the marker write, an attacker with write access to the parent directory could race a symlink in before the marker write lands. Low exploitability (needs parent-dir write access not normally attacker-controlled under$HOME;is_root_markerelsewhere usessymlink_metadataso this can't make an unrelated folder deletable). Confidence 55 · architectural · Fix: write the marker relative to the just-created directory handle rather than by path. - Vacuous/tautological test assertion —
apps/rocm/src/uninstall_plan.rs:1412:assert!(!rendered.contains("Choose Review uninstall"), ...). The real heading is "Uninstall review" (line ~789), so this can never be false; looks like copy/paste leftover insideuninstall_plan_refuses_the_filesystem_root. Confidence 80 · mechanical · Fix: assert the real heading text instead. - Two runtime-folder tests assert only the refusal message, not resulting filesystem state —
apps/rocm/src/runtime_uninstall.rs:764(ensure_runtime_install_root_refuses_the_home_folder_by_name) andapps/rocm/src/storage.rs:1635(prune_plan_leaves_a_protected_install_folder_and_says_why). AGENTS.md §3 asks for the message and resulting state to be asserted together, or a comment naming the test that proves the state separately; neither is present here, unlike sibling tests elsewhere in this same PR. The actual no-deletion guarantee is structurally enforced via?-propagation and indirectly covered byensure_runtime_install_root_rejects_every_spelling_of_a_protected_path, so real risk is low. Confidence 70 · mechanical · Fix: add the missing state assertion, or a comment pointing at the test that proves it. - Doc comment on
system_roots()documents the differing root lists between the runtime-folder rule and therocm uninstallrule, but not that home-vs-system precedence order also differs —crates/rocm-core/src/runtime.rs:830-839.uninstall_root_verdict_onchecks system-roots before the home exemption; the legacyprotected_location_onchecks home first (pre-existing, unchanged, intentional and tested either way). Confidence low · mechanical. - Undocumented load-bearing sort order —
apps/rocm/src/uninstall_plan.rs(thesort_by/dedup_byonplan.actions, ~line 612-614; not on a diff line so no inline comment). Guarantees ancestors sort before descendants, which is what makes the "already removed by its turn" accounting correct inuninstall.rs's recheck. Nothing documents that this ordering is load-bearing for that guarantee. Confidence low · architectural. - Non-directory roots don't get the short-name/symlinked-parent exemption directory roots get —
apps/rocm/src/uninstall_plan.rs:309-319. Fails safe (over-refuses) rather than under-refusing; just an asymmetry versus the thoroughly-tested directory case. Confidence low · mechanical. homes_parents_onover-refuses siblings of an atypical$HOME—crates/rocm-core/src/runtime.rs:971-992. An unusual$HOME(e.g. a service-account-style path under a shared parent) causes sibling folders to be classifiedOtherUsersHomeeven though they aren't anyone's home. Fail-safe direction, not a vulnerability — a possible false-positive "stuck uninstall" for atypical setups. Confidence low.plan.path_record/plan.self_deletebypass the per-entryrecheck()type-reverification other plan entries get inapps/rocm/src/uninstall.rs, going straight throughremove_path/delete_running_executable. Exploitable only with the same install-directory write access already needed to tamper with therocm/rocmdbinaries directly; pre-existing pattern, not introduced by this diff. Confidence 50 · architectural.
Decisions for the author
.rocm-cli-rootmarker proves only "a plain file with this name exists," never provenance — tradeoff.is_root_marker(apps/rocm/src/uninstall_plan.rs:409-415) checks file type (correctly rejecting a symlink) but never content; an empty file is sufficient to clear a refusal (confirmed by the PR's owna_linked_marker_does_not_mark_a_foldertest). This is clearly deliberate — the documented, low-friction way to vouch for a legacy/foreign folder — but means anyone with write access to a candidate root (e.g. a misconfigured shared/group-writableROCM_CLI_DATA_DIR) can self-mark it and trigger a full recursive delete of its contents. Worth explicitly confirming this is an accepted tradeoff given the PR's purpose.
Positive signals
apply_uninstall_planindependently re-derives and checks plan refusal rather than trusting a pre-filtered plan — proven directly by a test that calls it standalone, bypassing the higher-level entry point entirely.- The pre-removal recheck genuinely re-resolves/re-stats each entry rather than trusting the earlier judgment, and is itself tested against a moved directory, a link/file that became a directory, and a parent swapped for a link.
deletion_properties.rs's property-test oracle is the real filesystem, not a restatement of the code's own path logic — stronger than a typical mirrored oracle and avoids the self-referential-oracle trap that would hide a shared bug.- All 7 new Gherkin scenarios (
uninstall-16through-22) exist with the claimed@id:tags and correct@requires-os:linuxgating, and each pairs the refusal-message assertion with the resulting filesystem-state assertion in the same scenario;uninstall-17vsuninstall-20correctly distinguish "ROCm CLI never removes this" (home) from "refused until marked, not claimed un-removable" (an unmarked folder) — exactly the nuance the PR description claims to have gotten right. - Windows system-drive detection (
windows_system_drive()) reads the actual system drive (SystemDrive/windirenv) rather than hardcodingC:, with its own test proving a non-C:drive is honored. - README's refused-folder list, the
system_roots()doc comment,docs/architecture.md's module descriptions, and thextask/src/prepush.rsREADME-reader wiring (rocm-coreadded so the narrowed pre-push hook runsreadme_names_every_uninstall_system_rootwhen README changes) all verified accurate against the actual code. - Fail-closed design throughout the refusal path — every uncertain case refuses — with the one exception noted above as blocking.
Deployment notes
- Behavior change: previously-removable protected roots (home, system folders, unmarked custom folders) are now refused by
rocm uninstall,rocm storage remove-old-installs, androcm runtimes uninstall. Any automation relying onROCM_CLI_DATA_DIR/_CONFIG_DIR/_CACHE_DIRpointed at a pre-existing, unmarked folder will need to either redirect the setting or create the.rocm-cli-rootmarker the refusal names. - New
ROCM_CLI_APP_PATH_SOURCESenvironment variable is now set onrocmchild processes the dashboard/assistant spawn, so their refusals name the setting the user actually made.
What this covered
All 31 changed files across the full diff, via 4 independent fan-out workers reading their files completely plus cross-file context (core policy logic in crates/rocm-core/src/{paths,runtime,config,confirm,lib}.rs; apps/rocm/src/uninstall_plan.rs; apps/rocm/src/uninstall.rs + deletion_properties.rs; apps/rocm/src/{cli,storage,runtime_uninstall,engine_runtime_select}.rs), plus my own direct, targeted verification (not independently fanned-out, since a concurrency limit in this environment blocked launching dedicated workers for these) of: all 5 marker-writer call sites (therock.rs, therock/fetch.rs, therock/python.rs, logging.rs, engines/vllm/src/install.rs), the dash-TUI /uninstall unknown-flag refusal and --keep-* pass-through in slash.rs, the ROCM_CLI_APP_PATH_SOURCES producer/consumer chain, all 7 e2e Gherkin scenarios' text in uninstall.feature, and README/docs/architecture.md/xtask/src/prepush.rs.
Did not run: cargo xtask check-module-size (not executed in this environment — production-line counts for every touched file were estimated by hand from #[cfg(test)] boundaries and are comfortably under the 1,500-line cap, per multiple independent counts). Did not deeply read every step-definition implementation in tests/e2e-cucumber/tests/e2e/uninstall_steps.rs (897 changed lines) line-by-line — verified the Gherkin feature text matches the claimed scenarios and distinguishing wording, but did not independently verify every step's assertion strength. CI: all required checks green at review time (one E2E tests (MI300X, current) job was still queued and not yet observed to completion). This review was not reconciled against the PR's existing review threads/comments — those were not read, per the blind-review method this uses.
🤖 Automated by an AI agent
| }; | ||
| let resolved_home = home.map(|home| { | ||
| canonicalize(home).unwrap_or_else(|_| rocm_core::resolve_path_through_symlinks(home)) | ||
| }); |
There was a problem hiding this comment.
Blocking: resolved_home is the one resolution step in this function that is not fail-closed.
let resolved_home = home.map(|home| {
canonicalize(home).unwrap_or_else(|_| rocm_core::resolve_path_through_symlinks(home))
});Every other resolution failure in judge_uninstall_root refuses the root as Unresolvable. Here, if canonicalizing the home path itself fails (a broken intermediate symlink, a permission error on a path component, etc.), the code silently falls back to a weaker, non-canonical resolution instead of refusing. If the candidate root canonicalizes fully (succeeds) to the same real location that home's degraded fallback resolves to differently, the equality check used to detect "this root is home" can miss the match — meaning a root that really is the user's home could fail to be flagged as Home and become removable. That is exactly the property this PR exists to guarantee.
Suggest: make this arm refuse (Unresolvable) on a canonicalize failure too, consistent with the rest of the function, or explicitly document why home resolution alone is allowed a non-full fallback.
Confidence 70 — reasoned from the code's own established pattern in this function, not exercised against a live repro.
There was a problem hiding this comment.
Fixed in 337dad1. Home is now resolved like everything else in judge_uninstall_root, failing closed. A home folder that exists but cannot be resolved (permission denied, for example) refuses the root as unresolvable, as an unresolvable system location already did.
Only a home folder that does not exist keeps the spelling fallback. An existing root cannot really be a place that does not exist, so no match with home can be lost that way.
a_home_folder_that_cannot_be_resolved_refuses_the_root injects both errors for the home path: permission denied refuses, and not-found still plans a root inside it. It goes red with the old fallback restored.
|
|
||
| /// Whether `dir` carries the marker as a regular file of its own. A link named | ||
| /// like the marker is not one: anything that can plant a link there could | ||
| /// point it at any file, and ROCm CLI only ever writes a plain file. |
There was a problem hiding this comment.
Decision for the author (tradeoff, not a bug): is_root_marker proves only "a plain file with this name exists," never provenance.
It checks file-type (via symlink_metadata, correctly rejecting a symlinked marker) but never content. The PR's own test (a_linked_marker_does_not_mark_a_folder) confirms an empty file is sufficient to clear a refusal. This is clearly deliberate — it's the documented, low-friction way to let a user manually vouch for a pre-existing/legacy folder — but it does mean anyone with write access to a candidate root (e.g. a misconfigured shared/group-writable directory pointed at by ROCM_CLI_DATA_DIR) can self-mark it and trigger a full recursive delete of everything inside, not just ROCm's own files. Worth having this explicitly confirmed as an accepted tradeoff given the PR's purpose is hardening against exactly this class of destructive-delete risk.
There was a problem hiding this comment.
Confirmed: this is a deliberate tradeoff. The marker means "this folder may be removed as a whole", not "ROCm CLI wrote this", and README documents creating it by hand as the way to vouch for a folder ROCm CLI did not create.
Why it is acceptable here:
- The marker only matters for a folder the user has already configured as a config, data or cache root, outside their home.
- A real uninstall lists every root it will remove and asks for confirmation (or
--yes) before removing anything. - A marker that is a link does not count (
a_linked_marker_does_not_mark_a_folder).
Checking the marker's content or owner would not close the shared-folder case: anyone who can write the folder can write a marker with the expected content. The protection against a group-writable folder is not pointing a ROCm CLI setting at one. So no code change here.
| write_marker: impl FnOnce(&Path) -> std::io::Result<()>, | ||
| ) -> Result<()> { | ||
| if let Some(parent) = dir.parent().filter(|parent| !parent.as_os_str().is_empty()) { | ||
| std::fs::create_dir_all(parent) |
There was a problem hiding this comment.
Non-blocking: TOCTOU window in create_marked_root_with between directory creation and the marker write.
Between std::fs::create_dir(dir) succeeding and the subsequent marker write, an attacker with write access to the parent directory could race to delete the just-created empty dir and replace it with a symlink, redirecting the marker write elsewhere. Low exploitability in practice: it requires attacker write access to the parent of a config/data/cache root (not attacker-controlled for default $HOME-based locations), and is_root_marker elsewhere uses symlink_metadata, so a marker planted this way doesn't make some other folder deletable. Still worth a defense-in-depth note or hardening (e.g. write relative to the just-opened directory handle instead of by path) given the security-sensitive context. Confidence ~55, non-blocking.
There was a problem hiding this comment.
Not changed in this PR. The window is real, but a swap cannot turn it into a removal:
- If the new folder is replaced by a link before the marker is written, the marker lands in the link's target, and the configured root is now that link.
judge_uninstall_rootjudges a root that is a link as a link: it is unlinked and never walked, so the target's contents are not removed through it.- The swap also needs write access to the folder's parent, which for the default locations is the user's own home.
Closing it fully means writing the marker relative to the directory handle just created. openat would do that on Unix, but Windows needs its own handle-based path. That platform-specific FFI is a separate hardening change with its own tests, so I am recording it as a follow-up rather than adding it here.
| )), | ||
| "{rendered}" | ||
| ); | ||
| assert!(!rendered.contains("Choose Review uninstall"), "{rendered}"); |
There was a problem hiding this comment.
Non-blocking: vacuous/tautological assertion.
assert!(!rendered.contains("Choose Review uninstall"), "{rendered}");The actual rendered heading is "Uninstall review" (see line ~789), so this substring can never appear — the assertion is tautologically true and tests nothing. Looks like a copy/paste leftover. Harmless on its own, but it's dead weight inside an otherwise safety-critical test (uninstall_plan_refuses_the_filesystem_root). Confidence 80 (directly read).
There was a problem hiding this comment.
Fixed in 337dad1. The dead assertion is gone. The test now also renders the refused plan for a terminal, the one audience whose dry run otherwise ends by inviting a real run. It checks that the plan says This uninstall would be refused. and does not show the To remove these items, run it again without --dry-run footer. That fails if the refusal branch of the footer is skipped.
| /// refused — and the refusal says it is the home folder, not a system | ||
| /// location. | ||
| #[test] | ||
| fn ensure_runtime_install_root_refuses_the_home_folder_by_name() { |
There was a problem hiding this comment.
Non-blocking: this test (and prune_plan_leaves_a_protected_install_folder_and_says_why in storage.rs) asserts only the refusal message, not that the folder actually survives.
This repo's AGENTS.md §3 requires a message about the CLI's own behavior to be asserted together with the resulting state in the same test, or — where that's genuinely impractical — a comment naming the test that proves the behavior separately. Neither is present here, unlike sibling tests elsewhere in this same PR (e.g. uninstall.rs's tests consistently pair message + fs::exists checks). The actual non-deletion guarantee is structurally enforced via ?-propagation and is indirectly covered by ensure_runtime_install_root_rejects_every_spelling_of_a_protected_path, so real risk is low, but this is a cheap, concrete gap against the project's own written test-quality rule. Confidence 70.
There was a problem hiding this comment.
Fixed in 337dad1, both of them.
- Runtime uninstall: the new
runtime_uninstall_of_a_runtime_in_the_home_folder_is_refused_and_removes_nothingruns a realuninstall_runtime, with home pointed at the runtime's own sandbox folder under the process-wide env locks. It asserts the refusal (... because it is your home folder) together with the folder, its files and its registry entry still being there. It goes red with the gate call inshould_remove_runtime_install_rootremoved. - Prune: a protected system folder cannot be staged in a sandbox, so
prune_plan_leaves_a_protected_install_folder_and_says_whykeeps pinning the plan (plan.removeis empty) and the line together. It now has a comment namingprune_removes_the_install_it_named_and_not_a_case_twin_of_it, which shows on disk that prune removes exactly what its plan lists. That is the AGENTS §3 form for this case.
| /// both ways. `/opt`, `/var` and `/root` are refused here (a runtime prefix | ||
| /// there is the system's), while `rocm uninstall` refuses only their top level | ||
| /// and lets a marked folder below them go. And `/lib32`, `/libx32`, `/run`, | ||
| /// `/media`, `/snap`, `/mnt/wsl` and `/mnt/wslg`, which [`uninstall_system_roots`] |
There was a problem hiding this comment.
Non-blocking/informational: the doc comment here documents that the runtime-folder rule and the rocm uninstall rule use different root lists, but not that they also check home-vs-system in a different order.
uninstall_root_verdict_on checks system-roots before the home exemption (so $HOME=/usr/sbin can't open up /usr), while the legacy protected_location_on/runtime_protected_location checks home before system-roots (pre-existing, unchanged by this PR, e.g. /root/.rocm stays removable by design). Both orderings are intentional and tested, but a one-line addition here noting the precedence also differs (not just the lists) would save the next reader from re-deriving it. Confidence low/informational.
There was a problem hiding this comment.
Added in 337dad1. The system_roots doc now also says the two rules check in different orders. The uninstall rule checks system locations first, so a home of /usr/sbin cannot open up /usr. The runtime-folder rule checks home first, so /root/.rocm stays removable when /root is home. It names a_root_users_home_is_refused_as_a_home for the second.
| if let UninstallRootVerdict::Refused(why) = rocm_core::uninstall_root_verdict(path, home, &[]) | ||
| && !(why == ProtectedLocation::OtherUsersHome | ||
| && metadata.is_dir() | ||
| && resolves_inside_own_home(path, home, canonicalize)) |
There was a problem hiding this comment.
Non-blocking/informational: asymmetry between directory and file/symlink roots for the short-name/symlinked-parent exemption.
The exemption that allows a root spelled outside home but really resolving inside it (e.g. a Windows 8.3 short name) only applies when metadata.is_dir(). A file or symlink root in the same situation is always refused rather than exempted the way a directory root would be. This fails safe (over-refuses) rather than under-refusing, so it's not a security bug — just an inconsistency versus the directory case, which is otherwise thoroughly tested. Confidence low.
There was a problem hiding this comment.
Deliberate, so left as is. The exemption works by canonicalizing the whole path. For a directory that is exactly what is removed, but for a link root it would follow the link and judge the target, while the uninstall only unlinks the link. A file or link root is instead judged by its resolved folder under its own name (real_location_of_non_dir), after the spelling check.
So a file root spelled with the short 8.3 home name is refused rather than planned, as you say. That fails safe, and a setting naming a single file under a short-named home is not a case I have seen. If it comes up, the fix is to resolve only the folder for the exemption too.
judge_uninstall_root fell back to the home folder's spelling, resolved as far as it goes, on any error canonicalizing it. A home folder that exists but cannot be resolved (permission denied on a component) could then miss the comparison with a root that really is home. Only a home folder that does not exist keeps the fallback now; any other error refuses the root as unresolvable, as a system location already does (a_home_folder_that_cannot_be_resolved_refuses_the_root). From the same review: - runtime_uninstall_of_a_runtime_in_the_home_folder_is_refused_and_removes_nothing runs a real runtime uninstall with home pointed at the runtime's folder and checks the refusal together with the folder, its files and its registry entry still being there. - uninstall_plan_refuses_the_filesystem_root asserted the absence of a heading that no longer exists; it now checks that a refused dry run on a terminal says it would be refused instead of inviting a real run. - prune_plan_leaves_a_protected_install_folder_and_says_why names the test that shows prune removes exactly what its plan lists. - The load-bearing sort of planned removals, and the different home/system precedence of the two protected-location rules, are documented. Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
…ed-roots Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com> # Conflicts: # docs/architecture.md # docs/manual-testing.md
|
Answers juhovainio's review of acc80d1. The fixes are in 337dad1, on top of a merge of current Diffed whole against acc80d1 (
Re-verified on this head: fmt, |
juhovainio
left a comment
There was a problem hiding this comment.
I went through the full diff. The overall approach looks sound and the scenarios (uninstall-16 to 22) cover the new refusals well. One thing is worth fixing before merge, and a few smaller points are below.
Worth fixing
- In
ensure_marked_uv_venv(inline comment), "this call created the folder" is decided withexists()before the slowuv venvruns. A folder someone else creates in that window still gets marked as ROCm CLI's own. That is a wider window than the one already listed under follow-ups, and it weakens the README claim that the marker only goes into folders ROCm CLI creates. Creating the folder throughcreate_marked_rootfirst, or narrowing the claim, would fix it.
Questions / smaller points
- On Windows the removal target now comes back from
canonicalize_for_comparewith the\\?\prefix stripped. For roots longer than MAX_PATH, canremove_pathstill handle that? I could not verify it from the diff alone. - Six
uninstall_plantests fail whenTMPDIRis under/home(the PR body notes this). Could they pin their own temp root so they pass wherever they run? - The marker scheme goes beyond what #531 asked for: a root outside home that this release did not create, such as a pre-made
--prefix /opt/xor a customROCM_CLI_*_DIR, is refused on upgrade until the user creates.rocm-cli-root. It is documented, but it needs a release-notes entry. - Two protected-location policies now coexist (runtime folders and uninstall roots), and the doc comment in
runtime.rsadmits they are unreconciled. Is there a plan to merge them? - The PR also bundles dashboard
/uninstallflag handling,ROCM_CLI_APP_PATH_SOURCESforwarding, and removal of the publicruntime_install_root_is_protectedAPI. These would be easier to review and revert as separate changes.
CI is green on every required check; only the MI300X lane is pending, and it has no runner.
| // Both decided BEFORE `ensure_uv_venv`, which may remove and recreate the | ||
| // folder (an incompatible venv is rebuilt) and so lose the marker: a | ||
| // folder ROCm CLI created, or one it had already marked, is marked again. | ||
| let created = !install_root.exists(); |
There was a problem hiding this comment.
created is decided with exists() before uv venv runs, so a folder someone else creates in between is still marked as ROCm CLI's own. This is a wider window than the create_dir-to-marker one listed under follow-ups, and it weakens the README claim that the marker only goes into a folder ROCm CLI creates itself. Consider creating the folder via create_marked_root first, or narrowing the claim.
Fixes #531.
rocm uninstallhad no protected-location check. SettingROCM_CLI_DATA_DIR=/, or installing an SDK with--prefix ~, could make it remove/or the home folder. So could a home folder spelled as.or reached through a symlinked parent.Each config, data or cache root is now judged both as written and by where it really is. A file or link root is judged by where its folder really is, under its own name (
~/x/config.jsonwith~/x -> /etcis/etc/config.json); the link itself is unlinked, never followed:/./usr /etc /boot /bin /sbin /lib /lib32 /lib64 /libx32 /sys /proc /dev /run /media /snap /mnt/wsl /mnt/wslg, andWindows,Program Files*andProgramDataon the system drive or a WSL/mnt/<drive>./,/var/{lib,cache,log,tmp}, and/mnt/<x>.RUNNER~1-style 8.3 name) is judged by where it really is, so it is allowed, or refused as your home if it is your home itself; a link or file spelled that way keeps the refusal its spelling earns. A real Windows 8.3 name is exercised only by the Windows install-lifecycle lane; the unit tests stand a symlink in for it..rocm-cli-root. ROCm CLI writes that file only into a folder it creates itself: its config, data and cache setup, the first log line, the first config save, the download-metadata and vLLM cache writes, and an SDK--prefix. Folders from earlier releases, made by hand, or first created by some other command are unmarked and refused rather than removed; the refusal names the file to create.What a refusal does
ROCM_CLI_DATA_DIRnames that variable, not "the default location".--keep-<kind>, pointing that variable elsewhere, or creating the marker. Forsetup.therock_venvit leads with--keep-data, because moving the setting would orphan the SDK./, a home folder, a system or shared folder, another user's home). An unmarked folder, which the marker clears, gets no such sentence.This uninstall would be refused. <advice>instead of the usual next-step line, whoever reads it, and exits non-zero./uninstallnow refuses a flag it does not know (so a typo cannot turn into a full removal) and passes--keep-*and--force-dev-binariesthrough, the assistant's preview honours them, androcmchildren the dashboard and assistant start get a newROCM_CLI_APP_PATH_SOURCESvariable so their refusals name the setting the user actually made.Checks just before removal
require_yes_or_interactiveguard (its injectable_withform, now public, so the tests drive the terminal probe).rocm.fishincluded, is removed.rocm uninstall(ProgramData included) on the system drive, not a fixedC:.rocm runtimes uninstall,rocm storage remove-old-installs) keep their existing rule, but their refusal now names the reason, e.g. "because it is your home folder". On Unix that rule still does not refuse/lib32,/libx32,/run,/media,/snap,/mnt/wslor/mnt/wslg, whichrocm uninstalldoes; the two lists are not reconciled here, andsystem_roots' doc comment says so.--prefixby the runtime-folder rule (which now also covers the home folder) and says why.Tests
features/uninstall.feature, each asserting the message together with the resulting state:uninstall-16(@id:uninstall-filesystem-root-refused, Linux):ROCM_CLI_DATA_DIR=/is refused in a dry run, naming the variable and--keep-data.uninstall-17(@id:uninstall-home-refused-nothing-removed): the home folder as data folder is refused, saying ROCm CLI never removes it, the home file and config folder survive, and re-running with the flag taken from the message succeeds.uninstall-18(@id:uninstall-shared-cache-inside-root-warned): shared caches inside the cache folder are named as deleted and a preview deletes nothing; a real run with--keep-cachekeeps the uv cache and one without removes it.uninstall-19(@id:uninstall-dot-from-home-refused, Linux):ROCM_CLI_DATA_DIR=.from home is refused and nothing is removed.uninstall-20(@id:uninstall-unmarked-folder-refused-until-marked, Linux): a real run refuses an unmarked folder, leaves it in place and does not claim it is never removed; creating the marker the message names clears the refusal, and a real run then removes the folder.uninstall-21(@id:uninstall-dashboard-names-the-real-setting): the dashboard's approved-command path namessetup.therock_venv.uninstall-22(@id:uninstall-file-through-linked-folder-refused, Linux): a data setting naming a file through a home-folder link to/procis refused as/proc/version, and the config folder is left in place.users/home/.rocm/...), since a folder beside HOME counts as another user's home;uninstall-05anduninstall-06likewise keep their isolated config and data folders inside it (on Windows the harness's own folders sit insideC:\Users\<runner>, which is another user's home there).readme_names_every_uninstall_system_rootholds README's list of refused system folders to the code in both directions for both platforms, on every lane (it reads README at run time, andxtask/src/prepush.rslistsrocm-coreas a README reader so the narrowed pre-push hook runs it when README changes), anduninstall_help_names_only_folders_it_refuseschecks each folderrocm uninstall --helpnames is really refused (each platform's names on its own lane)./and/usr/sbin, other users' homes,/mntdrives, shared folders, extra resolved system roots), the deletion property tests, unit tests for every class, piece of advice and re-check, Windows-parameterised tests on all platforms, and a dashboard pass-through test.uninstall-17anduninstall-19with the refusal taken out of the uninstall path.@requires-os:linuxones on Linux only); the lifecycle ones on the Linux and Windows acceptance lanes. Not run locally: anything on Windows (windows-build-and-testcovers the Windows-parameterised unit tests).--prefix, the metadata cache, the vLLM cache) has a test that the folder it creates is marked and an existing one is not; the tarball and metadata steps sit in small helpers for that. A system location that exists but cannot be resolved refuses the root as unresolvable instead of dropping out of the comparison.a_system_location_that_cannot_be_resolved_refuses_the_root,a_home_folder_that_cannot_be_resolved_refuses_the_root).runtime_uninstall_of_a_runtime_in_the_home_folder_is_refused_and_removes_nothingruns a real runtime uninstall against a home folder and checks the refusal together with the folder and its registry entry being left.uninstall_plantests that build a fake home under the temp folder fail whenTMPDIRis itself under/home, which CI's is not.create_dir, so a parent-folder writer could swap in a link in between (a link root is still only unlinked, never walked); writing it relative to the new directory's handle needs per-platform code. The binaries' path record and the running binary's self-delete are not re-checked right before removal like the other entries; both predate this change.Docs
rocm uninstallsection lists what it never removes, how a file or link root is judged, and what clears each refusal;rocm uninstall --helpsays the same in short.docs/manual-testing.mdgains an "Uninstall Safety" section (17) to run in a throwaway home,docs/testing.mddescribes the new uninstall properties and scenarios, anddocs/architecture.mddescribes the uninstall modules' new roles.Interactions
ensure_uv_venvso it no longer deletes the venv folder. This PR re-marks a rebuilt folder that was marked before, so the two work together whichever merges first.uninstall.rsand the uninstall docs too. Whichever merges second must route removal throughapply_uninstall_planand keep the refusal check before fix(uninstall): stop managed services before removing the tooling that stops them (EAI-8014) #299's service-stop step.