Skip to content

fix(watch): preserve semantic edges of re-extracted sources (#1865)#1868

Open
xor-xe wants to merge 1 commit into
Graphify-Labs:v8from
xor-xe:fix/1865-semantic-edge-eviction
Open

fix(watch): preserve semantic edges of re-extracted sources (#1865)#1868
xor-xe wants to merge 1 commit into
Graphify-Labs:v8from
xor-xe:fix/1865-semantic-edge-eviction

Conversation

@xor-xe

@xor-xe xor-xe commented Jul 13, 2026

Copy link
Copy Markdown

Fixes #1865

What was broken: A full graphify update (and the post-checkout hook) silently evicted LLM-extracted semantic edges (semantically_similar_to, …) whose source_file is a document that also has an AST extractor (.md, .mdx, .qmd). Concept nodes survived; the edges connecting them were dropped, and since the graph grew overall the shrink guard never fired.

Root cause: _reconcile_existing_graph preserves nodes provenance-aware (_origin == "ast", #1116) but evicted edges purely by source_file membership in the re-extracted set. On a full rebuild that set includes every doc with an AST extractor, so semantic edges were treated as owned by an AST pass that cannot regenerate them.

Change: AST-extracted edges now carry the same _origin: "ast" marker as nodes, and rebuild-driven edge eviction only claims that tier — a re-extraction replaces a source's AST edges while its semantic edges survive until a semantic re-extraction supersedes them. Deletion-driven eviction stays provenance-blind, so edges of deleted or excluded sources are still purged. graph.json already persists _-prefixed edge attrs (_src/_tgt) and to_graphml already strips them, so the marker stays internal.

Migration note: edges from graphs built before this change lack the marker; a stale AST edge from a file changed exactly once across the version boundary can linger until its source is deleted — the same trade-off the #1116 node marker made. Regenerating the graph clears it.

Testing: new regression test (full + incremental) reproducing the issue's scenario — fails on current v8, passes here — plus an assertion that stale AST-tier edges of a re-extracted source are still evicted. Full suite: 3195 passed, 3 skipped. Verified end-to-end with the issue's CLI repro.

…-Labs#1865)

A full graphify update evicted every edge whose source_file was a
re-extracted source, including LLM semantic edges (e.g.
semantically_similar_to) from Markdown docs that also have an AST
extractor. The AST pass cannot regenerate those edges, so they were
silently lost while their concept nodes survived — node eviction is
provenance-aware via _origin (Graphify-Labs#1116), edge eviction was not.

Tag AST-extracted edges with the same _origin=ast marker nodes already
carry, and scope rebuild-driven edge eviction to that tier: re-extraction
replaces a source's AST edges, while its semantic edges survive until a
semantic re-extraction supersedes them. Deletion-driven eviction stays
provenance-blind, so edges of deleted or excluded sources are still
purged regardless of tier.

Edges from graphs built before this change lack the marker; a stale
AST edge from a file changed exactly once between the old and new
version can linger until its source is deleted — the same migration
trade-off the Graphify-Labs#1116 node marker made.
@rickgonzalez

Copy link
Copy Markdown

An explanation of this PR using Lenzon - hope that it helps explain this clearly. https://www.lenzon.ai/viewer/cmrjtm9ky000codzhxj2cbext?voice=google-chirp3

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Full graphify update silently evicts LLM semantic edges from re-extracted Markdown/doc sources (edge eviction is provenance-blind)

2 participants