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

Open
github-bot wants to merge 1 commit from github-bot/gh-1538 into main AGit
Owner

@⁠Vemast on GitHub · 2026-11-25 03:52 UTC · original
Vemast:bcpack-calib-dedup-path-guard → main · +191 −31 · 2 files · 1 commits · open

Claimed in the coordination issue as: BCPACK-CALIB-DEDUP-PATH-GUARD (addresses finding #14; #14 hit GitHub's 2,500-comment cap before a claim comment could be posted and no successor coordination issue was open yet)

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.)
**@⁠Vemast** on GitHub · 2026-11-25 03:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1538) `Vemast:bcpack-calib-dedup-path-guard` → `main` · +191 −31 · 2 files · 1 commits · open Claimed in the coordination issue as: BCPACK-CALIB-DEDUP-PATH-GUARD (addresses finding https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14; #14 hit GitHub's 2,500-comment cap before a claim comment could be posted and no successor coordination issue was open yet) ### 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.)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:55:46 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 03:52 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 03:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1538#pullrequestreview-6051614188) · **reviewed** 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1538/head:github-bot/gh-1538'
git switch 'github-bot/gh-1538'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1538'
git switch 'github-bot/gh-1538'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1538'
git switch 'github-bot/gh-1538'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1538'
git switch 'main'
git merge --squash 'github-bot/gh-1538'
git switch 'main'
git merge --ff-only 'github-bot/gh-1538'
git switch 'main'
git merge 'github-bot/gh-1538'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.