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

Open
opened 2026-11-26 20:21:42 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1538
Author: @Vemast
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: bcpack-calib-dedup-path-guard


📝 Commits (1)

  • 4f383c8 bcpack_history_calib: deduplicate pools and guard outputs with report_paths (BCPACK-CALIB-DEDUP-PATH-GUARD)

📊 Changes

2 files changed (+191 additions, -31 deletions)

View changed files

📝 tests/test_bcpack_history_calib.py (+96 -0)
📝 tools/bcpack_history_calib.py (+95 -31)

📄 Description

Claimed in the coordination issue as: BCPACK-CALIB-DEDUP-PATH-GUARD (addresses finding https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7148659650; #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.)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1538 **Author:** [@Vemast](https://github.com/Vemast) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `bcpack-calib-dedup-path-guard` --- ### 📝 Commits (1) - [`4f383c8`](https://github.com/ubiquitarianism/leonida/commit/4f383c8aee2e2c0e3b996b209b6a8b16e8524df8) bcpack_history_calib: deduplicate pools and guard outputs with report_paths (BCPACK-CALIB-DEDUP-PATH-GUARD) ### 📊 Changes **2 files changed** (+191 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_bcpack_history_calib.py` (+96 -0) 📝 `tools/bcpack_history_calib.py` (+95 -31) </details> ### 📄 Description Claimed in the coordination issue as: BCPACK-CALIB-DEDUP-PATH-GUARD (addresses finding https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7148659650; #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.) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1565
No description provided.