manifest: exclude a manifest spelled with another case (carry of #1441) #3087

Merged
MoonEyes merged 3 commits from upstream-pr/3087 into main 2026-12-02 12:58:44 +00:00
MoonEyes commented 2026-12-02 10:29:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T10:29:43Z.


Claimed in the coordination issue as: MANIFEST-WALK-CASE-EXCLUDE, claimed by the original author of #1441 (Dashhhhhhhh) at https://github.com/ProjectLeonida/mandy/issues/14#issuecomment-7148360501 (marked done -> #1441 at https://github.com/ProjectLeonida/mandy/issues/14#issuecomment-7148376289).

What and why

Carry of #1441 (Dashhhhhhhh), unchanged since 2026-11-25 (last commit 21227adbd; no author push or comment after that). Branch = main (a917c54d6) + the author's head with its commit kept + a merge commit with one conflict resolution. I added no commits of my own.

tools/manifest.py excluded the manifest from the scan with normcase(realpath()), which keeps the typed case on macOS, so Game/Manifest.json and game/manifest.json stayed apart: the next create hashed the manifest as an input and verify listed it as new. The change compares through the shared report_paths.path_key in walk() and in a new _inside() helper used by create(), so a case-variant spelling is excluded from the scan and a hashed file under another spelling is still refused. Three tests are added to tests/test_manifest.py.

Conflict: main added from file_mode import published_mode at the same place the PR changed the report_paths import. I kept both lines (published_mode and path_key, same_report_path); nothing else conflicted.

Review on #1441: two approvals (tiguan26, aslan2142) and test comments; no defect was raised, so there is no review-fix commit. MoonEyes asked "which case fails without the fix?": on Windows none does, see Tested. zmasi's non-blocking note (a Linux case-folding mount such as vfat/exFAT/CIFS is not detected by report_paths.case_insensitive_volume) concerns that shared helper, not this change, and is left out of this carry.

Tested

Windows 11, no GPU, no game files, on main a917c54d6 plus this branch.

  • python -I tests/test_manifest.py: Ran 43 tests, OK (skipped=1).
  • Red, native: I temporarily put main's tools/manifest.py back (git show origin/main:tools/manifest.py) and reran: Ran 43 tests, OK (skipped=1). There is no native red on Windows, as already reported on #1441: normcase(realpath()) already folds case on NTFS.
  • Red, simulated macOS: a throwaway script kept outside the repository (not committed) runs the three new tests with sys.platform = "darwin", os.pathconf returning 0 (case-insensitive), os.path.normcase set to posixpath.normcase and a case-preserving os.path.realpath. With main's tools/manifest.py: FAILED (failures=1, errors=1 of 3): test_walk_excludes_another_case_of_the_manifest fails and test_create_replaces_a_manifest_under_another_case_and_verify_ignores_it errors. With this branch: 3 tests OK. This simulates macOS behaviour on NTFS; it is not a run on a Mac.
  • I restored tools/manifest.py with git checkout; the working tree is clean.
  • python -I scripts/check_no_game_data.py tools/manifest.py tests/test_manifest.py: clean.
  • git merge-base --is-ancestor of the author's head (21227adbd) and this branch's HEAD succeeds.

Not run: the full suite, CI.

GPUs tested: n/a (unit tests only)

AI-assisted: yes. Models: Claude Opus 5.5 in Claude Code (carry, conflict resolution, fixes, tests); separate read-only reviewer agent: Claude Opus 5.5.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator rule.)

Supersedes #1441 once merged; the original stays open until a maintainer decides.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5604596708 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3087). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T10:29:43Z. --- Claimed in the coordination issue as: MANIFEST-WALK-CASE-EXCLUDE, claimed by the original author of #1441 (Dashhhhhhhh) at https://github.com/ProjectLeonida/mandy/issues/14#issuecomment-7148360501 (marked done -> #1441 at https://github.com/ProjectLeonida/mandy/issues/14#issuecomment-7148376289). ### What and why Carry of #1441 (Dashhhhhhhh), unchanged since 2026-11-25 (last commit `21227adbd`; no author push or comment after that). Branch = `main` (`a917c54d6`) + the author's head with its commit kept + a merge commit with one conflict resolution. I added no commits of my own. `tools/manifest.py` excluded the manifest from the scan with `normcase(realpath())`, which keeps the typed case on macOS, so `Game/Manifest.json` and `game/manifest.json` stayed apart: the next `create` hashed the manifest as an input and `verify` listed it as new. The change compares through the shared `report_paths.path_key` in `walk()` and in a new `_inside()` helper used by `create()`, so a case-variant spelling is excluded from the scan and a hashed file under another spelling is still refused. Three tests are added to `tests/test_manifest.py`. Conflict: `main` added `from file_mode import published_mode` at the same place the PR changed the `report_paths` import. I kept both lines (`published_mode` and `path_key, same_report_path`); nothing else conflicted. Review on #1441: two approvals (tiguan26, aslan2142) and test comments; no defect was raised, so there is no review-fix commit. MoonEyes asked "which case fails without the fix?": on Windows none does, see Tested. zmasi's non-blocking note (a Linux case-folding mount such as vfat/exFAT/CIFS is not detected by `report_paths.case_insensitive_volume`) concerns that shared helper, not this change, and is left out of this carry. ### Tested Windows 11, no GPU, no game files, on `main` `a917c54d6` plus this branch. - `python -I tests/test_manifest.py`: Ran 43 tests, OK (skipped=1). - Red, native: I temporarily put `main`'s `tools/manifest.py` back (`git show origin/main:tools/manifest.py`) and reran: Ran 43 tests, OK (skipped=1). There is no native red on Windows, as already reported on #1441: `normcase(realpath())` already folds case on NTFS. - Red, simulated macOS: a throwaway script kept outside the repository (not committed) runs the three new tests with `sys.platform = "darwin"`, `os.pathconf` returning 0 (case-insensitive), `os.path.normcase` set to `posixpath.normcase` and a case-preserving `os.path.realpath`. With `main`'s `tools/manifest.py`: FAILED (failures=1, errors=1 of 3): `test_walk_excludes_another_case_of_the_manifest` fails and `test_create_replaces_a_manifest_under_another_case_and_verify_ignores_it` errors. With this branch: 3 tests OK. This simulates macOS behaviour on NTFS; it is not a run on a Mac. - I restored `tools/manifest.py` with `git checkout`; the working tree is clean. - `python -I scripts/check_no_game_data.py tools/manifest.py tests/test_manifest.py`: clean. - `git merge-base --is-ancestor` of the author's head (`21227adbd`) and this branch's HEAD succeeds. Not run: the full suite, CI. GPUs tested: n/a (unit tests only) AI-assisted: yes. Models: Claude Opus 5.5 in Claude Code (carry, conflict resolution, fixes, tests); separate read-only reviewer agent: Claude Opus 5.5. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator rule.) Supersedes #1441 once merged; the original stays open until a maintainer decides. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
enlight3d commented 2026-12-02 12:29:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-12-02T12:29:56Z.


RUN (independent run on Windows, #3087 head c83bf63a8, merged locally into main 9b4d71899 with git merge --no-ff, no conflicts. CI on the head: change-scope, check, linux-python-and-viewer, no-game-data and semantic-tests all pass.)

  • History: #1441's head 21227adbd (Dashhhhhhhh) is an ancestor of the head through the merge 6e7f8d303, under its author's name.
  • Merge resolution: main's from file_mode import published_mode stays next to the pull request's from report_paths import path_key, same_report_path.
  • python -I tests/test_manifest.py -v: main 40 tests OK (1 skipped); merge 43 tests OK (the same skip, "backslashes are path separators on Windows").
  • python -m pytest on the 7 test files that use tools/manifest.py: main 193 passed / 4 skipped; merge 196 passed / 4 skipped.
  • Red on Windows: not reachable, as the body says. With main's tools/manifest.py, the pull request's 43 tests pass, because normcase(realpath()) already folds case on NTFS.
  • macOS simulation, my own runner outside the repository. It runs the three new tests of tests/test_manifest.py with sys.platform set to "darwin", os.pathconf returning 0 (case-insensitive volume), os.path.normcase set to posixpath.normcase and os.path.realpath set to abspath:
    • main's tool: 1 failure and 1 error. test_walk_excludes_another_case_of_the_manifest finds Manifest.json in the scan. test_create_replaces_a_manifest_under_another_case_and_verify_ignores_it errors with "--out would overwrite the input", because the old manifest is hashed as an input. This matches the body's simulated red.
    • The merge's tool: 3 tests OK.
  • Mutations of the merge's tools/manifest.py, each run with the whole test file and the simulation, and restored afterwards (git status clean):
    • walk() exclusion back to normcase(realpath()): survives on Windows, killed in the simulation (the same failure and error as main).
    • _inside() back to normcase(realpath()): survives on Windows, killed in the simulation (test_create_refuses_another_case_of_a_hashed_file).
    • _inside() always False: killed on Windows (test_create_cannot_overwrite_a_file_it_hashes and the new refusal test) and in the simulation.
    • walk() exclusion removed: killed on Windows (3 tests) and in the simulation.
    • _inside() prefix without the separator: survives both. A sibling folder whose name starts with the scanned folder's name would count as inside, which is an over-refusal, not a loss of data.

Not covered here: a real macOS volume (the red above is a simulation on NTFS), and Linux case-folding mounts (zmasi's note on #1441 is about report_paths.case_insensitive_volume, outside this change).

Verdict: PASS. The change does what the body says. In the macOS simulation, the pull request's own tests fail with main's tool for the stated reasons and pass with the merge's, and they catch both case mutations there. On Windows nothing regresses, and the author's commit is kept. A real APFS run would still be welcome.

Machine: Windows 11 Pro 26300 (NTFS), i9-13900K, 64 GB, CPython 3.13.12 (CI uses 3.12); unit tests only, no GPU or game files used.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345430334 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3087#issuecomment-7345430334). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-12-02T12:29:56Z. --- RUN (independent run on Windows, #3087 head c83bf63a8, merged locally into `main` 9b4d71899 with `git merge --no-ff`, no conflicts. CI on the head: change-scope, check, linux-python-and-viewer, no-game-data and semantic-tests all pass.) - History: #1441's head 21227adbd (Dashhhhhhhh) is an ancestor of the head through the merge 6e7f8d303, under its author's name. - Merge resolution: `main`'s `from file_mode import published_mode` stays next to the pull request's `from report_paths import path_key, same_report_path`. - `python -I tests/test_manifest.py -v`: main 40 tests OK (1 skipped); merge 43 tests OK (the same skip, "backslashes are path separators on Windows"). - `python -m pytest` on the 7 test files that use `tools/manifest.py`: main 193 passed / 4 skipped; merge 196 passed / 4 skipped. - Red on Windows: not reachable, as the body says. With `main`'s `tools/manifest.py`, the pull request's 43 tests pass, because `normcase(realpath())` already folds case on NTFS. - macOS simulation, my own runner outside the repository. It runs the three new tests of `tests/test_manifest.py` with `sys.platform` set to `"darwin"`, `os.pathconf` returning 0 (case-insensitive volume), `os.path.normcase` set to `posixpath.normcase` and `os.path.realpath` set to `abspath`: - `main`'s tool: 1 failure and 1 error. `test_walk_excludes_another_case_of_the_manifest` finds `Manifest.json` in the scan. `test_create_replaces_a_manifest_under_another_case_and_verify_ignores_it` errors with "--out would overwrite the input", because the old manifest is hashed as an input. This matches the body's simulated red. - The merge's tool: 3 tests OK. - Mutations of the merge's `tools/manifest.py`, each run with the whole test file and the simulation, and restored afterwards (`git status` clean): - `walk()` exclusion back to `normcase(realpath())`: survives on Windows, killed in the simulation (the same failure and error as `main`). - `_inside()` back to `normcase(realpath())`: survives on Windows, killed in the simulation (`test_create_refuses_another_case_of_a_hashed_file`). - `_inside()` always False: killed on Windows (`test_create_cannot_overwrite_a_file_it_hashes` and the new refusal test) and in the simulation. - `walk()` exclusion removed: killed on Windows (3 tests) and in the simulation. - `_inside()` prefix without the separator: survives both. A sibling folder whose name starts with the scanned folder's name would count as inside, which is an over-refusal, not a loss of data. Not covered here: a real macOS volume (the red above is a simulation on NTFS), and Linux case-folding mounts (zmasi's note on #1441 is about `report_paths.case_insensitive_volume`, outside this change). Verdict: PASS. The change does what the body says. In the macOS simulation, the pull request's own tests fail with `main`'s tool for the stated reasons and pass with the merge's, and they catch both case mutations there. On Windows nothing regresses, and the author's commit is kept. A real APFS run would still be welcome. Machine: Windows 11 Pro 26300 (NTFS), i9-13900K, 64 GB, CPython 3.13.12 (CI uses 3.12); unit tests only, no GPU or game files used.
MoonEyes commented 2026-12-02 12:46:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:46:44Z.


Merging. Head c83bf63a8 merges cleanly with main 23a51c494 and does not force a rebase of #2566. Moon's own pull request, merged on green CI at his instruction. An independent read-only check by a separate agent on head c83bf63a8 found every CI check green including no-game-data, no conflict with current main, no open review or unanswered question, and for a carry the original author's commits kept as ancestors. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345866020 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3087#issuecomment-7345866020). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:46:44Z. --- Merging. Head `c83bf63a8` merges cleanly with `main` `23a51c494` and does not force a rebase of #2566. Moon's own pull request, merged on green CI at his instruction. An independent read-only check by a separate agent on head c83bf63a8 found every CI check green including no-game-data, no conflict with current main, no open review or unanswered question, and for a carry the original author's commits kept as ancestors. Merged by MoonEyes. AI-assisted (Claude Code).
Kal0s-design commented 2026-12-02 12:55:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T12:55:26Z.


Ran natively on Windows 11, Python 3.13, head c83bf63a8 merged into current main (23a51c494, no conflicts). py -3.13 -I tests/test_manifest.py: 43 tests OK (skipped=1), same as already reported. I didn't repeat the macOS simulation; two Windows things the existing runs don't cover:

1. A case-sensitive NTFS folder: a real input named like the manifest in another case is still left out of the hash list.
NTFS can turn case sensitivity on per folder (fsutil file setCaseSensitiveInfo <dir> enable, no admin; folders created from WSL get it by default). In such a folder Manifest.json and manifest.json are two files, but path_key folds them because ntpath.normcase lowercases unconditionally:

g/Manifest.json   (a game file, not a manifest)
g/a.bin
> py -I tools/manifest.py create g --out g/manifest.json
1 files, 0.0 GiB -> g/manifest.json          # "files" only has a.bin
> (edit g/Manifest.json)
> py -I tools/manifest.py verify g --manifest g/manifest.json
OK                                            # rc 0, the change is not seen

main's tool does exactly the same (normcase(name) == normcase(excluded) also folds), so this is not a regression, just a case the new helper doesn't fix either. The shared module already knows about it: in that folder report_paths.same_report_path("Manifest.json", "manifest.json") returns False while path_key(...) compares equal. Skipping a file only when it really is the --out file (os.path.exists(exclude) and os.path.samefile(p, exclude), falling back to path_key when the manifest doesn't exist yet) would cover both this and the macOS case. Fine as a follow-up if you'd rather keep this one small.

2. walk() now resolves every file instead of every folder.
The old code called realpath once per directory; the new one calls path_key(p), so realpath, for each file. On Windows realpath opens a handle per call. Throwaway tree of 20,000 empty files in 200 folders, plus manifest.json, timing only walk(data, exclude=data/manifest.json) (2 runs each, both yield 20,000 files):

tool run 1 run 2
main 0.355 s 0.351 s
this PR 4.876 s 4.330 s

About 0.2 ms more per file, ~12x on the walk itself. On a real install hashing dominates, so this is minor, but it is cheap to avoid: only call path_key(p) when name.casefold() (NFD-normalised, for the macOS branch) matches the manifest's basename, which skips the realpath for nearly every file.

Not checked: a real macOS volume, Linux case-folding mounts, the full test suite.

GPUs tested: n/a (CPU-only tests).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7346086383 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3087#issuecomment-7346086383). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T12:55:26Z. --- Ran natively on Windows 11, Python 3.13, head `c83bf63a8` merged into current `main` (`23a51c494`, no conflicts). `py -3.13 -I tests/test_manifest.py`: 43 tests OK (skipped=1), same as already reported. I didn't repeat the macOS simulation; two Windows things the existing runs don't cover: **1. A case-sensitive NTFS folder: a real input named like the manifest in another case is still left out of the hash list.** NTFS can turn case sensitivity on per folder (`fsutil file setCaseSensitiveInfo <dir> enable`, no admin; folders created from WSL get it by default). In such a folder `Manifest.json` and `manifest.json` are two files, but `path_key` folds them because `ntpath.normcase` lowercases unconditionally: ``` g/Manifest.json (a game file, not a manifest) g/a.bin > py -I tools/manifest.py create g --out g/manifest.json 1 files, 0.0 GiB -> g/manifest.json # "files" only has a.bin > (edit g/Manifest.json) > py -I tools/manifest.py verify g --manifest g/manifest.json OK # rc 0, the change is not seen ``` `main`'s tool does exactly the same (`normcase(name) == normcase(excluded)` also folds), so this is not a regression, just a case the new helper doesn't fix either. The shared module already knows about it: in that folder `report_paths.same_report_path("Manifest.json", "manifest.json")` returns `False` while `path_key(...)` compares equal. Skipping a file only when it really is the `--out` file (`os.path.exists(exclude) and os.path.samefile(p, exclude)`, falling back to `path_key` when the manifest doesn't exist yet) would cover both this and the macOS case. Fine as a follow-up if you'd rather keep this one small. **2. `walk()` now resolves every file instead of every folder.** The old code called `realpath` once per directory; the new one calls `path_key(p)`, so `realpath`, for each file. On Windows `realpath` opens a handle per call. Throwaway tree of 20,000 empty files in 200 folders, plus `manifest.json`, timing only `walk(data, exclude=data/manifest.json)` (2 runs each, both yield 20,000 files): | tool | run 1 | run 2 | |---|---|---| | `main` | 0.355 s | 0.351 s | | this PR | 4.876 s | 4.330 s | About 0.2 ms more per file, ~12x on the walk itself. On a real install hashing dominates, so this is minor, but it is cheap to avoid: only call `path_key(p)` when `name.casefold()` (NFD-normalised, for the macOS branch) matches the manifest's basename, which skips the realpath for nearly every file. Not checked: a real macOS volume, Linux case-folding mounts, the full test suite. GPUs tested: n/a (CPU-only tests). AI-assisted: yes (Claude Code).
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
ProjectLeonida/mandy!3087
No description provided.