Repository navigation
fix: keep a wiki page relabelled only by case (#4508) - #4521
Deepjyoti-Sarmah wants to merge 1 commit into
Conversation
On a case-insensitive filesystem (APFS, NTFS) a community relabelled only by case, such as "groups" to "Groups", is written into the old directory entry, which keeps the old case. The end-of-run orphan sweep compared file names case-sensitively, so it deleted the page the run had just written and left index.md linking to a missing file. The sweep now matches files by identity (device and inode). A page the run wrote is kept even when its name differs only by case, and the entry is renamed to the produced case. Stale pages that are separate files are still removed, and a dangling symlink is still removed as before.
|
Thanks for the pull request, @Deepjyoti-Sarmah. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).
Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 vacuous).
Not verified on this run: to\_wiki (vacuous: never exercised).
Graphify review — findings
Fixes the wiki orphan sweep in to_wiki so a community relabelled only by case (groups to Groups) keeps its article on case-insensitive filesystems instead of having it deleted (#4508). The sweep now matches files by (device, inode) via _file_id rather than by name, and renames a surviving entry to the case this run produced with os.replace. Because any name reaching a produced file's inode counts as that page, symlinked and hard-linked aliases go through the same keep-or-rename path, while unstat-able paths such as dangling symlinks are treated as orphans and unlinked. Tests simulate a case-insensitive filesystem with a symlink stand-in and confirm the old page is still dropped on a case-sensitive one.
Worth a look
- Orphan sweep can turn a produced article into a self-referential symlink —
graphify/wiki.py:467· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 306 functions depend on the 25 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
to_wiki()— 50 callers, 9 callees
Verification — 306 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 85 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
6 of 433 test file(s) selected (1%) via static blast radius.
tests/test_export_idempotent_writes.py— impacttests/test_export_path_length.py— impacttests/test_wiki.py— impacttests/test_wiki_case_only_relabel.py— impact, changed-testtests/test_wiki_link_filename_parity.py— impacttests/test_wiki_truncation_indicator.py— impact
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
Could not verify: Could not verify to\_wiki.
The verifier did not have enough to check to\_wiki, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 225 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly TypeError — names the real obstacle, not a sampling gap)
· 1 more finding(s) on lines outside this diff (see the check run).
Fixes #4508. A community relabelled only by case keeps its wiki article on case-insensitive filesystems.
Summary
On APFS (macOS) and NTFS (Windows),
groups.mdandGroups.mdare one file. When a community's label changes fromgroupstoGroups, the export writes into the existing entry, and the entry keeps its old case. The end-of-run orphan sweep compared names case-sensitively, so it deleted the page the run had just written.flowchart LR subgraph Before B1["write Groups.md<br/>(lands in groups.md)"] --> B2{"sweep: 'groups.md' in produced?"} B2 -- "no (case differs)" --> B3["unlink groups.md<br/>index.md links to missing file"] end subgraph After A1["write Groups.md<br/>(lands in groups.md)"] --> A2{"sweep: same device+inode<br/>as a produced page?"} A2 -- yes --> A3["keep, rename to Groups.md"] A2 -- no --> A4["unlink stale page"] endThe sweep now matches files by identity (device and inode) instead of by name. A page this run wrote is kept, and its entry is renamed to the produced case. A stale page that is a separate file is still removed. Case-folding the names was the other option in the issue. It was rejected because on Linux
groups.mdandGroups.mdare two real files, so folding would keep a stale page.Changed:
graphify/wiki.py(the sweep block plus a_file_idhelper, 21 lines added, 1 removed). New:tests/test_wiki_case_only_relabel.py(2 tests).Evidence
to_wikirelabelgroups→Groupson upstreamv8:['Groups.md', 'index.md', 'other.md'], butGroups.mdis not a readable file.index.mdlinks to it.The test
test_case_only_relabel_keeps_article_on_case_insensitive_fsfails withAssertionErroronGroups.mdis_file().Groups.mdis readable andindex.mdlinks to it. Test passes.The case-insensitive test simulates APFS and NTFS with a symlink, because the test machine runs Linux. The test helper
_case_insensitive_writedocuments this.Merge Danger
Door: two-way. The change touches only the orphan sweep. No file format, schema or cache key changes. Reverting restores the name-based sweep.
Blast radius: wiki export (
to_wiki). It runs on everygraphifyexport that writes a wiki. Output is unchanged unless a case-only relabel happens. The sweep now callsstaton each*.mdin the wiki folder, which is one extra call per page. A stat failure on a dangling symlink still removes the link as before.What does this PR do?
Fixes #4508.
On a case-insensitive filesystem, a relabel that changes only case used to delete the new article and leave
index.mdpointing at it. The sweep now keeps any page this run wrote, even when its on-disk name has the old case, and renames the entry to the new case.Type of change
Verification & Invariants
Invariant: after an export, every page
index.mdlinks to exists, and the sweep never deletes a page the run wrote.v8and passes here.How was this tested?
Limitations
st_inovalues were not checked on Python 3.14. On Windows the sweep relies on device and inode numbers that Python reports for each file.to_obsidianhas a similar case-only collision (to_obsidian: case-only filename collisions silently overwrite node notes on case-insensitive filesystems #2650). This PR does not change it.Graphify-specific checklist