From cac3f98b76da0f3be8e005ed1df7c081164dd1b9 Mon Sep 17 00:00:00 2001 From: Farda Karimov Date: Mon, 13 Jul 2026 16:52:45 +0200 Subject: [PATCH] fix(watch): forward community_labels to to_json in _rebuild_code `graphify update` (and the git hooks that share its code path) wrote graph.json with numeric-only community IDs instead of readable hub names, because `_rebuild_code` called `to_json()` without the `community_labels` parameter that `cluster-only` already passes. Running `cluster-only` right after `update` "fixed" the names again, which was the visible symptom. - watch.py: forward the already-computed `labels` dict into `to_json`, matching the `cluster-only` code path (cli.py:1203). - watch.py: `_canonical_topology_for_compare` now also strips the new `community_name` field before diffing topology. Without this, the topology-unchanged cache (used to skip a full re-cluster) would never match again once graph.json started carrying names, forcing a full re-cluster on every subsequent `update` even with no code changes. Fixes #1808 --- graphify/watch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graphify/watch.py b/graphify/watch.py index db5d2a86d..14454bf08 100644 --- a/graphify/watch.py +++ b/graphify/watch.py @@ -566,6 +566,7 @@ def _canonical_topology_for_compare(graph_data: dict) -> dict: continue n = dict(node) n.pop("community", None) + n.pop("community_name", None) n.pop("norm_label", None) norm_nodes.append(n) canonical["nodes"] = sorted( @@ -1043,7 +1044,7 @@ def _add_deleted_source(path: Path) -> None: report_path = out / "GRAPH_REPORT.md" labels_json = json.dumps({str(k): v for k, v in sorted(labels.items())}, ensure_ascii=False, indent=2) + "\n" graph_tmp = out / ".graph.tmp.json" - json_written = to_json(G, communities, str(graph_tmp), force=True, built_at_commit=commit) + json_written = to_json(G, communities, str(graph_tmp), force=True, built_at_commit=commit, community_labels=labels) if not json_written: return False candidate_graph_data = json.loads(graph_tmp.read_text(encoding="utf-8"))