Fail semantic runs that exit without a trustworthy result (SEMANTIC-RUNNER-COMPLETION) #1437

Merged
titoreinaldo merged 2 commits from upstream-pr/1437 into main 2026-11-28 08:01:25 +00:00
titoreinaldo commented 2026-11-25 00:14:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by titoreinaldo on 2026-11-25T00:14:37Z.


Claimed in the coordination issue as: SEMANTIC-RUNNER-COMPLETION (#14 claim).

What and why

An incomplete semantic run can report success. A synthetic module calling os._exit(0) during import leaves no unittest result; the parallel runner counts zero for that worker and accepts its process status, and the serial runner simply forwards success. An exit handler can also overwrite the status after unittest has completed with a failure.

Use unittest’s completed result as well as the process exit status in both modes. Status 0 without a result, or after unittest reported a nonzero status, is an error. Empty package initializers are still ignored based on the recorded result, and timeouts retain their existing diagnostics. Discovery rules are unchanged.

Tested

  • Both synthetic regressions fail against main 1154976d with either -j 1 or -j 2: four false-green cases before, all four detected after.
  • python -I tests/test_run_semantic_tests.py: 24 tests pass.
  • python -I scripts/run_semantic_tests.py tests/semantic -j 8: 476 files, 6,223 tests, zero failing files.
  • Compile, diff whitespace and no-game-data checks passed.

GPUs tested: none, Linux x86-64 / Python 3.12.14, CPU-only. No game files, keys, decryption, or online game services. AI-assisted: yes, OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5482606958 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1437). Originally posted by [titoreinaldo](https://github.com/titoreinaldo) on 2026-11-25T00:14:37Z. --- Claimed in the coordination issue as: SEMANTIC-RUNNER-COMPLETION ([#14 claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7148212498)). ### What and why An incomplete semantic run can report success. A synthetic module calling `os._exit(0)` during import leaves no unittest result; the parallel runner counts zero for that worker and accepts its process status, and the serial runner simply forwards success. An exit handler can also overwrite the status after unittest has completed with a failure. Use unittest’s completed result as well as the process exit status in both modes. Status 0 without a result, or after unittest reported a nonzero status, is an error. Empty package initializers are still ignored based on the recorded result, and timeouts retain their existing diagnostics. Discovery rules are unchanged. ### Tested - Both synthetic regressions fail against main `1154976d` with either `-j 1` or `-j 2`: four false-green cases before, all four detected after. - `python -I tests/test_run_semantic_tests.py`: 24 tests pass. - `python -I scripts/run_semantic_tests.py tests/semantic -j 8`: 476 files, 6,223 tests, zero failing files. - Compile, diff whitespace and no-game-data checks passed. GPUs tested: none, Linux x86-64 / Python 3.12.14, CPU-only. No game files, keys, decryption, or online game services. AI-assisted: yes, OpenAI Codex.
PierreEbele commented 2026-11-25 15:27:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T15:27:14Z.


Reviewed 84f8fee73: run_semantic_tests.py now takes the verdict from the child's {testsRun, exitCode} result file: a child that exits 0 without a result, or against unittest's own verdict, fails the run, and -j 1 shares the child program instead of a bare python -m unittest discover. Ran tests/test_run_semantic_tests.py on both trees: 24 tests OK on the PR, and on main exactly the two new tests fail; both bugs reproduce (an import-time os._exit(0) and an atexit-forced exit 0 after a failed test report "0 files failed" on main). Ran the runner on tests/semantic -p 'test_alu_add*.py' in both modes on both trees: 6 files, 69 tests, 0 failed, identical output. Probed a passing module with an atexit os._exit(0) (still passes; no false positive) and a mid-test SIGKILL (still fails). No findings. Note, follow-up material only: a module that deliberately writes LEONIDA_TEST_COUNT can still forge a green verdict everywhere except main's serial mode, which was immune by accident.

AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7166866309 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1437#issuecomment-7166866309). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T15:27:14Z. --- Reviewed 84f8fee73: run_semantic_tests.py now takes the verdict from the child's `{testsRun, exitCode}` result file: a child that exits 0 without a result, or against unittest's own verdict, fails the run, and `-j 1` shares the child program instead of a bare `python -m unittest discover`. Ran tests/test_run_semantic_tests.py on both trees: 24 tests OK on the PR, and on main exactly the two new tests fail; both bugs reproduce (an import-time `os._exit(0)` and an atexit-forced exit 0 after a failed test report "0 files failed" on main). Ran the runner on `tests/semantic -p 'test_alu_add*.py'` in both modes on both trees: 6 files, 69 tests, 0 failed, identical output. Probed a passing module with an atexit `os._exit(0)` (still passes; no false positive) and a mid-test SIGKILL (still fails). No findings. Note, follow-up material only: a module that deliberately writes LEONIDA_TEST_COUNT can still forge a green verdict everywhere except main's serial mode, which was immune by accident. AI-assisted review. **Recommendation:** Merge
MoonEyes commented 2026-11-27 23:36:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T23:36:12Z.


Hi @titoreinaldo, thanks for this. #1749 by lixonik (SEMANTIC-WORKER-RESULT-REQUIRED) fixes the same false pass for the parallel runner only. Yours is the broader fix (it also covers -j 1 and a nonzero unittest status hidden by an exit handler) and your claim came first, but it now conflicts with main.

Could you rebase it? When you do, please also add the case #1749 tests and yours does not: a module whose worker exits with status 0 in the middle of a test (yours exits at import) next to a healthy module under -j 2. After that, #1749 can be closed in favor of this one. cc @lixonik, no action needed from you yet.

AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7230266767 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1437#issuecomment-7230266767). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-27T23:36:12Z. --- Hi @titoreinaldo, thanks for this. #1749 by `lixonik` (SEMANTIC-WORKER-RESULT-REQUIRED) fixes the same false pass for the parallel runner only. Yours is the broader fix (it also covers `-j 1` and a nonzero unittest status hidden by an exit handler) and your claim came first, but it now conflicts with `main`. Could you rebase it? When you do, please also add the case #1749 tests and yours does not: a module whose worker exits with status 0 in the middle of a test (yours exits at import) next to a healthy module under `-j 2`. After that, #1749 can be closed in favor of this one. cc @lixonik, no action needed from you yet. AI-assisted (Claude Code, Claude Opus 5.5)
akimfomin commented 2026-11-28 01:25:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by akimfomin on 2026-11-28T01:25:16Z.


I ran python -I tests/test_run_semantic_tests.py on 53bc0e3a in a standalone Windows checkout of the runner and its fixtures. It finished with 28 passed and one platform skip. The intentional nested boom-msg failure did not make the outer suite fail. VIctory #3636 has a related false-green control for worker initialization. If you publish a CI summary from this runner, labeling that nested diagnostic separately would keep it from looking like a failed verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7231653720 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1437#issuecomment-7231653720). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T01:25:16Z. --- I ran `python -I tests/test_run_semantic_tests.py` on `53bc0e3a` in a standalone Windows checkout of the runner and its fixtures. It finished with 28 passed and one platform skip. The intentional nested `boom-msg` failure did not make the outer suite fail. [VIctory #3636](https://github.com/Marvisak/VIctory/pull/3636) has a related false-green control for worker initialization. If you publish a CI summary from this runner, labeling that nested diagnostic separately would keep it from looking like a failed verification.
DadaCap commented 2026-11-28 08:01:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T08:01:28Z.


Merged into main (merge commit 7e4093c9e), approved by DadaCap (maintainer). Thanks!

Checked before merging: Tested in our local release candidate (main + 41 PRs): translator suite 512 files / 6,442 tests clean, Python suite with no new failure versus main, and 360 s game runs on an RTX 5080 with no regression. Note: #2073 touches the same lines of run_semantic_tests.py; it will be asked to rebase on this. The merge was pinned to the head commit that was tested (53bc0e3a8).

AI-assisted (Claude Code), posted for DadaCap.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7236311642 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1437#issuecomment-7236311642). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T08:01:28Z. --- Merged into `main` (merge commit 7e4093c9e), approved by DadaCap (maintainer). Thanks! Checked before merging: Tested in our local release candidate (main + 41 PRs): translator suite 512 files / 6,442 tests clean, Python suite with no new failure versus main, and 360 s game runs on an RTX 5080 with no regression. Note: #2073 touches the same lines of `run_semantic_tests.py`; it will be asked to rebase on this. The merge was pinned to the head commit that was tested (53bc0e3a8). _AI-assisted (Claude Code), posted for DadaCap._
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!1437
No description provided.