Repository navigation
sampler_source_census: refuse a --json that would overwrite the carve index, a listing or a container it reads - #6266
Conversation
…a listing it reads The census is written last, after every input has been read, so a report landing on the carve index, a listing, a DXBC container or an FSSM header silently replaced an input the run just used. Refuse those names with report_paths.same_report_path, as heap_index_census already does, and say so in the module docstring.
… container is refused Test fails on the previous sampler_source_census (exit 0 and the input replaced) and passes with the guard: the carve index, a listing inside disasm and a DXBC container each give ERROR and exit 2, nothing is printed, and the index still holds its bytes.
…s refused too The same input under another name must not be written over either; a name with no link to an input is still written (negative control). os.path.samefile alone would miss the second name on a volume whose name rules hide it, which is why report_paths.same_report_path is used.
|
Tested 80fc560 on Windows 11 (NTFS), Python 3.12.10 (CPU only, no GPU, no game files): pass What I ran:
Edge cases by hand, using the test's
Non-blocking point, the last row: Overlap: no other open PR changes this guard. #4268 adds the whole tool again and already has add/add conflicts with AI-assisted (Claude Code). |
|
Tested 80fc560 merged with main 496da20 on Linux/Python 3.12.16: pass Commands run (merged worktree,
Diff read: |
The census writes its
--jsonreport last, after it has read the carve index, every listing, every DXBC container and every FSSM header. It had no guard on that path, so a report naming one of those inputs silently replaced it:--json <work>/shaders/dxbc/index.jsonoverwrote the carve indexmake_game.pytrusts as proof the carve finished,--json <work>/shaders/dxbc/disasm/a.sreplaced a listing, and--json <work>/shaders/dxbc/a.dxbcreplaced a container the run had just read.tools/heap_index_census.pyreads the same folder and already refuses those names; this does the same with the sharedtools/report_paths.same_report_pathhelper, which also catches a hard link under another name, and records the refusal in the module docstring.Test:
python -I tests/test_sampler_source_census.py(no game files, no GPU).Before (the tool from
main): the two new tests fail, exit 0 with the input replaced.After (this branch): all 32 pass.
The first test also checks that nothing is printed before the refusal and that the carve index still holds its bytes; the second ends with a negative control (a
--jsonname with no link to an input is still written).Item: EGEN-SAMPLER-CENSUS-JSON
Notes
same_report_pathcan.ERROR:wording identical toheap_index_census, so a script that reads either tool sees the same shape.No GPU needed.
AI-assisted.