gamedata_blobs: fix unshipped count, index type checks, and atomic JSON #2258

Merged
kirigayakazima merged 2 commits from upstream-pr/2258 into main 2026-11-29 14:09:21 +00:00
kirigayakazima commented 2026-11-26 10:51:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-26T10:51:26Z.


Claimed in the coordination issue as: GAMEDATA-BLOBS-UNSHIPPED-OVERLAP-INDEX-TYPES-AND-ATOMIC-JSON (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7189816855)

What and why

  • Fix unshipped overlap double-subtraction in cross_reference_sgd5() (tools/gamedata_blobs.py) so preload-list entries present in both db0 and db1 are counted accurately via sum(1 for s in stems if s not in db0_set and s not in db1_set) instead of p["entries"] - len(in_db0) - len(in_db1).
  • Tighten check_carve_index() to convert UnicodeDecodeError and RecursionError from json.load() into single-line ValueError diagnostics and require type(row.get("off")) is int and type(row.get("stored")) is int (non-bool, >= 0).
  • Avoid double-parsing index.json across main() and read_payloads(..., _checked_index=is_dir), reject trailing / or \ --json directory paths in check_report_path() and non-file --shaders upfront before read_payloads(), and catch RecursionError cleanly in main().
  • Write --json output atomically via _write_json_atomic() (staging next to os.path.realpath(out_path), trailing LF \n, os.fsync(), preserving permissions with published_mode(), publishing via replace_retry.replace(), and unlinking .blobs-*.tmp files on failure).
  • Add GamedataBlobsSafetyTests to tests/test_gamedata_blobs.py (without overlapping #1269's lines) covering overlap unshipped, bool/negative/str index types, RecursionError, single index.json parse, early CLI validation, and atomic JSON write/failure rollback.

Tested

  • Patched: python -I tests/test_gamedata_blobs.py -v -> Ran 14 tests in 1.178s (OK).
  • Baseline check (upstream/main a73a57e1 with updated tests/test_gamedata_blobs.py copied into detached worktree): Ran 14 tests in 1.119s (FAILED (failures=10)).
  • Repo gates: python -I tests/test_ci_registration.py (Ran 16 tests in 5.560s, OK), python -I tests/test_text_write_line_endings.py (Ran 3 tests in 13.499s, OK), python -I scripts/check_no_game_data.py (exit 0), python -I -m compileall -q tools/gamedata_blobs.py tests/test_gamedata_blobs.py (exit 0), git diff --check (exit 0).

GPUs tested: n/a (synthetic carve/RPF/SGD5 fixtures and atomic JSON output tests)

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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5508645884 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2258). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-26T10:51:26Z. --- Claimed in the coordination issue as: GAMEDATA-BLOBS-UNSHIPPED-OVERLAP-INDEX-TYPES-AND-ATOMIC-JSON (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7189816855) ### What and why - Fix `unshipped` overlap double-subtraction in `cross_reference_sgd5()` (`tools/gamedata_blobs.py`) so preload-list entries present in both `db0` and `db1` are counted accurately via `sum(1 for s in stems if s not in db0_set and s not in db1_set)` instead of `p["entries"] - len(in_db0) - len(in_db1)`. - Tighten `check_carve_index()` to convert `UnicodeDecodeError` and `RecursionError` from `json.load()` into single-line `ValueError` diagnostics and require `type(row.get("off")) is int` and `type(row.get("stored")) is int` (non-`bool`, `>= 0`). - Avoid double-parsing `index.json` across `main()` and `read_payloads(..., _checked_index=is_dir)`, reject trailing `/` or `\` `--json` directory paths in `check_report_path()` and non-file `--shaders` upfront before `read_payloads()`, and catch `RecursionError` cleanly in `main()`. - Write `--json` output atomically via `_write_json_atomic()` (staging next to `os.path.realpath(out_path)`, trailing LF `\n`, `os.fsync()`, preserving permissions with `published_mode()`, publishing via `replace_retry.replace()`, and unlinking `.blobs-*.tmp` files on failure). - Add `GamedataBlobsSafetyTests` to `tests/test_gamedata_blobs.py` (without overlapping `#1269`'s lines) covering overlap `unshipped`, `bool`/negative/`str` index types, `RecursionError`, single `index.json` parse, early CLI validation, and atomic JSON write/failure rollback. ### Tested - Patched: `python -I tests/test_gamedata_blobs.py -v` -> `Ran 14 tests in 1.178s` (`OK`). - Baseline check (`upstream/main` `a73a57e1` with updated `tests/test_gamedata_blobs.py` copied into detached worktree): `Ran 14 tests in 1.119s` (`FAILED (failures=10)`). - Repo gates: `python -I tests/test_ci_registration.py` (`Ran 16 tests in 5.560s`, `OK`), `python -I tests/test_text_write_line_endings.py` (`Ran 3 tests in 13.499s`, `OK`), `python -I scripts/check_no_game_data.py` (exit 0), `python -I -m compileall -q tools/gamedata_blobs.py tests/test_gamedata_blobs.py` (exit 0), `git diff --check` (exit 0). GPUs tested: n/a (synthetic carve/RPF/SGD5 fixtures and atomic JSON output tests) 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. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
lixonik commented 2026-11-26 10:58:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T10:58:27Z.

Review: COMMENTED


Windows 11: 14/14 Python tests passed. Two additional checks on a synthetic carve reproduced a missed output collision and a second index.json parse. Details inline.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6072924808 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2258#pullrequestreview-6072924808). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T10:58:27Z. **Review:** COMMENTED --- Windows 11: 14/14 Python tests passed. Two additional checks on a synthetic carve reproduced a missed output collision and a second `index.json` parse. Details inline. AI-assisted.
lixonik commented 2026-11-26 10:58:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T10:58:27Z.

Code review location: tools/gamedata_blobs.py; line 385

@@ -370,7 +382,7 @@ def cross_reference_sgd5(payloads: list[dict], shaders_rpf: str) -> dict:
 def check_report_path(out_path: str, target: str, shaders_rpf: str | None = None,
                       rows: list[dict] | None = None) -> None:
     """Refuse a --json destination that is a directory or aliases any input file."""
-    if os.path.isdir(out_path):
+    if os.path.isdir(out_path) or out_path.endswith(("/", "\\")):

[P2] Reject reports that would overwrite a .bk2 carve input.

DirectorySource.read() reads <off>.bk2 for type: "bink2", while the delegated gamedata_maps.check_report_path() checks only .bin. I used a single synthetic row at offset 4096 and set --json to the corresponding 000000001000.bk2 file. The CLI returned 0 and atomically replaced that input with the JSON report. Can the guard use the same filename rule as DirectorySource.read() for both payload types?

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4707375737 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2258#discussion_r4707375737). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T10:58:27Z. **Code review location:** `tools/gamedata_blobs.py`; line 385 ~~~~diff @@ -370,7 +382,7 @@ def cross_reference_sgd5(payloads: list[dict], shaders_rpf: str) -> dict: def check_report_path(out_path: str, target: str, shaders_rpf: str | None = None, rows: list[dict] | None = None) -> None: """Refuse a --json destination that is a directory or aliases any input file.""" - if os.path.isdir(out_path): + if os.path.isdir(out_path) or out_path.endswith(("/", "\\")): ~~~~ --- [P2] Reject reports that would overwrite a `.bk2` carve input. `DirectorySource.read()` reads `<off>.bk2` for `type: "bink2"`, while the delegated `gamedata_maps.check_report_path()` checks only `.bin`. I used a single synthetic row at offset 4096 and set `--json` to the corresponding `000000001000.bk2` file. The CLI returned 0 and atomically replaced that input with the JSON report. Can the guard use the same filename rule as `DirectorySource.read()` for both payload types?
lixonik commented 2026-11-26 10:58:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T10:58:28Z.

Code review location: tools/gamedata_blobs.py; line 446

@@ -395,15 +434,18 @@ def main(argv=None) -> int:
         print(f"ERROR: cannot read {a.target}: no such file or folder", file=sys.stderr)
         return 2
     try:
+        if a.shaders and not os.path.isfile(a.shaders):
+            raise ValueError(f"{a.shaders}: no such file")
         if a.json:
             check_report_path(a.json, a.target, a.shaders)
-        if os.path.isdir(a.target):
+        is_dir = os.path.isdir(a.target)
+        if is_dir:
             rows = check_carve_index(a.target)
             if a.json:
                 check_report_path(a.json, a.target, a.shaders, rows=rows)
-        payloads = read_payloads(a.target)
+        payloads = read_payloads(a.target, _checked_index=is_dir)

[P3] Pass the parsed index through to DirectorySource if the CLI should parse it once.

Spying on json.load for the synthetic carve shows two real reads of index.json. _checked_index skips another call to check_carve_index(), while DirectorySource.__init__ opens and parses the file again. The new test counts calls to the validator only, so it misses this second read. Reusing the validated document would also keep path validation and payload reading on the same index snapshot.

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4707375744 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2258#discussion_r4707375744). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T10:58:28Z. **Code review location:** `tools/gamedata_blobs.py`; line 446 ~~~~diff @@ -395,15 +434,18 @@ def main(argv=None) -> int: print(f"ERROR: cannot read {a.target}: no such file or folder", file=sys.stderr) return 2 try: + if a.shaders and not os.path.isfile(a.shaders): + raise ValueError(f"{a.shaders}: no such file") if a.json: check_report_path(a.json, a.target, a.shaders) - if os.path.isdir(a.target): + is_dir = os.path.isdir(a.target) + if is_dir: rows = check_carve_index(a.target) if a.json: check_report_path(a.json, a.target, a.shaders, rows=rows) - payloads = read_payloads(a.target) + payloads = read_payloads(a.target, _checked_index=is_dir) ~~~~ --- [P3] Pass the parsed index through to `DirectorySource` if the CLI should parse it once. Spying on `json.load` for the synthetic carve shows two real reads of `index.json`. `_checked_index` skips another call to `check_carve_index()`, while `DirectorySource.__init__` opens and parses the file again. The new test counts calls to the validator only, so it misses this second read. Reusing the validated document would also keep path validation and payload reading on the same index snapshot.
tiguan26 commented 2026-11-27 04:36:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:36:00Z.

Review: APPROVED


Approving d1545dfde.

The unshipped-count fix is real: entries - len(in_db0) - len(in_db1) subtracted a stem present in both databases twice (it could go negative); counting stems in neither set is right. Index rows now need nonnegative integer off/stored, bad UTF-8 is reported, the index is not checked twice, and the JSON is written atomically.

Merged onto main d1dff7949 in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13. tests/test_gamedata_blobs.py: 14 passed (main: 10). AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6083536098 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2258#pullrequestreview-6083536098). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-27T04:36:00Z. **Review:** APPROVED --- Approving d1545dfde. The unshipped-count fix is real: `entries - len(in_db0) - len(in_db1)` subtracted a stem present in both databases twice (it could go negative); counting stems in neither set is right. Index rows now need nonnegative integer `off`/`stored`, bad UTF-8 is reported, the index is not checked twice, and the JSON is written atomically. Merged onto `main` `d1dff7949` in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13. `tests/test_gamedata_blobs.py`: 14 passed (main: 10). AI-assisted (Claude Code, Claude Opus 5.5).
kirigayakazima commented 2026-11-27 12:07:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-27T12:07:05Z.

Code review location: tools/gamedata_blobs.py; line 385

@@ -370,7 +382,7 @@ def cross_reference_sgd5(payloads: list[dict], shaders_rpf: str) -> dict:
 def check_report_path(out_path: str, target: str, shaders_rpf: str | None = None,
                       rows: list[dict] | None = None) -> None:
     """Refuse a --json destination that is a directory or aliases any input file."""
-    if os.path.isdir(out_path):
+    if os.path.isdir(out_path) or out_path.endswith(("/", "\\")):

Fixed: check_report_path() now checks each row's resolved .bk2/.bin payload path matching DirectorySource.read(), rejecting --json destinations that alias .bk2 carve inputs. Added regression coverage in tests/test_gamedata_blobs.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4719169834 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2258#discussion_r4719169834). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-27T12:07:05Z. **Code review location:** `tools/gamedata_blobs.py`; line 385 ~~~~diff @@ -370,7 +382,7 @@ def cross_reference_sgd5(payloads: list[dict], shaders_rpf: str) -> dict: def check_report_path(out_path: str, target: str, shaders_rpf: str | None = None, rows: list[dict] | None = None) -> None: """Refuse a --json destination that is a directory or aliases any input file.""" - if os.path.isdir(out_path): + if os.path.isdir(out_path) or out_path.endswith(("/", "\\")): ~~~~ --- Fixed: `check_report_path()` now checks each row's resolved `.bk2`/`.bin` payload path matching `DirectorySource.read()`, rejecting `--json` destinations that alias `.bk2` carve inputs. Added regression coverage in `tests/test_gamedata_blobs.py`.
kirigayakazima commented 2026-11-27 12:07:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-27T12:07:09Z.

Code review location: tools/gamedata_blobs.py; line 446

@@ -395,15 +434,18 @@ def main(argv=None) -> int:
         print(f"ERROR: cannot read {a.target}: no such file or folder", file=sys.stderr)
         return 2
     try:
+        if a.shaders and not os.path.isfile(a.shaders):
+            raise ValueError(f"{a.shaders}: no such file")
         if a.json:
             check_report_path(a.json, a.target, a.shaders)
-        if os.path.isdir(a.target):
+        is_dir = os.path.isdir(a.target)
+        if is_dir:
             rows = check_carve_index(a.target)
             if a.json:
                 check_report_path(a.json, a.target, a.shaders, rows=rows)
-        payloads = read_payloads(a.target)
+        payloads = read_payloads(a.target, _checked_index=is_dir)

Fixed: main() passes the already-validated rows to read_payloads(..., _rows=rows) using _LoadedDirectorySource, so index.json is opened and parsed once cleanly. Verified via json.load spy in tests/test_gamedata_blobs.py (15 tests OK + 5 repo checks).

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4719170288 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2258#discussion_r4719170288). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-27T12:07:09Z. **Code review location:** `tools/gamedata_blobs.py`; line 446 ~~~~diff @@ -395,15 +434,18 @@ def main(argv=None) -> int: print(f"ERROR: cannot read {a.target}: no such file or folder", file=sys.stderr) return 2 try: + if a.shaders and not os.path.isfile(a.shaders): + raise ValueError(f"{a.shaders}: no such file") if a.json: check_report_path(a.json, a.target, a.shaders) - if os.path.isdir(a.target): + is_dir = os.path.isdir(a.target) + if is_dir: rows = check_carve_index(a.target) if a.json: check_report_path(a.json, a.target, a.shaders, rows=rows) - payloads = read_payloads(a.target) + payloads = read_payloads(a.target, _checked_index=is_dir) ~~~~ --- Fixed: `main()` passes the already-validated `rows` to `read_payloads(..., _rows=rows)` using `_LoadedDirectorySource`, so `index.json` is opened and parsed once cleanly. Verified via `json.load` spy in `tests/test_gamedata_blobs.py` (15 tests OK + 5 repo checks).
lixonik commented 2026-11-27 14:23:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T14:23:23Z.

Review: COMMENTED


Re-checked at 843a265f4 (merged onto main ec91d695c).

Both earlier points are cleanly addressed:

  • check_report_path() now rejects .bk2 and .bin carve-input aliases matching DirectorySource.read().
  • _LoadedDirectorySource reuses the validated sorted rows from check_carve_index() so index.json is parsed once, covered by the json.load spy test.

Verified locally on Windows 11 (Python 3):

  • tests/test_gamedata_blobs.py: 15/15 passed
  • scripts/check_no_game_data.py and git diff --check: clean

No remaining findings.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6089570550 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2258#pullrequestreview-6089570550). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-27T14:23:23Z. **Review:** COMMENTED --- Re-checked at `843a265f4` (merged onto `main` `ec91d695c`). Both earlier points are cleanly addressed: - `check_report_path()` now rejects `.bk2` and `.bin` carve-input aliases matching `DirectorySource.read()`. - `_LoadedDirectorySource` reuses the validated sorted rows from `check_carve_index()` so `index.json` is parsed once, covered by the `json.load` spy test. Verified locally on Windows 11 (Python 3): - `tests/test_gamedata_blobs.py`: 15/15 passed - `scripts/check_no_game_data.py` and `git diff --check`: clean No remaining findings. AI-assisted.
sodove commented 2026-11-28 09:15:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T09:15:35Z.


#2258 | head 843a265f47d63dec939e7f69ac1f26ebde1ae193 | python3 -I tests/test_gamedata_blobs.py -v | red: 15 tests, 11 assertion failures | green: 15 passed | Red → green

Baseline assertions failed on summary counts, invalid index diagnostics and output handling.

Pinned main 4938673668d807bf365b61284bf22b1ff8d02cc4, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237122134 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2258#issuecomment-7237122134). Originally posted by [sodove](https://github.com/sodove) on 2026-11-28T09:15:35Z. --- #2258 | head `843a265f47d63dec939e7f69ac1f26ebde1ae193` | `python3 -I tests/test_gamedata_blobs.py -v` | red: 15 tests, 11 assertion failures | green: 15 passed | **Red → green** Baseline assertions failed on summary counts, invalid index diagnostics and output handling. Pinned main `4938673668d807bf365b61284bf22b1ff8d02cc4`, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7236982945).
zmasi commented 2026-11-28 22:08:32 +00:00 (Migrated from github.com)

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


Native Windows 11 NTFS Verification (843a265f47)

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

  • Red (origin/main c7753ed98a): python -I tests/test_gamedata_blobs.py failed 11/15 (FAILED (failures=11)).
  • Green (origin/main + 843a265f47):
    • python -I tests/test_gamedata_blobs.py: 15/15 OK (overlap-safe unshipped count, strict int row type/sign checks, RecursionError handling, single index.json parse, .bk2 input-alias refusal, and pure-LF atomic JSON output).
    • Live unmocked Windows 11 NTFS stat.S_IREAD probe: Ran gamedata_blobs.main([carve, "--json", blobs.json]) against a read-only blobs.json (stat.S_IREAD): exited rc=1, left 0 .blobs-*.tmp staged files, and preserved blobs.json byte-for-byte.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246525089 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2258#issuecomment-7246525089). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T22:08:32Z. --- ### Native Windows 11 NTFS Verification (`843a265f47`) Verified `843a265f47d63dec939e7f69ac1f26ebde1ae193` merged cleanly onto `origin/main` (`c7753ed98a56677f10e34078b37eab0540e190ec`, `git merge-tree --write-tree` `rc=0`) on native **Windows 11 (`26200`) + NTFS**: - **Red (`origin/main` `c7753ed98a`)**: `python -I tests/test_gamedata_blobs.py` failed **`11/15`** (`FAILED (failures=11)`). - **Green (`origin/main + 843a265f47`)**: - `python -I tests/test_gamedata_blobs.py`: **`15/15 OK`** (overlap-safe `unshipped` count, strict `int` row type/sign checks, `RecursionError` handling, single `index.json` parse, `.bk2` input-alias refusal, and pure-LF atomic JSON output). - **Live unmocked Windows 11 NTFS `stat.S_IREAD` probe**: Ran `gamedata_blobs.main([carve, "--json", blobs.json])` against a read-only `blobs.json` (`stat.S_IREAD`): exited `rc=1`, left **`0` `.blobs-*.tmp` staged files**, and preserved `blobs.json` byte-for-byte. AI-assisted.
timbot103 commented 2026-11-29 04:27:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T04:27:13Z.

Review: COMMENTED


Static audit of 843a265f4 against the base code. No builds, tests, or GPU runs were performed for this review. The unshipped calculation counts each preload entry absent from both databases. Both index fields require exact nonnegative integers, which excludes booleans, and the validated rows are reused after one parse. The writer stages beside the resolved destination, flushes and syncs before os.replace, and pins LF in the form recognized by tests/test_text_write_line_endings.py. The added tests cover overlap, malformed index rows, recursion, a single parse, early argument checks, a carve-input alias, and rollback on dump and replace errors.

  • Major — tools/gamedata_blobs.py:430 can replace a read-only report in a writable POSIX directory or turn an existing FIFO into a regular file. Preserve the nontruncating writability check for regular files and handle special destinations before the rename, as in tools/bink_index.py:364.
  • Major — tools/gamedata_blobs.py:414 turns the invalid POSIX destination regular-file/../keep.json into keep.json and can overwrite it. Validate the unreduced path before resolving it so an existing non-directory component still produces ENOTDIR.
  • Minor — tools/gamedata_blobs.py:433 skips unlinking the stage if cleanup chmod fails. Attempt unlink independently and cover that failure path in the rollback test.
  • Minor — tools/gamedata_blobs.py:394 rejects a literal trailing backslash in a valid POSIX filename. Check separators for the active platform and update the test at tests/test_gamedata_blobs.py:438.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6101396357 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2258#pullrequestreview-6101396357). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-29T04:27:13Z. **Review:** COMMENTED --- Static audit of `843a265f4` against the base code. No builds, tests, or GPU runs were performed for this review. The `unshipped` calculation counts each preload entry absent from both databases. Both index fields require exact nonnegative integers, which excludes booleans, and the validated rows are reused after one parse. The writer stages beside the resolved destination, flushes and syncs before `os.replace`, and pins LF in the form recognized by `tests/test_text_write_line_endings.py`. The added tests cover overlap, malformed index rows, recursion, a single parse, early argument checks, a carve-input alias, and rollback on dump and replace errors. - **Major** — `tools/gamedata_blobs.py:430` can replace a read-only report in a writable POSIX directory or turn an existing FIFO into a regular file. Preserve the nontruncating writability check for regular files and handle special destinations before the rename, as in `tools/bink_index.py:364`. - **Major** — `tools/gamedata_blobs.py:414` turns the invalid POSIX destination `regular-file/../keep.json` into `keep.json` and can overwrite it. Validate the unreduced path before resolving it so an existing non-directory component still produces `ENOTDIR`. - **Minor** — `tools/gamedata_blobs.py:433` skips unlinking the stage if cleanup `chmod` fails. Attempt unlink independently and cover that failure path in the rollback test. - **Minor** — `tools/gamedata_blobs.py:394` rejects a literal trailing backslash in a valid POSIX filename. Check separators for the active platform and update the test at `tests/test_gamedata_blobs.py:438`. AI-assisted.
MoonEyes commented 2026-11-29 14:19:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:19:07Z.


Merged at head 843a265. Tested by others on this head: sodove (WSL, Python 3.14) and zmasi (Windows 11 NTFS): tests/test_gamedata_blobs.py 11/15 fail on main, 15/15 pass with the PR. No GPU involved. AI-assisted: yes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257209581 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2258#issuecomment-7257209581). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T14:19:07Z. --- Merged at head 843a265. Tested by others on this head: sodove (WSL, Python 3.14) and zmasi (Windows 11 NTFS): `tests/test_gamedata_blobs.py` 11/15 fail on main, 15/15 pass with the PR. No GPU involved. AI-assisted: yes.
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!2258
No description provided.