scripts/check_compute_journal_overlay: validate journal dirs/exe, enforce UTF-8, extract main, add tests #2254

Merged
leonida/mandy
kirigayakazima merged 2 commits from fix/check-compute-journal-overlay-safety into main 2026-11-29 03:38:18 +00:00

Pull request successfully merged and closed

kirigayakazima commented 2026-11-26 10:38:19 +00:00

Claimed in the coordination issue as: CHECK-COMPUTE-JOURNAL-OVERLAY-SAFETY-AND-TESTS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7189582869)

What and why

  • Check d.is_dir() in entries() (scripts/check_compute_journal_overlay.py) before iterating pipeline_cache.d.
  • Replace bare tuple-unpacking on new-B/pipeline_cache.d and cold/pipeline_cache.d with explicit directory, single-entry, and .is_file() checks giving clear RuntimeError messages.
  • Pass encoding="utf-8" alongside errors="replace" in subprocess.run(...) so redirected stdout/stderr does not depend on the host ANSI code page.
  • Extract a testable main(argv=None) -> int validating executable existence/regular-file status and allowing both d3d12_compute_journal_test.exe and POSIX d3d12_compute_journal_test, catching runtime errors cleanly on stderr with exit status 1/2.
  • Add mocked unit coverage in tests/test_check_compute_journal_overlay.py.

Tested

  • Patched: python -I tests/test_check_compute_journal_overlay.py -v -> Ran 3 tests in 0.755s (OK).
  • Baseline check (upstream/main a73a57e1 with tests/test_check_compute_journal_overlay.py copied into detached worktree): Ran 3 tests in 0.027s (FAILED (errors=3)).
  • Repo gates: python -I tests/test_ci_registration.py (Ran 16 tests in 13.847s, OK), python -I tests/test_text_write_line_endings.py (Ran 3 tests in 17.336s, OK), python -I scripts/check_no_game_data.py (exit 0), python -I -m compileall -q (exit 0), git diff --check (exit 0).

GPUs tested: n/a (mocked subprocess harness and CLI validation tests)

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.
Claimed in the coordination issue as: CHECK-COMPUTE-JOURNAL-OVERLAY-SAFETY-AND-TESTS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7189582869) ### What and why - Check `d.is_dir()` in `entries()` (`scripts/check_compute_journal_overlay.py`) before iterating `pipeline_cache.d`. - Replace bare tuple-unpacking on `new-B/pipeline_cache.d` and `cold/pipeline_cache.d` with explicit directory, single-entry, and `.is_file()` checks giving clear `RuntimeError` messages. - Pass `encoding="utf-8"` alongside `errors="replace"` in `subprocess.run(...)` so redirected stdout/stderr does not depend on the host ANSI code page. - Extract a testable `main(argv=None) -> int` validating executable existence/regular-file status and allowing both `d3d12_compute_journal_test.exe` and POSIX `d3d12_compute_journal_test`, catching runtime errors cleanly on `stderr` with exit status `1`/`2`. - Add mocked unit coverage in `tests/test_check_compute_journal_overlay.py`. ### Tested - Patched: `python -I tests/test_check_compute_journal_overlay.py -v` -> `Ran 3 tests in 0.755s` (`OK`). - Baseline check (`upstream/main` `a73a57e1` with `tests/test_check_compute_journal_overlay.py` copied into detached worktree): `Ran 3 tests in 0.027s` (`FAILED (errors=3)`). - Repo gates: `python -I tests/test_ci_registration.py` (`Ran 16 tests in 13.847s`, `OK`), `python -I tests/test_text_write_line_endings.py` (`Ran 3 tests in 17.336s`, `OK`), `python -I scripts/check_no_game_data.py` (exit 0), `python -I -m compileall -q` (exit 0), `git diff --check` (exit 0). GPUs tested: n/a (mocked subprocess harness and CLI validation tests) 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.
lixonik reviewed 2026-11-26 10:50:42 +00:00
lixonik left a comment
No description provided.
Windows 11: 3/3 Python tests passed. I built `d3d12_compute_journal_test` at this head and ran the overlay checker with `--require-hit` on Vulkan. All four cases passed, including the external-A cache hit and both expected readbacks. One CLI error path below. AI-assisted.
tiguan26 approved these changes 2026-11-27 04:35:32 +00:00
tiguan26 left a comment

Approving aa95d15fd.

Each iterdir() unpacking that would raise a bare ValueError is replaced by a check with its own message, the script gets a main(argv) that validates the executable, and child output is decoded as UTF-8. The overlay run itself needs a GPU and the built test, which this machine does not have.

Merged onto main d1dff7949 in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13. tests/test_check_compute_journal_overlay.py: 3 passed (new). AI-assisted (Claude Code, Claude Opus 5.5).

Approving aa95d15fd. Each `iterdir()` unpacking that would raise a bare `ValueError` is replaced by a check with its own message, the script gets a `main(argv)` that validates the executable, and child output is decoded as UTF-8. The overlay run itself needs a GPU and the built test, which this machine does not have. Merged onto `main` `d1dff7949` in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13. `tests/test_check_compute_journal_overlay.py`: 3 passed (new). AI-assisted (Claude Code, Claude Opus 5.5).
kirigayakazima reviewed 2026-11-27 12:07:14 +00:00
lixonik reviewed 2026-11-27 14:23:26 +00:00
lixonik left a comment
No description provided.
Re-checked at `c5a52e67f` (merged onto `main` `ec91d695c`). Catching `OSError` alongside `(RuntimeError, subprocess.TimeoutExpired)` in `main()` cleanly converts spawn errors (such as `WinError 193`) into `ERROR: ...` without a traceback, backed by both mocked and live 0-byte `.exe` regression tests. Verified locally on Windows 11 (Python 3): - `tests/test_check_compute_journal_overlay.py`: 4/4 passed - `scripts/check_no_game_data.py` and `git diff --check`: clean No remaining findings. AI-assisted.
sodove commented 2026-11-28 09:15:18 +00:00

#2254 | head c5a52e67f528844dd11edbc4ef531bf269726d1c | python3 -I tests/test_check_compute_journal_overlay.py -v | red: 4 tests, 4 errors | green: 4 passed | Exceptions on main → pass

The baseline raised exceptions on all four tests, including a missing main entry point and an unhandled invalid directory. The merged tests exercised the expected error handling.

Pinned main 4938673668d807bf365b61284bf22b1ff8d02cc4, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.

#2254 | head `c5a52e67f528844dd11edbc4ef531bf269726d1c` | `python3 -I tests/test_check_compute_journal_overlay.py -v` | red: 4 tests, 4 errors | green: 4 passed | **Exceptions on main → pass** The baseline raised exceptions on all four tests, including a missing main entry point and an unhandled invalid directory. The merged tests exercised the expected error handling. Pinned main `4938673668d807bf365b61284bf22b1ff8d02cc4`, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7236982945).
zmasi commented 2026-11-28 22:14:15 +00:00

Native Windows 11 + NVIDIA GeForce RTX 3090 Verification (c5a52e67f5)

Verified c5a52e67f528844dd11edbc4ef531bf269726d1c merged cleanly onto origin/main (c7753ed98a56677f10e34078b37eab0540e190ec, git merge-tree --write-tree rc=0) on native Windows 11 (26200) + NVIDIA GeForce RTX 3090 (610.88):

  • Red (origin/main c7753ed98a): python -I tests/test_check_compute_journal_overlay.py failed (FAILED (errors=4) — no extractable main(argv) entry point or structured journal/CLI error handling).
  • Green (origin/main + c5a52e67f5):
    • python -I tests/test_check_compute_journal_overlay.py: 4/4 OK, including the Windows-specific os.name == "nt" 0-byte executable WinError 193 (ERROR_BAD_EXE_FORMAT) path (rc=1, clean ERROR: line without Traceback).
    • Live RTX 3090 4-stage pipeline-cache journal overlay run: python -I scripts/check_compute_journal_overlay.py <build>/d3d12_compute_journal_test.exe --require-hit exited 0 (cold driver_hit=0, readback=[4, 10], external-A driver_hit=1, readback=[4, 10], new-B driver_hit=0, readback=[4, 14], local-B driver_hit=1, readback=[4, 14]).

AI-assisted.

### Native Windows 11 + NVIDIA GeForce RTX 3090 Verification (`c5a52e67f5`) Verified `c5a52e67f528844dd11edbc4ef531bf269726d1c` merged cleanly onto `origin/main` (`c7753ed98a56677f10e34078b37eab0540e190ec`, `git merge-tree --write-tree` `rc=0`) on native **Windows 11 (`26200`) + NVIDIA GeForce RTX 3090 (`610.88`)**: - **Red (`origin/main` `c7753ed98a`)**: `python -I tests/test_check_compute_journal_overlay.py` failed (`FAILED (errors=4)` — no extractable `main(argv)` entry point or structured journal/CLI error handling). - **Green (`origin/main + c5a52e67f5`)**: - `python -I tests/test_check_compute_journal_overlay.py`: **`4/4 OK`**, including the Windows-specific `os.name == "nt"` 0-byte executable `WinError 193` (`ERROR_BAD_EXE_FORMAT`) path (`rc=1`, clean `ERROR:` line without `Traceback`). - **Live RTX 3090 4-stage pipeline-cache journal overlay run**: `python -I scripts/check_compute_journal_overlay.py <build>/d3d12_compute_journal_test.exe --require-hit` exited `0` (`cold` `driver_hit=0, readback=[4, 10]`, `external-A` `driver_hit=1, readback=[4, 10]`, `new-B` `driver_hit=0, readback=[4, 14]`, `local-B` `driver_hit=1, readback=[4, 14]`). AI-assisted.
OreoFR commented 2026-11-29 03:27:46 +00:00

Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main c8bf0e7b6, PR head c5a52e67f : red 4 failures / green 4 OK

python3.12 -I tests/test_check_compute_journal_overlay.py (new file, 4 tests):

  • Merge: clean (git merge-tree).
  • Red (main + only this test file): 4 failures: test_four_stage_happy_path_env_scrubbing_and_encoding, test_require_hit_mutation_and_skip_propagation, test_entries_and_main_reject_bad_paths_without_traceback, test_executable_launch_oserror_reports_cli_error. Note: 3 of the 4 fail only because main has no main() yet (AttributeError, the refactor); the fake pipeline_cache.d case (NotADirectoryError on main) is the real behaviour change.
  • Green (main + git merge --no-ff): 4 OK + 3 subtests OK, skipped 0.
  • (MEASURED n=3) red 4 failures and green 4 OK on every run.
  • Neighbours (test_report_paths, test_tool_startup, navmesh*/ttpf*/dds/zero_span/staging tests): 102 OK, 7 skipped (rpf9dump not built, bcpack_calibration dylib absent, one Windows-only case-sensitivity test), 1 failure — test_tool_startup psin_dialogue (ModuleNotFoundError: psin_data), identical on main (MEASURED n=3), unrelated.
  • Diff: the fragile src, = iterdir() becomes an explicit require; encoding="utf-8" added; a testable main() returns 2/1 instead of a traceback; an executable name without .exe is now accepted (seems intended for other platforms). No game data or local paths.

Verdict: READY

AI-assisted: Claude Code

Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main c8bf0e7b6, PR head c5a52e67f : red 4 failures / green 4 OK `python3.12 -I tests/test_check_compute_journal_overlay.py` (new file, 4 tests): - Merge: clean (`git merge-tree`). - **Red** (main + only this test file): 4 failures: `test_four_stage_happy_path_env_scrubbing_and_encoding`, `test_require_hit_mutation_and_skip_propagation`, `test_entries_and_main_reject_bad_paths_without_traceback`, `test_executable_launch_oserror_reports_cli_error`. Note: 3 of the 4 fail only because main has no `main()` yet (AttributeError, the refactor); the fake `pipeline_cache.d` case (NotADirectoryError on main) is the real behaviour change. - **Green** (main + `git merge --no-ff`): 4 OK + 3 subtests OK, skipped 0. - (MEASURED n=3) red 4 failures and green 4 OK on every run. - Neighbours (`test_report_paths`, `test_tool_startup`, navmesh*/ttpf*/dds/zero_span/staging tests): 102 OK, 7 skipped (rpf9dump not built, `bcpack_calibration` dylib absent, one Windows-only case-sensitivity test), 1 failure — `test_tool_startup` `psin_dialogue` (`ModuleNotFoundError: psin_data`), identical on main (MEASURED n=3), unrelated. - Diff: the fragile `src, = iterdir()` becomes an explicit `require`; `encoding="utf-8"` added; a testable `main()` returns 2/1 instead of a traceback; an executable name without `.exe` is now accepted (seems intended for other platforms). No game data or local paths. **Verdict: READY** AI-assisted: Claude Code
DadaCap commented 2026-11-29 03:38:15 +00:00

Merging, thank you @kirigayakazima! OreoFR's agent verified this head merged with current main: the test fails on main and passes with the PR (https://github.com/ProjectLeonida/mandy/pull/2254#issuecomment-7250061937), and it still merges cleanly.

AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.

Merging, thank you @kirigayakazima! OreoFR's agent verified this head merged with current main: the test fails on main and passes with the PR (https://github.com/ProjectLeonida/mandy/pull/2254#issuecomment-7250061937), and it still merges cleanly. AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.
Sign in to join this conversation.
No description provided.