fix(core): keep persistent data outside the cache #1788

Open
dereoalex wants to merge 2 commits from upstream-pr/1789 into main
dereoalex commented 2026-11-24 22:38:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dereoalex on 2026-11-24T22:38:23Z.


Claimed in the coordination thread.

Problem and fix

Effective configuration could place persistent data at or below the disposable cache. A synthetic probe with VICTORY_DATA_DIR set to a child of VICTORY_CACHE_DIR successfully created the data subdirectory there. Clearing that cache could delete persistent storage.

Validate the two configured paths after environment and file precedence has been applied, using the existing path resolver. Reject equal and nested data paths with an actionable error. The new tests cover an environment override and an adjacent directory with a similar name. This addresses configured overlap, complementary to the default-path changes in #708.

On Windows, canonicalization retains the spelling of path components that do not yet exist, so the original case-sensitive component check could miss a data path beneath a differently cased cache alias. The follow-up compares Windows components using case-insensitive UTF-16 ordinal comparison and adds a Windows-only regression fixture with a missing cache directory and a non-ASCII case alias. The check conservatively rejects case aliases even in Windows directories configured as case-sensitive.

Validation

  • cargo +1.98.1 test --offline --locked -p victory-core persistent_data_cannot_be_inside_cache failed on the base as expected.
  • cargo +1.98.1 test --offline --locked -p victory-core passed all 13 tests on the candidate.
  • cargo +1.98.1 clippy --offline --locked -p victory-core --all-targets -- -D warnings passed.
  • cargo +1.98.1 clippy --offline --locked -p victory-core --all-targets --target x86_64-pc-windows-msvc -- -D warnings passed under Linux and type-checked the Windows-only regression test.
  • cargo +1.98.1 xtask policy passed for all 174 tracked files. git diff --check passed.

Draft pending the native Windows checks. The Linux workspace baseline fails with victory-gpu E0425, tracked in #523. The Windows-only regression test was cross-checked and has not yet been run natively. All fixtures were synthetic.

AI-assisted. An independent reviewer approved the original guard and its Windows follow-up.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6592820826 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1789). Originally posted by [dereoalex](https://github.com/dereoalex) on 2026-11-24T22:38:23Z. --- Claimed in [the coordination thread](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7145770836). ## Problem and fix Effective configuration could place persistent data at or below the disposable cache. A synthetic probe with `VICTORY_DATA_DIR` set to a child of `VICTORY_CACHE_DIR` successfully created the data subdirectory there. Clearing that cache could delete persistent storage. Validate the two configured paths after environment and file precedence has been applied, using the existing path resolver. Reject equal and nested data paths with an actionable error. The new tests cover an environment override and an adjacent directory with a similar name. This addresses configured overlap, complementary to the default-path changes in #708. On Windows, canonicalization retains the spelling of path components that do not yet exist, so the original case-sensitive component check could miss a data path beneath a differently cased cache alias. The follow-up compares Windows components using case-insensitive UTF-16 ordinal comparison and adds a Windows-only regression fixture with a missing cache directory and a non-ASCII case alias. The check conservatively rejects case aliases even in Windows directories configured as case-sensitive. ## Validation - `cargo +1.98.1 test --offline --locked -p victory-core persistent_data_cannot_be_inside_cache` failed on the base as expected. - `cargo +1.98.1 test --offline --locked -p victory-core` passed all 13 tests on the candidate. - `cargo +1.98.1 clippy --offline --locked -p victory-core --all-targets -- -D warnings` passed. - `cargo +1.98.1 clippy --offline --locked -p victory-core --all-targets --target x86_64-pc-windows-msvc -- -D warnings` passed under Linux and type-checked the Windows-only regression test. - `cargo +1.98.1 xtask policy` passed for all 174 tracked files. `git diff --check` passed. Draft pending the native Windows checks. The Linux workspace baseline fails with `victory-gpu` E0425, tracked in #523. The Windows-only regression test was cross-checked and has not yet been run natively. All fixtures were synthetic. AI-assisted. An independent reviewer approved the original guard and its Windows follow-up.
catminou4 commented 2026-11-25 00:06:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:05:48Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae).

cargo test -p victory-core --locked → 13 passed, 0 failed. persistent_data_cannot_be_inside_cache + path_starts_with guard keep persistent data outside the cache dir — path-prefix check is the right primitive; watch for symlink/relative-path edge cases on Windows.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048825968 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1789#pullrequestreview-6048825968). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:05:48Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae). cargo test -p victory-core --locked → 13 passed, 0 failed. persistent_data_cannot_be_inside_cache + path_starts_with guard keep persistent data outside the cache dir — path-prefix check is the right primitive; watch for symlink/relative-path edge cases on Windows.
Marvisak commented 2026-11-25 02:06:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:36:19Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-core/src/config.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149741007 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1789#issuecomment-7149741007). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:36:19Z. --- <!-- victory-triage v1 head=d09311e7c1417eff6b31b62e1aa88164c7710a6b verdict=needs-rebase at=2026-11-25T01:36:19Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-core/src/config.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
AgneyaK commented 2026-11-25 07:03:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AgneyaK on 2026-11-25T06:17:16Z.


The native Windows checks this draft was waiting for. Windows 11 26300, MSVC, PR head d09311e7 (on its base 70564ae, because it conflicts with main):

  • cargo test -p victory-core --locked: 14 passed, 0 failed, including the Windows-only persistent_data_cannot_use_a_case_alias_of_a_missing_cache (non-ASCII CachÉ / caché).
  • The tests fail without the fix. I put the three new tests onto the base's config.rs: persistent_data_cannot_be_inside_cache and the case-alias test fail, and adjacent_data_and_cache_directories_are_allowed passes (12 passed, 2 failed).
  • cargo clippy -p victory-core --all-targets --locked -- -D warnings: clean.
  • Two cases the tests don't cover, checked with a throwaway test (not in the PR):
    • The cache already exists and the data dir inside it doesn't, which is the usual case. Rejected, since resolve canonicalises the existing ancestor, so both sides get the same \?\ prefix.
    • A directory junction pointing at the cache (mklink /J alias cache, data = alias\saves). Also rejected, because canonicalisation follows the junction.

Not checked: the rebase. main changed config.rs by +20/−1 since 70564ae, which is the conflict the triage names.

AI use: Claude Code (Claude Opus 5.5) ran these checks and wrote this; synthetic paths only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154635336 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1789#issuecomment-7154635336). Originally posted by [AgneyaK](https://github.com/AgneyaK) on 2026-11-25T06:17:16Z. --- The native Windows checks this draft was waiting for. Windows 11 26300, MSVC, PR head `d09311e7` (on its base `70564ae`, because it conflicts with `main`): - `cargo test -p victory-core --locked`: **14 passed, 0 failed**, including the Windows-only `persistent_data_cannot_use_a_case_alias_of_a_missing_cache` (non-ASCII `CachÉ` / `caché`). - **The tests fail without the fix.** I put the three new tests onto the base's `config.rs`: `persistent_data_cannot_be_inside_cache` and the case-alias test fail, and `adjacent_data_and_cache_directories_are_allowed` passes (12 passed, 2 failed). - `cargo clippy -p victory-core --all-targets --locked -- -D warnings`: clean. - Two cases the tests don't cover, checked with a throwaway test (not in the PR): - **The cache already exists** and the data dir inside it doesn't, which is the usual case. Rejected, since `resolve` canonicalises the existing ancestor, so both sides get the same `\?\` prefix. - **A directory junction pointing at the cache** (`mklink /J alias cache`, data = `alias\saves`). Also rejected, because canonicalisation follows the junction. Not checked: the rebase. `main` changed `config.rs` by +20/−1 since `70564ae`, which is the conflict the triage names. AI use: Claude Code (Claude Opus 5.5) ran these checks and wrote this; synthetic paths only.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1789:upstream-pr/1789'
git switch 'upstream-pr/1789'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1789'
git switch 'upstream-pr/1789'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1789'
git switch 'upstream-pr/1789'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1789'
git switch 'main'
git merge --squash 'upstream-pr/1789'
git switch 'main'
git merge --ff-only 'upstream-pr/1789'
git switch 'main'
git merge 'upstream-pr/1789'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!1788
No description provided.