Refactor tool management and subprocess execution #12

Closed
leonida/mandy
StaticM223 wants to merge 0 commits from main into main

Pull request closed

Please reopen this pull request to perform a merge.

StaticM223 commented 2026-11-24 01:37:40 +00:00

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.
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.
wavehs commented 2026-11-24 01:43:49 +00:00

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.

**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.
ubiquitarianism commented 2026-11-24 02:34:14 +00:00

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

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).
QemmHD commented 2026-11-24 05:28:44 +00:00

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.

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 commented 2026-11-24 05:43:33 +00:00

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

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).
MoonEyes commented 2026-11-27 22:42:29 +00:00

Hi @StaticM223, thanks for this pull request.

CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post claiming: <ID> there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one.

The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time.

Could you post the claim in #1608 and put its ID (or a link to it) on the pull request's "Claimed in the coordination issue as:" line? If you already claimed it in another form, a link to your comment is enough.

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

Hi @StaticM223, thanks for this pull request. CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post `claiming: <ID>` there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one. The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time. Could you post the claim in #1608 and put its ID (or a link to it) on the pull request's "Claimed in the coordination issue as:" line? If you already claimed it in another form, a link to your comment is enough. AI-assisted (Claude Code, Claude Opus 5.5).
DadaCap commented 2026-11-28 10:32:34 +00:00

Thanks for the contribution! This PR was reviewed by the maintainers and is being closed as part of a large batch of closures.

Reason: unexplained refactor, empty description.

If this looks like a mistake, mention @DadaCap here at any time and it will be looked at again.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

Thanks for the contribution! This PR was reviewed by the maintainers and is being closed as part of a large batch of closures. Reason: unexplained refactor, empty description. If this looks like a mistake, mention @DadaCap here at any time and it will be looked at again. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
Sign in to join this conversation.
No description provided.