Skip to content
Viewing as a member

Graph — the KBVE Monorepo as One Living Graph

What it is

/graph/ draws the monorepo as one graph. Each bubble is a moon project; zoom in and it opens into its files, then their symbols. Edges are moon’s project dependencies, and a project with a page here links to it. The list view puts the same three feeds — moon projects, the code graph and the site’s own page graph — in a searchable table.

It began as a plan for an Obsidian-style 3D view of the notes on this site. The notes are still in it, as the site graph the list view reads, but the code became the centre: the question it answers best is what depends on what.

Why it is a service

A whole-tree graphify pass is minutes of work, and no site release should wait on it. services/graph builds the graph on its own daily schedule and the site only fetches JSON at runtime, so a new graph needs no site release and a site release never rebuilds the graph.

StageReadsWrites
projectsmoon query projectsprojects.json, docs.json
tieredgraphify’s symbol graphoverview.json, dir/*.json
enrichboth of the aboveoverview.json
reportcloc, .prototoolsreport.json

graphify has no .proto parser, so the tiered stage merges in the schemas’ messages, enums and imports itself. Generated code, configuration and data files are left out by services/graph/graphifyignore. A page here links to its project when its source_path, app_name or key names that project’s directory or id; a nested project, such as an e2e suite, takes the page of the project it tests.

Running it

Terminal window
moon run graph:test graph:lint
moon run graph:graph # HEAD -> services/graph/out
moon run graph:ask -- where navigate --local # query that build

Asking it

moon run graph:ask answers the questions an edit raises:

CommandAnswersReads
dependents <project>Who builds against it, transitivelythe working tree
deps <project>What it builds againstthe working tree
doc <path>The project that owns a path, and its page herethe working tree
where <symbol>Where a symbol is definedthis daily graph

A target can be a project id, its root, or any path inside it. Edges are moon’s plus the path and workspace: dependencies of nested manifests, which moon reads only at a project’s root. The same edges draw the page.

Over MCP

The repository’s .mcp.json registers graph: graphify’s own MCP server over the daily graph’s graph.json.gz, so an agent can walk symbols (get_neighbors, shortest_path, query_graph) rather than shelling out. The archive is fetched once per build and cached beside ask’s. The server sits in the mcp dependency group, which neither the image nor CI installs.

Terminal window
uv run --project services/graph --group mcp kbve-graph-mcp # the daily graph
uv run --project services/graph --group mcp kbve-graph-mcp --local # out/ from graph:graph

Deployment

kube/graph holds the CronJob, the nginx that serves /graphify/* from the shared volume, and the Cilium policies: the builder may reach the internet over HTTPS and nothing in the cluster; the server answers the gateway only. Each build lands in its own directory and the served link swaps to it whole, so a reader never sees half a graph. The clone reads with a read_repository token that kube/gitlab/system seals once and hands out through External Secrets.

Discuss on the forum

Questions, fixes and notes on this page live in the KBVE forum.