tools/ab_control_flow.py: upfront out/harness/names guards and spvasm OSError handling #2289

Merged
kirigayakazima merged 1 commit from upstream-pr/2289 into main 2026-11-28 15:10:27 +00:00
kirigayakazima commented 2026-11-26 12:49:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-26T12:49:42Z.


Claimed in the coordination issue as: AB-CONTROL-FLOW-UPFRONT-OUT-AND-NAMES-EMPTY-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7192453000)

What and why

  • Add _validate_out_dir() in tools/ab_control_flow.py and run upfront CLI checks before opening index.json: reject empty/whitespace out directories, non-directory out targets/parents (with "cannot create" messages matching existing CLI conventions), empty/directory --harness values (still allowing mocked harness names), and empty/missing --names files.
  • Open translated .spvasm files with encoding="utf-8-sig" inside a try/except OSError block so a missing or unreadable assembly records a per-shader note() outcome instead of aborting the batch with an unhandled traceback.
  • Add regression tests in tests/test_ab_control_flow.py.

Tested

  • python -I tests/test_ab_control_flow.py -v: 72 tests (71 passed, 1 skipped on Windows: test_mode_000_output_folder). Detached upstream/main baseline with only the updated test file fails with 8 failures and 1 error (1 skipped).
  • python -I tests/test_ci_registration.py: 16 passed.
  • python -I tests/test_text_write_line_endings.py: 3 passed.
  • python -I scripts/check_no_game_data.py, python -I -m compileall -q tools/ab_control_flow.py tests/test_ab_control_flow.py, and git diff --cached --check: passed.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5510323906 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2289). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-26T12:49:42Z. --- Claimed in the coordination issue as: AB-CONTROL-FLOW-UPFRONT-OUT-AND-NAMES-EMPTY-GUARD (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7192453000) ### What and why - Add `_validate_out_dir()` in `tools/ab_control_flow.py` and run upfront CLI checks before opening `index.json`: reject empty/whitespace `out` directories, non-directory `out` targets/parents (with `"cannot create"` messages matching existing CLI conventions), empty/directory `--harness` values (still allowing mocked harness names), and empty/missing `--names` files. - Open translated `.spvasm` files with `encoding="utf-8-sig"` inside a `try/except OSError` block so a missing or unreadable assembly records a per-shader `note()` outcome instead of aborting the batch with an unhandled traceback. - Add regression tests in `tests/test_ab_control_flow.py`. ### Tested - `python -I tests/test_ab_control_flow.py -v`: 72 tests (71 passed, 1 skipped on Windows: `test_mode_000_output_folder`). Detached `upstream/main` baseline with only the updated test file fails with 8 failures and 1 error (1 skipped). - `python -I tests/test_ci_registration.py`: 16 passed. - `python -I tests/test_text_write_line_endings.py`: 3 passed. - `python -I scripts/check_no_game_data.py`, `python -I -m compileall -q tools/ab_control_flow.py tests/test_ab_control_flow.py`, and `git diff --cached --check`: passed. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
tiguan26 commented 2026-11-27 04:40:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:40:34Z.

Review: APPROVED


Approving 56e5b9a3f.

The output folder, --harness and --names are checked before any work, and a translated .spvasm that cannot be read is noted for that shader instead of ending the run (read as utf-8-sig, so a BOM is harmless).

Merged onto main d1dff7949 in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13. tests/test_ab_control_flow.py: 71 passed, 1 skipped (main: 69). AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6083565032 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2289#pullrequestreview-6083565032). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-27T04:40:34Z. **Review:** APPROVED --- Approving 56e5b9a3f. The output folder, `--harness` and `--names` are checked before any work, and a translated `.spvasm` that cannot be read is noted for that shader instead of ending the run (read as `utf-8-sig`, so a BOM is harmless). Merged onto `main` `d1dff7949` in one batch with 15 other tool PRs of this series (no conflicts), on Linux with Python 3.13. `tests/test_ab_control_flow.py`: 71 passed, 1 skipped (main: 69). AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-28 10:23:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T10:23:51Z.


#2289 | head 56e5b9a3f0 (merged cleanly with main 901b6c1bf) | python -I tests/test_ab_control_flow.py | red on main: FAILED (failures=8, errors=1, skipped=1) (index.json read attempted before validating out / --harness / --names, and unhandled FileNotFoundError when a translated .spvasm file is missing) | green on PR+main: 72 tests OK (skipped=1) | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited _validate_out_dir, upfront --harness / --names checks, and utf-8-sig + OSError handling when reading translated .spvasm files in tools/ab_control_flow.py. Exercised all 8 invalid path/blocker/directory cases on Windows 11 NTFS plus UTF-8 BOM and missing .spvasm reporting into outcomes.tsv. Also passed tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), tests/test_runner_calls_all_tests.py (3 OK), and scripts/check_no_game_data.py on the merged tree.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237869922 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2289#issuecomment-7237869922). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T10:23:51Z. --- #2289 | head 56e5b9a3f0e74f80275c0157580c2afc59df1bd1 (merged cleanly with main 901b6c1bf) | `python -I tests/test_ab_control_flow.py` | red on main: `FAILED (failures=8, errors=1, skipped=1)` (`index.json` read attempted before validating `out` / `--harness` / `--names`, and unhandled `FileNotFoundError` when a translated `.spvasm` file is missing) | green on PR+main: `72 tests OK (skipped=1)` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `_validate_out_dir`, upfront `--harness` / `--names` checks, and `utf-8-sig` + `OSError` handling when reading translated `.spvasm` files in `tools/ab_control_flow.py`. Exercised all 8 invalid path/blocker/directory cases on Windows 11 NTFS plus UTF-8 BOM and missing `.spvasm` reporting into `outcomes.tsv`. Also passed `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), `tests/test_runner_calls_all_tests.py` (`3 OK`), and `scripts/check_no_game_data.py` on the merged tree.
MoonEyes commented 2026-11-28 15:10:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T15:10:24Z.


Red/green: classified READY by cloud-6 (red on main 09c153948, green on head merged with main); head 56e5b9a3f0 unchanged since 2026-11-26, 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:7241259846 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2289#issuecomment-7241259846). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T15:10:24Z. --- Red/green: classified READY by cloud-6 (red on main 09c153948, green on head merged with main); head 56e5b9a3f0e7 unchanged since 2026-11-26, 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!2289
No description provided.