bcpack_history_calib: deduplicate pools and guard outputs with report_paths (BCPACK-CALIB-DEDUP-PATH-GUARD) #1538

Merged
Vemast merged 1 commit from upstream-pr/1538 into main 2026-11-28 13:41:07 +00:00
Vemast commented 2026-11-25 03:52:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Vemast on 2026-11-25T03:52:24Z.


Claimed in the coordination issue as: BCPACK-CALIB-DEDUP-PATH-GUARD (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7232954975; addresses finding https://github.com/ProjectLeonida/mandy/issues/14#issuecomment-7148659650)

What and why

Fixes two path-handling issues in tools/bcpack_history_calib.py (reported as a finding in #14):

  • _resolve_pools deduplication: _resolve_pools() previously deduplicated .ttpf pools with os.path.normcase(os.path.abspath(p)), which keeps distinct case spellings apart on macOS APFS/HFS+ and case-folding mounts (and does not collapse symlinks or hard links), scanning the same pool twice. It now deduplicates with report_paths.path_key, report_paths.same_report_path, and (st_dev, st_ino) checks while keeping deterministic sort order.
  • Shared --out overwrite guards and atomic JSON staging: Switches write_outputs() from _ttpf.same_output_path to report_paths.same_report_path (per CONTRIBUTING.md), validates all --out target paths up front in run() before creating directories or scanning pools, guards --ref-dds (pool, dds) and --ref-pairs (pairs_path, plus nested pool, dds, chunk_file, and ref_file entries) in addition to .ttpf pools, and stages JSON writes atomically via tempfile.mkstemp (newline="\n"), file_mode.published_mode, and replace_retry.
  • Tests: Adds synthetic unit tests in tests/test_bcpack_history_calib.py covering macOS case-insensitive APFS and NFD/NFC accent deduplication, case-sensitive preservation, relative/hard-link/symlink deduplication, and pre-flight refusal when --out collides with pairs.json or nested reference files.

Tested

  • python -m compileall -q tools/bcpack_history_calib.py tests/test_bcpack_history_calib.py — clean
  • python -I tests/test_bcpack_history_calib.py — 22 tests, OK (symlink subtest skipped on unprivileged Windows)
  • python -I tests/test_text_write_line_endings.py — 3 tests, OK
  • python -I tests/test_report_paths.py — 22 tests, OK (2 skipped)
  • python -I scripts/check_no_game_data.py tools/bcpack_history_calib.py tests/test_bcpack_history_calib.py — clean

GPUs tested: n/a (CPU-only Python tool and synthetic standard-library unit tests on Windows 11, Python 3.14; host GPU: NVIDIA GeForce RTX 5060, driver 621.24)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase). No open pull request changes tools/bcpack_history_calib.py or tests/test_bcpack_history_calib.py.
  • 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. (No translator change.)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5484847649 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1538). Originally posted by [Vemast](https://github.com/Vemast) on 2026-11-25T03:52:24Z. --- Claimed in the coordination issue as: BCPACK-CALIB-DEDUP-PATH-GUARD (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7232954975; addresses finding https://github.com/ProjectLeonida/mandy/issues/14#issuecomment-7148659650) ### What and why Fixes two path-handling issues in `tools/bcpack_history_calib.py` (reported as a finding in #14): - **`_resolve_pools` deduplication**: `_resolve_pools()` previously deduplicated `.ttpf` pools with `os.path.normcase(os.path.abspath(p))`, which keeps distinct case spellings apart on macOS APFS/HFS+ and case-folding mounts (and does not collapse symlinks or hard links), scanning the same pool twice. It now deduplicates with `report_paths.path_key`, `report_paths.same_report_path`, and `(st_dev, st_ino)` checks while keeping deterministic sort order. - **Shared `--out` overwrite guards and atomic JSON staging**: Switches `write_outputs()` from `_ttpf.same_output_path` to `report_paths.same_report_path` (per `CONTRIBUTING.md`), validates all `--out` target paths up front in `run()` before creating directories or scanning pools, guards `--ref-dds` (`pool`, `dds`) and `--ref-pairs` (`pairs_path`, plus nested `pool`, `dds`, `chunk_file`, and `ref_file` entries) in addition to `.ttpf` pools, and stages JSON writes atomically via `tempfile.mkstemp` (`newline="\n"`), `file_mode.published_mode`, and `replace_retry`. - **Tests**: Adds synthetic unit tests in `tests/test_bcpack_history_calib.py` covering macOS case-insensitive APFS and NFD/NFC accent deduplication, case-sensitive preservation, relative/hard-link/symlink deduplication, and pre-flight refusal when `--out` collides with `pairs.json` or nested reference files. ### Tested - `python -m compileall -q tools/bcpack_history_calib.py tests/test_bcpack_history_calib.py` — clean - `python -I tests/test_bcpack_history_calib.py` — 22 tests, OK (symlink subtest skipped on unprivileged Windows) - `python -I tests/test_text_write_line_endings.py` — 3 tests, OK - `python -I tests/test_report_paths.py` — 22 tests, OK (2 skipped) - `python -I scripts/check_no_game_data.py tools/bcpack_history_calib.py tests/test_bcpack_history_calib.py` — clean GPUs tested: n/a (CPU-only Python tool and synthetic standard-library unit tests on Windows 11, Python 3.14; host GPU: NVIDIA GeForce RTX 5060, driver 621.24) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). No open pull request changes `tools/bcpack_history_calib.py` or `tests/test_bcpack_history_calib.py`. - [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. (No translator change.)
copilot-pull-request-reviewer[bot] commented 2026-11-25 03:52:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T03:52:35Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6051614188 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1538#pullrequestreview-6051614188). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T03:52:35Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
MoonEyes commented 2026-11-28 03:02:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T03:02:02Z.


Hi @Vemast, thanks for this pull request.

CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post claiming: <ID> there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one (the ID BCPACK-CALIB-DEDUP-PATH-GUARD appears in the pull request, but there is no claiming: line for it).

The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time.

Could you post the claim in #1608 and add the ID to the pull request description? If you already claimed it in another form, a link to your comment is enough.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232750074 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1538#issuecomment-7232750074). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T03:02:02Z. --- Hi @Vemast, thanks for this pull request. CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post `claiming: <ID>` there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one (the ID `BCPACK-CALIB-DEDUP-PATH-GUARD` appears in the pull request, but there is no `claiming:` line for it). The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time. Could you post the claim in #1608 and add the ID to the pull request description? If you already claimed it in another form, a link to your comment is enough. AI-assisted (Claude Code, Claude Opus 5.5).
Vemast commented 2026-11-28 03:18:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Vemast on 2026-11-28T03:18:11Z.


Thanks @MoonEyes! #14 had already hit GitHub's 2,500-comment cap when this PR opened, and #1608 wasn't linked yet. I've now posted claiming: BCPACK-CALIB-DEDUP-PATH-GUARD in #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7232954975, along with done: at https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7232955325) and updated the PR description with the claim link.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232962971 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1538#issuecomment-7232962971). Originally posted by [Vemast](https://github.com/Vemast) on 2026-11-28T03:18:11Z. --- Thanks @MoonEyes! `#14` had already hit GitHub's 2,500-comment cap when this PR opened, and `#1608` wasn't linked yet. I've now posted `claiming: BCPACK-CALIB-DEDUP-PATH-GUARD` in #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7232954975, along with `done:` at https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7232955325) and updated the PR description with the claim link. AI-assisted.
MoonEyes commented 2026-11-28 13:41:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T13:41:11Z.


Merged after local re-verification: this PR merged onto main 259be59b9 without conflict, and its test file(s) (tests/test_bcpack_history_calib.py) pass there. Earlier today the same tests failed on main without the PR (red/green) and a bundle with other open PRs showed no new failures. check_no_game_data.py is clean. Windows 11, Python 3.14; no GPU needed for these tests.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7240112209 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1538#issuecomment-7240112209). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T13:41:11Z. --- Merged after local re-verification: this PR merged onto `main` 259be59b9 without conflict, and its test file(s) (`tests/test_bcpack_history_calib.py`) pass there. Earlier today the same tests failed on `main` without the PR (red/green) and a bundle with other open PRs showed no new failures. `check_no_game_data.py` is clean. Windows 11, Python 3.14; no GPU needed for these tests. _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
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!1538
No description provided.