story_index: make the staging file deletable when a replace fails (STORY-INDEX-STAGE-CLEANUP) #789
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/789"
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 djrolfes on 2026-11-24T13:50:46Z.
Claimed in the coordination issue as: STORY-INDEX-STAGE-CLEANUP (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7133415910)
Depends on: none
Fixes: none (the work item is the finding pattern in issue #14; there is no separate issue to close)
Independent branch update
Head
692b65cb1, based one18b59a5b, contains exactly one topic commit. Removed the accidentally inherited #771 concurrency change and all sibling cleanup commits; this PR is now genuinely independent, soDepends on: noneis accurate. Retested on Linux: 34 tests pass, Python compileall, changed-file scanner and diff checks pass. Clean merge-tree against5da72d19f. Original head preserved; branch updated with an explicit lease. A passing label check is not full CI, and no hosted-suite pass is claimed. AI-assisted.What and why
tools/story_index.py'swrite_outputstages the report in aTemporaryDirectorynext to the destination and chmods the staged file to the destination's permission bits beforeos.replace. When the replace fails over a read-only report on Windows, the staged file is read-only, so the context-manager cleanup cannot delete it: the staging directory is stranded beside the report and the cleanup'sPermissionErrorreplaces the real error, breaking the tool's{out}: {error}reporting at exactly the interesting moment.The cleanup now runs in a
finally: make the staged file writable (0o600) before the directory is cleaned up, and let one delete failure pass (suppress(OSError)) so the caller'sexcept OSErrorreports the replace error and exits 2. A successful publish is byte-for-byte unchanged, and a failed one still leaves the prior report intact — the behavior the two existing partial-write tests already pin down. The shape is the onenavmesh_index.pyandbvh_index.pyuse for their staging cleanup.Tested
python3 -I tests/test_story_index.py: 34 tests OK, including the newtest_failed_replace_of_read_only_report_makes_stage_deletable, which fails against the old code on the made-deletable assertion (it mocks the replace as failing over a0o444report, asserts the stage was made deletable, the prior report untouched, and no staging directory stranded).test_csv_partial_staged_write_keeps_prior_bytes_and_cleans_up,test_json_partial_staged_write_keeps_prior_bytes_and_cleans_up).python3 -m compileall -q tools/story_index.py tests/test_story_index.pyclean;python3 -I scripts/check_no_game_data.py tools/story_index.py tests/test_story_index.pypasses; synthetic archives only.GPUs tested: n/a (standard-library tool; no game files, nothing online)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a)Imported from ubiquitarianism/leonida. Originally posted by djrolfes on 2026-11-25T19:45:33Z.
Rebuilt this branch independently on main
e18b59a5b:692b65cb1, exactly one cleanup commit. Removed #771 and sibling cleanup commits rather than adding a false dependency. 34 focused tests, compileall, changed-file scan and diff checks pass; clean merge-tree against5da72d19f. Explicit old-head lease used; prior head preserved. No full hosted CI result is inferred from a label check. AI-assisted.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T13:05:20Z.
Red/green: tests/test_story_index.py 1 failed on main, 34 passed with the PR.
Targeted batch of 30 PRs (their tests, the tests importing the changed modules, the docs tests, the translator suite) on main
a997a3c: no new failure, Windows 11 / Python.AI-assisted (Claude Code, Claude Opus 5.5)