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

Merged
leonida/mandy
quietfold merged 1 commit from fix/texoff-probe-oracle-validation into main 2026-11-28 14:54:24 +00:00

Pull request successfully merged and closed

quietfold commented 2026-11-25 08:04:15 +00:00

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
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] reviewed 2026-11-25 08:04:30 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
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

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.

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

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)

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 description provided.