Skip to content

ROCMAI-826: keep the cache folder under an overridden data folder - #834

Merged
volen-silo merged 1 commit into
mainfrom
rocmai-826-cache-dir-data-dir
Nov 3, 2026
Merged

volen-silo merged 1 commit into
mainfrom
rocmai-826-cache-dir-data-dir

Conversation

@volen-silo

@volen-silo volen-silo commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

With ROCM_CLI_CONFIG_DIR and ROCM_CLI_DATA_DIR set but no ROCM_CLI_CACHE_DIR, AppPaths::discover fell back to the default ~/.rocm/cache. rocm storage then reported the default install's cache, and rocm uninstall of the isolated install listed it and deleted it. Found while testing the v0.2.1 release on Windows from an isolated config/data folder.

Change

The cache folder now follows ROCM_CLI_DATA_DIR to <data>/cache: where it sits by default (~/.rocm/cache under ~/.rocm) and where a setup.therock_venv managed root already puts it. ROCM_CLI_CACHE_DIR still wins when set. The installers only read ROCM_CLI_CONFIG_DIR and are unaffected. The README's uninstall section now names the three variables and says where the cache goes.

A setup.therock_venv managed root does not re-root this cache: discover_from_paths applies a managed root only when ROCM_CLI_DATA_DIR is not set, so a cache derived from the data folder is never moved. a_managed_root_does_not_move_a_cache_that_followed_the_data_dir pins this.

Behaviour change

(The README's uninstall section carries a line about this; the repo has no changelog or release-notes file, so this PR text is where it is recorded.)

A user who set only ROCM_CLI_DATA_DIR (no ROCM_CLI_CACHE_DIR) now gets a new, empty <data>/cache. Their previous cache at ~/.rocm/cache is orphaned from that install: archives it held are downloaded again into the new folder, and rocm uninstall of that install no longer removes ~/.rocm/cache. The cache holds only re-downloadable archives, so nothing is lost; the old folder can be deleted by hand.

Docs

README (uninstall section) is updated. docs/testing.md and docs/manual-testing.md set all three variables explicitly, which stays correct, and neither they nor the --help text for storage and uninstall --keep-cache state where the cache lives, so they need no change.

Tests

  • Unit, in crates/rocm-core/src/paths.rs (from_overrides takes a small named PathOverrides struct rather than three positional Option<PathBuf> arguments):
    • cache_dir_follows_an_overridden_data_dir: the cache follows the data folder; an explicit cache override still wins.
    • a_managed_root_does_not_move_a_cache_that_followed_the_data_dir: the discover() path with a data override and a managed root in the config.
    • cache_dir_keeps_its_default_without_a_data_override: moving only the config folder leaves the default cache. It no longer returns early on a host without a default cache folder.
  • Scenario: uninstall-05, @id:uninstall-moved-data-folder-keeps-its-own-cache, in tests/e2e-cucumber/features/uninstall.feature. It has no OS, GPU or link tags, so it runs on the mock lane in the required E2E tests job on every PR, and passes there. It plants a file in the default home cache and one in the data folder's own cache, runs storage report and uninstall --yes --keep-binaries with config and data moved but no cache override, and asserts that the uninstall prints exactly one removed cache <data>/cache line, that the data folder's cache is gone, and that the home cache is neither named nor removed. (An earlier version looped over whatever removed cache lines were printed, so it passed when none were: the data folder's cache did not exist, so the uninstall printed "cache path not present". It is tightened and now plants that cache.)

The tests fail without the fix. With the or_else(managed_runtime_cache_dir) line removed from from_overrides:

Test Without the fix With the fix
cache_dir_follows_an_overridden_data_dir fail pass
a_managed_root_does_not_move_a_cache_that_followed_the_data_dir fail pass
cache_dir_keeps_its_default_without_a_data_override pass pass (pins the unchanged default)
uninstall-05 fails at "the storage report names the cache folder inside the data folder" pass

cargo nextest run -p rocm-core (886 passed), clippy for rocm-core and e2e-cucumber (including --test e2e), cargo fmt --check: pass. Manual check on Windows with the built binary: uninstall removed only the isolated data folder; the planted home-cache file survived.

Note for the protected-roots uninstall work

An open branch on uninstall protected roots reports the cache's source as Default whenever ROCM_CLI_CACHE_DIR is unset. After this change, a cache that followed ROCM_CLI_DATA_DIR should be reported as coming from the data override instead. That branch also uses scenario number uninstall-05, so one of the two will need renumbering (uninstall-04 is taken by #823 on main, so this PR uses uninstall-05).

CI on the Windows lane

On the previous head E2E tests (Strix Halo, Windows, current) failed 4 of 174 scenarios: serve-01 and serve-02 (no "resolved model" line), runtime-02 (no Folder: line in the examine output) and runtime-09 (the SDK install preview declared a mirror source rather than the canonical release aggregate). uninstall-05 passed there, and none of the four exercises the cache folder. I could not compare against a green run on main, because the other Windows runs were skipped or still running. The two Strix Halo, Ubuntu lanes hit the 45-minute cap, which #852 addresses.

@volen-silo
volen-silo marked this pull request as ready for review November 2, 2026 14:37
@volen-silo
volen-silo requested a review from a team as a code owner November 2, 2026 14:37

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fix is at the right layer: the cache now follows ROCM_CLI_DATA_DIR unless ROCM_CLI_CACHE_DIR says otherwise. The pure from_overrides helper plus the uninstall-04 scenario cover it well, and the spec matches ROCMAI-826. I found nothing broken, but I'd like a few things closed before merge:

  1. Docs sync. Only README.md changed. Please grep docs/testing.md, docs/manual-testing.md and the storage/uninstall --help text for the old "cache is always ~/.rocm/cache" claim and update or confirm each.
  2. Behavior change in the PR body. Anyone with only ROCM_CLI_DATA_DIR set now gets a fresh <data>/cache; the old ~/.rocm/cache is orphaned (re-download, and uninstall no longer cleans it). Please state this in the PR text.
  3. Evidence the new tests bite. Please show the unit tests and uninstall-04 go red with the or_else(managed_runtime_cache_dir) line reverted, and say so in the PR text.
  4. PR text. Name the scenario id (@id:uninstall-moved-data-folder-keeps-its-own-cache) and the lane that exercises it.
  5. Vacuous unit test. cache_dir_keeps_its_default_without_a_data_override returns early when default_cache_dir() is None, so it can pass without asserting anything (inline).
  6. Please confirm discover_from_paths/with_managed_root doesn't re-root a cache derived from the data folder: cache_dir_override.is_some() stays false in that case. The discover() wiring is covered only by the e2e scenario, not the unit tests.

CI: all completed checks are green; the GPU hardware lanes were still pending when I looked.

Comment thread crates/rocm-core/src/paths.rs Outdated
data_dir: Option<PathBuf>,
cache_dir: Option<PathBuf>,
) -> Result<Self> {
let cache_dir = cache_dir.or_else(|| data_dir.as_deref().map(managed_runtime_cache_dir));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is the behavior change: a user with only ROCM_CLI_DATA_DIR set now gets a new empty <data>/cache, and the old ~/.rocm/cache is orphaned (re-download, and uninstall no longer cleans it). Worth a line in the PR body. Also, please show a test fails when this line is reverted.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done. The behaviour change is now spelled out in the PR description (a user with only ROCM_CLI_DATA_DIR set gets a new empty <data>/cache; the old ~/.rocm/cache is orphaned from that install, so archives are downloaded again and uninstall no longer removes it). Red evidence is in the description too: with the or_else(managed_runtime_cache_dir) line removed, cache_dir_follows_an_overridden_data_dir, a_managed_root_does_not_move_a_cache_that_followed_the_data_dir and the e2e scenario (now uninstall-05, after a rebase onto main where uninstall-04 was taken) all fail; with it restored they pass. Pushed as 265fddd.

Comment thread crates/rocm-core/src/paths.rs Outdated
// Only the config folder moved: data and cache both stay at their
// defaults, so the cache is not pulled under the config folder.
let (root, _) = temp_app_paths("cache-default");
let Some(default_cache) = default_cache_dir() else {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This returns early when default_cache_dir() is None, so the test passes without asserting anything on such a host. Consider asserting (or expect) so it cannot pass vacuously.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 265fddd: it now expects a default cache folder instead of returning early, so it cannot pass without asserting. To the second point (that it does not exercise the new branch): agreed, and it is not meant to. It pins the unchanged default, i.e. that moving only the config folder does not pull the cache under it, which guards against an over-correction of this change. The tests that exercise the fix are the two above it, and the description says which tests fail without it.

Comment thread README.md
cache directory is `~/.rocm/cache`. `uninstall` removes a category's directory
cache directory is `~/.rocm/cache`. The `ROCM_CLI_CONFIG_DIR`,
`ROCM_CLI_DATA_DIR`, and `ROCM_CLI_CACHE_DIR` environment variables move them;
when only `ROCM_CLI_DATA_DIR` is set, the cache directory moves with it, to

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please also check docs/testing.md, docs/manual-testing.md and the storage/uninstall --help text for the old "cache is always ~/.rocm/cache" claim and update them in this change.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Checked docs/testing.md, docs/manual-testing.md and the storage / uninstall --keep-cache help text for a claim that the cache is always ~/.rocm/cache: none makes it. Both docs set all three ROCM_CLI_*_DIR variables explicitly, which stays correct, and the help text only says "the cache directory". The README paragraph is the one place that stated the location, so it is the only doc changed; the PR description now says this.

@nowycondro nowycondro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review — needs work

Full review of the whole change.
Implements ROCMAI-826 exactly as scoped: the cache directory now follows ROCM_CLI_DATA_DIR to <data>/cache unless ROCM_CLI_CACHE_DIR overrides it. The ticket's own suggested remedy ("the cache directory follows the configured data directory (or has its own documented override)") is implemented verbatim. The related ticket ROCMAI-465 (uninstall protected-roots guard) is correctly left out of scope and not claimed as closed.

Blocking

  • cache_dir_keeps_its_default_without_a_data_override does not test the change, and can pass vacuously — crates/rocm-core/src/paths.rs:432-446
    Traced both required verdicts for an added test: (1) would it still pass with the fix reverted? Yes — with both data_dir and cache_dir overrides absent, from_overrides never reaches the new or_else(|| data_dir.as_deref().map(managed_runtime_cache_dir)) branch either before or after the fix, so this test exercises no code path the change touches. (2) it can also assert nothing at all: let Some(default_cache) = default_cache_dir() else { return Ok(()) }; (lines 436-438) silently short-circuits to a passing Ok(()) on any host where default_cache_dir() resolves to None. No other test in this file uses an early-return-on-None pattern, so this isn't an established repo convention. An independent pass over the same file reached the identical conclusion on verdict (1).
    Confidence 85 · logic · Fix: either delete this test (the "config dir alone" invariant it checks was never at risk and isn't touched by this diff) or rewrite it to assert something only the new code path could produce, and drop the silent-None escape in favor of an explicit skip/log.

  • PR text does not show the required red-test evidence for all new tests — PR description; AGENTS.md:86-90, AGENTS.md:483
    AGENTS.md §3 states plainly: "Every bug fix ships with a regression test ... test fails before fix and passes after fix" and "A new test is shown to fail when the code it covers is broken. Before pushing, break the branch under test ... and confirm the test goes red" — repeated as checklist item 14 ("New tests shown to fail when their target is broken"). The PR body states this only for cache_dir_follows_an_overridden_data_dir ("The first fails without the fix (resolves to the home cache)"). It gives no such confirmation for the uninstall-04 e2e scenario, which is the test that actually exercises the fixed discover() wiring end-to-end (the unit tests exercise from_overrides directly, not discover_from_paths/with_managed_root's interaction with it). Reasoning through it, the scenario would plausibly fail correctly if reverted (storage report would then name the simulated home cache, and the uninstall would remove it) — but the repo's own rule requires this to be shown, not reasoned about, before the PR is upstream-ready.
    Confidence 80 · logic · Fix: state in the PR text that uninstall-04 was run with the fix reverted and went red (or do so and report it).

Non-blocking

  • docs/testing.md and docs/manual-testing.md weren't touched despite AGENTS.md:200-205's "update README.md, ... docs/testing.md, and docs/manual-testing.md in the same change" rule for an observable-behavior change. Checked both files directly: neither currently makes a stale or incorrect claim about where the cache directory resolves (docs/manual-testing.md always sets ROCM_CLI_CACHE_DIR explicitly; docs/testing.md just lists all three override variables without asserting a relationship between them), so there is no live inaccuracy today — only an unticked procedural step.

Decisions for the author

  • Orphaning the old home-directory cache instead of migrating it — tradeoff
    The PR explicitly chooses to leave ~/.rocm/cache behind rather than move its contents when ROCM_CLI_DATA_DIR alone is set, reasoning the cache only holds re-downloadable archives. That's a reasonable call, but it is a one-time, silent storage-usage increase (stale archives sit un-cleaned at the old location indefinitely, since uninstall of the isolated install no longer reaches them) for any existing isolated-data-dir user who upgrades. Confirm that's acceptable versus, e.g., a one-time migration or a note in the storage report about the orphaned folder.

Positive signals

  • from_overrides is a good extraction — pulling the override-resolution logic into a pure helper that takes overrides as arguments (rather than reading the environment inside the function) is exactly what let the new unit tests drive it directly without mutating process-global env vars, consistent with the pattern already used elsewhere in this file (e.g. engine_envs_dir_from).
  • The e2e step assertions are tied to the real production string formats, not re-implemented guesses — storage_names_data_cache's expected (<path>) suffix and uninstall_skips_default_cache's "removed cache <path>" string both match storage.rs::render_report and uninstall.rs's report(format!("removed {} {}", ...)) exactly, verified by reading both sides.

Deployment notes

  • Confirmed behavior change, consistent with what the PR states: any existing install that sets only ROCM_CLI_DATA_DIR (not ROCM_CLI_CACHE_DIR) will, after upgrading, resolve its cache to a fresh <data>/cache rather than the previous ~/.rocm/cache; the old location is left on disk and is no longer reachable by rocm uninstall or rocm storage for that install.

What this covered

Read completely: README.md's diff hunk, crates/rocm-core/src/paths.rs in full (both at bcd879d007 and at e51a0770e), the relevant functions in crates/rocm-core/src/runtime.rs (env_path_override, default_config_dir/default_data_dir/default_cache_dir, managed_runtime_cache_dir, managed_runtime_data_root, normalize_runtime_path_for_host), tests/e2e-cucumber/features/uninstall.feature, tests/e2e-cucumber/tests/e2e.rs (the isolation/env-override harness), tests/e2e-cucumber/tests/e2e/uninstall_steps.rs in full, the corresponding production string formats in apps/rocm/src/storage.rs and apps/rocm/src/uninstall.rs/uninstall_plan.rs, and AGENTS.md in full. Diff reviewed: bcd879d007ba2db287688147637af2386e979616…e51a0770e500732ea328fe22f624683316206ad7.

An independent fan-out worker reviewed paths.rs/runtime.rs blind and reached the same conclusions (no defect in the override-resolution logic across all four override combinations; the same test-quality gap on cache_dir_keeps_its_default_without_a_data_override). A second worker, scoped to the e2e harness files, failed to spawn twice due to a concurrency limit in this environment; that pass was performed directly by me instead of independently, and is disclosed as such. History pass: paths.rs has only one prior commit (its original extraction), nothing relevant surfaced. Prior-changes pass (review comments on earlier changes to these files) did not run — no access to historical review threads. Could not execute cargo test/cargo nextest locally (no Rust toolchain available in this environment); the production-logic and test-quality findings above are argued from reading the code paths directly rather than from a run, and CI's own E2E tests job (which exercises uninstall-04) is read from the PR's check-run list and reports green. Not reconciled against any discussion on this PR: this review was conducted from the code, the PR description, and the linked Jira ticket (ROCMAI-826) only, per this method's blind-review rule. Note for transparency: an existing review from another reviewer was unavoidably visible in this review's mandatory pre-publish duplicate-check query before this review began; its text was not used to derive, word, or bias any finding here, though some overlap exists because both reviews independently check the same code against the same repository rules.

@volen-silo
volen-silo force-pushed the rocmai-826-cache-dir-data-dir branch from e51a077 to 265fddd Compare November 3, 2026 07:25
@volen-silo

Copy link
Copy Markdown
Collaborator Author

Pushed 265fddd, rebased onto main (the old scenario number uninstall-04 was taken by #823, so this is now uninstall-05). Points in the review:

  1. Docs: audited, nothing else claims the old location (reply on the README thread).
  2. Behaviour change: stated in the description.
  3. Red evidence: in the description, as a before/after table, including the e2e scenario.
  4. Scenario id and lane: named in the description; it runs in the required E2E tests job.
  5. Vacuous unit test: fixed.
  6. Managed root re-rooting a cache derived from the data folder: it cannot, since discover_from_paths only applies a managed root when ROCM_CLI_DATA_DIR is not set. A new unit test, a_managed_root_does_not_move_a_cache_that_followed_the_data_dir, pins it through discover_from_paths and fails without the fix.

On orphaning the old home cache rather than migrating it: kept as is, since the cache holds only re-downloadable archives; the description says so.

@volen-silo
volen-silo dismissed juhovainio’s stale review November 3, 2026 07:27

All six points are addressed in 265fddd and the updated description; see the replies and the summary comment on this PR. Dismissing so the PR is not blocked on a review that no longer reflects its head; a re-review is welcome.

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I went through the diff, the new unit tests and the uninstall-05 scenario. I didn't find a defect in the fix itself: resolving the cache folder at the AppPaths layer, reusing the managed-root layout, and keeping ROCM_CLI_CACHE_DIR as the explicit override all look right, and the scenario matches the "cache follows the data dir" option in ROCMAI-826.

Requesting changes only because of what I can't yet clear:

  • CI: "E2E tests (Strix Halo, Windows, current)" failed after about 15 minutes, and I couldn't get its log. uninstall-05 has no OS tags and so runs on Windows too, so please check whether that failure comes from the new scenario before this merges. The two Strix Halo Ubuntu jobs hit the 45m timeout, which looks like infrastructure. The W7900 and MI300X jobs were still pending when I looked.
  • Behavior change worth a note: users who set only ROCM_CLI_DATA_DIR now get a fresh, empty <data>/cache, and their old cache is orphaned. The PR body mentions this, but the README and release notes don't. A line in the release notes would save some confusion.

Two smaller things are in inline comments (a vacuous assertion in the scenario step, and positional Option<PathBuf> arguments).

);
// Whatever cache it did remove is the isolated install's own.
let expected = format!("removed cache {}", data_cache(world).display());
for line in stdout.lines().filter(|l| l.starts_with("removed cache ")) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If no removed cache line is printed, this loop runs zero times and the check passes. Consider also asserting that exactly one such line exists, so the check can't pass without anything having been removed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You were right, and it was worse than a loose loop: when I required exactly one removed cache line the scenario failed on Windows, because it never created the data folder's cache, so the uninstall printed "cache path not present" and the old loop saw zero lines and passed. The step now requires exactly one removed cache <data>/cache line, and a new Given plants a file in that cache and a new Then asserts the folder is gone. With the or_else(managed_runtime_cache_dir) line removed, uninstall-05 goes red at the storage-report step (so the new removal steps are not reached in that red run), and it passes with the fix. Pushed as 4e91f44.

Comment thread crates/rocm-core/src/paths.rs Outdated
///
/// Takes the overrides as arguments so tests can drive it without
/// mutating the process environment.
fn from_overrides(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor: three positional Option<PathBuf> parameters (config/data/cache) compile fine if transposed, and the tests would still read plausibly. A small struct or named setters would make a mix-up a compile error. Related nit: managed_runtime_cache_dir is now also used for the plain data-dir case, so the name is slightly misleading.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done: from_overrides now takes a private PathOverrides { config, data, cache } struct, and discover and the unit tests use named fields. The fields are not named *_dir because clippy::struct_field_names rejects a shared postfix under -D warnings. I left managed_runtime_cache_dir as it is: it is the canonical <data>/cache layout function that the managed-root path also uses.

@jussielo-amd jussielo-amd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of 265fddd: needs work (one red check, plus a few non-blocking points)

The fix itself looks right to me. from_overrides makes the cache follow ROCM_CLI_DATA_DIR to <data>/cache, the same place it sits by default and where with_managed_root already puts it, and ROCM_CLI_CACHE_DIR still wins. I read the diff completely, ran the new paths:: tests and the full rocm-core suite on the PR head (942 passed), and mutated each branch of the change one at a time to see which tests notice.

Blocking

  • E2E tests (Strix Halo, Windows, current) is red on this head. The job's own reconciliation reports one unexpected failure, runtime-resolve-canonical-release (runtime-09). The preview printed a runner-local pip mirror as canonical_source and index_url, where the step asserts https://repo.amd.com/rocm/whl-multi-arch. I see nothing tying that to this change, and uninstall-05 passed in the same log with all four of its steps, but I can't show it is red on main too, because every E2E self-hosted run on main is still queued. Please rerun the job, or have a maintainer confirm the mirror is the cause. The MI300X and W7900 jobs are still queued and the two Strix Ubuntu jobs were cancelled, so they have not covered this head either. The required CI / E2E tests job, which carries uninstall-05 on the mock lane, is green, as are clippy and the Windows debug build.

Non-blocking

  • discover()'s wiring of the "data folder was overridden" flag is untested, but the PR text says it is pinned. The comment in a_managed_root_does_not_move_a_cache_that_followed_the_data_dir says it is "the path discover() takes", and the PR body says it covers "the discover() path". The test calls discover_from_paths(paths, true, false) with hand-supplied flags. When I changed discover() to pass false for the data-override flag, all of paths:: stayed green (11 passed) and so did the whole rocm-core suite. With that mutation, ROCM_CLI_DATA_DIR plus a setup.therock_venv config would re-root the data folder and the cache with it, which is exactly what the PR says cannot happen. The other two mutations were caught: dropping the new or_else(managed_runtime_cache_dir) fails cache_dir_follows_an_overridden_data_dir and the managed-root test, and dropping the !data_dir_overridden guard fails the managed-root test and app_paths_apply_configured_managed_root_when_unoverridden. Either give discover() and the test one shared seam that takes the three overrides, or reword the comment and PR body to say the test covers discover_from_paths.

  • --keep-cache no longer protects the cache on an install with only ROCM_CLI_DATA_DIR set, and the README scope phrase is now too narrow. With this change <data>/cache is the cache for those installs. build_uninstall_plan lists data and cache as separate actions, and remove_path runs fs::remove_dir_all on a real directory, so rocm uninstall --keep-cache without --keep-data removes the cache along with the data folder, while the plan still prints "cache removal disabled by command line flag" under "Left alone". Default installs already behave this way, since ~/.rocm contains ~/.rocm/cache, and the README says so with "on a default installation a flag doesn't protect its files by itself". After this PR a second class of installs behaves the same way, so that phrase is incomplete. I traced this from the code and did not run it. Suggest widening the README sentence to say when a folder sits inside another, as the cache does by default and whenever only ROCM_CLI_DATA_DIR is set. The "Left alone" line being false for nested folders is pre-existing and could be its own ticket.

  • The PR body describes an earlier revision of one test. "It no longer returns early on a host without a default cache folder" has no referent in a one-commit diff, since cache_dir_keeps_its_default_without_a_data_override is new here and uses .expect(...). Worth dropping the clause so the body matches the final diff.

Decisions for the author

  • The old cache is orphaned silently. A user with only ROCM_CLI_DATA_DIR set gets a new empty <data>/cache, and ~/.rocm/cache is no longer reported by rocm storage or removed by rocm uninstall for that install, with no notice. The PR body discloses this and notes the cache only holds re-downloadable archives. The alternative is a one-time notice or a migration, at the cost of extra code for a low-value cache. Please confirm "document it, don't migrate" is the intent.
  • The cache now lives wherever ROCM_CLI_DATA_DIR points. Anyone who put the data folder on a small volume will now accumulate large archive caches there. ROCM_CLI_CACHE_DIR still wins and the README now says so.

What I liked

  • from_overrides takes the three overrides as arguments, so the unit tests need no set_var.
  • The managed-root test asserts its config fixture really is one configured_managed_root_from_config reads, so it cannot pass vacuously.
  • uninstall-05 asserts both the message and the resulting state: the storage row must end with the data folder's cache, the uninstall must not name the home cache, and the planted file must survive. By reading the code, reverting the fix makes the storage assertion fail. I did not run the scenario, because that needs a full rocm build.
  • The step helper sets HOME and USERPROFILE and uses env_remove rather than an empty value, so a regression deletes only the scenario's own home.

Not covered

I did not run the uninstall-05 scenario itself, the cargo nextest and manual-Windows claims in the PR body, the full workspace tests, clippy or smoke_local.py; I relied on CI for those. I also did not retrieve ROCMAI-826. A merge-tree check against current main shows no conflicts and no scenario-number collision.

@nowycondro nowycondro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 Automated review (Claude Code) · 265fddd

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 — no blocking findings

Full review of the whole change.
Implements ROCMAI-826 exactly as scoped: the cache directory now follows ROCM_CLI_DATA_DIR to <data>/cache unless ROCM_CLI_CACHE_DIR overrides it, matching the ticket's own stated remedy verbatim. Ticket status is "In Progress"; the PR does not claim to close it.

Blocking

None

Non-blocking

None

Decisions for the author

  • Orphaning the old home-directory cache instead of migrating it — tradeoff
    Traced independently from from_overrides/default_cache_dir: a user who set only ROCM_CLI_DATA_DIR now gets a fresh, empty <data>/cache, while the old ~/.rocm/cache is left on disk, no longer reported by storage or reachable by uninstall for that install. The PR body already discloses this and argues it's acceptable because the cache only holds re-downloadable archives. Reasonable call; confirm it's still the intended tradeoff versus a one-time migration or a storage-report note about the orphaned folder.

Positive signals

  • from_overrides is a clean extraction: taking the three directory overrides as arguments (rather than reading the environment inside the function) is what lets the new unit tests drive precedence logic directly, without mutating process-global env vars.
  • The new e2e scenario's step assertions are tied to the real production string formats rather than re-implemented guesses — verified storage_names_data_cache's expected (<path>) suffix against storage.rs::render_report's actual " - {label}: {size} ({path})" line format, and it matches exactly.
  • cache_dir_keeps_its_default_without_a_data_override fails loudly (.expect(...), a panic) rather than silently short-circuiting to a vacuous pass on a host where default_cache_dir() resolves to None — good test hygiene for this class of guard.
  • The PR body documents an explicit per-test fail-without-fix/pass-with-fix table and states the orphaned-cache behavior change with its own reasoning, rather than leaving either to be inferred.

Deployment notes

  • Confirmed behavior change, consistent with what the PR states: any existing install with only ROCM_CLI_DATA_DIR set (no ROCM_CLI_CACHE_DIR) will, after upgrading, resolve its cache to a fresh <data>/cache rather than the previous ~/.rocm/cache; the old location is left on disk and is no longer reachable by rocm uninstall or rocm storage for that install.
  • CI at commit 265fddd2e74e4eb39d63b22ff04ccf0d34ed272f: the required E2E tests job (mock lane, which carries the new uninstall-05 scenario) is green, as are the Linux build/test, Windows debug/release builds, clippy, and CodeQL jobs. E2E tests (Strix Halo, Windows, current) is red — read directly from its job log: all 7 steps of uninstall-05 passed cleanly in that run; the one failure is a different, pre-existing scenario (runtime-09, "Previewing a release SDK install resolves the canonical aggregate for this GPU") asserting a canonical repo.amd.com package-index URL where the run observed an internal mirror hostname — unrelated to this diff. Two Strix Halo Ubuntu lanes show cancelled and the W7900/MI300X hardware lanes were still queued at review time, so hardware-lane coverage for this change was incomplete when reviewed.
  • GitHub reports mergeable_state: blocked for this PR independent of the above.

What this covered

Diff reviewed: 6eeec620c3d451a52bd8f98ef218fb9e8a0549a4...265fddd2e74e4eb39d63b22ff04ccf0d34ed272f (the PR's one commit, 5 files, +244/-17). Read completely: crates/rocm-core/src/paths.rs (full file + diff), crates/rocm-core/src/runtime.rs (full file, ~1823 lines, for every helper paths.rs calls into), README.md (diff), tests/e2e-cucumber/features/uninstall.feature (full + diff), tests/e2e-cucumber/tests/e2e.rs (diff plus the isolation/env-override harness it extends), tests/e2e-cucumber/tests/e2e/uninstall_steps.rs (full + diff), the relevant sections of apps/rocm/src/storage.rs (to verify step-assertion strings against production output), and AGENTS.md (full). Impact analysis: grepped every call site touching cache_dir/default_cache_dir/managed_runtime_cache_dir repo-wide; every production consumer reads AppPaths.cache_dir through the single discover() path this change fixes, so no other call site needs updating. CI read directly for this exact commit via check-runs/status, and the one failing job's log fetched and read in full rather than inferred. Ticket ROCMAI-826 retrieved directly by key; its description matches this change's scope exactly.

Fan-out: three worker groups by coupling (production logic + its unit tests + README; e2e test files + the production string formats they assert against; agent-instruction/history/prior-changes). Two ran as independent sub-agents and returned no findings ≥70 confidence. The e2e-test-group worker failed to spawn twice under a concurrency limit shared across this account's active sessions; per the fallback for that case, I performed that pass myself directly rather than spawning a third time, so it was not independent of the driver — disclosed here rather than silently absorbed.

Disclosure: this task's mandatory duplicate-review checks (run both before this review began and again immediately before publishing, to avoid double-posting against a stale commit) return full review bodies rather than metadata only. They exposed four prior reviews from earlier commits on this PR, plus — on the final pre-publish check — a fifth review from a different human reviewer submitted at this exact commit while this review was already in progress. That content was read as an unavoidable side effect of the required checks; none of it was used to derive, word, or bias any finding in this report, and it was not reconciled against this report's conclusions. Could not run cargo test/clippy locally (no Rust toolchain in this environment); the conclusions above are argued from tracing the code directly, cross-checked against the exact strings storage.rs emits and against CI's own completed runs for this commit, rather than from a local run.


🤖 Generated with Claude Code

With ROCM_CLI_CONFIG_DIR and ROCM_CLI_DATA_DIR set but no
ROCM_CLI_CACHE_DIR, AppPaths::discover fell back to the default
~/.rocm/cache. `rocm storage` then reported the default install's cache,
and `rocm uninstall` of the isolated install listed it and deleted it.

The cache folder now follows ROCM_CLI_DATA_DIR to <data>/cache, the
place it sits by default (~/.rocm/cache under ~/.rocm) and where a
setup.therock_venv managed root already puts it. ROCM_CLI_CACHE_DIR
still wins when set. A managed root is applied only when
ROCM_CLI_DATA_DIR is not set, so it never re-roots a cache that followed
the data folder.

Covered by unit tests on the override resolution and on its interaction
with a managed root, and by uninstall-05
(@id:uninstall-moved-data-folder-keeps-its-own-cache), which runs storage
and uninstall without ROCM_CLI_CACHE_DIR, with a file in the data folder's
cache, and checks that cache is removed (exactly one `removed cache` line)
while the default install's cache is neither named nor removed.

The README notes that a cache an earlier version kept at ~/.rocm/cache
with only ROCM_CLI_DATA_DIR set is no longer used or removed.

Signed-off-by: Eugene Volen <eugene.volen@amd.com>
@volen-silo
volen-silo force-pushed the rocmai-826-cache-dir-data-dir branch from 265fddd to 4e91f44 Compare November 3, 2026 11:32
@volen-silo

Copy link
Copy Markdown
Collaborator Author

Pushed 4e91f44 (rebased onto main). On the review:

  • CI: I read the Strix Halo, Windows report for the previous head. uninstall-05 passed there; the four failures were serve-01, serve-02, runtime-02 and runtime-09, none of which touches the cache folder (details in the description). I could not compare against a green run on main, since the other Windows runs were skipped or still running. The two Ubuntu lanes are the 45-minute cap, addressed in ci(e2e): move the AIM serve scenarios off the per-PR Strix Ubuntu lane #852.
  • Vacuous assertion: fixed, and it exposed that the data folder's cache was never created by the scenario; see the thread.
  • Positional arguments: replaced with a named struct.
  • Behaviour change: the README uninstall section now says the old ~/.rocm/cache is no longer used or removed for such an install and can be deleted by hand. The repo has no changelog or release-notes file, so the description carries the note; say if there is a release-notes place I should add it to.

@volen-silo
volen-silo dismissed juhovainio’s stale review November 3, 2026 11:37

The CI question is answered (the failing Windows scenarios are unrelated; details in the description) and the two inline points and the behaviour note are done in 4e91f44; see the replies and the summary comment. A re-review is welcome.

@juhovainio juhovainio left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at 4e91f44. No blocking findings; the change does what ROCMAI-826 asks. The cache directory follows ROCM_CLI_DATA_DIR unless ROCM_CLI_CACHE_DIR is set, and uninstall leaves the default ~/.rocm/cache alone. The uninstall-05 scenario asserts that outcome (exactly one removed cache <data>/cache line, home cache untouched), and the unit tests cover the override precedence. CI checks that had completed were green when I looked; E2E and a few build jobs were still pending.

Non-blocking:

  • README: the new text splits the inline rocm uninstall code span across two lines and sits mid-paragraph in front of the original sentence tail. Reflowing it, with the orphaned-cache note as its own sentence, would read better.
  • discover() passing the data/cache override flags into discover_from_paths is covered only by the e2e scenario; the unit test hard-codes true, false. Acceptable, just noting the gap.
  • The ticket's exact command, rocm uninstall --dry-run, is not exercised; the scenario uses --yes --keep-binaries. Same code path, so low risk.

For awareness: users who set only ROCM_CLI_DATA_DIR get a fresh empty cache under <data>/cache and their old ~/.rocm/cache is orphaned. That is documented in the README and the PR body. The uninstall-05 id also collides with the open protected-roots branch, which the PR body already flags.

Comment thread README.md
when only `ROCM_CLI_DATA_DIR` is set, the cache directory moves with it, to
`<data directory>/cache`. A cache that an earlier version kept at `~/.rocm/cache`
while only `ROCM_CLI_DATA_DIR` was set is no longer used or removed by `rocm
uninstall`; delete it by hand if you don't need it. `uninstall` removes a category's directory

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The inline code span rocm uninstall is split across lines 1294-1295, and the original sentence tail now starts mid-line after the added text. Consider reflowing and putting the orphaned-cache note in its own sentence.

@jussielo-amd jussielo-amd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks Volen, this is a clean fix. I read the whole change and checked the PR's claims against the code (by reading; I did not run tests).

Checked and holds:

  • The cache resolves as ROCM_CLI_CACHE_DIR, else <data>/cache, else the default. A configured managed root cannot move it when ROCM_CLI_DATA_DIR is set (the discover_from_paths guard).
  • With the or_else(managed_runtime_cache_dir) line reverted, the two unit tests and uninstall-05 go red. uninstall-05 fails at the storage-report step, as you describe.
  • The orphaned ~/.rocm/cache note in the PR body and README is accurate. Hosted CI is green on this head; the self-hosted GPU lanes have not reported yet.

Non-blocking:

  1. README (~1289-1297): please reflow so rocm uninstall isn't split across lines and the original sentence stays together. "On a default installation a flag doesn't protect its files" is now also true when only ROCM_CLI_DATA_DIR is set. The cache sits inside data, so --keep-cache alone no longer keeps it. Suggest "when the cache sits inside the data folder, as by default or with only ROCM_CLI_DATA_DIR set".
  2. paths.rs: a_managed_root_does_not_move_a_cache_that_followed_the_data_dir never removes its temp root (siblings call fs::remove_dir_all(root).ok()). The older test near line 405 builds cache_dir as root/cache, which is no longer what discover() returns for a data override. Consider data.join("cache") there.
  3. uninstall_steps.rs: data_cache_gone cannot fail on its own, because data is removed first and the cache is nested in it. The raw line break in its assert message could be \n. The "exactly one removed cache line" check also relies on the plan printing a nested-cache line after data is already gone; a one-line comment on that coupling would help.
  4. The managed-root test hand-feeds (true, false) to discover_from_paths, so a wrong flag inside discover() itself would stay green (only the e2e scenario covers that wiring). The test comment and PR body say it pins "the discover() path", which is slightly stronger than what it does.
  5. PR body: "it no longer returns early on a host without a default cache folder" refers to an earlier revision; the test is new in this diff.
  6. docs/testing.md (~876): the uninstall-NN description could name uninstall-05.

FYI, the Strix Halo Windows lane showed runtime-09 failing on the earlier head. That same single scenario is red on other open PRs today, so it looks unrelated to this change.


🤖 by agenthub on AMD AgentHub

@volen-silo
volen-silo added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 95e6338 Nov 3, 2026
26 checks passed
@volen-silo
volen-silo deleted the rocmai-826-cache-dir-data-dir branch November 3, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants