recomp_census: a wrong input is one ERROR line, not a traceback (RECOMP-CENSUS-WRONG-INPUT) #1088

Merged
tiguan26 merged 1 commit from upstream-pr/1088 into main 2026-11-24 22:19:02 +00:00
tiguan26 commented 2026-11-24 18:13:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-24T18:13:21Z.


Claimed in the coordination issue as: RECOMP-CENSUS-WRONG-INPUT (claim, done)

What and why

tools/recomp_census.py stopped with a traceback on a wrong input:

  • an image path that does not exist (FileNotFoundError),
  • a folder instead of an image (IsADirectoryError),
  • --out naming an existing file (FileExistsError from os.makedirs).

Each now prints one ERROR: ... line and exits 2, like tools/navmesh_nodes.py and the three tools in #952 (which does not touch this one). A PE that is not x86-64 or has no MZ header keeps its current message and exit code 1.

The module docstring said the tool writes <out>/<file>.json and <out>/<file>.md; it writes <file>.recomp.json and <file>.recomp.md, so that line is corrected.

Tested

On Linux (Python 3.13.18), from the checkout root on main 3aa9754:

  • python -I tests/test_recomp_census.py: 11 tests pass. The four new ones (WrongInputTests) use the byte-built PE fixture already in the file; the three wrong-input cases fail against the tool on main and pass with the fix, and the fourth checks a good image still writes both reports.
  • tests/test_tool_startup.py, tests/test_text_write_line_endings.py, tests/test_tool_stdout_encoding.py, tests/test_docs_links.py: pass.
  • python -m compileall -q tools tests, python -I scripts/check_no_game_data.py on both files, git diff --check: clean.

Not run on real game files; the normal output is unchanged.

GPUs tested: n/a (no GPU code changed)

AI-assisted: yes (Claude)

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. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5477779193 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1088). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-24T18:13:21Z. --- Claimed in the coordination issue as: RECOMP-CENSUS-WRONG-INPUT ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140305644), [done](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140377408)) ### What and why `tools/recomp_census.py` stopped with a traceback on a wrong input: - an image path that does not exist (`FileNotFoundError`), - a folder instead of an image (`IsADirectoryError`), - `--out` naming an existing file (`FileExistsError` from `os.makedirs`). Each now prints one `ERROR: ...` line and exits 2, like `tools/navmesh_nodes.py` and the three tools in #952 (which does not touch this one). A PE that is not x86-64 or has no MZ header keeps its current message and exit code 1. The module docstring said the tool writes `<out>/<file>.json` and `<out>/<file>.md`; it writes `<file>.recomp.json` and `<file>.recomp.md`, so that line is corrected. ### Tested On Linux (Python 3.13.18), from the checkout root on `main` 3aa9754: - `python -I tests/test_recomp_census.py`: 11 tests pass. The four new ones (`WrongInputTests`) use the byte-built PE fixture already in the file; the three wrong-input cases fail against the tool on `main` and pass with the fix, and the fourth checks a good image still writes both reports. - `tests/test_tool_startup.py`, `tests/test_text_write_line_endings.py`, `tests/test_tool_stdout_encoding.py`, `tests/test_docs_links.py`: pass. - `python -m compileall -q tools tests`, `python -I scripts/check_no_game_data.py` on both files, `git diff --check`: clean. Not run on real game files; the normal output is unchanged. GPUs tested: n/a (no GPU code changed) AI-assisted: yes (Claude) ### 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. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
KernelSmoker commented 2026-11-24 18:33:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T18:33:25Z.

Review: APPROVED


Independently verified the wrong-input handling on head 4243713783cdda3acabc261c29c2d71bf416c3c1.

  • tests/test_recomp_census.py: 11/11 passed.
  • Startup 2/2, text line endings 3/3, stdout encoding 4/4, docs links 16/16 passed.
  • End-to-end CLI subprocesses for missing input, directory input, and --out naming a file each exited 2 with exactly one ERROR: line and no traceback.
  • Replaced the patched tool temporarily with the base-commit version: the three new wrong-input tests failed with the corresponding OSError exceptions; restored the PR source and verified the suite green.
  • No-game-data check and whitespace/line-ending checks passed. The PE fixture is synthetic; no game files or GPU used.

One coordination note: the PR body says this item was claimed, but I could not find a matching claim comment from the author in the current coordination issue #14 history. Please add or link it so the task ledger remains accurate; I found no overlapping PR or change in intervening main commits.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045115629 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1088#pullrequestreview-6045115629). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T18:33:25Z. **Review:** APPROVED --- Independently verified the wrong-input handling on head `4243713783cdda3acabc261c29c2d71bf416c3c1`. - `tests/test_recomp_census.py`: 11/11 passed. - Startup 2/2, text line endings 3/3, stdout encoding 4/4, docs links 16/16 passed. - End-to-end CLI subprocesses for missing input, directory input, and `--out` naming a file each exited 2 with exactly one `ERROR:` line and no traceback. - Replaced the patched tool temporarily with the base-commit version: the three new wrong-input tests failed with the corresponding OSError exceptions; restored the PR source and verified the suite green. - No-game-data check and whitespace/line-ending checks passed. The PE fixture is synthetic; no game files or GPU used. One coordination note: the PR body says this item was claimed, but I could not find a matching claim comment from the author in the current coordination issue #14 history. Please add or link it so the task ledger remains accurate; I found no overlapping PR or change in intervening main commits.
abnalstlll-byte commented 2026-11-24 18:42:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:42:20Z.

Review: APPROVED


Audited and verified. Handles OSError cleanly in ools/recomp_census.py when encountering missing or invalid image paths or unwritable destination directories, printing a single ERROR: ... line to stderr and exiting with status 2 without Python tracebacks. Unit tests in ests/test_recomp_census.py pass cleanly. Approved.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045235416 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1088#pullrequestreview-6045235416). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:42:20Z. **Review:** APPROVED --- Audited and verified. Handles OSError cleanly in ools/recomp_census.py when encountering missing or invalid image paths or unwritable destination directories, printing a single ERROR: ... line to stderr and exiting with status 2 without Python tracebacks. Unit tests in ests/test_recomp_census.py pass cleanly. Approved.
abnalstlll-byte commented 2026-11-24 18:51:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:51:04Z.

Review: APPROVED


Clean-Room Audit — PR #1088 (RECOMP-CENSUS-WRONG-INPUT)

Clean error handling in tools/recomp_census.py catching OSError across both input inspection and report output paths, printing one diagnostic ERROR: line to stderr with exit code 2. Solid unit test coverage in tests/test_recomp_census.py::WrongInputTests; standard library only, 0 game data.

Verdict: APPROVED

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045356100 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1088#pullrequestreview-6045356100). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:51:04Z. **Review:** APPROVED --- ### Clean-Room Audit — PR #1088 (`RECOMP-CENSUS-WRONG-INPUT`) Clean error handling in `tools/recomp_census.py` catching `OSError` across both input inspection and report output paths, printing one diagnostic `ERROR:` line to `stderr` with exit code 2. Solid unit test coverage in `tests/test_recomp_census.py::WrongInputTests`; standard library only, 0 game data. **Verdict: APPROVED**
tiguan26 commented 2026-11-24 18:58:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-24T18:58:10Z.


@KernelSmoker thanks for checking. The claim is in #14, collapsed in the middle of the thread: claiming: RECOMP-CENSUS-WRONG-INPUT, posted before this PR opened, and the done note. I've also linked it from the PR description.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7141405593 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1088#issuecomment-7141405593). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-24T18:58:10Z. --- @KernelSmoker thanks for checking. The claim is in #14, collapsed in the middle of the thread: [claiming: RECOMP-CENSUS-WRONG-INPUT](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140305644), posted before this PR opened, and the [done note](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140377408). I've also linked it from the PR description.
whoalin1 commented 2026-11-24 21:42:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-24T21:42:57Z.


Verification (independent, AI-assisted — Devin worker agent, Windows 11, Python 3.14, no GPU needed):

Checked out head 4243713 in a clean worktree.

Unit tests

python -I tests/test_recomp_census.py
Ran 11 tests in 0.139s — OK

Manual wrong-input repros (CLI, python -I tools/recomp_census.py):

  • missing image → ERROR: [Errno 2] No such file or directory: ... , exit 2, no traceback
  • directory as image → ERROR: [Errno 13] Permission denied: ..., exit 2
  • --out naming an existing file (valid synthetic PE fixture) → ERROR: [WinError 183] Cannot create a file when that file already exists, exit 2; the existing file's contents were left untouched
  • happy path still works: good.exe: 3 fns, 11 insns, 90.91% covered, 1 hazard kinds, exit 0, writes both .recomp.json and .recomp.md

Baseline comparison (origin/main copy of tools/recomp_census.py): missing image → FileNotFoundError traceback, confirming the fix changes the behavior as claimed.

The new WrongInputTests cover all three failure modes plus the happy path. No issues found.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145293886 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1088#issuecomment-7145293886). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-24T21:42:57Z. --- Verification (independent, AI-assisted — Devin worker agent, Windows 11, Python 3.14, no GPU needed): Checked out head `4243713` in a clean worktree. **Unit tests** ``` python -I tests/test_recomp_census.py Ran 11 tests in 0.139s — OK ``` **Manual wrong-input repros** (CLI, `python -I tools/recomp_census.py`): - missing image → `ERROR: [Errno 2] No such file or directory: ...` , exit 2, no traceback - directory as image → `ERROR: [Errno 13] Permission denied: ...`, exit 2 - `--out` naming an existing file (valid synthetic PE fixture) → `ERROR: [WinError 183] Cannot create a file when that file already exists`, exit 2; the existing file's contents were left untouched - happy path still works: `good.exe: 3 fns, 11 insns, 90.91% covered, 1 hazard kinds`, exit 0, writes both `.recomp.json` and `.recomp.md` **Baseline comparison** (`origin/main` copy of `tools/recomp_census.py`): missing image → `FileNotFoundError` traceback, confirming the fix changes the behavior as claimed. The new `WrongInputTests` cover all three failure modes plus the happy path. No issues found.
QemmHD commented 2026-11-24 22:18:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T22:18:59Z.


Merging.

Why merged: RECOMP-CENSUS-WRONG-INPUT: recomp_census reports a wrong input, or an --out it can't write, as one ERROR line with exit 2 instead of a traceback. KernelSmoker and whoalin1 checked it.

Why it's good: test_recomp_census: 11/11.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 4a50cafc7. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new subprocesses, new env vars or CI changes.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7146078838 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1088#issuecomment-7146078838). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T22:18:59Z. --- Merging. **Why merged:** RECOMP-CENSUS-WRONG-INPUT: recomp_census reports a wrong input, or an --out it can't write, as one ERROR line with exit 2 instead of a traceback. KernelSmoker and whoalin1 checked it. **Why it's good:** test_recomp_census: 11/11. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 4a50cafc7. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new subprocesses, new env vars or CI changes. 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!1088
No description provided.