fog_volumes: find a zlib header that starts on a scan-range boundary (carry of #2108) #3091

Merged
MoonEyes merged 3 commits from upstream-pr/3091 into main 2026-12-02 13:29:06 +00:00
MoonEyes commented 2026-12-02 10:30:38 +00:00 (Migrated from github.com)

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


Claimed in the coordination issue as: FOG-VOLUMES-SCAN-BOUNDARY (the original author's item ID, claimed in https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7173922396)

What and why

Carry of #2108 (syfyra), unchanged since 2026-11-25; branch = main + the author's head (commit kept) + conflict resolution. I added no commit of my own: the reviews on #2108 only ask for a rebase and a CI run, and raise no code defect.

tools/fog_volumes.py scans an RPF in ranges, one per worker, and _scan_rpf_chunk searched for the 2-byte zlib header only up to the range end. A header starting at end - 1 was found by no range, so that resource was missing from the report for some --jobs values. The search now runs to end + 1 and keeps only a match that starts before end, so each header is counted by exactly one range.

Conflict resolution: tools/fog_volumes.py merged cleanly. tests/test_fog_volumes.py conflicted because main appended three report-writing tests at the end of the file and the PR appended two boundary tests at the same place; I kept all of them.

Tested

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

  • python -I tests/test_fog_volumes.py: Ran 15 tests, OK.
  • Red: with tools/fog_volumes.py restored to main's version, the same command gives Ran 15 tests, FAILED (failures=2): test_a_header_on_a_range_boundary_is_found_once (split=257) and test_jobs_do_not_change_what_is_found (jobs=2). The file was restored afterwards.
  • python -I scripts/check_no_game_data.py tools/fog_volumes.py tests/test_fog_volumes.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. (n/a: no translator change)

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5604610531 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3091). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T10:30:38Z. --- Claimed in the coordination issue as: FOG-VOLUMES-SCAN-BOUNDARY (the original author's item ID, claimed in https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7173922396) ### What and why Carry of #2108 (syfyra), unchanged since 2026-11-25; branch = main + the author's head (commit kept) + conflict resolution. I added no commit of my own: the reviews on #2108 only ask for a rebase and a CI run, and raise no code defect. `tools/fog_volumes.py` scans an RPF in ranges, one per worker, and `_scan_rpf_chunk` searched for the 2-byte zlib header only up to the range end. A header starting at `end - 1` was found by no range, so that resource was missing from the report for some `--jobs` values. The search now runs to `end + 1` and keeps only a match that starts before `end`, so each header is counted by exactly one range. Conflict resolution: `tools/fog_volumes.py` merged cleanly. `tests/test_fog_volumes.py` conflicted because main appended three report-writing tests at the end of the file and the PR appended two boundary tests at the same place; I kept all of them. ### Tested Windows 11, no GPU, no game files, on main a917c54d6 plus this branch: - `python -I tests/test_fog_volumes.py`: Ran 15 tests, OK. - Red: with `tools/fog_volumes.py` restored to main's version, the same command gives Ran 15 tests, FAILED (failures=2): `test_a_header_on_a_range_boundary_is_found_once` (split=257) and `test_jobs_do_not_change_what_is_found` (jobs=2). The file was restored afterwards. - `python -I scripts/check_no_game_data.py tools/fog_volumes.py tests/test_fog_volumes.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. (n/a: no translator change) Supersedes #2108 once merged; the original stays open until a maintainer decides. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Kal0s-design commented 2026-12-02 12:56:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T12:56:03Z.


Ran natively on Windows 11, Python 3.13, head 9089dae4e merged into current main (23a51c494), no conflicts.

py -3.13 -I tests/test_fog_volumes.py: 15 tests OK. With main's tools/fog_volumes.py the same two subtests fail as in the body (split=257, jobs=2), so nothing new there.

The tests check one resource and five split points. I wanted every split point, more than one resource, and more than two ranges, so I wrote throwaway RPF-like buffers (9FPR + padding + the test file's build_synthetic_fog_0x7a output, zlib-compressed) and compared _scan_rpf_chunk on the whole buffer with the sum over the ranges:

layout size whole-file result 2-range splits (every byte) PR / main 3-range splits (sampled) PR / main
two resources back to back, no gap 495 offsets [16, 242], 2 complete 0 / 2 mismatches 0 / 13
two resources, second on a 16-byte boundary 509 [16, 256], 2 0 / 2 0 / 14
non-0x7a zlib stream between them 507 [16, 254], 2 0 / 2 0 / 13
one resource, lone 0x78 as the very last byte 246 [16], 1 0 / 1 0 / 1

On main the misses are exactly split = header + 1 for each resource (for example split 17 loses the resource at 16, split 243 loses the one at 242), which matches the bug described. With the PR no split point changes the offsets or the complete/incomplete counts, the stream in between is never counted, and a 0x78 in the last byte of the file (where end + 1 is capped at the file size) does not break anything.

Not checked: real archives (no game files used), continuation pages joined by world_census.assemble across a boundary, --jobs above 2.

GPUs tested: n/a (CPU-only tests).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7346101754 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3091#issuecomment-7346101754). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T12:56:03Z. --- Ran natively on Windows 11, Python 3.13, head `9089dae4e` merged into current `main` (`23a51c494`), no conflicts. `py -3.13 -I tests/test_fog_volumes.py`: 15 tests OK. With main's `tools/fog_volumes.py` the same two subtests fail as in the body (split=257, jobs=2), so nothing new there. The tests check one resource and five split points. I wanted every split point, more than one resource, and more than two ranges, so I wrote throwaway RPF-like buffers (`9FPR` + padding + the test file's `build_synthetic_fog_0x7a` output, zlib-compressed) and compared `_scan_rpf_chunk` on the whole buffer with the sum over the ranges: | layout | size | whole-file result | 2-range splits (every byte) PR / main | 3-range splits (sampled) PR / main | |---|---|---|---|---| | two resources back to back, no gap | 495 | offsets [16, 242], 2 complete | 0 / 2 mismatches | 0 / 13 | | two resources, second on a 16-byte boundary | 509 | [16, 256], 2 | 0 / 2 | 0 / 14 | | non-0x7a zlib stream between them | 507 | [16, 254], 2 | 0 / 2 | 0 / 13 | | one resource, lone `0x78` as the very last byte | 246 | [16], 1 | 0 / 1 | 0 / 1 | On main the misses are exactly split = header + 1 for each resource (for example split 17 loses the resource at 16, split 243 loses the one at 242), which matches the bug described. With the PR no split point changes the offsets or the complete/incomplete counts, the stream in between is never counted, and a `0x78` in the last byte of the file (where `end + 1` is capped at the file size) does not break anything. Not checked: real archives (no game files used), continuation pages joined by `world_census.assemble` across a boundary, `--jobs` above 2. GPUs tested: n/a (CPU-only tests). AI-assisted: yes (Claude Code).
MoonEyes commented 2026-12-02 13:14:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T13:14:18Z.


Merging. Head 9089dae4e merges cleanly with main bf7886746 and does not force a rebase of #2566. Independent check on head 9089dae4e: Kal0s-design's native run on Windows 11 merged into main (on main every split at header + 1 loses the resource just before it, as the bug describes; with this head none is lost), comment 7346101754; syfyra's commit from #2108 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:7346561425 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3091#issuecomment-7346561425). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T13:14:18Z. --- Merging. Head `9089dae4e` merges cleanly with `main` `bf7886746` and does not force a rebase of #2566. Independent check on head 9089dae4e: Kal0s-design's native run on Windows 11 merged into main (on main every split at header + 1 loses the resource just before it, as the bug describes; with this head none is lost), comment 7346101754; syfyra's commit from #2108 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!3091
No description provided.