fog_volumes: find a zlib header that starts on a scan-range boundary (FOG-VOLUMES-SCAN-BOUNDARY) #2108

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

@⁠syfyra on GitHub · 2026-11-25 20:57 UTC · original
syfyra:fix/fog-volumes-scan-boundary → main · +41 −2 · 2 files · 1 commits · draft

Claimed in the coordination issue as: FOG-VOLUMES-SCAN-BOUNDARY (#1608)

What and why

tools/fog_volumes.py scans an RPF in ranges (one per worker) and _scan_rpf_chunk looked for the 2-byte zlib header with ZHDR.search(m, pos, end). A header that starts at end - 1 does not match there, because its second byte lies past end, and the next range starts at end, after its first byte. No range found it, so that fog-volume resource was missing from the report.

Where the ranges split depends on --jobs and the file size (chunk_sz = ceil(size / workers), clamped to 4..64 MiB), so the same archive could give different counts for different --jobs values. The search now runs to end + 1 and keeps only a match that starts before end; a header is still counted by exactly one range. world_census.scan_shard already reads past its end the same way.

Tested

Windows 11, Python 3.14.7, synthetic archives only (built with the test file's build_synthetic_fog_0x7a):

  • python -I tests/test_fog_volumes.py: two new tests, both fail on main and pass with the fix; 12 tests OK.
    • test_a_header_on_a_range_boundary_is_found_once: split points at, before and after one header; on main the split one byte after the header start finds nothing.
    • test_jobs_do_not_change_what_is_found: an 8 MiB + 2 byte archive with a resource at 4 MiB; on main --jobs 1 finds it and --jobs 2 returns ([], 0, 0).
  • A sweep over all 556 split points of an archive with two back-to-back resources: each is found exactly once with the fix; on main two split points lost one of them.
  • python -m compileall; scripts/check_no_game_data.py on both files.

GPUs tested: n/a (CPU-only scanner)

AI-assisted: yes (Claude Code, 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)

🤖 Generated with Claude Code

**@⁠syfyra** on GitHub · 2026-11-25 20:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2108) `syfyra:fix/fog-volumes-scan-boundary` → `main` · +41 −2 · 2 files · 1 commits · draft Claimed in the coordination issue as: FOG-VOLUMES-SCAN-BOUNDARY (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why `tools/fog_volumes.py` scans an RPF in ranges (one per worker) and `_scan_rpf_chunk` looked for the 2-byte zlib header with `ZHDR.search(m, pos, end)`. A header that starts at `end - 1` does not match there, because its second byte lies past `end`, and the next range starts at `end`, after its first byte. No range found it, so that fog-volume resource was missing from the report. Where the ranges split depends on `--jobs` and the file size (`chunk_sz = ceil(size / workers)`, clamped to 4..64 MiB), so the same archive could give different counts for different `--jobs` values. The search now runs to `end + 1` and keeps only a match that starts before `end`; a header is still counted by exactly one range. `world_census.scan_shard` already reads past its end the same way. ### Tested Windows 11, Python 3.14.7, synthetic archives only (built with the test file's `build_synthetic_fog_0x7a`): - `python -I tests/test_fog_volumes.py`: two new tests, both fail on `main` and pass with the fix; 12 tests OK. - `test_a_header_on_a_range_boundary_is_found_once`: split points at, before and after one header; on `main` the split one byte after the header start finds nothing. - `test_jobs_do_not_change_what_is_found`: an 8 MiB + 2 byte archive with a resource at 4 MiB; on `main` `--jobs 1` finds it and `--jobs 2` returns `([], 0, 0)`. - A sweep over all 556 split points of an archive with two back-to-back resources: each is found exactly once with the fix; on `main` two split points lost one of them. - `python -m compileall`; `scripts/check_no_game_data.py` on both files. GPUs tested: n/a (CPU-only scanner) AI-assisted: yes (Claude Code, 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) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
_scan_rpf_chunk searched [start, end) for the 2-byte zlib header with
ZHDR.search(m, pos, end), so a header starting at end - 1 did not match:
its second byte lies past end. The next range starts at end, after the
header's first byte, so no range found it and the resource was lost. The
split points depend on --jobs and the file size, so the same archive gave
different counts for different --jobs values. Search to end + 1 and keep
only a match that starts before end, as world_census.scan_shard does.

Tested: two new tests in tests/test_fog_volumes.py (every split point
around one header; an 8 MiB + 2 byte archive with --jobs 1 and 2), both
fail before the fix. A sweep over all 556 split points of a two-resource
archive finds each resource exactly once (two split points lost one
before).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:18:09 +00:00
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/2108/head:github-bot/gh-2108'
git switch 'github-bot/gh-2108'

Merge

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