Repository navigation
Description
Pre-flight checks
- I have checked the Troubleshooting section in the README
What happened?
Node ID collisions silently drop nodes on documentation-heavy corpora
Summary
On a 474-file Markdown corpus, graphify extract resolved 18 distinct node-ID collisions by silently dropping one node each. The IDs in question are minted from a referenced document's path while the node carries the citing document's source_file, so two unrelated files legitimately produce the same ID and the loser is lost.
The workaround the warning itself recommends — graphify extract per subfolder + graphify merge-graphs — does not fully fix it. Splitting by top-level folder still left 7 collisions inside a single subtree, which only cleared after a second, manual recursion. There is no file-level extraction mode to fall back on.
Environment
- graphify
0.9.94(installed from source inpython:3.12-slim,pip install ".[mcp,openai]") - Backend:
deepseek/deepseek-flash - Corpus: 474 Markdown files (~4.8 MB), 470 docs + 4 code files
- Platform: macOS (Docker Desktop, arm64)
Reproduction
Any corpus where document A links to or cites document B in another folder reproduces this, because A mints a node whose ID is derived from B's path.
docker run --rm --entrypoint graphify -e DEEPSEEK_API_KEY \
-v /path/to/docs:/work graphify:extract extract /workObserved collisions
Real examples from the run:
WARNING: node 'specifications_20_architecture_operational_logging_document'
is minted by two different files — keeping 'Logging' from
'specifications/20-architecture/delivery/change-policy.md',
dropping 'Logging specification' from '.github/instructions/rust.instructions.md'
WARNING: node 'functional_agent_runtime_doc'
is minted by two different files — keeping 'Agent runtime' from
'functional/agents/agent-operator.md',
dropping 'Agent Runtime and Subagent Contract (referenced)' from
'delivery/developer-interaction.md'
WARNING: node 'company_license_schedule_c'
is minted by two different files — keeping 'Schedule C - Support' from
'company/license.md',
dropping 'Schedule C - Support' from 'company/license-schedule-c.md'
The core defect
Look at the surviving node for the first example:
{
"id": "specifications_20_architecture_operational_logging_document",
"label": "Logging",
"file_type": "document",
"source_file": "specifications/20-architecture/delivery/change-policy.md"
}The ID says .../operational/logging, but source_file says .../delivery/change-policy.md. The node was minted from a reference to operational/logging.md and never got the identity of the file it actually came from.
So:
- A reference stub is minted with the target's path in its ID but the citing file's
source_file. - When the real target document is extracted, it mints the same ID.
- Dedup keeps one and drops the other — and in this case it kept the stub whose
source_filecontradicts its own ID, not the defining document.
That last point is the sharpest bug: the survivor is the wrong node. A node whose source_file disagrees with its ID should lose to one where they agree.
Why the documented workaround is insufficient
The warning says: "run 'graphify extract' per subfolder and merge with 'graphify merge-graphs'."
merge-graphs correctly prefixes IDs per input (repo::id), so merged IDs are unique — that part works. But the loss happens inside each subfolder's own dedup pass, before the merge:
| Grouping | Collisions observed |
|---|---|
| Whole corpus, one run | 11 distinct IDs (enumerated from the semantic cache) |
18 folder groups (specifications split by subfolder, company split per file) |
7 more, all inside specifications/20-architecture |
| + 8 subfolder groups for that subtree | 0 |
18 distinct colliding IDs in total.
The 7 extra ones are instructive: they did not appear in the whole-corpus run at all. Per-folder chunking changes which neighbours the model sees, so it emits reference stubs it had not emitted before. Collision count is therefore not stable across groupings — you cannot verify a corpus is clean by checking one configuration. Reaching zero required hand-inspecting each round's warnings and recursing manually; nothing in the tooling detects that a group is still internally lossy, and a lossy run still exits 0.
Two further gaps make the workaround harder than it should be:
- File-level extraction is not supported.
graphify extract /work/README.mdfails withNot a directory, even though a single file is a perfectly valid extraction unit. This is the natural granularity when two files in the same folder collide (thecompany/license.mdcase above). - Symlinks are not followed, so you cannot assemble a synthetic "group" directory of links; I had to physically copy files into a mirror tree (and preserve their relative paths so
source_filestayed correct).
Impact
- Silent data loss at the node level: 18 nodes dropped, and with them their edges. The run reports success.
- The surviving node can be the wrong one (stub over definition), corrupting
source_fileprovenance for that entity. - Affects documentation corpora specifically, where cross-references are the norm — i.e. the exact input graphify is marketed for.
- Only surfaces as a stderr
WARNING; nothing in the exit code or summary line reflects it.
Suggested fixes
- Don't mint a node for a cross-document reference. Emit an edge to the target's own node when it exists, or give the stub an ID that encodes the citing file (
<citing>__ref__<target>), so it can never collide with the definition. - Prefer the defining node in dedup. When IDs collide, prefer the node whose
source_filematches the path segment embedded in the ID; treat a node whosesource_filecontradicts its ID as the loser. - Report collisions in the run summary, not just stderr — e.g.
18 node-ID collisions resolved by dropping nodes; re-run per folder to keep them. A non-zero count currently looks identical to a clean run. - Add an extraction-unit flag (
--unit=folder|file) so the recommended workaround is expressible without shell scripting, and/or--id-namespace=<tag>to prefix IDs within a single run. - If neither is done, at least follow symlinks so group directories can be assembled without copying.
Workaround used
18 folder groups (with specifications and company split further), 8 additional groups for the specifications/20-architecture subtree, then merge-graphs over 25 graphs:
| Single run | Per-folder + merge | |
|---|---|---|
| Nodes | 2,692 | 3,504 |
| Edges | 4,490 | 5,466 |
| Duplicate IDs | 0 | 0 |
| Node-ID collision warnings | 18 | 0 |
Merge dropped 4 nodes versus the sum of its inputs; those are external stubs (stdlib/third-party), which prefix_graph_for_global intentionally leaves unprefixed so they unify across inputs. That is expected behavior, not a collision.
Activity
github-actions commentedon Oct 24, 2026
Thanks for opening this issue, @snapp-kenya. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
BreBryBro commentedon Oct 29, 2026
Two more data points from graphify 0.9.97 (a newer release than the 0.9.94 in the report), on a mixed code + docs repo with about 9,200 source files and an Anthropic backend through the Message Batches API. The run emitted 4
minted by two different fileswarnings. They show two distinct mechanisms, and the second one is not a cross-reference stub.1. Same shape as your
company/license.mdvslicense-schedule-c.mdexample: a filename stem that is a prefix of another.Path stem
docs_prds_prd_1572+ entitygov_actor_integrity_engineproduces the same string as path stemdocs_prds_prd_1572_gov_actor_integrity_engine+ the file's own title entity. Joining with_is not injective when one stem is a prefix of another. Both are real defining documents, so neither is a stub and a "prefer the defining file" rule (#4743) cannot choose between them. Only a non-ambiguous separator or a salt can.2. Semantic ids with no path prefix at all. Three of the four look like this:
causal_use_warningandforbidden_token_lintbehave the same way, with the same two files. In each case the model emitted the bare constant name as the id. In the same graph, a sibling ADR's node for the same concept was path-qualified (docs_adr_<C>_..._min_sample_n_floor). So qualification depends on what the model returns, and nothing re-qualifies a bare id afterwards. The ids carry no path, so they are not the #4281 case, which drops only the directory. #4281's path-qualifying pass keys on a shorter path stem and would not apply to these, as far as I can tell.Here B is a newer ADR that restates A's constants. Whether one shared node is the right answer is arguable: they are the same constant. But the loser's label carries information the survivor lacks (
/ INCONCLUSIVE), and the drop is silent apart from stderr.Counts: the run had 4 collisions and 654
extracted twice from '<same file>' under different labelsnotes. The 654 are same-file and much less concerning.Suggestions, in addition to the ones in the report:
source_filestem before dedup, rather than relying on the model to emit a qualified id.__) between the path stem and the entity, or salt on collision as the AST tier already does for class ids (JS/TS/Python: distinct same-file symbols still collapse after ID normalization in v0.9.45 #2810 in the cache changelog).CBEPX commentedon Nov 10, 2026
A related case still reproduces in
graphifyy==0.9.104: two slices of one file can emit a definition and a marked reference stub with the same ID.The same-file case can lose substantive information. This synthetic reproducer needs no model, credentials, or source repository:
The assertion fails. Both input orders select
Readonly role (reference only)and remove the permission details and approval condition._namespace_reference_stub_collisionsrequires at least two distinctsource_filevalues. It does not protect different slices of the same file._collision_rankthen favors the shorter label.This also occurred in a real extraction from a split YAML file. A separate validation guard rejected the duplicate IDs before publication. Direct native dedup of that retained result selected the stub over the detailed definition.
A possible fix is to retain fragment identity until collision resolution. Preserve each fragment's node attributes and rewire its edges and hyperedges together. Merely choosing the first or shortest label can discard conditions.
I tested a local wrapper workaround with fragment-scoped IDs. Native CLI cold and warm runs preserve both labels and their relationships. This is not an upstream patch.
BreBryBro commentedon Nov 10, 2026
A correction to our 2026-10-29 comment. There we called our 654 same-file
extracted twice from '<same file>' under different labelsnotes "much less concerning". Measured against CBEPX's same-file case, that judgment was wrong.Reproducer on our build version. We ran CBEPX's model-free reproducer unchanged on
graphifyy==0.9.97, the version our graph was built with. It fails the same way: the reference stub wins in both input orders.A variant with no stub marker fails too: two plain same-file definitions with the same id, one with a longer, more detailed label. The shorter label is kept in both input orders. So in 0.9.97 the same-file path loses information even without
graphify_reference_stub.Our 654 notes, counted from the run's stderr (all 654 parsed):
The notes come from 106 distinct files, mostly Markdown (570), then HTML (35), text (27) and PDF (22). So on same-file collisions the shorter label wins every time, and in about a quarter of cases what is dropped is substantially longer.
This supports keeping fragment identity until collision resolution, as proposed above. A tie-break of "shortest label" (or "first seen") cannot tell a qualifier-bearing definition from a terse duplicate.