rtti_scan: ask report_paths for the report-path guard (RTTI-SCAN-SHARED-REPORT-PATH) #1229

Closed
breachato wants to merge 2 commits from upstream-pr/1229 into main
breachato commented 2026-11-24 20:37:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by breachato on 2026-11-24T20:37:49Z.


Claimed in the coordination issue as: RTTI-SCAN-SHARED-REPORT-PATH (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143810576)

Depends on: none

Fixes: none

What and why

tools/rtti_scan.py derived the report-path answer inline in main (:518-524): realpath + normcase compared
by hand, then os.path.samefile inside a bare except OSError: pass, to refuse an --out that would overwrite
the image being scanned. That is the answer tools/report_paths.same_report_path exists to give, and
CONTRIBUTING.md asks a report writer to call it rather than derive it again.

The inline copy also missed that helper's folding-volume probe, so on a Linux mount that ignores case (vfat,
exFAT, CIFS) --out IMAGE.rtti.json beside an existing image.rtti.json was not refused and the report replaced
the previous one.

The five lines become one call. The tool already puts its own folder on sys.path for file_mode, so the import
is one line, and nothing else references the inline name. Different topic from RTTI-SCAN-STAGE-CLEANUP (#798,
staged-file permissions). No behaviour change on Windows, macOS or a case-sensitive Linux filesystem.

Tested

  • tests/test_rtti_scan.py: 29 passed, 1 skipped, 47 subtests passed.
  • python -I tools/rtti_scan.py --help: prints its usage (the import works under -I).
  • python -m compileall -q tools/rtti_scan.py: clean.
  • Not tested: the folding-volume case this fixes, which needs a case-folding mount (vfat/exFAT/CIFS); this
    machine is NTFS, where normcase already folds case. tests/test_report_paths.py covers the helper's own
    folding-volume answer.
  • No game files, no GPU; nothing was built.

GPUs tested: n/a

AI-assisted: yes

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 change)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5479932504 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1229). Originally posted by [breachato](https://github.com/breachato) on 2026-11-24T20:37:49Z. --- Claimed in the coordination issue as: RTTI-SCAN-SHARED-REPORT-PATH (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7143810576) Depends on: none Fixes: none ### What and why `tools/rtti_scan.py` derived the report-path answer inline in `main` (`:518-524`): realpath + normcase compared by hand, then `os.path.samefile` inside a bare `except OSError: pass`, to refuse an `--out` that would overwrite the image being scanned. That is the answer `tools/report_paths.same_report_path` exists to give, and CONTRIBUTING.md asks a report writer to call it rather than derive it again. The inline copy also missed that helper's folding-volume probe, so on a Linux mount that ignores case (vfat, exFAT, CIFS) `--out IMAGE.rtti.json` beside an existing `image.rtti.json` was not refused and the report replaced the previous one. The five lines become one call. The tool already puts its own folder on `sys.path` for `file_mode`, so the import is one line, and nothing else references the inline name. Different topic from RTTI-SCAN-STAGE-CLEANUP (#798, staged-file permissions). No behaviour change on Windows, macOS or a case-sensitive Linux filesystem. ### Tested - `tests/test_rtti_scan.py`: **29 passed, 1 skipped**, 47 subtests passed. - `python -I tools/rtti_scan.py --help`: prints its usage (the import works under `-I`). - `python -m compileall -q tools/rtti_scan.py`: clean. - **Not tested:** the folding-volume case this fixes, which needs a case-folding mount (vfat/exFAT/CIFS); this machine is NTFS, where `normcase` already folds case. `tests/test_report_paths.py` covers the helper's own folding-volume answer. - No game files, no GPU; nothing was built. GPUs tested: n/a AI-assisted: yes ### 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. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change)
PierreEbele commented 2026-11-25 07:16:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T07:16:40Z.


Reviewed 8bde265: verified in the arm64 Linux sandbox against origin/main and PR head. test_rtti_scan (30 ok), test_report_paths (22 ok), test_report_path_case (3 ok, 1 macOS skip), test_missing_input_exit_codes (2 ok), test_file_mode (5 ok), compileall, and check_no_game_data.py tools/rtti_scan.py all pass on both trees, and git merge-tree against origin/main is clean. Synthetic-PE probes (identical path, ./-spelling, hard link, default name, distinct --out, case-alias on case-sensitive Linux, and simulated folding-volume os.stat alias) match main with no regressions, while patching report_paths.case_insensitive_volume confirms the guard now delegates to report_paths.same_report_path per CONTRIBUTING.md (note main's os.path.samefile already caught existing-image case aliases on real folding volumes, so this is a clean deduplication refactor). Optional follow-up: add "rtti_scan" to SHARED in tests/test_report_paths.py. AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7155683064 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1229#issuecomment-7155683064). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T07:16:40Z. --- Reviewed 8bde265: verified in the arm64 Linux sandbox against `origin/main` and PR head. `test_rtti_scan` (30 ok), `test_report_paths` (22 ok), `test_report_path_case` (3 ok, 1 macOS skip), `test_missing_input_exit_codes` (2 ok), `test_file_mode` (5 ok), `compileall`, and `check_no_game_data.py tools/rtti_scan.py` all pass on both trees, and `git merge-tree` against `origin/main` is clean. Synthetic-PE probes (identical path, `./`-spelling, hard link, default name, distinct `--out`, case-alias on case-sensitive Linux, and simulated folding-volume `os.stat` alias) match `main` with no regressions, while patching `report_paths.case_insensitive_volume` confirms the guard now delegates to `report_paths.same_report_path` per `CONTRIBUTING.md` (note `main`'s `os.path.samefile` already caught existing-image case aliases on real folding volumes, so this is a clean deduplication refactor). Optional follow-up: add `"rtti_scan"` to `SHARED` in `tests/test_report_paths.py`. AI-assisted review. **Recommendation:** Merge
zmasi commented 2026-11-28 22:29:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:29:10Z.


Native Windows 11 NTFS Verification (8bde265e5a)

Verified 8bde265e5a015bd0f2492191c95b74c1b2354e25 merged cleanly onto origin/main (adfb3821a23612263c1c5b195453ed01c4c114db, git merge-tree --write-tree rc=0) on native Windows 11 (26200) + NTFS:

  • Red (origin/main adfb3821a): Enabled real Windows 11 per-directory NTFS case sensitivity (fsutil.exe file setCaseSensitiveInfo <dir> enable) and invoked python -I tools/rtti_scan.py img.bin --out IMG.BIN: origin/main exited rc=2 with rtti_scan.py: error: output must not overwrite the source image (false collision) because os.path.normcase lowercased both paths before os.path.samefile.
  • Green (origin/main + 8bde265e5a): Using report_paths.same_report_path accepted IMG.BIN as a distinct destination on the live case-sensitive NTFS directory while still refusing IMG.BIN on a standard case-insensitive NTFS directory; python -I tests/test_rtti_scan.py passed (32 ran, OK (skipped=1)).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246767992 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1229#issuecomment-7246767992). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T22:29:10Z. --- ### Native Windows 11 NTFS Verification (`8bde265e5a`) Verified `8bde265e5a015bd0f2492191c95b74c1b2354e25` merged cleanly onto `origin/main` (`adfb3821a23612263c1c5b195453ed01c4c114db`, `git merge-tree --write-tree` `rc=0`) on native **Windows 11 (`26200`) + NTFS**: - **Red (`origin/main` `adfb3821a`)**: Enabled real Windows 11 per-directory NTFS case sensitivity (`fsutil.exe file setCaseSensitiveInfo <dir> enable`) and invoked `python -I tools/rtti_scan.py img.bin --out IMG.BIN`: `origin/main` exited `rc=2` with `rtti_scan.py: error: output must not overwrite the source image` (false collision) because `os.path.normcase` lowercased both paths before `os.path.samefile`. - **Green (`origin/main + 8bde265e5a`)**: Using `report_paths.same_report_path` accepted `IMG.BIN` as a distinct destination on the live case-sensitive NTFS directory while still refusing `IMG.BIN` on a standard case-insensitive NTFS directory; `python -I tests/test_rtti_scan.py` passed (`32 ran, OK (skipped=1)`). AI-assisted.
TheGeogeo commented 2026-11-29 01:12:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T01:12:51Z.


Checked 8bde265e5 merged (no commit) with main 87a39df94: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • This PR adds no test, so there is no red/green to show.
  • No regression: the existing tests that cover the tool give the same result on main and on the merge (test_rtti_scan.py 32 OK, test_file_mode.py, test_missing_input_exit_codes.py).
  • The same pattern runs through #1162, #1170-#1173, #1214, #1215, #1227-#1229, #1243 and #1244. Each one replaces its tool's own copy of the same-path check with report_paths.same_report_path (tools/report_paths.py:117 on main). They share that one helper and touch one different tool each, so they do not depend on each other. Only #1228 conflicts with main.

No blocker from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248635853 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1229#issuecomment-7248635853). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T01:12:51Z. --- Checked `8bde265e5` merged (no commit) with `main` `87a39df94`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - This PR adds no test, so there is no red/green to show. - No regression: the existing tests that cover the tool give the same result on `main` and on the merge (`test_rtti_scan.py` 32 OK, `test_file_mode.py`, `test_missing_input_exit_codes.py`). - The same pattern runs through #1162, #1170-#1173, #1214, #1215, #1227-#1229, #1243 and #1244. Each one replaces its tool's own copy of the same-path check with `report_paths.same_report_path` (`tools/report_paths.py:117` on `main`). They share that one helper and touch one different tool each, so they do not depend on each other. Only #1228 conflicts with `main`. No blocker from my side. AI-assisted (Claude Code).
MoonEyes commented 2026-11-29 17:09:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T17:09:02Z.


Tested 8bde265e5 merged (no commit) with main 4364a4fa6: Python 3.12, Windows 11 10.0.26300, CPU only.

  • Red test: "rtti_scan" added to SHARED in tests/test_report_paths.py, then python -I tests/test_report_paths.py.
  • Red on main: 'from report_paths import same_report_path' not found in tools/rtti_scan.py.
  • Green with this PR: OK (1 skipped).
  • That SHARED entry is my edit, not part of the PR. Adding it to the PR would give the PR its own red test.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7259462237 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1229#issuecomment-7259462237). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T17:09:02Z. --- Tested `8bde265e5` merged (no commit) with `main` `4364a4fa6`: Python 3.12, Windows 11 10.0.26300, CPU only. - Red test: `"rtti_scan"` added to `SHARED` in `tests/test_report_paths.py`, then `python -I tests/test_report_paths.py`. - Red on `main`: `'from report_paths import same_report_path' not found` in `tools/rtti_scan.py`. - Green with this PR: OK (1 skipped). - That `SHARED` entry is my edit, not part of the PR. Adding it to the PR would give the PR its own red test. AI-assisted (Claude Code).
breachato commented 2026-11-29 18:02:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by breachato on 2026-11-29T18:02:27Z.


Added: rtti_scan is now in SHARED in tests/test_report_paths.py in this PR (commit b6ceede1).

  • python -I tests/test_report_paths.py — OK (1 skipped), with the entry in place.
  • python -I tests/test_rtti_scan.py — OK.
  • The red is the one you described: the same entry without this branch fails with 'from report_paths import same_report_path' not found.

Every PR in this series now touches that SHARED line, so I expect to rebase the rest as merges land; say the word if you would rather keep the list to a single follow-up.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7260161181 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1229#issuecomment-7260161181). Originally posted by [breachato](https://github.com/breachato) on 2026-11-29T18:02:27Z. --- Added: `rtti_scan` is now in `SHARED` in `tests/test_report_paths.py` in this PR (commit `b6ceede1`). - `python -I tests/test_report_paths.py` — OK (1 skipped), with the entry in place. - `python -I tests/test_rtti_scan.py` — OK. - The red is the one you described: the same entry without this branch fails with `'from report_paths import same_report_path' not found`. Every PR in this series now touches that `SHARED` line, so I expect to rebase the rest as merges land; say the word if you would rather keep the list to a single follow-up. AI-assisted.
breachato commented 2026-11-30 19:23:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by breachato on 2026-11-30T19:23:30Z.


Rebased onto main (8f41d7d0) to clear the SHARED tuple conflict that #2637 (bink_index) opened for every sibling: the entry now sits in the tuple next to bink_index, and the branch is two commits again.

Verified on the new head:

  • python -I tests/test_report_paths.py — OK (26 tests, 1 skipped)
  • python -I tests/test_rtti_scan.py — OK
  • git diff main — 2 files: the tool and tests/test_report_paths.py

No behaviour change beyond the shared helper.

Ready to merge: MERGEABLE / CLEAN, all five checks green. Every sibling PR touches the same SHARED line, so please merge one at a time — I'll rebase the remaining ones after each merge and keep them green.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7289314665 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1229#issuecomment-7289314665). Originally posted by [breachato](https://github.com/breachato) on 2026-11-30T19:23:30Z. --- Rebased onto `main` (`8f41d7d0`) to clear the `SHARED` tuple conflict that #2637 (`bink_index`) opened for every sibling: the entry now sits in the tuple next to `bink_index`, and the branch is two commits again. Verified on the new head: - `python -I tests/test_report_paths.py` — OK (26 tests, 1 skipped) - `python -I tests/test_rtti_scan.py` — OK - `git diff main` — 2 files: the tool and `tests/test_report_paths.py` No behaviour change beyond the shared helper. Ready to merge: `MERGEABLE` / `CLEAN`, all five checks green. Every sibling PR touches the same `SHARED` line, so please merge one at a time — I'll rebase the remaining ones after each merge and keep them green.
aslan2142 commented 2026-12-01 11:49:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:49:12Z.

Review: CHANGES_REQUESTED


Reviewed the diff against main: delegating the report-path guard in tools/rtti_scan.py to report_paths.same_report_path is clean and clean-room verified, but this branch currently conflicts with main in tests/test_report_paths.py:8-12 (SHARED tuple updated by #2639 and earlier merges). Please rebase onto current main so CI runs cleanly.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130644765 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1229#pullrequestreview-6130644765). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:49:12Z. **Review:** CHANGES_REQUESTED --- Reviewed the diff against `main`: delegating the report-path guard in `tools/rtti_scan.py` to `report_paths.same_report_path` is clean and clean-room verified, but this branch currently conflicts with `main` in `tests/test_report_paths.py:8-12` (`SHARED` tuple updated by `#2639` and earlier merges). Please rebase onto current `main` so CI runs cleanly. *(AI-assisted review.)*
aslan2142 commented 2026-12-02 05:10:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-02T05:10:28Z.


Thank you @breachato! Both commits from this PR (rtti_scan) have been landed on main with full original authorship preserved in batch PR #3024 (commit 4dfd90c35), which consolidated all 15 tools/report_paths.py PRs together to avoid sequential tests/test_report_paths.py merge conflicts. Closing this PR now that it is merged!

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7335657667 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1229#issuecomment-7335657667). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-02T05:10:28Z. --- Thank you @breachato! Both commits from this PR (`rtti_scan`) have been landed on `main` with full original authorship preserved in batch PR #3024 (commit `4dfd90c35`), which consolidated all 15 `tools/report_paths.py` PRs together to avoid sequential `tests/test_report_paths.py` merge conflicts. Closing this PR now that it is merged!

Pull request closed

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!1229
No description provided.