Skip to content

fix: keep a wiki page relabelled only by case (#4508) - #4521

Open
Deepjyoti-Sarmah wants to merge 1 commit into
Graphify-Labs:v8from
Deepjyoti-Sarmah:fix/4508-wiki-case-only-sweep
Open

Deepjyoti-Sarmah wants to merge 1 commit into
Graphify-Labs:v8from
Deepjyoti-Sarmah:fix/4508-wiki-case-only-sweep

Conversation

@Deepjyoti-Sarmah

@Deepjyoti-Sarmah Deepjyoti-Sarmah commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4508. A community relabelled only by case keeps its wiki article on case-insensitive filesystems.

Summary

On APFS (macOS) and NTFS (Windows), groups.md and Groups.md are one file. When a community's label changes from groups to Groups, 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"]
  end
Loading

The 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.md and Groups.md are two real files, so folding would keep a stale page.

Changed: graphify/wiki.py (the sweep block plus a _file_id helper, 21 lines added, 1 removed). New: tests/test_wiki_case_only_relabel.py (2 tests).

Evidence

  • Before: to_wiki relabel groups → Groups on upstream v8:
    ['Groups.md', 'index.md', 'other.md'], but Groups.md is not a readable file. index.md links to it.
    The test test_case_only_relabel_keeps_article_on_case_insensitive_fs fails with AssertionError on Groups.md is_file().
  • After: same run on this branch: Groups.md is readable and index.md links to it. Test passes.
upstream v8        test_case_only_relabel_keeps_article_on_case_insensitive_fs   FAILED
                   test_case_only_relabel_drops_old_page_on_case_sensitive_fs     passed
this branch        test_case_only_relabel_keeps_article_on_case_insensitive_fs   passed
                   test_case_only_relabel_drops_old_page_on_case_sensitive_fs     passed
wiki suites (test_wiki, link_filename_parity, idempotent_writes, path_length)  70 passed, 3 skipped
full suite (tests/)                                                             8394 passed, 14 skipped, 0 failed
ruff check graphify/wiki.py + new test                                          All checks passed

The case-insensitive test simulates APFS and NTFS with a symlink, because the test machine runs Linux. The test helper _case_insensitive_write documents 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 every graphify export that writes a wiki. Output is unchanged unless a case-only relabel happens. The sweep now calls stat on each *.md in 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.md pointing 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.

  • Single-case runs are unchanged. Each produced page still gets one file.
  • A stale page that is a different file is still removed on every platform.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Tests or CI
  • Refactor
  • Security fix

Verification & Invariants

Invariant: after an export, every page index.md links to exists, and the sweep never deletes a page the run wrote.

  • Read the CONTRIBUTING.md guide.
  • Reproduced the issue and identified the invariant.
  • Made the smallest fix necessary.
  • Added a regression test that fails on upstream v8 and passes here.
  • Kept the PR description synchronized with the final implementation.
  • Documented limitations / unsupported cases explicitly.

How was this tested?

PYTHONPATH=/var/tmp/wt-4508 .venv/bin/python -m pytest -p no:cacheprovider --basetemp=/var/tmp/... -q tests/test_wiki_case_only_relabel.py
  -> 2 passed (this branch); 1 failed, 1 passed (upstream v8)
full suite: 8394 passed, 14 skipped, 0 failed

Limitations

Graphify-specific checklist

  • I updated generated skill artifacts. N/A: no skill fragments changed.
  • AST/structural extraction is deterministic. N/A: wiki export only.
  • I reviewed security implications: no shell or Python interpolation added.
  • No API keys or local-only graph data are included.
  • I disclosed AI authorship in my commit messages. N/A: no AI attribution in the commits.

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.
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Oct 17, 2026

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — impact
  • tests/test_export_path_length.py — impact
  • tests/test_wiki.py — impact
  • tests/test_wiki_case_only_relabel.py — impact, changed-test
  • tests/test_wiki_link_filename_parity.py — impact
  • tests/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).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

export wiki: a community relabelled only by case loses its article on case-insensitive filesystems (orphan sweep compares names case-sensitively)

1 participant