Skip to content

Feature request: let the git-hook/watch rebuild honor a persisted clustering config (exclude-hubs) #1800

Open

Description

@jerp86

Context

--exclude-hubs (shipped in v0.8.11 via #919) works great as a cluster-only flag. On our TS/React graph (2091 nodes), cluster-only --exclude-hubs 99.5 dramatically improves community↔subsystem alignment: core/style/ consolidates from 10 communities (53% top-share) to 4 (85%), core/layout/ top-share 15%→43%, core/dsl/ 17%→43% — reproducing the pattern reported in #919.

Problem

The flag cannot be adopted as the graph's official clustering when the post-commit/post-checkout hooks are installed: the hook rebuild path (watch.py) re-clusters with defaults and has no way to pick the setting up (no flag, no env var — checked v0.9.12: cli.py knows exclude_hubs, watch.py doesn't). So an exclude-hubs clustering is overwritten on the next commit, and each flip-flop renumbers communities and invalidates labels (.graphify_labels.json is keyed by community number).

Proposal

Persist clustering parameters chosen at cluster-only/build time (e.g. an exclude_hubs_percentile field in manifest.json or a small graphify-out/.graphify_cluster.json) and have the watch/hook rebuild reuse them, so hooks preserve rather than revert the operator's clustering choice. An env var (e.g. GRAPHIFY_EXCLUDE_HUBS) read by watch.py would also work as a minimal version.

Environment

graphify 0.9.12, macOS, hooks installed via graphify hook install.

Workaround we're using meanwhile: keep the official graph on default clustering and run exclude-hubs analyses on a copy (cluster-only --graph <copy> — the #1747 fix in 0.9.12 makes this clean, outputs land beside the copy).

Activity

  1. jerp86 commented on Jul 12, 2026

    @jerp86
    ContributorAuthor

    Additional evidence: even trivial incremental changes trigger full recluster instability

    Follow-up from our side after filing this. We observed the flip-flop/instability problem play out again, but from an even smaller trigger than deliberately setting --exclude-hubs: two ordinary commits that only added a single new (~4-5 node) document file to the corpus, unrelated to the actual application code.

    Each commit's post-commit hook ran the ordinary incremental watch.py rebuild (no manual clustering flags involved at all), and each time the community structure shifted:

    • Commit 1: total community count unchanged (107→107), but community 107 (a real, stable 4-node community, "Moldura do Grupo de Problemas") disappeared and a brand-new community 92 appeared in its place — a straight renumbering, not a content change.
    • Commit 2: community count dropped (107→106) — community 98 ("Passagem de Tempo", also a stable 4-node community) was silently merged away with no replacement ID.

    Both times, graph.json and graph.html diffed ~90k lines even though only a handful of nodes/edges actually changed — consistent with a full recluster-from-scratch rather than an incremental community assignment for just the new nodes.

    This reinforces the FR's core ask (persist clustering config across watch/hook reruns) but also broadens the stakes a bit: it's not only that a deliberately-set --exclude-hubs gets silently reverted — any topology change at all, however small and unrelated to the communities in question, can renumber or merge existing communities and invalidate their saved labels. A config-persistence fix would presumably need to be paired with (or benefit from) more stable community IDs/labels across incremental reruns, not just carrying the --exclude-hubs value forward.

    Happy to share the two graph.json/.graphify_labels.json diffs if useful for reproduction.

  2. jerp86 commented on Jul 13, 2026

    @jerp86
    ContributorAuthor

    Additional evidence: default graphify label (no clustering flags at all) can silently attach a stale label to the wrong community

    Follow-up from our side, found while running routine maintenance (graphify label . --backend=claude-cli --missing-only on v0.9.13, with no --exclude-hubs or other clustering override involved at all — the plain default path).

    We snapshotted graph.json + .graphify_labels.json before and after the run. Node/edge counts were identical before/after (2100 nodes, 6215 links — a pure recluster, not a rebuild), and the labels dict came back byte-identical (same 106 keys, same string values per key). So on the surface the run looked like a total no-op. But diffing each node's community field before vs. after showed 18 nodes reassigned to a different community id, including two clean pairs of small (4-8 node), topically-related communities that swapped members wholesale — e.g. community A (originally holding nodes for topic "X-header") and community B (originally holding nodes for the closely-related topic "Y-header") ended up with each other's members after the recluster, and a second, unrelated pair did the same for two other closely-related component groups.

    Because --missing-only's label-reuse path (cli.py) does labels[cid] = existing_labels.get(cid, hub_labels[cid]) keyed purely by the cid integer, with no re-validation that cid's current membership still matches what it was when that label was written, both swapped communities kept their old, now-wrong label text pinned to their new content. Community A is now literally full of "Y-header" nodes but still reports as the "X-header" label, and vice versa for B.

    This is a sharper version of the concern already raised in this issue (label invalidation via community-number keying) — it's not just that a label goes missing/renumbered on recluster, it's that a plausible-looking, semantically wrong label can persist silently with what looks like a "0 changes" result, since the run reports success and nothing in the labels diff looks abnormal (same keys, same values) unless you cross-check node membership per community, which we only did as a sanity check for an unrelated task. We reverted the recluster locally (git restore) since it provided no benefit for our actual goal (naming one hub-fallback community) and only introduced this drift.

    Happy to share the before/after graph.json diff (with real names) privately if useful for reproduction — the affected communities are small (4-8 nodes) and structurally similar to their swap partner, which seems to be what makes them borderline for the clustering algorithm.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions