wave_trace: validate select_case and --out upfront, harden render_report, unlink partial output (WAVE-TRACE-VALIDATION-AND-WRITE-CLEANUP) #1590

Open
github-bot wants to merge 1 commit from github-bot/gh-1590 into main AGit
Owner

@⁠IlyassRS3 on GitHub · 2026-11-25 05:21 UTC · original
IlyassRS3:fix/wave-trace-validation-and-write-cleanup → main · +126 −7 · 2 files · 1 commits · open

Item: WAVE-TRACE-VALIDATION-AND-WRITE-CLEANUP (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/wave_trace.py).

Summary

  • Validate case_index (type is int, >= 0) and max_ops (type is int, >= 1) in select_case() so negative case_index raises ValueError instead of UnboundLocalError and booleans are rejected.
  • Harden render_report() by verifying the <!-- WAVE_TRACE_DATA --> placeholder exists in wave_trace.html, passing allow_nan=False to json.dumps(), and escaping > (\u003e) alongside < (\u003c).
  • Validate --out before running inspect_case() (reject empty/whitespace strings, trailing directory separators, existing paths via os.path.lexists(), and missing parent directories) instead of silently accepting Path("") as . or wasting simulation work before failing.
  • Keep exclusive creation (open("x")) so existing files are never overwritten, and close and unlink the newly created file if stream.write() fails mid-write so no partial HTML report is left behind.

Verification

  • python3 -W error -I tests/test_wave_trace.py -v: 10/10 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/wave_trace.py tests/test_wave_trace.py: passed.
  • python3 -m compileall -q tools/wave_trace.py tests/test_wave_trace.py: passed.
  • Mutation check (running tests/test_wave_trace.py against unpatched main:tools/wave_trace.py): failures=9, errors=1 across all 4 new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python interpreter/report tool; synthetic wave32 cases only, no game data)

**@⁠IlyassRS3** on GitHub · 2026-11-25 05:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1590) `IlyassRS3:fix/wave-trace-validation-and-write-cleanup` → `main` · +126 −7 · 2 files · 1 commits · open Item: `WAVE-TRACE-VALIDATION-AND-WRITE-CLEANUP` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/wave_trace.py`). ### Summary - Validate `case_index` (`type is int`, `>= 0`) and `max_ops` (`type is int`, `>= 1`) in `select_case()` so negative `case_index` raises `ValueError` instead of `UnboundLocalError` and booleans are rejected. - Harden `render_report()` by verifying the `<!-- WAVE_TRACE_DATA -->` placeholder exists in `wave_trace.html`, passing `allow_nan=False` to `json.dumps()`, and escaping `>` (`\u003e`) alongside `<` (`\u003c`). - Validate `--out` before running `inspect_case()` (reject empty/whitespace strings, trailing directory separators, existing paths via `os.path.lexists()`, and missing parent directories) instead of silently accepting `Path("")` as `.` or wasting simulation work before failing. - Keep exclusive creation (`open("x")`) so existing files are never overwritten, and close and unlink the newly created file if `stream.write()` fails mid-write so no partial HTML report is left behind. ### Verification - `python3 -W error -I tests/test_wave_trace.py -v`: 10/10 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/wave_trace.py tests/test_wave_trace.py`: passed. - `python3 -m compileall -q tools/wave_trace.py tests/test_wave_trace.py`: passed. - Mutation check (running `tests/test_wave_trace.py` against unpatched `main:tools/wave_trace.py`): `failures=9, errors=1` across all 4 new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python interpreter/report tool; synthetic wave32 cases only, no game data)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:57:25 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 05:22 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 05:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1590#pullrequestreview-6052248247) · **reviewed** 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1590/head:github-bot/gh-1590'
git switch 'github-bot/gh-1590'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1590'
git switch 'github-bot/gh-1590'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1590'
git switch 'github-bot/gh-1590'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1590'
git switch 'main'
git merge --squash 'github-bot/gh-1590'
git switch 'main'
git merge --ff-only 'github-bot/gh-1590'
git switch 'main'
git merge 'github-bot/gh-1590'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.