graphify icon indicating copy to clipboard operation
graphify copied to clipboard

extract: LLM-omitted documents vanish silently — no dispatch/return reconciliation, no anti-regression guard (53% of docs lost even with gpt-5)

Open AndreLFSMartins opened this issue 4 months ago • 2 comments

Summary

graphify extract dispatches every detected document to the LLM but never verifies that a node came back for each one. Documents the model silently omits simply vanish from the graph — no warning, no count mismatch, no error. And unlike update, the extract path has no anti-regression guard, so the shrunken graph overwrites the good one unconditionally.

Coverage degrades with model strength, but is never complete, even with a frontier model.

Measurement

Repo: council (Python + heavy docs). detect() classifies 33 code + 265 document files. Same repo, same command, three runs:

build nodes edges files covered .md covered (of 265 docs)
existing graph (built via the Claude Code skill) 3,085 3,673 229 166
extract --backend openai --model gpt-4.1-mini 1,679 2,455 118 47
extract --backend openai --model gpt-5 2,135 3,167 276 125

So with gpt-5 — the strongest model available — 140 of 265 detected documents (53%) produced no node at all. The run log is clean: zero chunk ... failed, zero invalid JSON, zero truncation retries. The model simply didn't emit nodes for them, and graphify accepted that silently.

The dropped files are ordinary tracked sources — README.md, CLAUDE.md, AGENTS.md, PLAN.md, docs/objectives.md. All exist on disk; only 2 of the missing set are gitignored. Code coverage is unaffected (AST is deterministic), which is what makes this hard to notice: the graph still answers code queries correctly while half the documentation is gone.

Why this is a bug and not just "use a better model"

  1. No dispatch/return reconciliation. graphify knows it sent N documents to the LLM. It knows it got M nodes back. It never compares N to M. A file that goes in and produces nothing should at minimum be logged.
  2. No guard on the extract path. The guard that protects update — WARNING: new graph has N nodes but existing graph.json has M. Refusing to overwrite. — does not fire here. extract overwrites regardless of how much coverage was lost.
  3. The failure is invisible and cumulative. A user rebuilding a docs-heavy repo loses half their document graph and has no signal that it happened.

Suggested fixes

  • After the semantic pass, diff the dispatched file set against the file set present in the returned nodes; warn (or fail) on the delta. Even a one-line N documents produced no nodes: ... would have made this self-evident.
  • Extend the existing anti-regression guard to extract, keyed on covered source files, not just node count.
  • Consider making document nodes deterministic (the update quick-scan already does this correctly for .md) and letting the LLM pass add semantic edges on top, rather than being the sole source of document nodes. That would make document coverage independent of model quality. Cf. #1799.

Notes

  • I originally suspected the scan was at fault. It isn't: detect() correctly reports all 265 documents. The loss happens between dispatch and merge.
  • Related: #1865 (a full update evicts semantic edges from Markdown — this issue is about losing the document nodes, on the extract path).
  • The Claude Code skill path produces materially better document coverage (166/265) than any CLI backend I tested. That gap is itself worth a look — the CLI is the path CI and scripts use.

Environment

graphifyy==0.9.15 (uv tool), macOS arm64, Python 3.12. Backends tested: openai with gpt-4.1-mini and gpt-5.

AndreLFSMartins avatar Jul 14 '26 15:07 AndreLFSMartins

Follow-up with a control I should have run before filing: the project's own deterministic path covers the documents that the LLM path loses.

Same repo (council, 33 code + 265 documents), clean clone, no prior graph:

build nodes files .md .py LLM cost
graphify update 2,767 188 159 27 no $0
extract --model gpt-5 2,135 276 125 71 yes ~$3–4
extract --model gpt-4.1-mini 1,679 118 47 42 yes ~$0.08

update's markdown quick-scan (file → heading → link) reaches 159 of 265 documents with no model at all, while extract with a frontier model reaches 125. So this isn't "the LLM needs to be better" — the deterministic extractor that already ships in graphify outperforms the LLM path on document coverage, for free.

That strengthens the third suggestion in the issue body: make document nodes deterministic (reuse the update quick-scan) and let the semantic pass only add edges on top. Document coverage would stop depending on model quality, and the extract/update divergence (#1799) would collapse.

Also worth noting for anyone hitting this: update does have the anti-regression guard and extract does not, so the safe path today is to never run extract over an existing graph.

AndreLFSMartins avatar Jul 14 '26 15:07 AndreLFSMartins

Fixed (visibility guard) in a4ab6ed (ships in 0.9.16): extract now reconciles dispatched vs returned files and warns loudly on silently-omitted documents. The larger fix (route docs through the deterministic extractor for a guaranteed file node) is tracked separately.

safishamsi avatar Jul 14 '26 23:07 safishamsi