Skip to main content

Module subgraph

Module subgraph 

Source
Expand description

Shared seeded, depth-limited subgraph traversal (entry-point-agnostic, format-agnostic). Backs the Archify exporter and future seeded exports. Shared seeded, depth-limited subgraph builder.

This is the reusable traversal primitive behind seeded exports (today the Archify architecture exporter). It is deliberately entry-point-agnostic: it takes a set of concrete [NodeId] seeds and walks the graph. Resolving which nodes are seeds (by symbol name, file, or entry-point heuristic) is a higher-layer concern and stays out of sqry-core (entry-point detection lives in sqry-db). The builder never invents seeds.

It is also format-agnostic: the caller supplies an edge classifier that decides, per [EdgeKind], whether an edge is retained (and under what caller-defined class) and whether the traversal follows it. This keeps each export format’s edge-retention policy fully independent. In particular the Archify path classifies (and retains) semantically rich cross-service edges (HttpRequest, DbQuery, MessageQueue, …) that the raw dot / d2 / mermaid / json exporters intentionally drop, and it does so through its own classifier so those existing formats are provably unchanged.

§Determinism

Every ordering decision is explicit and stable so identical input yields byte-identical output, including across parallel (rayon) graph rebuilds where the underlying arena/edge iteration order can differ:

  • Seeds are sorted by NodeId index and de-duplicated before the walk.
  • Outgoing edges of each node are sorted by (target index, edge-kind discriminant, sequence) before they are recorded or enqueued.
  • BFS uses a per-node visited set keyed on NodeId (never on qualified name), so same-named nodes in unrelated files never fuse.

The resulting [SeededSubgraph::nodes] is in stable BFS discovery order and [SeededSubgraph::edges] is in stable emission order.

Structs§

EdgeRetention
Decision returned by a caller-supplied edge classifier.
RetainedEdge
A retained edge between two visited nodes, carrying the caller’s class.
SeededSubgraph
The result of a seeded subgraph walk.
SeededSubgraphConfig
Configuration for a seeded subgraph walk.

Constants§

DEFAULT_MAX_DEPTH
Default BFS depth (hops from the seed) for a seeded subgraph.
DEFAULT_MAX_RESULTS
Default cap on the number of raw nodes visited during BFS.
MAX_DEPTH_CAP
Hard cap on BFS depth. Anything deeper is already too dense to read.

Functions§

build_seeded_subgraph
Build a seeded, depth-limited subgraph.