scripts/corpus_watch: strip BOM JSON, check --out/--game collisions, validate args, enforce UTF-8 #2256
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2256"
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 kirigayakazima on 2026-11-26T10:43:07Z.
Claimed in the coordination issue as: CORPUS-WATCH-CLI-ENCODING-COLLISION-AND-BOM-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7189698488)
What and why
dxbc/index.json,spirv/index.json, and--resultsJSONL withencoding="utf-8-sig"inscripts/corpus_watch.pyand validate parsed container root types (list/dictfor carved index,dictforspirv/index.json).outputs_collide()(keeping 4-argument default compatibility) to check--outand--gamealongsidework,report,results, andlog.main(argv=None)to reject non-finite or negative--interval, non-positive--jobs, and directory/trailing-separator--resultsor--logpaths viaap.error(...)before tool checks or runningmake_game.py.--resultsand--logare created once prerequisites pass, and passencoding="utf-8", errors="replace"to bothsubprocess.run()invocations.tests/test_corpus_watch.pywith tests covering BOM indexes, malformed roots,--out/--gamecollision checks, CLI argument validation, nested parent folder creation, and subprocess encoding.Tested
python -I tests/test_corpus_watch.py -v->Ran 7 tests in 0.149s(OK).upstream/maina73a57e1with updatedtests/test_corpus_watch.pycopied into detached worktree):Ran 7 tests in 0.101s(FAILED (errors=10)).python -I tests/test_ci_registration.py(Ran 16 tests in 5.514s,OK),python -I tests/test_text_write_line_endings.py(Ran 3 tests in 13.118s,OK),python -I scripts/check_no_game_data.py(exit 0),python -I -m compileall -q(exit 0),git diff --check(exit 0).GPUs tested: n/a (mocked subprocess calls and corpus-counting unit tests)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T10:50:44Z.
Review: COMMENTED
Windows 11: 7/7 Python tests passed. A synthetic end-to-end CLI check with child commands stubbed reproduced an input index being modified before the command fails. Details inline.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T10:50:44Z.
Code review location:
scripts/corpus_watch.py; line 86[P2] Include the corpus indexes consumed by the watcher in the output collision check.
For
--once --results <work>/shaders/dxbc/index.json, this guard accepts the path. With a synthetic DXBC index containing[{"stage":"vs"}], the watcher counts the index and appends its JSONL result to the same file. A subsequentjson.load()fails withExtra data, and the watcher itself fails while reading the original list as a results record. This also applies to the SPIR-V index and legacy index paths. Can the guard reject results/log aliases of the actual index files before it writes anything?Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:35:42Z.
Review: APPROVED
Approving
fa4d7ae12.Outputs are now checked against the game folder as well as the work folder (and
--outamong them),--interval/--jobs/--results/--logare validated, the JSON inputs must be the expected shapes, and llvm-mc output is decoded as UTF-8.Merged onto
maind1dff7949in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_corpus_watch.py: 7 passed (main: 4). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-27T12:07:12Z.
Code review location:
scripts/corpus_watch.py; line 86Fixed:
outputs_collide()now also guardswork's corpus index paths (shaders/{dxbc,spirv}/index.jsonand legacy{dxbc,spirv}/index.json) so--results/--logcannot alias them. Added regression tests intests/test_corpus_watch.py(8 passed + 5 repo checks).Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T14:23:24Z.
Review: COMMENTED
Re-checked at
199c8c17e(merged ontomainec91d695c).Extending
outputs_collide()to includework'sshaders/{dxbc,spirv}/index.jsonand legacy{dxbc,spirv}/index.jsonpaths (with dedicated collision tests) cleanly covers the overlap with--report.Verified locally on Windows 11 (Python 3):
tests/test_corpus_watch.py: 8/8 passedscripts/check_no_game_data.pyandgit diff --check: cleanNo remaining findings.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T09:15:26Z.
#2256 | head
199c8c17e0e23ed4326c47404e66ad9d9e2f5821|python3 -I tests/test_corpus_watch.py -v| red: 8 tests, 15 errors | green: 8 passed | Exceptions on main → passBaseline errors included BOM decoding and incompatible call signatures. The merged tests exercised those paths successfully. Failure and error counts include subtest events.
Pinned main
4938673668d807bf365b61284bf22b1ff8d02cc4, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:14:13Z.
Native Windows 11 NTFS Verification (
199c8c17e0)Verified
199c8c17e0e23ed4326c47404e66ad9d9e2f5821merged cleanly ontoorigin/main(c7753ed98a56677f10e34078b37eab0540e190ec,git merge-tree --write-treerc=0) on native Windows 11 (26200) + NTFS:origin/mainc7753ed98a):python -I tests/test_corpus_watch.pyfailed (FAILED (errors=15)across8tests).origin/main + 199c8c17e0):python -I tests/test_corpus_watch.py:8/8 OK(utf-8-sigBOM handling ondxbc/spirvindexes andresults,--out/--game/corpus-index collision guards,--intervalfinite/nonnegative and--jobs >= 1CLI validation, parent folder creation, and explicitencoding="utf-8", errors="replace"subprocess calls).os.link) toshaders\dxbc\index.jsonand confirmedcorpus_watch.outputs_colliderejects it (True).AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T03:19:47Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main
c8bf0e7b6, PR head199c8c17e: red 15 errors / green 8 OKpython3.12 -I tests/test_corpus_watch.py(8 tests):git merge-tree).test_cli_validation_parent_creation_and_subprocess_encoding(interval nan / inf / -1, jobs 0 / -2, results/log pointing at a directory; main'smain()takes no argv yet),test_outputs_collide_checks_out_and_game,test_outputs_collide_rejects_work_corpus_indexes(4 index.json paths),test_utf8_bom_indexes_and_malformed_root_types.git merge --no-ff): 8/8 OK, skipped 0.test_tool_startupsamepsin_dialoguefailure on main and merge, unrelated.outputs_collidenow also compares out vs game and the 4 work-dir index.json files (still plain path equality, so an output placed inside the work dir is not caught); interval finite and >= 0, jobs >= 1; parents of results/log created; subprocess output read as utf-8 witherrors=replace. No game data.Verdict: READY
AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-29T03:38:06Z.
Merging, thank you @kirigayakazima! OreoFR's agent verified this head merged with current main: the test fails on main and passes with the PR (https://github.com/ProjectLeonida/mandy/pull/2256#issuecomment-7249981480), and it still merges cleanly.
AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.