tile_probe: make an impossible --offset a usage error with exit 2 #1622

Merged
xel1uz merged 1 commit from upstream-pr/1622 into main 2026-11-29 03:37:47 +00:00
xel1uz commented 2026-11-25 06:11:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by xel1uz on 2026-11-25T06:11:33Z.


Item ID: TILE-OFFSET-USAGE (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here)

Claimed as: TILE-OFFSET-USAGE - an offset outside the blob is reported as a run result (exit 1) while sibling tools treat it as usage (exit 2). Reproduced on 42537e7b.

What and why

An impossible --offset (-1, or at/past the end) reached the read and then raise SystemExit(... is outside ...) with exit 1, so a script could not separate a bad argument from a probe result. Validation now happens before --out, the numpy check and the read: ERROR: --offset must not be negative and ERROR: --offset N is past the end of <blob> (M bytes), both exit 2. The no layout fits result path deliberately stays at exit 1 - the offset is valid there, only the sample is short - and an empty blob at offset 0 keeps that result path, while the same blob at offset 5 is a usage error. Both decisions are commented in the code.

Note: tools/f16misc_diff.py was in this tree briefly and dropped again; fix/f16misc-arg-guards owns it.

Tested

  • pytest tests/test_tile_probe.py -q with the tool at 42537e7b: 4 failed, 12 passed, 1 skipped, 6 subtests passed.

  • With this branch: 14 passed, 1 skipped, 8 subtests passed.

  • Real repro on a 4096-byte blob: --offset -1 and --offset 4096 each print one ERROR line and exit 2.

  • git diff --check clean; python3 -I scripts/check_no_game_data.py clean on the changed files.

GPUs tested: n/a - CPU only, no Vulkan device involved.

AI-assisted: Yes.

Checklist

  • Based on current main (42537e7b) and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption; synthetic inputs only.
  • A new translator rule in the contract table of docs/design.md - not applicable, no translator change.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5486181040 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1622). Originally posted by [xel1uz](https://github.com/xel1uz) on 2026-11-25T06:11:33Z. --- Item ID: `TILE-OFFSET-USAGE` (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here) Claimed as: `TILE-OFFSET-USAGE` - an offset outside the blob is reported as a run result (exit 1) while sibling tools treat it as usage (exit 2). Reproduced on 42537e7b. ### What and why An impossible `--offset` (`-1`, or at/past the end) reached the read and then `raise SystemExit(... is outside ...)` with exit 1, so a script could not separate a bad argument from a probe result. Validation now happens before `--out`, the numpy check and the read: `ERROR: --offset must not be negative` and `ERROR: --offset N is past the end of <blob> (M bytes)`, both exit 2. The `no layout fits` result path deliberately stays at exit 1 - the offset is valid there, only the sample is short - and an empty blob at offset 0 keeps that result path, while the same blob at offset 5 is a usage error. Both decisions are commented in the code. Note: `tools/f16misc_diff.py` was in this tree briefly and dropped again; `fix/f16misc-arg-guards` owns it. ### Tested - `pytest tests/test_tile_probe.py -q` with the tool at 42537e7b: **4 failed, 12 passed, 1 skipped, 6 subtests passed**. - With this branch: **14 passed, 1 skipped, 8 subtests passed**. - Real repro on a 4096-byte blob: `--offset -1` and `--offset 4096` each print one ERROR line and exit 2. - `git diff --check` clean; `python3 -I scripts/check_no_game_data.py` clean on the changed files. GPUs tested: n/a - CPU only, no Vulkan device involved. AI-assisted: Yes. ### Checklist - [x] Based on current `main` (42537e7b) and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption; synthetic inputs only. - [ ] A new translator rule in the contract table of `docs/design.md` - not applicable, no translator change.
PierreEbele commented 2026-11-25 15:46:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T15:46:35Z.


Reviewed 69e6b59c7: ran tests/test_tile_probe.py on the PR (15 OK) and on main with the PR's test
file copied in (the new tests fail on main as intended, exit 1 → exit 2); also ran
test_missing_input_exit_codes.py, test_tool_startup.py, compileall and check_no_game_data.py on the
PR tree — all green. One reproduced edge case, judged not blocking: on a named-pipe blob with
--offset > 0 the tool now exits 2 "past the end (0 bytes)" (getsize is 0 on a fifo) where main
probed it fine — regular files are the documented input, but keeping the past-the-end check after
the read on len(data) would cover streams too. AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7167305991 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1622#issuecomment-7167305991). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T15:46:35Z. --- Reviewed 69e6b59c7: ran tests/test_tile_probe.py on the PR (15 OK) and on main with the PR's test file copied in (the new tests fail on main as intended, exit 1 → exit 2); also ran test_missing_input_exit_codes.py, test_tool_startup.py, compileall and check_no_game_data.py on the PR tree — all green. One reproduced edge case, judged not blocking: on a named-pipe blob with --offset > 0 the tool now exits 2 "past the end (0 bytes)" (getsize is 0 on a fifo) where main probed it fine — regular files are the documented input, but keeping the past-the-end check after the read on len(data) would cover streams too. AI-assisted review. **Recommendation:** Merge
MoonEyes commented 2026-11-28 03:02:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T03:02:54Z.


Hi @xel1uz, thanks for this pull request.

CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post claiming: <ID> there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one.

The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time.

Could you post the claim in #1608 and put its ID (or a link to it) on the pull request's "Claimed in the coordination issue as:" line? If you already claimed it in another form, a link to your comment is enough.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232759355 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1622#issuecomment-7232759355). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T03:02:54Z. --- Hi @xel1uz, thanks for this pull request. CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post `claiming: <ID>` there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one. The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time. Could you post the claim in #1608 and put its ID (or a link to it) on the pull request's "Claimed in the coordination issue as:" line? If you already claimed it in another form, a link to your comment is enough. AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-28 20:31:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T20:31:00Z.


#1622 | head 69e6b59c79 (merged cleanly with main 1bc055e6c2) | python tests/test_tile_probe.py (with numpy 2.5.1) + python -I tests/test_tile_probe.py (stdlib-only) | red on main: FAILED (failures=4) (--offset -5, 16384, and 99999 exited 1 instead of usage-error 2, and --offset 0 on 0-byte empty.bin rejected the offset instead of reporting no layout fits) | green on PR+main: 15 tests OK (0 skipped with numpy; 2/2 TileProbeWithoutNumpyTest OK under -I) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited tools/tile_probe.py and tests/test_tile_probe.py on Windows 11, verifying upfront --offset < 0 and --offset >= size exit-2 usage checks (before --out / numpy checks) while preserving --offset 0 on an empty file as an exit-1 short-sample probe failure (no layout fits). Also verified tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7245342489 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1622#issuecomment-7245342489). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T20:31:00Z. --- #1622 | head 69e6b59c7941dc1180f8f4a705b1a311d7d61d5e (merged cleanly with main 1bc055e6c2) | `python tests/test_tile_probe.py` (with `numpy` 2.5.1) + `python -I tests/test_tile_probe.py` (stdlib-only) | red on main: `FAILED (failures=4)` (`--offset -5`, `16384`, and `99999` exited `1` instead of usage-error `2`, and `--offset 0` on 0-byte `empty.bin` rejected the offset instead of reporting `no layout fits`) | green on PR+main: `15 tests OK` (0 skipped with `numpy`; `2/2` `TileProbeWithoutNumpyTest` `OK` under `-I`) | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `tools/tile_probe.py` and `tests/test_tile_probe.py` on Windows 11, verifying upfront `--offset < 0` and `--offset >= size` exit-2 usage checks (before `--out` / `numpy` checks) while preserving `--offset 0` on an empty file as an exit-1 short-sample probe failure (`no layout fits`). Also verified `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
TheGeogeo commented 2026-11-29 00:17:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:17:03Z.


Tested 69e6b59c7 merged (no commit) with main 829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Green: tests/test_tile_probe.py, 15 tests pass (1 skipped).
  • Red: with tools/tile_probe.py back to main, 4 failures (e.g. --offset 99999 is outside ... (16384 bytes): exit 1 != 2).

No blocker from my side.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248004800 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1622#issuecomment-7248004800). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T00:17:03Z. --- Tested `69e6b59c7` merged (no commit) with `main` `829530dbd`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Green: `tests/test_tile_probe.py`, 15 tests pass (1 skipped). - Red: with `tools/tile_probe.py` back to `main`, 4 failures (e.g. `--offset 99999 is outside ... (16384 bytes)`: exit `1 != 2`). No blocker from my side. AI-assisted (Claude Code).
OreoFR commented 2026-11-29 03:19:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T03:19:44Z.


Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main c8bf0e7b6, PR head 69e6b59c7 : red 4 failures / green 14 OK

tests/test_tile_probe.py (15 tests), run with pytest in a venv with numpy + Pillow (plain python3.12 -I skips 13 of 15 for lack of numpy, so that red proves nothing):

  • Merge: clean (git merge-tree).
  • Red (main + only this PR's test file): 4 failures: test_negative_offset_is_a_usage_error, test_offset_at_or_past_the_end_is_a_usage_error (16384 and 99999), test_empty_file_is_a_short_sample_not_a_bad_offset.
  • Green (main + git merge --no-ff): 14 OK, 1 skipped (the "-I without Pillow" case, since the venv's -I can import Pillow).
  • (MEASURED n=3) red results identical on each run.
  • Neighbours (test_amd_swizzle, _missing_input_exit_codes, _report_paths, _tile_probe_layout, _tool_startup): same on main and merge; only test_tool_startup fails on both (psin_dialogue → ModuleNotFoundError: psin_data), unrelated.
  • Diff: a negative or past-the-end offset now exits 2, checked before the numpy guard; an empty file at offset 0 stays on the "no layout fits" path. Minor: with a directory as blob and offset > 0 the message says "past the end … (0 bytes)" (exit code still 2); the "Before: … printed nothing" comment is inaccurate (main printed "outside"). No game data.

Verdict: READY

AI-assisted: Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249981011 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1622#issuecomment-7249981011). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T03:19:44Z. --- Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main c8bf0e7b6, PR head 69e6b59c7 : red 4 failures / green 14 OK `tests/test_tile_probe.py` (15 tests), run with pytest in a venv with numpy + Pillow (plain `python3.12 -I` skips 13 of 15 for lack of numpy, so that red proves nothing): - Merge: clean (`git merge-tree`). - **Red** (main + only this PR's test file): 4 failures: `test_negative_offset_is_a_usage_error`, `test_offset_at_or_past_the_end_is_a_usage_error` (16384 and 99999), `test_empty_file_is_a_short_sample_not_a_bad_offset`. - **Green** (main + `git merge --no-ff`): 14 OK, 1 skipped (the "-I without Pillow" case, since the venv's `-I` can import Pillow). - (MEASURED n=3) red results identical on each run. - Neighbours (`test_amd_swizzle`, `_missing_input_exit_codes`, `_report_paths`, `_tile_probe_layout`, `_tool_startup`): same on main and merge; only `test_tool_startup` fails on both (`psin_dialogue` → `ModuleNotFoundError: psin_data`), unrelated. - Diff: a negative or past-the-end offset now exits 2, checked before the numpy guard; an empty file at offset 0 stays on the "no layout fits" path. Minor: with a directory as blob and offset > 0 the message says "past the end … (0 bytes)" (exit code still 2); the "Before: … printed nothing" comment is inaccurate (main printed "outside"). No game data. **Verdict: READY** AI-assisted: Claude Code
DadaCap commented 2026-11-29 03:37:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-29T03:37:44Z.


Merging, thank you @xel1uz! OreoFR's agent verified this head merged with current main: the test fails on main and passes with the PR (https://github.com/ProjectLeonida/mandy/pull/1622#issuecomment-7249981011), and it still merges cleanly.

AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7250163430 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1622#issuecomment-7250163430). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-29T03:37:44Z. --- Merging, thank you @xel1uz! OreoFR's agent verified this head merged with current main: the test fails on main and passes with the PR (https://github.com/ProjectLeonida/mandy/pull/1622#issuecomment-7249981011), and it still merges cleanly. AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.
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!1622
No description provided.