sampler_lod_probe: validate oracle payloads, non-finite calibration starts, and run errors #1676

Merged
IlyassRS3 merged 1 commit from upstream-pr/1676 into main 2026-11-28 14:52:03 +00:00
IlyassRS3 commented 2026-11-25 07:50:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T07:50:30Z.


Item ID: SAMPLER-LOD-PROBE-ORACLE-AND-CALIBRATION (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156290731)

Summary

  • Hardware oracle payload validation (tools/sampler_lod_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(table) containing only non-bool int words (masking w & 0xFFFFFFFF before struct.pack("<I", ...)), returning exit 2 with a clear diagnostic instead of crashing with uncaught IndexError/TypeError/struct.error or accepting extra/bool words.
  • Calibration finiteness & runtime error lifecycle:
    • Reject non-finite (inf/NaN) calibration level starts with exit 2 instead of accepting +inf as a valid level start when wave32 and wave64 agree.
    • Catch runner.Unavailable (exit 77) and RuntimeError (exit 2) raised during oracle.run() inside try ... finally: oracle.close().
  • Regression tests (tests/test_sampler_lod_probe.py):
    • Added tests covering malformed batch/word payloads across wave32 and wave64, +inf calibration start rejection, 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/sampler_lod_probe.py tests/test_sampler_lod_probe.py passed)
  • GPUs tested: none (hostless macOS synthetic/unit test run)
  • Tests run:
    • python3 -W error -I tests/test_sampler_lod_probe.py -v: Ran 15 tests ... OK
    • Mutation test (new tests/test_sampler_lod_probe.py against unpatched main tools/sampler_lod_probe.py): Ran 15 tests ... FAILED (failures=9, errors=10)
    • 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:5487337500 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1676). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T07:50:30Z. --- Item ID: `SAMPLER-LOD-PROBE-ORACLE-AND-CALIBRATION` (claimed in https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156290731) ## Summary - **Hardware oracle payload validation (`tools/sampler_lod_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(table)` containing only non-bool `int` words (masking `w & 0xFFFFFFFF` before `struct.pack("<I", ...)`), returning exit `2` with a clear diagnostic instead of crashing with uncaught `IndexError`/`TypeError`/`struct.error` or accepting extra/bool words. - **Calibration finiteness & runtime error lifecycle**: - Reject non-finite (`inf`/`NaN`) calibration level starts with exit `2` instead of accepting `+inf` as a valid level start when wave32 and wave64 agree. - Catch `runner.Unavailable` (exit `77`) and `RuntimeError` (exit `2`) raised during `oracle.run()` inside `try ... finally: oracle.close()`. - **Regression tests (`tests/test_sampler_lod_probe.py`)**: - Added tests covering malformed batch/word payloads across wave32 and wave64, `+inf` calibration start rejection, `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/sampler_lod_probe.py tests/test_sampler_lod_probe.py` passed) - **GPUs tested**: none (hostless macOS synthetic/unit test run) - **Tests run**: - `python3 -W error -I tests/test_sampler_lod_probe.py -v`: `Ran 15 tests ... OK` - Mutation test (new `tests/test_sampler_lod_probe.py` against unpatched `main` `tools/sampler_lod_probe.py`): `Ran 15 tests ... FAILED (failures=9, errors=10)` - `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 07:50:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T07:50:45Z.

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:6053703902 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1676#pullrequestreview-6053703902). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T07:50:45Z. **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:52:24 +00:00 (Migrated from github.com)

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


Independent verification (Windows, Python 3.11.9 -I -W error): oracle batch/word validation (len-1 batch, exact table length, non-bool ints masked before POISON pack — comparison correctly uses masked value), non-finite calibration-start guard, Unavailable->77 / RuntimeError->2 with finally-close — all match claims. test_sampler_lod_probe.py 15 OK; --oracle rule full run exit 0; bad --oracle -> argparse exit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7157578176 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1676#issuecomment-7157578176). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T08:52:24Z. --- Independent verification (Windows, Python 3.11.9 `-I -W error`): oracle batch/word validation (len-1 batch, exact table length, non-bool ints masked before POISON pack — comparison correctly uses masked value), non-finite calibration-start guard, Unavailable->77 / RuntimeError->2 with finally-close — all match claims. `test_sampler_lod_probe.py` 15 OK; `--oracle rule` full run exit 0; bad `--oracle` -> argparse exit 2; compileall + line-endings + check_no_game_data clean. AI-assisted verification.
MoonEyes commented 2026-11-28 14:51:56 +00:00 (Migrated from github.com)

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


Red/green: classified READY by cloud-5 (red on main 09c153948, green on head merged with main); head 299325cb20 unchanged since 2026-11-25, before that run.
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:7240996247 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1676#issuecomment-7240996247). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:51:56Z. --- Red/green: classified READY by cloud-5 (red on main 09c153948, green on head merged with main); head 299325cb202d unchanged since 2026-11-25, before that run. 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!1676
No description provided.