Repository navigation
Description
Version: graphifyy 0.9.52 (PyPI), source verified against tag v0.9.52 · Type: bug / silent data loss
Summary
When an incremental graphify extract re-extracts a changed doc and the semantic chunk succeeds — valid JSON, nothing hollow, nothing truncated, the file covered by ≥ 1 node — but returns fewer or renamed doc nodes than the prior build, the file's missing nodes are dropped from graph.json with exit 0 and no warning beyond the informational Replaced N node(s) line. On the default flag set (dedup on, no --force, no --allow-partial), none of the existing guards is consulted for this write — including the #479 count comparison, which in the repro below would have refused the write had it been asked.
This is the quiet middle of the spectrum #3105 closed the loud end of: that fix arms the shrink guard for hollow/unparseable/omitted chunks, but a chunk that under-produces plausibly is a successful chunk by every check the pipeline applies.
Repro (deterministic, no API key)
Self-contained script — writes a 5-file corpus (3 small code files, 2 markdown docs), a deterministic OpenAI-compatible stub backend on 127.0.0.1:8973, installs graphifyy[openai]==0.9.52 into an isolated venv, and runs graphify extract twice with default flags:
bash graphify_silent_doc_loss_repro.sh # needs: bash, python3, uv
Steps it performs:
- Run 1 — full build. The stub answers the semantic pass with 6 nodes for
ARCHITECTURE.md, 5 forOPERATIONS.md, plus 3 cross-file edges fromOPERATIONS.md's concepts intoARCHITECTURE.md's. Result: 22 nodes, 29 edges, 11 semantic doc nodes. - Trivial edit — append a
_Last reviewed: 2026-08-29._line toARCHITECTURE.md. - Run 2 — same command. Incremental scan re-dispatches only
ARCHITECTURE.md. The stub now models the ordinary nondeterministic under-extraction: a valid, well-formed response with 2 nodes for the file — the surviving concept renamed (architecture_exponential_backoff→architecture_backoff). The chunk reportschunk 1/1 done; the file is covered; nothing is hollow, truncated, or omitted.
Observed (run 2):
run 2 exit code: 0
stderr, in full:
[graphify] Replaced 6 node(s) from re-extracted source file(s).
total nodes: 22 -> 18
total edges: 29 -> 21
semantic doc nodes: 11 -> 7
semantic doc nodes LOST (5):
- architecture_exponential_backoff (ARCHITECTURE.md)
- architecture_json_result_document (ARCHITECTURE.md)
- architecture_operator_escalation (ARCHITECTURE.md)
- architecture_run_context (ARCHITECTURE.md)
- architecture_startup_configuration (ARCHITECTURE.md)
edges that vanished with them: 9 — including all 3 cross-file edges
attributed to OPERATIONS.md, a file this run never touched:
- operations_deploy_healthiness -[references]-> architecture_run_context
- operations_error_stream -[references]-> architecture_operator_escalation
- operations_last_good_run -[references]-> architecture_exponential_backoff
The stub is a stand-in for behavior the tracker has already documented in real models: #3105's originating run went 570 → 111 nodes on well-formed responses, #3090 measured 28 per-file collapse episodes across 11 re-indexes, and I have hit 75 → 49 doc nodes on a one-line edit of a project CLAUDE.md (the run behind the PR linked at the end).
Why each existing guard misses it (v0.9.52 source)
build_merge's identity guard (#479, reworked in #2497) is gated if had_graph and not dedup: (graphify/build.py:1960) and dedup defaults to True (build.py:1632), so on the default path it never runs. Even with --no-dedup, _explained excuses every lost node whose source was re-extracted this run in the same tier (build.py:1983–1990) — the comment above it records this as an accepted residual tradeoff, deferring the under-production case to the extraction layer's incomplete-build guard. Which brings us to:
The #3105 completeness check (graphify/cli.py:3813–3842) arms _extraction_incomplete only for crashed chunks, partially-failed chunk counts, uncovered_files (a dispatched file with zero returned nodes), and truncated/hollow chunks. A successful chunk returning 2 nodes where the prior build had 6 trips none of those — this run is complete by its definition.
The to_json count backstop (#479, graphify/export.py:308–321) is then bypassed entirely: a complete extraction sets _force_write = True (cli.py:4240) and to_json(..., force=True) skips the comparison. The bypass matters concretely here — the repro's write is a strict net shrink (22 → 18) that the count guard would have refused had it been consulted. And for the variant where the re-extract returns the same count under different IDs, the count guard couldn't see it even when consulted — the unit critiques in #3090 and #2229 apply.
watch._check_shrink — the source-aware guard on the watch/update path — first gates on net count (graphify/watch.py:1125), so a rename-neutral loss never reaches its identity diff, and when it does run, losses from rebuilt_sources are "accounted" unless the file's extraction failed (watch.py:1132–1140). A successful re-extract is in rebuilt_sources and not in failed_sources by definition.
The compounding factor: run 2 stamps the manifest, so nothing ever re-dispatches the file. The loss is permanent until a human notices the graph can no longer answer something it used to — which, for cross-file edges from files the run never touched, is exactly the kind of degradation an incremental user has no reason to go looking for.
Relation to open neighbours
#3090 and #2229 critique the count guard's unit (per-file vs. total; per-layer vs. total) in scenarios where the guard runs. This report is about the gating: on the default incremental path the guard is not consulted at all, and the guards that do run check completeness, not fidelity. #1652 asks for adjacent tooling (dry-run, degree-drop alerts). Fixing any one of those would not close this path; closing this path would make those checks reachable.
Closing
PR #2162 implements one shape of guard for exactly this class — a skill-level mandatory-ID gate for re-extracted docs on --update (rebased; content unchanged since 2026-08-10). But the mechanism matters less than the property: on the default path, a lost doc node should be either explained or refused. An identity-diff before the write, an opt-in strictness flag, or a config default would each close it, and I'm glad to rework the PR toward whichever shape fits — same offer as before.
Activity
fix: protect against unverified semantic node loss (#3203)
refactor(cli): factor the duplicated unverified-semantic-shrink block…
chore: bump to 0.9.53
safishamsi commentedon Aug 30, 2026
Fixed in v0.9.53: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.53. Closing as resolved.
AirRocker commentedon Aug 31, 2026
Verified on 0.9.53 — thanks for the fast turnaround.
Re-ran the gist repro pinned to
graphifyy==0.9.53: run 2 now exits 1 withunverified semantic shrink detected for 'ARCHITECTURE.md' (6 -> 2 nodes), the write is refused,graph.jsonis untouched, and the file's manifest stamp is withheld so it re-dispatches next run. The same script on 0.9.52 lost 5 nodes and 9 edges with exit 0.One measured residual, offered as a data point rather than a bug report: a count-neutral variant (the stub returns the same 6 nodes for the file, all 5 concepts under new IDs) still writes on 0.9.53 — exit 0, 22 → 22 nodes, 29 → 26 edges, the same 9 edges gone, including the 3 cross-file edges attributed to
OPERATIONS.md, a file the run never touched. I seetest_build_merge_equal_count_different_ids_not_flaggedmarks that shape as by design, so this is for the record only.If an identity-level comparison is ever wanted for that residual, #2162 remains available in whatever shape fits — no rush.
Let a self explained semantic shrink proceed
Update shrink guard tests for the new behavior
Let a self explained semantic shrink proceed
Update shrink guard tests for the new behavior
fix(cache): stop a degraded semantic entry from pinning the corpus (#…
fix(export): don't count replaced or pruned sources as lost in the wr…
extract: сообщения shrink-guard'ов не вводят в заблуждение