Skip to content

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

Merged
QemmHD merged 1 commit into
ProjectLeonida:mainfrom
tiguan26:fix/recomp-census-wrong-input
Nov 24, 2026
Merged

QemmHD merged 1 commit into
ProjectLeonida:mainfrom
tiguan26:fix/recomp-census-wrong-input

Conversation

@tiguan26

@tiguan26 tiguan26 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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

…MP-CENSUS-WRONG-INPUT)

A missing image (FileNotFoundError), a folder for the image
(IsADirectoryError) and an --out that names an existing file
(FileExistsError from os.makedirs) stopped the tool with a traceback.
Each now prints one ERROR line and exits 2, like tools/navmesh_nodes.py.
A PE that is not x86-64 keeps its current message and exit code.

The docstring named the reports <file>.json and <file>.md; the tool
writes <file>.recomp.json and <file>.recomp.md.

Synthetic tests only, on the byte-built PE fixture; no game files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tiguan26
tiguan26 force-pushed the fix/recomp-census-wrong-input branch from 64e789a to 4243713 Compare November 24, 2026 18:14

@KernelSmoker KernelSmoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

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

@whoalin1

Copy link
Copy Markdown
Contributor

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

QemmHD commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

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

@QemmHD
QemmHD merged commit 1412262 into ProjectLeonida:main Nov 24, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants