From 2ad472b0cc18bb2fe3af087b79aff6282ad5fd8e Mon Sep 17 00:00:00 2001 From: Hugh Scott Date: Thu, 30 Apr 2026 01:01:05 -0500 Subject: [PATCH] persist manifest after _rebuild_code (fixes #538) graphify update, graphify watch, and the installed post-checkout hook all call _rebuild_code() but never call save_manifest(). On the next detect_incremental call the manifest read returns a stale baseline, so every file looks "new" and the rebuild re-fires every time. Add save_manifest(detected['files']) at the end of _rebuild_code, gated by try/except so a manifest write failure does not fail the rebuild. detected was already built at the top of the function, so this is a one-line write at no extra cost. Single edit covers three call sites: graphify update (CLI), the watch loop, and .git/hooks/post-checkout. Does not touch the skill markdown pipeline mentioned in the issue's suggested fix; that path may still need its own Step 9 patch. --- graphify/watch.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/graphify/watch.py b/graphify/watch.py index 3902a5e37..6e0f6c49d 100644 --- a/graphify/watch.py +++ b/graphify/watch.py @@ -43,7 +43,7 @@ def _rebuild_code(watch_path: Path, *, follow_symlinks: bool = False) -> bool: report_root = _report_root_label(watch_path) try: from graphify.extract import extract - from graphify.detect import detect + from graphify.detect import detect, save_manifest from graphify.build import build_from_json from graphify.cluster import cluster, score_all from graphify.analyze import god_nodes, surprising_connections, suggest_questions @@ -125,6 +125,15 @@ def _rebuild_code(watch_path: Path, *, follow_symlinks: bool = False) -> bool: if flag.exists(): flag.unlink() + # Persist manifest so detect_incremental has a fresh baseline. + # Without this, detect_incremental returns every file as "new" on + # the next call, so `graphify update` and `graphify watch` re-fire + # every time. Closes #538. + try: + save_manifest(detected['files']) + except Exception as exc: + print(f"[graphify watch] Warning: manifest save failed: {exc}") + print(f"[graphify watch] Rebuilt: {G.number_of_nodes()} nodes, " f"{G.number_of_edges()} edges, {len(communities)} communities") products = "graph.json" + (", graph.html" if html_written else "") + " and GRAPH_REPORT.md"