You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
watch._rebuild_code produces a ~4× bloated graph vs graphify . --update — AST-scans Markdown docs, then merges preserved semantic nodes on top #1915
graphify.watch._rebuild_code (invoked by the git hooks that graphify hook install generates for post-commit and post-checkout) produces a structurally different graph than the public graphify . --update CLI — bloated by ~4× on a mid-size corpus. This means every commit silently leaves an inconsistent, bloated graphify-out/ in the working tree.
Repro (this repo)
Corpus: 369 files, 391k words (188 code + 181 docs + some SVGs). Curated semantic layer already cached in graphify-out/cache/ (243 files).
Post-commit hook rebuild (_rebuild_code via graphify hook install) → 8359 nodes / 9561 edges / 33 hyperedges. ❌ 4.4× the size. Also exceeds the 5000-node HTML viz limit, so graph.html gets deleted on every commit.
Root cause (as I read it)
In graphify/watch.py around lines 822–829:
detected=detect(watch_path, follow_symlinks=follow_symlinks)
code_files= [Path(f) forfindetected['files']['code']]
# Include document files that have AST extractors (e.g. .md, .mdx, .qmd)fordoc_fileindetected['files'].get('document', []):
p=Path(doc_file)
if_get_extractor(p) isnotNone:
code_files.append(p)
Every .md file with a tree-sitter grammar gets AST-extracted into the "code" side. Then the preservation logic at lines 467–485 keeps the existing semantic doc nodes on top, so the final graph contains both: the semantic concept nodes we curated AND thousands of tree-sitter Markdown paragraph/header nodes. That's the ~4× bloat.
By contrast, graphify . --update (via graphify/extract.py's incremental path) reads the semantic cache correctly, doesn't re-tree-sitter documents when they already have cached semantic extraction, and produces the shape the graph was originally built as.
Expected
Either:
_rebuild_code should honor the semantic cache the same way graphify . --update does — if a document has cached semantic nodes, don't AST-tree-sitter it as well.
Or: graphify hook install should generate hooks that call graphify . --update --no-viz instead of the internal _rebuild_code, so authors get the same graph shape from hooks as they do from manual rebuilds.
Impact
Any repo using graphify hook install gets bloated graphs on every commit, then either commits the bloat or has to git checkout -- graphify-out/ after every commit.
On repos where the initial graph was <5000 nodes but the bloated rebuild exceeds it, graph.html gets deleted every commit — surprising and disruptive.
The "freshness contract" (post-commit rebuild trails the committed graph by one commit) doesn't actually hold in shape, only in file existence.
Workaround (what I ended up shipping)
Replaced the graphify-installed hook scripts with a small wrapper that calls the public CLI:
# .husky/post-commit (37 lines, was ~200)# ...standard guards for rebase/merge/SKIP_HOOK/graph-only-commits...
nohup graphify . --update --no-viz >>"$LOG"2>&1&
Fixed on v8 in 76f5bc9 (ships in 0.9.17). _rebuild_code no longer AST-quick-scans a document that already has semantic nodes (they become its sole representation), so docs are no longer doubly represented; docs with no semantic layer still get the quick-scan, incremental rebuilds preserve semantic nodes, and previously-bloated graphs self-heal on the next full rebuild.
Activity
fix(watch): stop AST-quick-scanning docs that already have semantic n…
docs(changelog): record #1894(PR-1) #1916 #1915 #1912 in unreleased 0…
safishamsi commentedon Jul 15, 2026
Fixed on v8 in 76f5bc9 (ships in 0.9.17). _rebuild_code no longer AST-quick-scans a document that already has semantic nodes (they become its sole representation), so docs are no longer doubly represented; docs with no semantic layer still get the quick-scan, incremental rebuilds preserve semantic nodes, and previously-bloated graphs self-heal on the next full rebuild.
Squashed commit of the following:
fix(watch): stop AST-quick-scanning docs that already have semantic n…
docs(changelog): record Graphify-Labs#1894(PR-1) Graphify-Labs#1916 G…
merge: backport upstream graph-integrity fixes (Graphify-Labs#1795 Gr…
test(watch): lock the Graphify-Labs#1915 gate for semantic-backed pap…