rootsig_census: guard --json with same_report_path and catch write OSError (ROOTSIG-CENSUS-JSON-GUARD) #1360
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1360"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by JesusACD on 2026-11-24T22:31:02Z.
Claimed in the coordination issue as: ROOTSIG-CENSUS-JSON-GUARD (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7146264254)
What and why
tools/rootsig_census.pypreviously checked--jsononly withos.path.samefile(a.root, a.json)(:298-303) and wrote--jsonwithout catchingOSError(:331-334):--jsonnaming an unpacked input or manifest (<root>/<name>.dxbc,<root>/fspx/<name>.json,<root>/index.json, or<disasm>/<name>.s/<disasm>/index.jsonwhen--disasmis given) — directly, via another relative spelling, a link, or a case-folded alias — was not refused and overwrote the file.--jsonnaming--disasmor any existing directory other thanrootran the entire census first and then crashed with an unhandledIsADirectoryError/PermissionErrortraceback.--jsonpaths crashed with an unhandledOSErrortraceback instead of reporting a one-line error with exit code2.This switches
tools/rootsig_census.pytotools/report_paths.same_report_path(perCONTRIBUTING.md), refuses directory targets and input/manifest collisions before scanning, creates missing parent directories for--json, and catchesOSErroron write to printerror: cannot write <path>: <reason>tostderrand exit2.Tested
python -m compileall -q make_game.py tools tests: clean.python -I make_game.py --helpandpython -I tools/rootsig_census.py --help: clean.python -I tests/test_rootsig_census.py -v: 30 passed (added 5 regression tests covering input/manifest preservation, delegation tosame_report_path, pre-scan directory refusal, nested parent creation, and cleanOSErrorreporting on Windows 11 / Python 3.13.17).python -I tests/test_report_paths.py,python -I tests/test_report_path_case.py, andpython -I tests/test_text_write_line_endings.py: 28 passed, 1 skipped.python -I scripts/check_no_game_data.py tools/rootsig_census.py tests/test_rootsig_census.py: clean.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)Imported from ubiquitarianism/leonida. Originally posted by xel1uz on 2026-11-24T22:49:53Z.
I reproduced this on
8270eaeawith an emptyroot/directory. Runningpython -I tools/rootsig_census.py root --json root/index.jsontwice gave exit 0 on the first run (it wrote the census report to the manifest path) and exit 2 on the second. I saw the same behavior with an emptydisasm/directory and--disasm disasm --json disasm/index.json.Fix and regression test: both paths are now rejected before the first write. All 30 tests passed with
python -I tests/test_rootsig_census.py.Imported from ubiquitarianism/leonida. Originally posted by JesusACD on 2026-11-24T23:01:27Z.
Thanks for catching this, @xel1uz! Updated in
85b44dd10so<root>/index.jsonand<disasm>/index.jsonare reserved unconditionally before the first write, along with the regression test for empty directories. Re-ranpython -I tests/test_rootsig_census.py -v(30 passed),test_report_paths.py,test_report_path_case.py,test_text_write_line_endings.py,compileall, andcheck_no_game_data.py.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:31:08Z.
Red/green: classified READY by cloud-5 (red on main
09c153948, green on head merged with main); head85b44dd105unchanged since 2026-11-24, before that run.Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
d48a957bbin GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)