scripts/vs_layout_census: support BOM index, validate limit/paths, write --json atomically #2257
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2257"
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:45:20Z.
Claimed in the coordination issue as: VS-LAYOUT-CENSUS-BOM-LIMIT-AND-ATOMIC-JSON-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7189748056)
What and why
<dxbc>/index.jsonwithencoding="utf-8-sig"and convertRecursionErrorfromjson.load()intoValueErroracrossload_index(),input_paths(), andmain()(scripts/vs_layout_census.py) so single-line error reporting holds without tracebacks.limit/--limit(< 1) insurvey()andmain()as well as trailing-separator--jsondirectory paths (/or\) before callingsurvey().--jsonoutput atomically via_write_json_atomic()(creating missing parent directories cleanly, writing trailing LF\n, fsyncing, preserving permissions withpublished_mode(), publishing viareplace_retry.replace(), and cleaning.vs-layout-*.tmpfiles on failure).tests/test_vs_layout_census.pycovering UTF-8 BOM index parsing,RecursionErrorCLI handling,--limitvalidation, trailing-separator--jsonrefusal, and atomic JSON write/failure rollback.Tested
python -I tests/test_vs_layout_census.py -v->Ran 19 tests in 0.629s(OK).upstream/maina73a57e1with updatedtests/test_vs_layout_census.pycopied into detached worktree):Ran 19 tests in 0.690s(FAILED (failures=5, errors=1)).python -I tests/test_ci_registration.py(Ran 16 tests in 5.365s,OK),python -I tests/test_text_write_line_endings.py(Ran 3 tests in 13.271s,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 (synthetic containers/listings and atomic JSON output 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:46Z.
Review: COMMENTED
Windows 11: 19/19 Python tests passed. I also held an existing JSON output open without
FILE_SHARE_DELETE. The actual Win32 sharing restriction made the replacement fail, the original stayed byte-for-byte intact, and the temporary file was cleaned up. After closing the handle, a second write succeeded with valid UTF-8 JSON and LF endings. No findings from these checks.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by real-rusher on 2026-11-26T12:23:40Z.
Verified on main
a73a57e1(Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. With this PR, python -I tests/test_vs_layout_census.py: 19 tests OK (1 skipped). The PR's test file against main's script: 4 failures and 2 errors, so the new tests fail on main and pass with the change. compileall clean.AI-assisted: yes (Claude Code)
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:35:51Z.
Review: APPROVED
Approving
8755879c0.The index is read BOM-tolerant with a deep-JSON guard,
--limitmust be at least 1, and--jsonis written through a temp file andreplace_retry.Merged onto
maind1dff7949in one batch with 22 other tool PRs of this series (no conflicts), on Linux with Python 3.13.tests/test_vs_layout_census.py: 18 passed, 1 skipped (main: 15). AI-assisted (Claude Code, Claude Opus 5.5).Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T09:15:31Z.
#2257 | head
8755879c0d12a8658aace63c28467ff76f4ac761|python3 -I tests/test_vs_layout_census.py -v,py -3.12 -I tests/test_vs_layout_census.py -v| red: Linux 19 tests, 4 assertion failures, 2 errors, 1 skipped. Windows 19 tests, 5 assertion failures, 1 error | green: Linux 18 passed, 1 skipped. Windows 19 passed | Red → greenRepeated both phases natively on Windows to exercise the case-insensitive path check that skipped on Linux. Windows ran all 19 tests.
Pinned main
4938673668d807bf365b61284bf22b1ff8d02cc4, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4 and Windows 11 Pro, Python 3.12.10. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:19:34Z.
Independent verification on Windows 11 (
10.0.26200, x64) with8755879c0dmerged ontoorigin/main(5825b02ff8,0merge conflicts), tested under bothPython 3.12.10andPython 3.14.5:origin/mainscripts/vs_layout_census.py+#2257tests/test_vs_layout_census.py):python -I tests/test_vs_layout_census.py:Ran 19 tests,FAILED (failures=5, errors=1, skipped=1)on bothPython 3.12.10andPython 3.14.5.8755879c0dmerged ontoorigin/main):python -I tests/test_vs_layout_census.py:Ran 19 tests,OK (skipped=1)on bothPython 3.12.10(0.58 s) andPython 3.14.5(0.68 s; the 1 skip is the existingWinError 1314symlink privilege check).--jsontarget check: writingout.jsonfrom a UTF-8 BOMindex.json(rc=0), markingout.json0o444, and re-runningvs_layout_census.main([dx, "--json", out])returnsrc=2(Access is denied), preservesout.jsonbyte-for-byte, and leaves0.vs-layout-*.tmpstaging files behind.git diff --check,python -I -m compileall -q,python -I scripts/check_no_game_data.py,python -I tests/test_ci_registration.py(18/18), andpython -I tests/test_text_write_line_endings.py(3/3) all exited0.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T03:19:46Z.
Verified by OreoFR on macOS 27.2.1 (26B131), Apple M5, APFS (case-insensitive), Python 3.12.16, main
c8bf0e7b6, PR head8755879c0: red 4 failures + 2 errors / green 19 OKpython3.12 -I tests/test_vs_layout_census.py(19 tests):git merge-tree).test_atomic_json_creates_parent_ends_with_lf_and_cleans_on_failure,test_limit_validation_and_trailing_separator_json_guard(limit 0 / -1, trailing/and\),test_utf8_bom_index_and_recursion_error.git merge --no-ff): 19/19 OK, skipped 0.test_tool_startuphas the samepsin_dialoguefailure on main and merge, unrelated.utf-8-sig), RecursionError → ValueError,--limit>= 1,--jsonending in a separator refused; JSON write is atomic (temp file, fsync,published_mode,replace_retry, cleanup on failure), helpers exist intools/. Clean. No game data.Verdict: READY
AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-29T03:37:54Z.
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/2257#issuecomment-7249981238), and it still merges cleanly.
AI-assisted (Claude Code, Claude Opus 5.5), on behalf of DadaCap.