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

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

📋 Pull Request Information

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

Base: main ← Head: fix/fog-volumes-scan-boundary


📝 Commits (1)

  • 289c910 fog_volumes: find a zlib header that starts on a scan-range boundary (FOG-VOLUMES-SCAN-BOUNDARY)

📊 Changes

2 files changed (+41 additions, -2 deletions)

View changed files

📝 tests/test_fog_volumes.py (+35 -0)
📝 tools/fog_volumes.py (+6 -2)

📄 Description

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


🔄 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/2108 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/fog-volumes-scan-boundary` --- ### 📝 Commits (1) - [`289c910`](https://github.com/ubiquitarianism/leonida/commit/289c910baa2b96cc6994c4bb4e5d5acd55aa0013) fog_volumes: find a zlib header that starts on a scan-range boundary (FOG-VOLUMES-SCAN-BOUNDARY) ### 📊 Changes **2 files changed** (+41 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_fog_volumes.py` (+35 -0) 📝 `tools/fog_volumes.py` (+6 -2) </details> ### 📄 Description 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) --- <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#2114
No description provided.