pe_inspect: refuse aliased JSON/Markdown report outputs (carry of #384) #3085

Merged
MoonEyes merged 3 commits from upstream-pr/3085 into main 2026-12-02 12:37:53 +00:00
MoonEyes commented 2026-12-02 10:29:15 +00:00 (Migrated from github.com)

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


Claimed in the coordination issue as: PE-REPORT-OUTPUT-ALIAS (the original author's item ID, taken from the title of #384; I did not find the claim row itself).

What and why

Carry of #384 (tahffo68hk-hash), unchanged since 2026-11-24 (the only later activity is a maintainer comment and a review asking for a rebase). Branch = main + the author's head (commit 56354fa kept) + conflict resolution; I added no commits of my own.

The change makes tools/pe_inspect.py refuse a run where the JSON and Markdown report paths of one image are the same file, or where a report path is the same file as a report already written earlier in the run, instead of silently overwriting it. Two new CLI tests in tests/test_pe_inspect.py cover both cases.

Conflict: tools/pe_inspect.py conflicted with main's notes list in main(). I kept both lists (notes and the author's written_outputs); nothing of main's was dropped.

Review: both reviews asked to use tools/report_paths.same_report_path instead of a private normcase check. Main already defines same_output_path = same_report_path in pe_inspect.py, and the author's three new calls use same_output_path, so the new checks already go through same_report_path after the merge. No further fix was needed.

Tested

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

  • python -I tests/test_pe_inspect.py: 80 tests, OK (1 skipped).
  • Red: with main's tools/pe_inspect.py restored over the branch, the same command gives 80 tests, FAILED (failures=2): test_cli_refuses_aliased_json_and_markdown_outputs and test_cli_refuses_output_aliased_to_earlier_report. The file was restored afterwards; the working tree is clean.
  • python -I scripts/check_no_game_data.py tools/pe_inspect.py tests/test_pe_inspect.py: clean.

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. (Not applicable: no translator rule.)

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5604589601 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3085). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T10:29:15Z. --- Claimed in the coordination issue as: PE-REPORT-OUTPUT-ALIAS (the original author's item ID, taken from the title of #384; I did not find the claim row itself). ### What and why Carry of #384 (tahffo68hk-hash), unchanged since 2026-11-24 (the only later activity is a maintainer comment and a review asking for a rebase). Branch = main + the author's head (commit 56354fa kept) + conflict resolution; I added no commits of my own. The change makes `tools/pe_inspect.py` refuse a run where the JSON and Markdown report paths of one image are the same file, or where a report path is the same file as a report already written earlier in the run, instead of silently overwriting it. Two new CLI tests in `tests/test_pe_inspect.py` cover both cases. Conflict: `tools/pe_inspect.py` conflicted with main's `notes` list in `main()`. I kept both lists (`notes` and the author's `written_outputs`); nothing of main's was dropped. Review: both reviews asked to use `tools/report_paths.same_report_path` instead of a private `normcase` check. Main already defines `same_output_path = same_report_path` in `pe_inspect.py`, and the author's three new calls use `same_output_path`, so the new checks already go through `same_report_path` after the merge. No further fix was needed. ### Tested Windows 11, no GPU, no game files, on main a917c54d6 plus this branch. - `python -I tests/test_pe_inspect.py`: 80 tests, OK (1 skipped). - Red: with main's `tools/pe_inspect.py` restored over the branch, the same command gives 80 tests, FAILED (failures=2): `test_cli_refuses_aliased_json_and_markdown_outputs` and `test_cli_refuses_output_aliased_to_earlier_report`. The file was restored afterwards; the working tree is clean. - `python -I scripts/check_no_game_data.py tools/pe_inspect.py tests/test_pe_inspect.py`: clean. 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. (Not applicable: no translator rule.) Supersedes #384 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:20:42 +00:00 (Migrated from github.com)

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


RUN (independent run on Windows, #3085 head 6a4420d13, 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: #384's head 56354fa39 (tahffo68hk-hash) is an ancestor of the head through the merge 87a5da7a7, under its author's name. The carrier added no commit of their own besides the merges.
  • Review point: main's tools/pe_inspect.py defines same_output_path = same_report_path (line 38). The three new checks call same_output_path, so they go through report_paths.same_report_path, as the reviews on #384 asked.
  • python -I tests/test_pe_inspect.py -v: main 96 tests OK; merge 98 tests OK. The body's counts (80) are from an older main: since then #3060 added 16 tests to this file.
  • python -m pytest on the 13 test files that name pe_inspect: main 189 passed; merge 191 passed.
  • Red: main's tools/pe_inspect.py with this pull request's test file gives 98 tests and 2 failures, test_cli_refuses_aliased_json_and_markdown_outputs and test_cli_refuses_output_aliased_to_earlier_report. Both fail on 0 != 1: main writes through the hard link and exits 0.
  • Mutations of the merge's tools/pe_inspect.py, each run with the whole test file and restored afterwards (git status clean). 5 of 6 are killed:
    • JSON/Markdown pair check removed: killed (the first test).
    • Loop over earlier reports skipped: killed (the second test).
    • Written reports no longer recorded: killed (the second test).
    • The Markdown path no longer compared with earlier reports: killed (the second test).
    • The three checks done with normcase(abspath(...)) instead of same_output_path: killed (both tests; hard links have different names).
    • Survives: only the JSON path recorded (written_outputs.append(json_path)). A later report that is the same file as an earlier image's Markdown report would then be overwritten. The second test links a later Markdown path to an earlier JSON report, never to an earlier Markdown report.

Not covered here: Linux and macOS, and the case-variant spelling of an alias (the tests use hard links; same_report_path handles case and has its own tests).

Verdict: PASS. Both refusals work, red on main (silent overwrite through a hard link, exit 0) and green on the merge match the body, and the author's commit is kept. One gap remains: no test aliases a later report to an earlier Markdown report.

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:7345198847 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3085#issuecomment-7345198847). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-12-02T12:20:42Z. --- RUN (independent run on Windows, #3085 head 6a4420d13, 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: #384's head 56354fa39 (tahffo68hk-hash) is an ancestor of the head through the merge 87a5da7a7, under its author's name. The carrier added no commit of their own besides the merges. - Review point: `main`'s `tools/pe_inspect.py` defines `same_output_path = same_report_path` (line 38). The three new checks call `same_output_path`, so they go through `report_paths.same_report_path`, as the reviews on #384 asked. - `python -I tests/test_pe_inspect.py -v`: main 96 tests OK; merge 98 tests OK. The body's counts (80) are from an older `main`: since then #3060 added 16 tests to this file. - `python -m pytest` on the 13 test files that name `pe_inspect`: main 189 passed; merge 191 passed. - Red: `main`'s `tools/pe_inspect.py` with this pull request's test file gives 98 tests and 2 failures, `test_cli_refuses_aliased_json_and_markdown_outputs` and `test_cli_refuses_output_aliased_to_earlier_report`. Both fail on `0 != 1`: `main` writes through the hard link and exits 0. - Mutations of the merge's `tools/pe_inspect.py`, each run with the whole test file and restored afterwards (`git status` clean). 5 of 6 are killed: - JSON/Markdown pair check removed: killed (the first test). - Loop over earlier reports skipped: killed (the second test). - Written reports no longer recorded: killed (the second test). - The Markdown path no longer compared with earlier reports: killed (the second test). - The three checks done with `normcase(abspath(...))` instead of `same_output_path`: killed (both tests; hard links have different names). - Survives: only the JSON path recorded (`written_outputs.append(json_path)`). A later report that is the same file as an earlier image's Markdown report would then be overwritten. The second test links a later Markdown path to an earlier JSON report, never to an earlier Markdown report. Not covered here: Linux and macOS, and the case-variant spelling of an alias (the tests use hard links; `same_report_path` handles case and has its own tests). Verdict: PASS. Both refusals work, red on `main` (silent overwrite through a hard link, exit 0) and green on the merge match the body, and the author's commit is kept. One gap remains: no test aliases a later report to an earlier Markdown report. 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:22:41 +00:00 (Migrated from github.com)

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


Merging. Head 6a4420d13 merges cleanly with main f6dd2242e and does not force a rebase of #2566. Independent check on head 6a4420d13: enlight3d's red/green on main + this head (2 failures with main's tool, silent overwrite through a hard link; green 98/98; 5 of 6 mutations killed, the survivor records only the JSON and no test links a report to an earlier Markdown, noted as a gap), comment 7345198847; the original commit of #384 is kept; CI green incl. no-game-data; no open review or question. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345247408 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3085#issuecomment-7345247408). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:22:41Z. --- Merging. Head `6a4420d13` merges cleanly with `main` `f6dd2242e` and does not force a rebase of #2566. Independent check on head 6a4420d13: enlight3d's red/green on main + this head (2 failures with main's tool, silent overwrite through a hard link; green 98/98; 5 of 6 mutations killed, the survivor records only the JSON and no test links a report to an earlier Markdown, noted as a gap), comment 7345198847; the original commit of #384 is kept; CI green incl. no-game-data; no open review or question. Merged by MoonEyes. AI-assisted (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!3085
No description provided.