Expand description
Deterministic, language-tagged code topology built from one snapshot-bound symbol-resolution result.
The graph separates three relations a consumer would otherwise have to reconstruct itself: logical containment, source association, and certainty-carrying reference and dependency edges. It consumes already validated in-memory facts and widens nothing: it loads no project, reads no file, parses no source, invokes no build tool, and evaluates no policy.
The snapshot must be the one the resolution was validated against, and a
successful build serializes to the compact version-1 JSON described below
through serde_json::to_string.
pedant_graph::build_rust_graph(snapshot, resolution)§A second language behind a feature
The default build projects Rust. Selecting the go feature adds the Go
adapter beside it: build_go_graph and build_go_graph_with_limits — named
here rather than linked, because the default build has no such item —
take a Go snapshot and the resolution validated against it and answer the
same CodeGraph the Rust builders answer, through the same checked
assembler. The feature forwards to pedant-core/go-resolution and nothing
else, so a build without it links no Go grammar through this crate, and the
optional graph cache below stays Rust-only either way.
§The version-1 shape
One object with six keys, in this order:
schema_version: the integerCodeGraph::SCHEMA_VERSION.tier:"syntactic"or"semantic", taken from the supplied report.nodes:id,language,name,kind,location.kindis tagged bycategory;locationisnullor tagged bykindasfileorspan.containment:parentandchild, sorted by child then parent.references:id,source,language,kind,text,span,gaps,edges, in mint order.edges:id,source,target,kind,certainty,origin, in mint order.originis tagged bykindasreferenceordependency.
Every identity is an integer equal to the record’s position in its own slice, and every graph-owned enum is one lower-snake-case string. No key states a coordinate, a size, a color, or any other layout choice.
§Bounded queries over a built graph
A caller states which edges to admit and what the answer may cost, then asks. Nothing about the graph changes.
let analysis = GraphAnalysis::new(
graph,
GraphEdgeSelection::code_relations(),
GraphAnalysisLimits::new(100_000, 400_000, 8, 50_000_000),
)?;
analysis.neighbors(node, 2, GraphDirection::Incoming)The same view answers the derived questions. Cohesion, modularity, affinity, and boundary-crossing cycles are evidence about the partition the graph declares; layout metadata is that evidence beside the degrees and weights a ranker or a renderer would otherwise measure itself.
let analysis = GraphAnalysis::new(
graph,
GraphEdgeSelection::code_relations(),
GraphAnalysisLimits::new(100_000, 400_000, 8, 50_000_000),
)?;
let evidence = analysis.divergence();
for module in evidence.cohesion() {
let _ = (module.root(), module.internal_edges(), module.score());
}
analysis.layout_assist()§Optional bounded reuse
A caller that inspects successive repository states may keep a cache of the work it already admitted. The cache builds nothing of its own: it takes the same snapshot and validated resolution the direct builder takes, returns the same graph, and states how many values it may retain. Zero disables a category without disabling the computation behind it.
let mut cache = GraphCache::new(GraphCacheLimits::new(4_096, 8, 4, 256));
let held = cache.build_rust_graph(snapshot, resolution, GraphLimits::default())?;
let analysis = held.analyze(
GraphEdgeSelection::code_relations(),
GraphAnalysisLimits::new(100_000, 400_000, 8, 50_000_000),
)?;
let _ = (analysis.divergence(), cache.stats().exact_graph_hits());The returned handles are the caller’s: a graph, an analysis, and every
product they answer with stay valid and immutable after eviction, after
clear, and after the cache itself is dropped. Nothing about the version-1
object above changes, and no cache value is serialized.
Structs§
- Betweenness
Centrality - How much of the selected topology’s shortest routing passes through one node.
- Boundary
Crossing Component - One cycle whose members are declared in more than one partition.
- Cached
Code Graph - One immutable graph, shared with the cache that produced it.
- Cached
Graph Analysis - One shared analysis over one cached graph.
- Code
Graph - One deterministic, language-tagged code topology.
- Component
IdKind - Marker distinguishing component identities from the graph’s own identities.
- Condensation
Edge - Every selected edge between one ordered pair of components.
- Condensation
Graph - One selected topology with every component contracted to a single node.
- Containment
Edge - One logical-ownership edge between a parent node and the node it owns.
- Declared
Module Partition - Which container owns each node, and which nodes each container owns.
- Degree
Centrality - How many selected edges arrive at and leave one node.
- Dependency
Evidence - What one build-unit dependency edge retained from its declaration.
- Edge
IdKind - Marker distinguishing edge identities from the other identity kinds.
- Graph
Analysis - One borrowed graph, the selection applied to it, and the indexes that selection produced.
- Graph
Analysis Limits - How much work one analysis of one graph may cost.
- Graph
Cache - A caller-owned cache of graphs built from complete resolution claims.
- Graph
Cache Limits - The retention ceilings one cache is bounded by.
- Graph
Cache Stats - A copied reading of one cache’s cumulative activity.
- Graph
Component - One set of nodes that all reach each other.
- Graph
Components - Every component of one selected topology, and which one each node belongs to.
- Graph
Divergence - What one selected topology says about the partition its graph declares.
- Graph
Edge - One directed relation between two graph nodes.
- Graph
Edge Selection - The edge kinds and certainties one analysis admits.
- GraphId
- One dense
u32position whose marker fixes the collection it addresses. - Graph
Limits - How many nodes, reference records, and edges one build may produce.
- Graph
Neighbor - One reached node and how many selected steps away it is.
- Graph
Node - One structural entity of a code graph.
- Graph
Path - One directed route over selected outgoing edges.
- Graph
Reference - One naming site, its copied evidence, and the edges its candidates produced.
- Graph
Subgraph - One selection into the raw graph, never a second graph.
- Layout
Assist Metadata - Every admitted node and every selected edge, described once.
- Layout
Edge Metadata - One selected edge, restated with both of its ends and its own evidence.
- Layout
Node Metadata - What one node is, is inside, and measures as.
- Misplacement
Candidate - One symbol’s selected edges into one partition other than its own.
- Module
Cohesion - How much of one partition’s outgoing traffic stays inside it.
- Node
IdKind - Marker distinguishing node identities from the other identity kinds.
- Reference
IdKind - Marker distinguishing reference identities from the other identity kinds.
Enums§
- Graph
Analysis Error - A refusal taken while building or querying one analysis.
- Graph
Build Error - A refusal taken while projecting one resolution into a graph.
- Graph
Certainty - How much an edge is known.
- Graph
Collection - Which graph collection a ceiling addresses.
- Graph
Dependency Kind - Which dependency table declared a build-unit edge.
- Graph
Direction - Which way a neighborhood or subgraph walk follows a selected edge.
- Graph
Edge Kind - What relation an edge states.
- Graph
Edge Origin - Why an edge exists. No edge exists without one of these.
- Graph
Node Kind - What kind of entity a node is.
- Graph
Node Location - Where a node’s bytes sit, when it has any.
- Graph
Reference Kind - What a naming site denotes at the graph layer.
Functions§
- build_
rust_ graph - Project one snapshot-bound Rust resolution under the default ceilings.
- build_
rust_ graph_ with_ limits - Project one snapshot-bound Rust resolution under caller-chosen ceilings.
Type Aliases§
- Graph
Component Id - A component’s dense identity within one
GraphComponents. - Graph
Edge Id - An edge’s dense identity within one
crate::CodeGraph. - Graph
Node Id - A node’s dense identity within one
crate::CodeGraph. - Graph
Reference Id - A reference record’s dense identity within one
crate::CodeGraph.