Skip to content

fix(wiki): keep an article labelled index from overwriting index.md - #3818

Closed
breken-ai wants to merge 1 commit into
Graphify-Labs:v8from
breken-ai:fix/wiki-index-slug-collision
Closed

breken-ai wants to merge 1 commit into
Graphify-Labs:v8from
breken-ai:fix/wiki-index-slug-collision

Conversation

@breken-ai

Copy link
Copy Markdown
Contributor

What does this PR do?

to_wiki writes index.md as the catalog, but the slug-dedup set never reserved that name. An article whose label slugs to index was written to index.md and then overwritten by the catalog. This happens with a god node labelled index() (a common web view), a community that the default hub labeler names after one, or an Index god node on a case-insensitive filesystem. The catalog entry for that article then linked back to the catalog itself ([index()](index.md)), and to_wiki still counted the lost article as written.

Reproduced end to end with a small Python project whose index() view calls four helpers, then graphify update . and graphify export wiki:

v8:  wiki/ has no article for index(); index.md lists "- [index()](index.md) — 5 connections"
fix: wiki/index_2.md holds the index() article; index.md lists "- [index()](index_2.md) — 5 connections"

Fix, in graphify/wiki.py:

  • _unique_slug's dedup set now starts with index (it is case-folded, so this also covers Index), so such an article gets index_2.md.
  • The navigation footer now links [index](index.md) directly and no longer goes through the label resolver. The resolver's hardcoded {"index": "index"} seed is removed, so a label of index resolves to its own deduplicated file. The footer text is byte-identical to before.

Type of change

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

How was this tested?

# New regression: tests/test_wiki.py::test_to_wiki_article_labelled_index_does_not_overwrite_index_md
# On v8 @ 4c735618 (before the fix): 1 failed (2 articles on disk, 3 reported; catalog links to (index.md))
# With the fix:
uv run --frozen pytest tests/test_wiki.py tests/test_wiki_link_filename_parity.py tests/test_wiki_truncation_indicator.py tests/test_export_idempotent_writes.py -q -> 55 passed

uv run --frozen pytest tests/ -q --tb=short      -> 5965 passed, 14 skipped
uv run --frozen ruff check graphify/wiki.py tests/test_wiki.py -> All checks passed

Tested on macOS with Python 3.12 (uv).

Graphify-specific checklist

  • I added or updated tests for behavior changes.
  • I updated documentation or confirmed that no documentation is needed.
  • I updated generated skill artifacts when changing their source fragments. (No skill fragments changed.)
  • I considered compatibility across supported Python versions.
  • I confirmed that no API keys, generated graph data, or local-only files are included.

This change was prepared with AI assistance (Claude) and verified with the commands above.

🤖 Generated with Claude Code

A god node labelled index() (an ordinary web view) or a community named
after one slugs to "index", so to_wiki wrote its article to index.md and
then replaced it with the catalog; the catalog entry linked back to the
catalog itself. Reserve the index slug in the dedup set, and link the
navigation footer to index.md directly so the label resolver can map an
"index" label to its own deduplicated file.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

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


Graphify review — findings

Reserves the index slug for the wiki catalog so a community or god node whose label slugs to index (e.g. a hub named index() or an Index class on a case-insensitive filesystem) gets its own file instead of being overwritten by index.md. Hardcodes the navigation footer's catalog link to index.md via _INDEX_LINK rather than routing through the label resolver, so an index-labelled article no longer links back to itself and the catalog no longer lists an entry pointing at itself. Adds test_to_wiki_article_labelled_index_does_not_overwrite_index_md covering both cases.

Worth a look

  • Removing 'index' from resolver breaks intra-article links to a community/god-node slugged 'index' — graphify/wiki.py:380 · 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 — 267 functions depend on the 70 functions this change touches.

Health — this change adds coupling hotspots:

  • new: to_wiki() — 45 callers, 8 callees
  • new: main() — 98 callers, 3 callees
  • new: dispatch_command() — 2 callers, 125 callees
  • new: test_poisoned_manifest_is_healed() — 0 callers, 6 callees

Verification — 267 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: 93 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

5 of 300 test file(s) selected (2%) via static blast radius.

  • tests/test_export_idempotent_writes.py — impact
  • tests/test_export_path_length.py — impact
  • tests/test_wiki.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.

· 4 more finding(s) on lines outside this diff (see the check run).

@breken-ai

Copy link
Copy Markdown
Contributor Author

Re the Graphify review finding "Removing 'index' from resolver breaks intra-article links to a community/god-node slugged 'index'" (graphify/wiki.py:380): I checked this and the change fixes those links. It does not break them.

used_slugs now starts with "index", so a community labelled index gets the slug index_2, and resolver.setdefault("index", "index_2") records that slug. Other articles link to it through _md_link, so they point at index_2.md. The catalog footer uses the fixed _INDEX_LINK, so it still reaches index.md.

Repro: a two-community graph labelled index and Parser, with one edge between them.

  • On this branch (aad5e0f), Parser.md has - [index](index_2.md) (1 shared connections), index.md lists [index](index_2.md), and index_2.md holds the community article.
  • On the base (4c73561), the pre-seeded {"index": "index"} mapping won the setdefault. Parser.md linked [index](index.md) to the catalog, and the community article itself was overwritten by index.md.

No code change needed.

safishamsi added a commit that referenced this pull request Sep 29, 2026
Atomic label sidecars (#3853), docx table/all-text extraction (#3833),
wiki index-collision (#3818) and escaped wikilink aliases (#3772),
community-listing real-node filter (#3836), warn-once on missing pypdf
extra (#3710), plus the --help logo banner + app.graphify.com line.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.72 (now on PyPI) via an authorship-preserving cherry-pick, so your commit keeps contributor-graph credit. Thanks @breken-ai! An article named index no longer overwrites the generated index.md hub.

Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.72

@safishamsi safishamsi closed this Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants