graphify icon indicating copy to clipboard operation
graphify copied to clipboard

Same file, two path forms: absolute source_file from semantic extraction collides with the relative AST id and the semantic node is dropped

Open febryo-sc opened this issue 2 months ago • 1 comments

Summary

A third trigger for the minted by two different files warning, distinct from #3322 (name normalization within a file) and #3352 (two files mentioning one entity): one file, two path forms. The semantic extraction prompt requires an absolute source_file, the AST layer and graph.json store repo-relative paths, and the collision check compares the raw strings — so the same file is treated as two files and one node is dropped.

Repro

Any --update run where the semantic pass re-covers a file the AST layer already produced heading nodes for. references/extraction-spec.md instructs each subagent:

set source_file to the path of the originating file EXACTLY as it appears in FILE_LIST — verbatim and absolute. Do NOT shorten to a basename, do NOT re-relativize

while the AST layer writes docs/ARCHITECTURE.md. Both mint docs_architecture_retrieval for the same heading. build_merge then reports:

[graphify] WARNING: node 'docs_architecture_retrieval' is minted by two different files —
keeping 'Retrieval' from 'docs/ARCHITECTURE.md',
dropping 'Hybrid Retrieval' from '/abs/path/to/docs/ARCHITECTURE.md'.
... the dropped node is lost.

23 of these in a single incremental update over a ~5,600-node TypeScript corpus (17 changed markdown files). Every one names the same file on both sides, differing only in /abs/prefix/.

Why it matters more than the node count suggests

The dropped side is the semantic node, so the surviving label is the raw heading text and the richer label plus its rationale attribute are what get discarded — Retrieval survives, Hybrid Retrieval is lost; Guardrails survives, Refusal in Two Layers, and Block-Buffered Streaming is lost. The warning's own remedy ("run graphify extract per subfolder and merge with graphify merge-graphs") does not apply, since there is only one file involved.

Suggested fix

Canonicalize source_file to the build root before the collision check, rather than after it — build_merge already takes root= and relativizes downstream, so the comparison just runs too early. Alternatively, treat two records whose canonicalized paths agree as the same file and merge their attributes (preferring the longer label / the one carrying rationale) instead of dropping one.

Version: 0.9.56, directed=False graph, build_merge via the documented --update runbook.

febryo-sc avatar Sep 10 '26 11:09 febryo-sc

Fixed in v0.9.58 by #3478 (thanks @hopstreax) — incremental merge no longer drops fields on a source_file path collision. Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.58

safishamsi avatar Sep 10 '26 22:09 safishamsi