[PR #1622] tile_probe: make an impossible --offset a usage error with exit 2 #1635

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

📋 Pull Request Information

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

Base: main ← Head: fix/tile-arg-guards


📝 Commits (1)

  • 69e6b59 tile_probe: reject a negative or past-the-end --offset with exit 2

📊 Changes

2 files changed (+33 additions, -9 deletions)

View changed files

📝 tests/test_tile_probe.py (+23 -7)
📝 tools/tile_probe.py (+10 -2)

📄 Description

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.

🔄 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/1622 **Author:** [@xel1uz](https://github.com/xel1uz) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/tile-arg-guards` --- ### 📝 Commits (1) - [`69e6b59`](https://github.com/ubiquitarianism/leonida/commit/69e6b59c7941dc1180f8f4a705b1a311d7d61d5e) tile_probe: reject a negative or past-the-end --offset with exit 2 ### 📊 Changes **2 files changed** (+33 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_tile_probe.py` (+23 -7) 📝 `tools/tile_probe.py` (+10 -2) </details> ### 📄 Description 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. --- <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#1635
No description provided.