Extractor produces edges missing required field `source_file`
Version
0.8.38
Steps to reproduce
Run a full extraction:
graphify extract <path> --backend gemini --model gemini-3.1-flash-lite
What happened
After extraction completes, the following warning is printed:
[graphify] Extraction warning (8 issues): Edge N missing required field 'source_file'
The same warning repeats on subsequent cluster-only runs, confirming the affected edges are persisted in graph.json.
Why it matters
source_file is listed as a required field by graphify itself. Edges missing it cannot be traced back to a source location. If graphify query returns a result that traverses one of these edges, the response will have no file reference — making it harder to navigate to the relevant code.
Expected behavior
All edges produced by the extractor should have source_file populated. If an edge genuinely cannot be attributed to a source file, the warning should identify which extractor (AST or semantic LLM) produced it to help narrow down the root cause.
Environment
- OS: Windows 11
- graphify: 0.8.38
- Install method:
uv tool install graphifyy[gemini] - Graph size: 121,500 nodes, 161,975 edges (8 affected)
Fixed in 8437ef4 (branch v8).
Root cause: I audited every edge-construction site in the AST extractor - all set source_file, so the AST path is clean. The offending edges come from the semantic/LLM extractor: _parse_llm_response returns the model's JSON as-is, and when the model omits source_file on an edge nothing repairs it. build_from_json only normalized source_file when already present, so the empty field reached graph.json and validate flagged it (Edge N missing required field 'source_file') - re-flagged on every cluster-only run.
Fix: backfill source_file from the edge's source node (then target; every node reliably carries one) in build_from_json, and mirror it in the --no-cluster raw-write path which bypasses build_from_json.
Verified: a --no-cluster build now produces edges with zero missing source_file; unit test added (test_edge_missing_source_file_backfilled_from_node) plus a guard that the AST path stays clean. Full suite green (2113 passed).
Note: this is a defensive backfill since the source is external LLM output. The backfilled value is the endpoint node's file, which is the correct provenance for these relation edges.