texoff_probe: validate oracle batch/word payloads and handle run errors #1684

Merged
IlyassRS3 merged 1 commit from upstream-pr/1684 into main 2026-11-28 14:54:24 +00:00
IlyassRS3 commented 2026-11-25 08:04:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T08:04:15Z.


Item ID: TEXOFF-PROBE-ORACLE-VALIDATION (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156550196)

Summary

  • Hardware oracle payload validation (tools/texoff_probe.py):
    • Validate that oracle.run([k]) returns a list/tuple of length 1, and that its non-string element is a list/tuple of exact length len(rows) containing only non-bool int words (masking w & 0xFFFFFFFF before the tsharp.POISON check and struct.pack("<I", ...)), returning exit 2 cleanly instead of crashing with IndexError/TypeError/struct.error or accepting extra/bool words.
  • Runtime error lifecycle:
    • Catch runner.Unavailable (exit 77) and RuntimeError (exit 2) raised during oracle.run() inside try ... finally: oracle.close().
  • Regression tests (tests/test_texoff_probe.py):
    • Added tests covering malformed batch/word payloads across wave32 and wave64, runner.Unavailable during run() -> exit 77, and RuntimeError during run() -> exit 2, verifying oracle.close() on every path.

Checklist & Verification

  • AI-assisted: yes
  • Game data included: none (python3 -I scripts/check_no_game_data.py tools/texoff_probe.py tests/test_texoff_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_texoff_probe.py -v: Ran 13 tests ... OK
    • Mutation test (new tests/test_texoff_probe.py against unpatched main tools/texoff_probe.py): Ran 13 tests ... FAILED (failures=8, errors=11)
    • python3 -m compileall -q make_game.py tools tests: passed
    • python3 -I tests/test_text_write_line_endings.py: Ran 3 tests ... OK
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5487504558 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1684). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T08:04:15Z. --- Item ID: `TEXOFF-PROBE-ORACLE-VALIDATION` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156550196) ## Summary - **Hardware oracle payload validation (`tools/texoff_probe.py`)**: - Validate that `oracle.run([k])` returns a `list`/`tuple` of length `1`, and that its non-string element is a `list`/`tuple` of exact length `len(rows)` containing only non-bool `int` words (masking `w & 0xFFFFFFFF` before the `tsharp.POISON` check and `struct.pack("<I", ...)`), returning exit `2` cleanly instead of crashing with `IndexError`/`TypeError`/`struct.error` or accepting extra/bool words. - **Runtime error lifecycle**: - Catch `runner.Unavailable` (exit `77`) and `RuntimeError` (exit `2`) raised during `oracle.run()` inside `try ... finally: oracle.close()`. - **Regression tests (`tests/test_texoff_probe.py`)**: - Added tests covering malformed batch/word payloads across wave32 and wave64, `runner.Unavailable` during `run()` -> exit `77`, and `RuntimeError` during `run()` -> exit `2`, verifying `oracle.close()` on every path. ## Checklist & Verification - **AI-assisted**: yes - **Game data included**: none (`python3 -I scripts/check_no_game_data.py tools/texoff_probe.py tests/test_texoff_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_texoff_probe.py -v`: `Ran 13 tests ... OK` - Mutation test (new `tests/test_texoff_probe.py` against unpatched `main` `tools/texoff_probe.py`): `Ran 13 tests ... FAILED (failures=8, errors=11)` - `python3 -m compileall -q make_game.py tools tests`: passed - `python3 -I tests/test_text_write_line_endings.py`: `Ran 3 tests ... OK`
copilot-pull-request-reviewer[bot] commented 2026-11-25 08:04:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T08:04:30Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6053852392 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1684#pullrequestreview-6053852392). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T08:04:30Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
whoalin1 commented 2026-11-25 08:41:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T08:41:56Z.


Independent verification (Windows, Python 3.11.9 -I): oracle.run must return exactly-1 batch of list/tuple of non-bool ints (previously raw[0] could IndexError/TypeError); words masked before tsharp.POISON pack; Unavailable->77, RuntimeError->2 inside try/finally close. test_texoff_probe.py 13 OK; neighbors tex_mode_probe 37, d16_image_probe 13, image_d16_probe 22 all OK; --oracle hw->77 / bogus->exit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7157359874 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1684#issuecomment-7157359874). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T08:41:56Z. --- Independent verification (Windows, Python 3.11.9 `-I`): oracle.run must return exactly-1 batch of list/tuple of non-bool ints (previously `raw[0]` could IndexError/TypeError); words masked before `tsharp.POISON` pack; `Unavailable`->77, `RuntimeError`->2 inside try/finally close. `test_texoff_probe.py` 13 OK; neighbors tex_mode_probe 37, d16_image_probe 13, image_d16_probe 22 all OK; `--oracle hw`->77 / bogus->exit 2; compileall + line-endings + `check_no_game_data` clean. AI-assisted verification.
MoonEyes commented 2026-11-28 14:54:20 +00:00 (Migrated from github.com)

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


Red/green: pytest tests/test_texoff_probe.py fails on main (19 failed, 7 passed, 14 subtests passed) and passes on head 74295d02e3 merged with main (13 passed, 34 subtests passed).
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7241027330 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1684#issuecomment-7241027330). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:54:20Z. --- Red/green: `pytest tests/test_texoff_probe.py` fails on main (19 failed, 7 passed, 14 subtests passed) and passes on head 74295d02e3ef merged with main (13 passed, 34 subtests passed). Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
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!1684
No description provided.