Skip to content

Backport cluster graphs and multigraph mode (T15) - #6

Open
TimothyNguyen wants to merge 2 commits into
perf-improve-v1from
cluster-graph-backport
Open

Backport cluster graphs and multigraph mode (T15)#6
TimothyNguyen wants to merge 2 commits into
perf-improve-v1from
cluster-graph-backport

Conversation

@TimothyNguyen

Copy link
Copy Markdown
Owner

Summary

  • Cluster graphs. A cluster.json spec names member repos and typed cross-repo links (api_call, shared_resource, mirrored_file, depends_on, references). kb-core cluster init/add/remove/locate/build/check/status manages it. A build composes the members into one directed graph plus a manifest and report, and writes a cluster-ref.json marker into each member so --cluster [NAME] resolves the composed graph from inside any of them — wired into query, path, explain and affected.
  • Multigraph mode. Parallel edges between a node pair survive build, analysis, query and export, each keyed by a content-derived stable_edge_key instead of NetworkX's positional key, so a rebuild does not renumber every edge when the extraction order shifts.
  • Both opt-in. The default single-repo path is unchanged. The tests that pin that default (test_default_build_stays_simple, test_build_merge_defaults_to_simple_without_a_stored_flag) ship in this PR rather than as an afterthought.

kb-core is a stripped fork of graphify and never received upstream PR Graphify-Labs/graphify#2134. The scaffolding was already present but dormant — require_multigraph_capabilities() had no call sites and link_shared_type_declarations() was never invoked. Without a composed graph.json there is nothing for kb-core-ui to render across repos.

New modules: kb_core/cluster_graph.py, kb_core/cluster_cli.py, kb_core/cluster_ref.py. Touched: build, global_graph, cluster, analyze, affected, export, watch, serve, manifest_ingest, cli, __main__.

Test plan

  • pytest tests/test_cluster_spec.py — 41 passed
  • pytest tests/test_cluster_links.py — 20 passed
  • pytest tests/test_cluster_build.py — 20 passed
  • pytest tests/test_cluster_refs.py — 28 passed
  • pytest tests/test_cluster_cli.py — 33 passed
  • pytest tests/test_multigraph_build.py — 21 passed
  • Manual end-to-end: two extracted repos, cluster init, add x2, one declared api_call, check exit 0, build producing graph + manifest + report + per-member markers, then query --cluster and affected --cluster crossing the repo boundary via calls_api. graph.json byte-stable across a --force rebuild.
  • 13-file CLI/hook regression name-diffed against the baseline worktree at 6c3f0e2 — identical failure sets (72 pre-existing on both sides).
  • Full-suite name-diff against the baseline worktree. Recorded baseline: 154 failed, 4404 passed, 173 skipped. Counts alone are not the gate; the failure names must match.
  • cd kb-core-ui && pytest python/tests -q for shared-import breakage.

The two unchecked items and the reasoning behind them are written up in spec/T15-CODEX.md, along with three known non-bugs so they are not re-investigated.

Generated with Claude Code
via Happy

TimothyNguyen and others added 2 commits August 30, 2026 18:55
kb-core is a stripped fork of graphify and never received upstream PR #2134,
which composes several repos into one graph and preserves parallel edges. The
scaffolding was already here but dormant: require_multigraph_capabilities() had
no call sites and link_shared_type_declarations() was never invoked. Without a
composed graph.json there is nothing for kb-core-ui to render across repos.

Cluster graphs: a cluster.json spec names member repos and typed cross-repo
links, and `kb-core cluster init/add/remove/locate/build/check/status` manages
it. A build composes the members into one directed graph, writes a manifest and
report, and drops a cluster-ref.json marker in each member so `--cluster [NAME]`
resolves the composed graph from inside any of them.

Multigraph mode: parallel edges between a node pair survive build, analysis,
query and export, each keyed by a content-derived stable_edge_key rather than
NetworkX's positional key, so a rebuild does not renumber every edge when the
extraction order shifts.

Both features are opt-in. The default single-repo path is unchanged, and the
tests that pin that default are part of this commit rather than an afterthought.

spec/T15-CODEX.md carries the remaining verification steps.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
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.

1 participant