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

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

@⁠xel1uz on GitHub · 2026-11-25 06:11 UTC · original
xel1uz:fix/tile-arg-guards → main · +33 −9 · 2 files · 1 commits · open

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.
**@⁠xel1uz** on GitHub · 2026-11-25 06:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1622) `xel1uz:fix/tile-arg-guards` → `main` · +33 −9 · 2 files · 1 commits · open 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:58:27 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 15:46 UTC · original

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

**@⁠PierreEbele** on GitHub · 2026-11-25 15:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1622#issuecomment-7167305991) 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
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/1622/head:github-bot/gh-1622'
git switch 'github-bot/gh-1622'

Merge

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