tools: close oracle in vcmp16_opsel_probe, support argv in main, and guard results (VCMP16-PROBE-GUARDS) #561

Merged
trigger337 merged 1 commit from upstream-pr/561 into main 2026-11-24 09:26:51 +00:00
trigger337 commented 2026-11-24 08:13:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T08:13:33Z.


What and why

tools/vcmp16_opsel_probe.py opened the hardware oracle without closing it in a finally block, accepted no argv argument in main(), and indexed oracle.run() directly without verifying whether the runner returned an empty, None, or short result list.

  1. CLI / main() invocation:

    • Accept optional argv in main(argv=None) and forward to ap.parse_args(argv).
  2. Oracle lifecycle:

    • Wrap the probe execution in a try ... finally: oracle.close() block so hardware resources / device state are cleaned up on all exit paths.
  3. Runner error guards:

    • Validate oracle.run() output: flag empty results, None results, or result lists shorter/longer than the expected word count as harness errors with exit code 2 instead of raising unhandled IndexError / TypeError.
  4. Unit test coverage:

    • Add MainAndOracleLifecycleTest in tests/test_vcmp16_opsel_probe.py covering rule mode, hardware success, mismatch, kernel rejection, empty/None/short result lists, and runner unavailability.

Claimed in the coordination issue as: VCMP16-PROBE-GUARDS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7125854727)

Standard library and synthetic unit tests only; no GPU or game files required.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5468502547 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/561). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T08:13:33Z. --- ### What and why `tools/vcmp16_opsel_probe.py` opened the hardware oracle without closing it in a `finally` block, accepted no `argv` argument in `main()`, and indexed `oracle.run()` directly without verifying whether the runner returned an empty, None, or short result list. 1. **CLI / `main()` invocation**: - Accept optional `argv` in `main(argv=None)` and forward to `ap.parse_args(argv)`. 2. **Oracle lifecycle**: - Wrap the probe execution in a `try ... finally: oracle.close()` block so hardware resources / device state are cleaned up on all exit paths. 3. **Runner error guards**: - Validate `oracle.run()` output: flag empty results, `None` results, or result lists shorter/longer than the expected word count as harness errors with exit code 2 instead of raising unhandled `IndexError` / `TypeError`. 4. **Unit test coverage**: - Add `MainAndOracleLifecycleTest` in `tests/test_vcmp16_opsel_probe.py` covering rule mode, hardware success, mismatch, kernel rejection, empty/None/short result lists, and runner unavailability. Claimed in the coordination issue as: VCMP16-PROBE-GUARDS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7125854727) Standard library and synthetic unit tests only; no GPU or game files required. AI-assisted: yes
QemmHD commented 2026-11-24 09:26:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T09:26:48Z.


Merging. Why merged: vcmp16_opsel_probe always closes the hardware oracle, accepts argv, and refuses empty, None or short results.
Why it's good: test_vcmp16_opsel_probe 7 -> 15 passed (8 of the new tests fail on main); clean on main 7430f59; consistency 565/0.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7127422997 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/561#issuecomment-7127422997). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T09:26:48Z. --- Merging. Why merged: vcmp16_opsel_probe always closes the hardware oracle, accepts argv, and refuses empty, None or short results. Why it's good: test_vcmp16_opsel_probe 7 -> 15 passed (8 of the new tests fail on main); clean on main 7430f59; consistency 565/0. 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!561
No description provided.