Skip to content

graphify update drops authored [[wikilinks]] whose target document is semantic-backed #3190

Closed

Description

@logan683

Summary

When a Markdown document already carries semantic (LLM) nodes, #1915 and its #1954 follow-up correctly
exclude it from AST quick-scan, so it never receives a canonical page node. But [[wikilinks]] in
other notes
still resolve to that canonical page id — which does not exist — and full reconcile
discards the edge silently.

Nothing is missing from the graph: the target is present as its preserved semantic document node,
under a different id. There is no mapping from the canonical page id to that preserved representative.

Environment

graphify 0.9.51, commit 281ccaa4ff38aaef3f19e823fb7645e19b28f591 (unmodified)
Python 3.13.14 · tree-sitter 0.25.2 · networkx 3.6.1 · Windows 11
run as: graphify update <root>

Expected vs actual

Expected: a uniquely resolvable [[link]] to an existing document yields a references edge to
that document.
Actual: if the target is semantic-backed, no edge is produced and nothing is reported.

Mechanism

Extraction resolves the link to the canonical page id for that path. That node does not exist, because
the target is semantic-backed and was never AST-quick-scanned. Reconcile then discards the edge —
silently, and without leaving a dangling endpoint behind, which is why aggregate integrity checks
stay clean.

Reproduce

root/
  hub.md      # contains: [[topic]]
  topic.md    # already carries semantic (LLM) nodes in the existing graph

graphify update root/ → the hub.md → topic.md references edge is absent, while topic.md's
semantic document node is present.

Nine self-contained tests covering this and the surrounding contract are in the linked PR; three
fail on unmodified 281ccaa4.

Why it is easy to miss

Node, semantic and hyperedge counts are all preserved, and no dangling endpoint appears. On one
~400-file corpus the link total was identical before and after — 82 edges removed, 82 added — so
every aggregate check passed. The loss is visible only by diffing edge identity, or by resolving
authored links against the graph.

Measured impact

404-file Markdown corpus, exhaustive sweep of 1,868 authored resolvable link pairs against the
post-update graph:

sweep-resolved references remainder
official 281ccaa4 1,739 129
with the linked fix 1,834 34

The remaining 34 are not losses: 27 have no unique representative and retain their existing
edges; 7 are already connected by a semantic relation, which a simple (non-multi) Graph cannot hold
in parallel with references. Disconnected authored pairs: 0.

Suggested fix

For a fresh references edge whose canonical page target is absent, re-point to a unique preserved
representative for the same normalized source, in this priority:

  1. exact canonical id
  2. unique node_kind=page
  3. unique non-AST file_type=document
  4. otherwise no mapping — report ambiguity

Never map concept-only sources, ambiguous sources, nonexistent or already-valid targets, or
non-references relations. Preserve existing edges for ambiguous targets rather than pruning them.

A tested implementation is linked.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions