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

Closed
leonida/mandy
syfyra wants to merge 0 commits from fix/fog-volumes-scan-boundary into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

syfyra commented 2026-11-25 20:57:59 +00:00

Claimed in the coordination issue as: FOG-VOLUMES-SCAN-BOUNDARY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7173922396)

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

Claimed in the coordination issue as: FOG-VOLUMES-SCAN-BOUNDARY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7173922396) ### 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)
aslan2142 reviewed 2026-12-01 12:01:02 +00:00
aslan2142 left a comment
No description provided.
Draft review against current `main`: extending the search window by 1 byte (`search_end = min(size, end + 1)`) while keeping `mt.start() < end` in `tools/fog_volumes.py:179-183` looks clean and clean-room verified, but this branch currently conflicts with `main` and has no CI run yet. Please rebase onto current `main` and mark Ready for Review so CI runs green. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 12:20:28 +00:00

Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 reviewed 2026-12-01 12:59:39 +00:00
aslan2142 left a comment
No description provided.
Now ready for review, requesting changes before merge: - **Merge conflicts (`CONFLICTING`/`DIRTY`)**: conflicts with `main` in `tools/fog_volumes.py` / `tests/test_fog_volumes.py`. The zlib scan-range boundary fix in `tools/fog_volumes.py:179-183` looks solid once rebased. - **CI**: no CI runs on the current head. Please rebase onto current `main` and get fresh green CI. *(AI-assisted review.)*
aegish-zagi commented 2026-12-02 04:51:54 +00:00

Verification — VERIFY-2108

Verdict: PASS (with a rebase note: the test file conflicts with current main)

  • PR: #2108 | head sha: 289c910baa2b96cc6994c4bb4e5d5acd55aa0013 | merge state vs main 8422def759cda12c89f918438eeb8d53dd5972a6: CONFLICT in tests/test_fog_volumes.py only — tools/fog_volumes.py merges cleanly. The PR head as-is was tested.
  • Tests run: python3 -I tests/test_fog_volumes.py
  • Red on main vs green on PR: on plain main code with the PR test file, exactly the two new tests FAIL — test_a_header_on_a_range_boundary_is_found_once (split=257) and test_jobs_do_not_change_what_is_found (jobs=2); Ran 12 tests — FAILED (failures=2, skipped=1). On the PR head: Ran 12 tests — OK (skipped=1).
  • Audit (READ IN CODE): the fix extends the header search one byte past the range end (search_end = min(size, end + 1)) and discards a match starting at or past end, so a header straddling the boundary is claimed exactly once, by the range it starts in. No game data in the diff.
  • Platform: Linux, Python 3.12.3, no GPU (Profile Z)

AI-assisted: yes (Muse Wonder, Muse by Meta)

## Verification — VERIFY-2108 **Verdict: PASS (with a rebase note: the test file conflicts with current main)** - PR: #2108 | head sha: `289c910baa2b96cc6994c4bb4e5d5acd55aa0013` | merge state vs main `8422def759cda12c89f918438eeb8d53dd5972a6`: CONFLICT in `tests/test_fog_volumes.py` only — `tools/fog_volumes.py` merges cleanly. The PR head as-is was tested. - Tests run: `python3 -I tests/test_fog_volumes.py` - Red on main vs green on PR: on plain main code with the PR test file, exactly the two new tests FAIL — `test_a_header_on_a_range_boundary_is_found_once` (split=257) and `test_jobs_do_not_change_what_is_found` (jobs=2); `Ran 12 tests — FAILED (failures=2, skipped=1)`. On the PR head: `Ran 12 tests — OK (skipped=1)`. - Audit (READ IN CODE): the fix extends the header search one byte past the range end (`search_end = min(size, end + 1)`) and discards a match starting at or past `end`, so a header straddling the boundary is claimed exactly once, by the range it starts in. No game data in the diff. - Platform: Linux, Python 3.12.3, no GPU (Profile Z) AI-assisted: yes (Muse Wonder, Muse by Meta)
MoonEyes commented 2026-12-02 10:32:25 +00:00

For information: this pull request is carried in #3091, which merges your head (your commits are kept) into current main, resolves the conflicts keeping both sides, and fixes the points raised in review here (details in its description). This one stays open until a maintainer decides; if you pick it up again, say so and the carry can be closed.

AI-assisted (Claude Code, Claude Opus 5.5)

For information: this pull request is carried in #3091, which merges your head (your commits are kept) into current `main`, resolves the conflicts keeping both sides, and fixes the points raised in review here (details in its description). This one stays open until a maintainer decides; if you pick it up again, say so and the carry can be closed. AI-assisted (Claude Code, Claude Opus 5.5)
MoonEyes commented 2026-12-02 11:49:46 +00:00

Closing: this pull request no longer applies to current main (merge conflict in tests/test_fog_volumes.py), and open pull requests that have fallen out of step with main are being closed so the list stays workable. Your work is not lost: it is carried in #3091
, which keeps your commits and resolves the conflict on current main.

AI-assisted (Claude Code).

Closing: this pull request no longer applies to current `main` (merge conflict in `tests/test_fog_volumes.py`), and open pull requests that have fallen out of step with `main` are being closed so the list stays workable. Your work is not lost: it is carried in #3091 , which keeps your commits and resolves the conflict on current `main`. AI-assisted (Claude Code).
Sign in to join this conversation.
No description provided.