xcl_compare: open transcript before Popen, format float timeouts, validate paths upfront, write JSON atomically (XCL-COMPARE-GUARDS-AND-ATOMIC-IO) #1591

Merged
IlyassRS3 merged 1 commit from upstream-pr/1591 into main 2026-11-28 10:29:15 +00:00
IlyassRS3 commented 2026-11-25 05:25:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T05:25:46Z.


Item: XCL-COMPARE-GUARDS-AND-ATOMIC-IO (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/xcl_compare.py).

Summary

  • Open transcript before spawning subprocess.Popen in run_title() and clean up any still-running child process on unexpected exceptions, preventing leaked child processes when opening the transcript fails.
  • Catch OSError (including ProcessLookupError) in kill_tree() when a hung process exits just before termination, and fall back to proc.kill() if taskkill fails on Windows.
  • Format hang reasons with %g s instead of %d s in _follow() so sub-second --timeout values (e.g. 0.5) report "no output for 0.5 s" rather than truncating to "no output for 0 s".
  • Validate empty/whitespace --xcl/--gta6rt/--work/--cdb/--out and directory/trailing-separator --out upfront before running either runtime, write report.json atomically via file_mode.published_mode + replace_retry.replace with allow_nan=False, accept optional argv=None in main(), and guard sys.stdout.reconfigure.

Verification

  • python3 -W error -I tests/test_xcl_compare.py -v: 20/20 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/xcl_compare.py tests/test_xcl_compare.py: passed.
  • python3 -m compileall -q tools/xcl_compare.py tests/test_xcl_compare.py: passed.
  • Mutation check (running tests/test_xcl_compare.py against unpatched main:tools/xcl_compare.py): failures=8, errors=1 across all 5 new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python test harness; synthetic Python stand-ins only, no game data)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5485707932 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1591). Originally posted by [IlyassRS3](https://github.com/IlyassRS3) on 2026-11-25T05:25:46Z. --- Item: `XCL-COMPARE-GUARDS-AND-ATOMIC-IO` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/xcl_compare.py`). ### Summary - Open `transcript` before spawning `subprocess.Popen` in `run_title()` and clean up any still-running child process on unexpected exceptions, preventing leaked child processes when opening the transcript fails. - Catch `OSError` (including `ProcessLookupError`) in `kill_tree()` when a hung process exits just before termination, and fall back to `proc.kill()` if `taskkill` fails on Windows. - Format hang reasons with `%g s` instead of `%d s` in `_follow()` so sub-second `--timeout` values (e.g. `0.5`) report `"no output for 0.5 s"` rather than truncating to `"no output for 0 s"`. - Validate empty/whitespace `--xcl`/`--gta6rt`/`--work`/`--cdb`/`--out` and directory/trailing-separator `--out` upfront before running either runtime, write `report.json` atomically via `file_mode.published_mode` + `replace_retry.replace` with `allow_nan=False`, accept optional `argv=None` in `main()`, and guard `sys.stdout.reconfigure`. ### Verification - `python3 -W error -I tests/test_xcl_compare.py -v`: 20/20 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/xcl_compare.py tests/test_xcl_compare.py`: passed. - `python3 -m compileall -q tools/xcl_compare.py tests/test_xcl_compare.py`: passed. - Mutation check (running `tests/test_xcl_compare.py` against unpatched `main:tools/xcl_compare.py`): `failures=8, errors=1` across all 5 new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python test harness; synthetic Python stand-ins only, no game data)
copilot-pull-request-reviewer[bot] commented 2026-11-25 05:25:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T05:25:54Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6052276801 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1591#pullrequestreview-6052276801). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-25T05:25:54Z. **Review:** COMMENTED --- 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.
MoonEyes commented 2026-11-28 10:29:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T10:29:06Z.


Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18).
Targeted batch of 18 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237925955 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1591#issuecomment-7237925955). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T10:29:06Z. --- Red/green: the PR's tests fail on main and pass with this PR (Linux, Python 3.13.18). Targeted batch of 18 PRs (their tests, the tests importing the changed modules, the docs tests) on main 3ca0707: no new failure, Linux / Python 3.13. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1591
No description provided.