op_reach: harden index parsing, report_paths guards, and atomic JSON I/O (OP-REACH-INDEX-AND-REPORT-GUARDS) #1556
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1556
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/op-reach-index-and-report-guards"
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?
Pull request successfully merged and closed
Claimed in the coordination issue as: OP-REACH-INDEX-AND-REPORT-GUARDS (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7232955159)
Depends on: none
What and why
Hardens
tools/op_reach.pyindex parsing, directory scanning, CLI output guards, and JSON output writing:stages_of):--indexwithutf-8-sig(handling UTF-8 BOM) and convertsRecursionErrortoValueError.fileentries viaos.path.basename(raw_file.replace("\\", "/"))before taking the stem (matchingfssm_header.stage_index), so directory-prefixed paths inindex.jsonresolve to listing stems.stageis a string (orNone) and strips whitespace instead of letting a non-stringstagecrashcensus()withTypeError."unindexed") while keeping identical duplicate rows, matchingfssm_header.stage_index.census,waves_of,report):*.sor*.fssmincensus()andwaves_of()instead of failing when opening them as files.report()(preserving order) so passing multiple encodings of one instruction (e.g.v_cndmask_b32_e32 v_cndmask_b32_e64) emits one combined base-op row.--index/--jsonguards and atomic JSON output (_inside_dir,_validate_json_path,_write_json_atomic):--indexand--jsonpaths (including--json ""and NUL bytes) and non-directory--jsonparents up front with exit code2.report_paths.same_report_pathto refuse--jsontargets that would overwrite--index,.s/.fssminputs (including hard-link/symlink/case-folded aliases), or write anywhere insidedisasmor--fssm.--jsonparent folders and publishes strict LF JSON (allow_nan=False, trailing\n) atomically viatempfile.mkstemp,file_mode.published_mode, andreplace_retry.replace, cleaning up the staged temp file on failure.tests/test_op_reach.py):index.json,*.s/*.fssmsubdirectories, op deduplication,--indexand--jsonoverwrite/containment guards (including hard links, symlinks, and mocked macOS case-insensitive aliases), nested atomic output, and temp-file cleanup onreplace_retry.replacefailure.Tested
python -m compileall -q tools/op_reach.py tests/test_op_reach.py— cleanpython -I -W error tests/test_op_reach.py -v— 18 tests, OKpython -I tests/test_text_write_line_endings.py— 3 tests, OKpython -I tests/test_report_paths.py— 22 tests, OK (2 skipped on unprivileged Windows)python -I scripts/check_no_game_data.py tools/op_reach.py tests/test_op_reach.py— cleanGPUs tested: n/a (CPU-only Python tool and synthetic standard-library unit tests on Windows 11)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (No translator change.)Hi @Vemast, thanks for this pull request.
CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post
claiming: <ID>there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one (the IDOP-REACH-INDEX-AND-REPORT-GUARDSappears in the pull request, but there is noclaiming:line for it).The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time.
Could you post the claim in #1608 and add the ID to the pull request description? If you already claimed it in another form, a link to your comment is enough.
AI-assisted (Claude Code, Claude Opus 5.5).
Thanks @MoonEyes!
#14had already hit GitHub's 2,500-comment cap when this PR opened, and#1608wasn't linked yet. I've now postedclaiming: OP-REACH-INDEX-AND-REPORT-GUARDSin #1608 (https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7232955159, along withdone:at https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7232955325) and updated the PR description with the claim link.AI-assisted.
Merged after local re-verification: this PR merged onto
mainfcbe97b9a without conflict, and its test file(s) (tests/test_op_reach.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.