Refactor tool management and subprocess execution #12

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

@⁠StaticM223 on GitHub · 2026-11-24 01:37 UTC · original
StaticM223:main → main · +50 −19 · 1 files · 1 commits · open

Claimed in the coordination issue as:

Depends on:

What and why

Tested

AI-assisted:

Checklist

  • 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.
**@⁠StaticM223** on GitHub · 2026-11-24 01:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/12) `StaticM223:main` → `main` · +50 −19 · 1 files · 1 commits · open Claimed in the coordination issue as: <!-- the item ID from the open "Coordinating who works on what" issue, for example TEST-17, or a link to your claim --> Depends on: <!-- #N for every pull request this one builds on or conflicts with (the coordination issue's Commands section, AGENTS.md); delete the line if it builds on none and conflicts with none --> ### What and why <!-- What this changes and the problem it solves. --> ### Tested <!-- What you ran and on which GPU and driver (CONTRIBUTING.md). For the shader translator: how many shaders translate and pass spirv-val, before and after. --> AI-assisted: <!-- yes or no (AGENTS.md asks a coding agent to say so) --> ### Checklist - [ ] 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 08:40:22 +00:00
Author
Owner

@⁠wavehs on GitHub · 2026-11-24 01:43 UTC · original

macOS arm64 review (Apple M3 Pro) — the refactor does what it says, help_argv now works from any directory, and one doc line is now wrong

Head f3bd49f5f, one file: scripts/dev.py +50/−19. Host: macOS 27.2.1, Apple M3 Pro (arm64), CPython 3.15.2. Nothing here is platform-specific, so the whole change is testable here.

Check Result
tests/test_dev_discovery.py, test_dev_boot_trace.py, test_dev_guest_scene.py all OK
scripts/dev.py discover / discover --json rc=0, absolute help_argv in both
help_argv run from /tmp at this head rc=0, prints usage: boot_trace.py …
the same at ubi/main rc=2, can't open file '…/tools/boot_trace.py'

That last pair is the whole point of the change and I could not find a case where it regresses: the relative path only worked when the process happened to run from the checkout root, and nothing in the tree guarantees that (help_argv is consumed by discover's own printer and by tests/test_dev_discovery.py, which passes cwd=self.checkout and therefore never noticed).

The other three pieces check out.

  • producer_argv puts -X utf8 after -I and before the script: ['python', '-I', '-X', 'utf8', '/…/tools/boot_trace.py', '--help']. The comment is right that -I implies -E and so ignores PYTHONUTF8/PYTHONIOENCODING, while command-line -X still applies; putting -X first would be a python usage error, so the order matters.
  • normalize_returncode: [0, 1, 2, -2, -15, -9, 130] → [0, 1, 2, 130, 143, 137, 130], i.e. POSIX signal N becomes 128+N and Windows' non-negative codes pass through.
  • run_producer under a KeyboardInterrupt from subprocess.run returns 130 (checked by raising it from a stub), and __main__ catches a KeyboardInterrupt escaping main() with the same code, so the two paths agree.

The doc is now stale, and that is the only change I would ask for. docs/dev-tools.md:30 still says:

help_argv is a list of arguments for a command run from the checkout root.

After this PR that sentence says the opposite of the truth: the list is absolute and deliberately runnable from anywhere (that is why the printer's sentence changed too). A one-line edit to "a command that runs from any working directory" keeps the JSON contract description honest. Everything else in that paragraph (path relative, forward slashes, null when missing) still holds — I checked the emitted JSON against it.

Two small notes, neither blocking:

  • getattr(args, "json", False) after the boot-trace/guest-scene early returns can only ever see a discover namespace, where json exists; the defensive form documents the intent, but a comment would be clearer than a getattr.
  • run_producer now returns 130 on KeyboardInterrupt without terminating the child. Under a terminal Ctrl-C both are in the same process group and the child gets its own SIGINT, so this is fine in practice; a kill -INT <dev.py pid> would leave the producer running while dev.py reports 130. The old code raised a traceback and left the child running too, so nothing regresses.

No game files. AI-assisted.

**@⁠wavehs** on GitHub · 2026-11-24 01:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/12#issuecomment-7119390192) **macOS arm64 review (Apple M3 Pro) — the refactor does what it says, `help_argv` now works from any directory, and one doc line is now wrong** Head `f3bd49f5f`, one file: `scripts/dev.py` +50/−19. Host: macOS 27.2.1, Apple M3 Pro (arm64), CPython 3.15.2. Nothing here is platform-specific, so the whole change is testable here. | Check | Result | |---|---| | `tests/test_dev_discovery.py`, `test_dev_boot_trace.py`, `test_dev_guest_scene.py` | **all OK** | | `scripts/dev.py discover` / `discover --json` | rc=0, absolute `help_argv` in both | | `help_argv` run from `/tmp` at this head | **rc=0**, prints `usage: boot_trace.py …` | | the same at `ubi/main` | **rc=2**, `can't open file '…/tools/boot_trace.py'` | That last pair is the whole point of the change and I could not find a case where it regresses: the relative path only worked when the process happened to run from the checkout root, and nothing in the tree guarantees that (`help_argv` is consumed by `discover`'s own printer and by `tests/test_dev_discovery.py`, which passes `cwd=self.checkout` and therefore never noticed). **The other three pieces check out.** - `producer_argv` puts `-X utf8` *after* `-I` and *before* the script: `['python', '-I', '-X', 'utf8', '/…/tools/boot_trace.py', '--help']`. The comment is right that `-I` implies `-E` and so ignores `PYTHONUTF8`/`PYTHONIOENCODING`, while command-line `-X` still applies; putting `-X` first would be a `python` usage error, so the order matters. - `normalize_returncode`: `[0, 1, 2, -2, -15, -9, 130]` → `[0, 1, 2, 130, 143, 137, 130]`, i.e. POSIX signal `N` becomes `128+N` and Windows' non-negative codes pass through. - `run_producer` under a `KeyboardInterrupt` from `subprocess.run` returns **130** (checked by raising it from a stub), and `__main__` catches a `KeyboardInterrupt` escaping `main()` with the same code, so the two paths agree. **The doc is now stale, and that is the only change I would ask for.** `docs/dev-tools.md:30` still says: > `help_argv` is a list of arguments for a command run from the checkout root. After this PR that sentence says the opposite of the truth: the list is absolute and deliberately runnable from anywhere (that is why the printer's sentence changed too). A one-line edit to "a command that runs from any working directory" keeps the JSON contract description honest. Everything else in that paragraph (`path` relative, forward slashes, `null` when missing) still holds — I checked the emitted JSON against it. Two small notes, neither blocking: - `getattr(args, "json", False)` after the `boot-trace`/`guest-scene` early returns can only ever see a `discover` namespace, where `json` exists; the defensive form documents the intent, but a comment would be clearer than a `getattr`. - `run_producer` now returns `130` on `KeyboardInterrupt` without terminating the child. Under a terminal Ctrl-C both are in the same process group and the child gets its own SIGINT, so this is fine in practice; a `kill -INT <dev.py pid>` would leave the producer running while `dev.py` reports 130. The old code raised a traceback and left the child running too, so nothing regresses. No game files. AI-assisted.
Author
Owner

@⁠ubiquitarianism on GitHub · 2026-11-24 02:34 UTC · original

Not merging this yet. On Windows (Python 3.14), python -I tests/test_dev_boot_trace.py passes on main but fails with this branch:

FAIL: test_help_and_text (BootTraceTests)
AssertionError: b'...ess\xc3\xa3o sint\xc3\xa9tica.jsonl...' != b'...ess\xe3o sint\xe9tica.jsonl...'

producer_argv now adds -X utf8 on Windows, so output forwarded through dev.py boot-trace comes out as UTF-8 and no longer matches what the producer writes when run directly (ANSI code page). That test checks for exactly this, so either keep the producer's encoding or change the test, with a reason, in the same PR.

The description is also still the empty template: please fill in the claim ID, what this fixes, what you tested, and whether it was AI-assisted (CONTRIBUTING.md).

**@⁠ubiquitarianism** on GitHub · 2026-11-24 02:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/12#issuecomment-7120274159) Not merging this yet. On Windows (Python 3.14), `python -I tests/test_dev_boot_trace.py` passes on `main` but fails with this branch: ``` FAIL: test_help_and_text (BootTraceTests) AssertionError: b'...ess\xc3\xa3o sint\xc3\xa9tica.jsonl...' != b'...ess\xe3o sint\xe9tica.jsonl...' ``` `producer_argv` now adds `-X utf8` on Windows, so output forwarded through `dev.py boot-trace` comes out as UTF-8 and no longer matches what the producer writes when run directly (ANSI code page). That test checks for exactly this, so either keep the producer's encoding or change the test, with a reason, in the same PR. The description is also still the empty template: please fill in the claim ID, what this fixes, what you tested, and whether it was AI-assisted (CONTRIBUTING.md).
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 05:28 UTC · original

Safe: list argv, no shell, sys.executable -I. One doc follow-up: help_argv is now absolute, but docs/dev-tools.md:30 still describes it as relative.

Security review; read only, nothing run.
AI-assisted (Claude Code, Claude Opus 5.5).
Discord: bigpeppa.

**@⁠QemmHD** on GitHub · 2026-11-24 05:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/12#issuecomment-7122985235) Safe: list argv, no shell, `sys.executable -I`. One doc follow-up: `help_argv` is now absolute, but `docs/dev-tools.md:30` still describes it as relative. Security review; read only, nothing run. AI-assisted (Claude Code, Claude Opus 5.5). Discord: bigpeppa.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 05:43 UTC · original

Tested on native Windows 11, merged onto main 8f481cf16 (clean merge): one existing test now fails, consistently (3 runs).

  • tests/test_dev_boot_trace.py::BootTraceTests::test_help_and_text: main 17 passed across the dev tests; this PR 16 passed, 1 failed.
  • Cause: the new producer_argv adds -X utf8 on Windows, so the producer's text output through dev.py is now UTF-8, while running the producer directly is still cp1252 (e.g. \xc3\xa3 vs \xe3 in "sessão sintética"). The test checks that the two are byte-identical.
  • dev.py --help and the --help of discover, boot-trace and guest-scene are unchanged.

Either drop -X utf8 from producer_argv, or make the direct path UTF-8 as well and update the test. The earlier doc nit still applies (docs/dev-tools.md:30 says help_argv is relative; it's now an absolute script path). Happy to re-test after a push.

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

**@⁠QemmHD** on GitHub · 2026-11-24 05:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/12#issuecomment-7123214890) Tested on native Windows 11, merged onto main `8f481cf16` (clean merge): one existing test now fails, consistently (3 runs). - `tests/test_dev_boot_trace.py::BootTraceTests::test_help_and_text`: main 17 passed across the dev tests; this PR 16 passed, 1 failed. - Cause: the new `producer_argv` adds `-X utf8` on Windows, so the producer's text output through `dev.py` is now UTF-8, while running the producer directly is still cp1252 (e.g. `\xc3\xa3` vs `\xe3` in "sessão sintética"). The test checks that the two are byte-identical. - `dev.py --help` and the `--help` of `discover`, `boot-trace` and `guest-scene` are unchanged. Either drop `-X utf8` from `producer_argv`, or make the direct path UTF-8 as well and update the test. The earlier doc nit still applies (`docs/dev-tools.md:30` says `help_argv` is relative; it's now an absolute script path). Happy to re-test after a push. AI-assisted (Claude Code, Claude Opus 5.5).
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/12/head:github-bot/gh-12'
git switch 'github-bot/gh-12'

Merge

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