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

Open
github-bot wants to merge 2 commits from github-bot/gh-2254 into main AGit
Owner

@⁠kirigayakazima on GitHub · 2026-11-26 10:38 UTC · original
kirigayakazima:fix/check-compute-journal-overlay-safety → main · +206 −12 · 2 files · 2 commits · open

Claimed in the coordination issue as: CHECK-COMPUTE-JOURNAL-OVERLAY-SAFETY-AND-TESTS (#1608)

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.
**@⁠kirigayakazima** on GitHub · 2026-11-26 10:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2254) `kirigayakazima:fix/check-compute-journal-overlay-safety` → `main` · +206 −12 · 2 files · 2 commits · open Claimed in the coordination issue as: CHECK-COMPUTE-JOURNAL-OVERLAY-SAFETY-AND-TESTS (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:24:35 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 10:50 UTC · original · reviewed

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.

**@⁠lixonik** on GitHub · 2026-11-26 10:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2254#pullrequestreview-6072803458) · **reviewed** 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.
@ -98,0 +121,4 @@
try:
with tempfile.TemporaryDirectory(prefix="leonida-authored-journal-") as tmp:
return run(exe, Path(tmp), args.device, args.require_hit)
except (RuntimeError, subprocess.TimeoutExpired) as exc:
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 10:50 UTC · original

[P3] Report Windows executable launch failures through the CLI error handler.

An otherwise valid path to a zero-byte file named d3d12_compute_journal_test.exe passes the file/name checks. On Windows, subprocess.run then raises OSError (WinError 193) and escapes as a traceback. A launch blocked by permissions can take the same path. Can this handler also catch OSError and return the existing ERROR: diagnostic?

**@⁠lixonik** on GitHub · 2026-11-26 10:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2254#discussion_r4707283323) [P3] Report Windows executable launch failures through the CLI error handler. An otherwise valid path to a zero-byte file named `d3d12_compute_journal_test.exe` passes the file/name checks. On Windows, `subprocess.run` then raises `OSError` (`WinError 193`) and escapes as a traceback. A launch blocked by permissions can take the same path. Can this handler also catch `OSError` and return the existing `ERROR:` diagnostic?
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-27 04:35 UTC · original · approved these changes

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).

**@⁠tiguan26** on GitHub · 2026-11-27 04:35 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2254#pullrequestreview-6083533693) · **approved these changes** 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).
Author
Owner

@⁠kirigayakazima on GitHub · 2026-11-27 12:07 UTC · original
On scripts/check_compute_journal_overlay.py line 124 (outdated):

@@ -95,17 +104,31 @@ def run(exe, root, device, strict):
     return 0
 
 
+def main(argv=None) -> int:
+    parser = argparse.ArgumentParser(description=__doc__)
+    parser.add_argument("executable", type=Path, help="built d3d12_compute_journal_test.exe")
+    parser.add_argument("--device", help="optional LEONIDA_VK_DEVICE selector")
+    parser.add_argument("--require-hit", action="store_true")
+    args = parser.parse_args(argv)
+    try:
+        exe = args.executable.resolve(strict=True)
+    except OSError as exc:
+        print(f"ERROR: {exc}", file=sys.stderr)
+        return 2
+    if not exe.is_file() or exe.name.lower() not in ("d3d12_compute_journal_test.exe", "d3d12_compute_journal_test"):
+        print(f"ERROR: expected the compute test executable, not {exe.name}", file=sys.stderr)
+        return 2
+    try:
+        with tempfile.TemporaryDirectory(prefix="leonida-authored-journal-") as tmp:
+            return run(exe, Path(tmp), args.device, args.require_hit)
+    except (RuntimeError, subprocess.TimeoutExpired) as exc:

Fixed: main() now catches OSError alongside (RuntimeError, subprocess.TimeoutExpired) so Windows/POSIX launch failures return exit 1 with an ERROR: message and no traceback. Added regression tests in tests/test_check_compute_journal_overlay.py (4 passed + 5 repo checks).

**@⁠kirigayakazima** on GitHub · 2026-11-27 12:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2254#discussion_r4719171061) On `scripts/check_compute_journal_overlay.py` line 124 (outdated): ```diff @@ -95,17 +104,31 @@ def run(exe, root, device, strict): return 0 +def main(argv=None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("executable", type=Path, help="built d3d12_compute_journal_test.exe") + parser.add_argument("--device", help="optional LEONIDA_VK_DEVICE selector") + parser.add_argument("--require-hit", action="store_true") + args = parser.parse_args(argv) + try: + exe = args.executable.resolve(strict=True) + except OSError as exc: + print(f"ERROR: {exc}", file=sys.stderr) + return 2 + if not exe.is_file() or exe.name.lower() not in ("d3d12_compute_journal_test.exe", "d3d12_compute_journal_test"): + print(f"ERROR: expected the compute test executable, not {exe.name}", file=sys.stderr) + return 2 + try: + with tempfile.TemporaryDirectory(prefix="leonida-authored-journal-") as tmp: + return run(exe, Path(tmp), args.device, args.require_hit) + except (RuntimeError, subprocess.TimeoutExpired) as exc: ``` Fixed: `main()` now catches `OSError` alongside `(RuntimeError, subprocess.TimeoutExpired)` so Windows/POSIX launch failures return exit 1 with an `ERROR:` message and no traceback. Added regression tests in `tests/test_check_compute_journal_overlay.py` (4 passed + 5 repo checks).
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/2254/head:github-bot/gh-2254'
git switch 'github-bot/gh-2254'

Merge

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