tile_probe: make an impossible --offset a usage error with exit 2 #1622
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1622
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/tile-arg-guards"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
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 thenraise 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 negativeandERROR: --offset N is past the end of <blob> (M bytes), both exit 2. Theno layout fitsresult 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.pywas in this tree briefly and dropped again;fix/f16misc-arg-guardsowns it.Tested
pytest tests/test_tile_probe.py -qwith 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 -1and--offset 4096each print one ERROR line and exit 2.git diff --checkclean;python3 -I scripts/check_no_game_data.pyclean on the changed files.GPUs tested: n/a - CPU only, no Vulkan device involved.
AI-assisted: Yes.
Checklist
main(42537e7b) and merges cleanly.docs/design.md- not applicable, no translator change.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
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).
#1622 | head 69e6b59c7941dc1180f8f4a705b1a311d7d61d5e (merged cleanly with main 1bc055e6c2) |
python tests/test_tile_probe.py(withnumpy2.5.1) +python -I tests/test_tile_probe.py(stdlib-only) | red on main:FAILED (failures=4)(--offset -5,16384, and99999exited1instead of usage-error2, and--offset 0on 0-byteempty.binrejected the offset instead of reportingno layout fits) | green on PR+main:15 tests OK(0 skipped withnumpy;2/2TileProbeWithoutNumpyTestOKunder-I) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yesAudited
tools/tile_probe.pyandtests/test_tile_probe.pyon Windows 11, verifying upfront--offset < 0and--offset >= sizeexit-2 usage checks (before--out/numpychecks) while preserving--offset 0on an empty file as an exit-1 short-sample probe failure (no layout fits). Also verifiedtests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK), andscripts/check_no_game_data.py.Tested
69e6b59c7merged (no commit) withmain829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only.check_no_game_data.pyis clean.tests/test_tile_probe.py, 15 tests pass (1 skipped).tools/tile_probe.pyback tomain, 4 failures (e.g.--offset 99999 is outside ... (16384 bytes): exit1 != 2).No blocker from my side.
AI-assisted (Claude Code).
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 (plainpython3.12 -Iskips 13 of 15 for lack of numpy, so that red proves nothing):git merge-tree).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.git merge --no-ff): 14 OK, 1 skipped (the "-I without Pillow" case, since the venv's-Ican import Pillow).test_amd_swizzle,_missing_input_exit_codes,_report_paths,_tile_probe_layout,_tool_startup): same on main and merge; onlytest_tool_startupfails on both (psin_dialogue→ModuleNotFoundError: psin_data), unrelated.Verdict: READY
AI-assisted: Claude Code
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.