mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1556] op_reach: harden index parsing, report_paths guards, and atomic JSON I/O (OP-REACH-INDEX-AND-REPORT-GUARDS) #1581
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1581
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1556
Author: @Vemast
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/op-reach-index-and-report-guards📝 Commits (1)
a237f51op_reach: harden index parsing, report_paths guards, and atomic JSON I/O (OP-REACH-INDEX-AND-REPORT-GUARDS)📊 Changes
2 files changed (+281 additions, -12 deletions)
View changed files
📝
tests/test_op_reach.py(+145 -0)📝
tools/op_reach.py(+136 -12)📄 Description
Claimed in the coordination issue as: OP-REACH-INDEX-AND-REPORT-GUARDS — verified 0 open PRs and 0 prior claims touching
tools/op_reach.py(unable to post a comment on#14because GitHub disabled commenting once#14reached its 2,500-comment cap, and no successor"Coordinating who works on what"issue is open yet)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.)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.