Repository navigation
world_names: refuse build --out overwriting an input - #4471
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 63e1f44d on Windows 11: python -I tests/test_world_names.py -> 25 tests, OK; git diff --check clean.
world_names build --out now refuses to overwrite an input, and the path tests pass. No blocking issue.
|
Tested
AI-assisted (Devin). |
|
Tested
No GPU, no game data. AI-assisted. |
|
Checked at 63e1f44 merged with main 3faac55: merges cleanly (older base, an ancestor of main — not stacked). tests/test_world_names.py passes fully including the new refusals across all six input kinds plus direct and discovered hardlinks (rc 1, one stderr line, input bytes untouched, stdout empty). The guard reuses same_report_path from report_paths.py and mirrors the existing resolve-side check, and it precedes any write or makedirs; test_report_paths, test_world_index and test_world_place all pass. test_joaat_agreement is red identically on clean main — the known utf-8/latin-1 breakage pending #4753/#4882, unrelated to this PR. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
Claimed in the coordination issue: #4421 (comment)
What and why
tools/world_names.pyalready refusesresolve --outwhen the output path would overwrite any input (--dict,--maps,--archetypes) viasame_report_path, tested byCliTest.test_resolve_out_refuses_to_overwrite_an_input.buildhad no equivalent guard: passing--outpointing to any--manifest,--scan,--names,--rpf9-names, or--xmlfile — or to amodels/manifest.jsondiscovered under a--manifest <dir>tree, or a hard link to any of them — silently overwrote the input file with the generated dictionary JSON and exited0.Changes:
_build_input_paths(args)and checksame_report_path(args.out, path)in_build()before callingbuild_dictionary(), raisingValueError(f"build: --out {args.out} would overwrite input {path}")(matching_resolve()'s error format and exit code1). When--outdoes not exist yet, directory traversal is skipped to avoid a redundant walk.CliTest.test_build_out_refuses_to_overwrite_an_inputintests/test_world_names.pycovering all five input flags, directory-discoveredmodels/manifest.json, and hard links to both direct and discovered inputs.Distinct from
#4404(build_dictionaryos.walkonerror) with no overlapping hunks.Tested
Windows 11, Python 3.14.8, CPU only, no game files (synthetic fixtures only).
63e1f44d):python -I tests/test_world_names.py-> 25 tests, OK.16282101tools/world_names.py+ HEAD tests): 8 subtest failures intest_build_out_refuses_to_overwrite_an_input(inputs silently overwritten on base).python -m compileall -q tools/world_names.py tests/test_world_names.py,git diff --check, LF check (i/lf w/lf), andgit merge-tree --write-tree upstream/main HEADall clean.Checklist
CONTRIBUTING.md).AI-assisted.