Skip to content

fix(lens): skip ghost page nodes for unresolved wikilinks #59

Description

@MarcoPorcellato

Bug Description

NetworkXVisitor.visit_node in lens.py always adds a graph node for every wikilink ref, even when the target page does not exist in the vault. LENS topology and visualize deep stats then count phantom pages (e.g. GhostPage linked from Src but never created on disk).

Steps to Reproduce

# Minimal vault: pages/Src.md contains "- see [[GhostPage]]"
from logseq_matryca_parser.graph import LogseqGraph
from logseq_matryca_parser.lens import GraphVisualizer

g = LogseqGraph.load_directory(graph_root)
viz = GraphVisualizer(list(g.iter_canonical_pages()), graph=g)
viz.build_network()
assert "GhostPage" in viz.graph.nodes  # phantom node today

Expected Behavior

Unresolved wikilinks should not create standalone page nodes (or should be tagged distinctly as unresolved and excluded from page counts / largest-pages stats).

Actual Behavior

visit_node calls add_node(ref) for every ref when get_page(ref) returns None, inflating node/edge counts and misleading LENS output.

Environment & Version

logseq-matryca-parser main (v1.4.1+), Python 3.12+

Context

Identified via local code study (wave 9). Related to BUG-020 in docs/BUG_HUNT_REPORT.md — alias canonicalization was fixed in v1.4.0, but missing-target wikilinks still create ghosts.

Suggested fix

  • When LogseqGraph is provided, only add page-group nodes for refs that resolve via get_page
  • Add regression test in tests/test_lens.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention or skill is welcome

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions