[PR #1684] texoff_probe: validate oracle batch/word payloads and handle run errors #1698

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

📋 Pull Request Information

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

Base: main ← Head: fix/texoff-probe-oracle-validation


📝 Commits (1)

  • 74295d0 texoff_probe: validate oracle batch/word payloads and handle run errors

📊 Changes

2 files changed (+95 additions, -3 deletions)

View changed files

📝 tests/test_texoff_probe.py (+72 -0)
📝 tools/texoff_probe.py (+23 -3)

📄 Description

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

🔄 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/1684 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/texoff-probe-oracle-validation` --- ### 📝 Commits (1) - [`74295d0`](https://github.com/ubiquitarianism/leonida/commit/74295d02e3efbb8a2afb4d6fa393291fa25f1c8c) texoff_probe: validate oracle batch/word payloads and handle run errors ### 📊 Changes **2 files changed** (+95 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_texoff_probe.py` (+72 -0) 📝 `tools/texoff_probe.py` (+23 -3) </details> ### 📄 Description 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` --- <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#1698
No description provided.