Skip to content

Incremental rebuild silently drops 56% of edges (16 → 7) while reporting success: out-of-scope node filter and required-field check both remove edges without saying so #2276

Open

Description

@vidaunited

Summary

On a 20-file, docs-only vault, one incremental rebuild took the graph from
18 nodes / 16 edges to 20 nodes / 7 edges — node coverage improved,
but 56% of the edges disappeared. Both before and after graphs are on
disk (graphify's own dated backups), so this is a measured before/after, not
an impression.

The run reports two separate losses and exits 0:

[graphify] WARNING: dropped 9 out-of-scope node(s) attributed to file(s) not
dispatched for extraction: andrej-karpathy.md, canteen-daily-sales-anomaly-checker.md,
claude-code-routines.md, compounding-knowledge.md, graphify.md (+4 more).
The model mis-attributed them to another corpus file; they were excluded from
the graph (#1895).
[graphify] Extraction warning (7 issues): 7x missing required field 'source_file'
(e.g. Edge 0 missing required field 'source_file')
[graphify extract] wrote .../graph.json: 20 nodes, 7 edges, 13 communities

Neither warning mentions edges being removed, and the final summary line
reports the post-loss count as a plain result. Nothing in the output says the
graph just lost more than half its edges.

Why this is not one of the existing issues

I checked before filing:

Reproduction

Corpus: 20 Markdown files, no code, no PDFs. Prior graph built the day before
by the same command.

  1. Add 1 new .md, edit 2 existing .md (ordinary [[wiki links]] between them).
  2. OLLAMA_API_KEY=local graphify . --backend ollama
  3. Compare graphify-out/graph.json with the dated backup graphify writes
    under graphify-out/<YYYY-MM-DD>/.

Incremental scan reported: 0 code, 9 docs, 0 papers, 0 images changed; 11 unchanged; 0 deleted; 1 excluded → 12 files cached/unchanged, 8 re-extracted.

Measured

before (2026-07-28) after (2026-07-29)
nodes 18 20
edges 16 (all references, all with source_file) 7
edges without source_file persisted 0 0
dangling edges 0 0
import json
d = json.load(open('graphify-out/graph.json'))
nodes = {n['id'] for n in d['nodes']}
print(len(d['nodes']), len(d['links']))
print(sum(1 for l in d['links'] if not l.get('source_file')))          # 0
print(sum(1 for l in d['links']
          if l['source'] not in nodes or l['target'] not in nodes))    # 0

Practical effect

The surviving 7 edges are almost entirely a star out of one hub file
(log.md → references → X). Deliberate page-to-page [[wiki links]] between
two documents edited in the same run did not survive: graphify query finds
both pages as nodes, but the relationship between them is gone. On a vault
where the whole point is cross-linking, the graph degrades to a file list with
one hub — while graphify query still answers, which is what makes it easy to
miss.

Suggested handling

Not a fix proposal, just what would have surfaced this:

  1. Report edge delta in the write summary when it is negative, e.g.
    wrote graph.json: 20 nodes, 7 edges (-9 vs base), 13 communities.
  2. When the out-of-scope node filter drops N nodes, say how many edges were
    dropped with them — the node warning currently implies the cost is N nodes.
  3. Treat an edge failing a required-field check as a warning that names the
    producing extractor and the endpoints, so it can be traced.

Environment

  • graphify 0.9.29 (uv tool install graphifyy), Python 3.11
  • Backend: ollama, qwen2.5-coder:7b, fully local
  • macOS 15 (Darwin 25.5.0), Apple Silicon
  • Corpus: 20 Markdown files (~120 KB), no code
  • Exit code: 0

Activity

  1. joriwang commented on Sep 18, 2026

    @joriwang

    A 13-rebuild longitudinal data point from a production CI pipeline, and a diagnostic blocker: graph.json has no version stamp

    Your report is a 20-file before/after. I have the same measurement across 13 consecutive incremental rebuilds over 3 months on a real corpus, which I hope is useful for judging how often this fires and what correlates with it. It also turned up a case that I think is the strongest argument for your suggestion 1: the net edge count went UP while a third of the graph's edges were being destroyed.

    Environment

    • Corporate SSOT documentation repo (robotics engineering specs), 938 files in the incremental manifest, ~96% Chinese Markdown + images, 14 Python files, 2 PDFs.
    • Latest published graph: 1,448 nodes / 1,186 links / 82 hyperedges.
    • GitLab CI runs graphify extract <root> --backend openai against an OpenAI-compatible gateway on every push to main, then commits graphify-out/ back. Every row below is a warm incremental rebuild that exited 0 and published.
    • Same measurement technique you used: graphify-out/<YYYY-MM-DD>/graph.json is graphify's own backup of the graph as it stood before that day's run overwrote it, so consecutive backup dirs are a before/after pair.

    Measured: edge retention across 13 rebuilds

    Edge set keyed on (source, target, relation). "code ids renamed" counts file_type == "code" nodes whose (source_file, label) is present in both graphs but under a different id — I added it as a version-migration probe, for reasons below.

    before → after nodes links retention lost gained code ids renamed
    06-11 → 06-12 689 → 670 267 → 306 64.0% 96 135 0/71
    06-12 → 06-15 670 → 849 306 → 410 99.0% 3 107 0/82
    06-15 → 06-25 849 → 854 410 → 414 100% 0 4 1/87
    06-25 → 07-21 854 → 873 414 → 450 93.2% 28 64 1/113
    07-21 → 07-28 873 → 892 450 → 468 100% 0 18 1/113
    07-28 → 08-05 892 → 945 468 → 548 100% 0 80 3/130
    08-05 → 08-12 945 → 961 548 → 576 65.0% 192 220 17/105
    08-12 → 08-21 961 → 1015 576 → 517 62.0% 219 160 71/95
    08-21 → 08-26 1015 → 1089 517 → 614 100% 0 97 1/95
    08-26 → 09-01 1089 → 1089 614 → 614 100% 0 0 1/95
    09-01 → 09-04 1089 → 1086 614 → 614 100% 0 0 1/95
    09-04 → 09-10 1086 → 1406 614 → 1152 100% 0 538 1/95
    09-10 → 09-12 1406 → 1407 1152 → 1152 100% 0 0 1/95

    Three of thirteen rebuilds lost edges (62–65% retention); ten retained 100%. Your −56% is therefore not an outlier — it's the same order as our three bad ones, on a corpus 70× larger.

    The row that argues for your suggestion 1 better than mine does

    08-05 → 08-12: 192 edges destroyed, 220 created, net +28. The summary line reads wrote graph.json: 961 nodes, 576 edges and the node count also rose. Every aggregate signal an operator would normally watch went up. A negative-delta report would not have fired here either, because the delta was positive — which suggests the summary needs churn, not just delta: 576 edges (+28 net, −192 dropped, +220 added).

    I broke the 192 down by endpoint fate; 38 of them have a surviving endpoint in a file whose node set is untouched and a dead endpoint in a file whose nodes were re-minted, which is #1711's exact signature. I've posted the full breakdown there rather than duplicating it.

    The diagnostic blocker: no version stamp

    I could not attribute any of the three bad rows to a cause, and I want to be explicit about that rather than imply more than I can show.

    graph.json carries built_at_commit but no graphify version. Our CI image tag was floating (…-graphify, i.e. latest) until we pinned it to 0.9.33 on 2026-08-05, so I tried to reconstruct version boundaries from CI-config git history. It isn't resolvable:

    • 08-12 → 08-21 renamed 71 of 95 code node ids while keeping labels and source_file identical (src_mujoco_builder_mujocobuilder_init → simulation_ssot_transform_xml_src_mujoco_builder_mujocobuilder_init). That is the source_file reduced to bare basename for all nodes in 0.9.16 (was relative path in 0.9.13) — breaks resolution against a code root #1941 basename→path-anchored id fix, i.e. an upgrade artifact, and it alone accounts for most of that row's 219 lost edges. Not your bug.
    • 08-05 → 08-12 renamed only 17/105 code ids but re-minted nodes in 399 files, which looks like a mass semantic re-dispatch — consistent with a prompt-fingerprint change invalidating the whole cache/semantic/p<fingerprint>/ namespace at once. Also plausibly an upgrade artifact.
    • 06-11 → 06-12 renamed zero code ids yet lost 96 edges and 19 nodes, with 485 files losing nodes and none gaining. Different signature again; I can't explain it.

    So: graphify_version in graph.json would have made this report three times shorter and actually conclusive. Without it, an operator seeing a bad row cannot tell "the tool silently ate a third of my edges" from "I upgraded and ids moved", and a maintainer receiving such a report cannot tell whether to investigate. I'd raise this to the same priority as the delta reporting.

    The control group is the useful half: after pinning the version, five consecutive rebuilds retained 100% of edges, including 09-04 → 09-10 which added 187 new documents (+320 nodes, +538 links, 0 lost). So on a pinned version, warm incremental rebuilds on this corpus do not lose edges. The losses cluster around version changes.

    Downstream-side detector

    Until the summary reports churn, this is what I settled on for CI — it uses the dated backups graphify already writes, so it costs nothing extra:

    import json, sys
    def edges(p):
        g = json.load(open(p, encoding="utf-8"))
        return {(l["source"], l["target"], l.get("relation"))
                for l in g.get("links", g.get("edges", []))}
    old, new = edges(sys.argv[1]), edges(sys.argv[2])
    if old:
        kept = len(old & new)
        print(f"edge retention {kept/len(old):.1%}  "
              f"(kept {kept}/{len(old)}, dropped {len(old-new)}, added {len(new-old)})")
        if kept / len(old) < 0.90:
            sys.exit(2)   # warn; use 1 to block the publish

    Note it has to compare set membership, not counts — our worst row had a positive count delta.

    On your three suggestions

    1. Report edge delta when negative — agreed, and per the 08-05 → 08-12 row above, negative-delta is not sufficient; churn is the signal.
    2. When the out-of-scope filter drops N nodes, say how many edges went with them — strongly agreed. In our 08-12 → 08-21 row the node warning implies a cost of N nodes while 219 edges disappeared.
    3. Name the producing extractor and endpoints for an edge failing a required-field check — agreed; we had 1 edge in the 08-05 → 08-12 row dropped with both endpoints still present in the graph, which is otherwise untraceable.
  2. omsenjalia commented on Oct 18, 2026

    @omsenjalia
    Contributor

    This looks fixed on the v8 branch by 642e4b84 (fix(extract): keep edges between kept nodes when edge source_file is undispatched (#2276)). Could a maintainer confirm and close?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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