Skip to main content

pedant_graph/
lib.rs

1//! Deterministic, language-tagged code topology built from one snapshot-bound
2//! symbol-resolution result.
3//!
4//! The graph separates three relations a consumer would otherwise have to
5//! reconstruct itself: logical containment, source association, and
6//! certainty-carrying reference and dependency edges. It consumes already
7//! validated in-memory facts and widens nothing: it loads no project, reads no
8//! file, parses no source, invokes no build tool, and evaluates no policy.
9//!
10//! The snapshot must be the one the resolution was validated against, and a
11//! successful build serializes to the compact version-1 JSON described below
12//! through `serde_json::to_string`.
13//!
14//! ```no_run
15//! # use pedant_core::resolution::rust::{RustResolutionSnapshot, RustTargetResolution};
16//! # use pedant_graph::{CodeGraph, GraphBuildError};
17//! # fn topology(
18//! #     snapshot: &RustResolutionSnapshot,
19//! #     resolution: &RustTargetResolution,
20//! # ) -> Result<CodeGraph, GraphBuildError> {
21//! pedant_graph::build_rust_graph(snapshot, resolution)
22//! # }
23//! ```
24//!
25//! # The version-1 shape
26//!
27//! One object with six keys, in this order:
28//!
29//! - `schema_version`: the integer [`CodeGraph::SCHEMA_VERSION`].
30//! - `tier`: `"syntactic"` or `"semantic"`, taken from the supplied report.
31//! - `nodes`: `id`, `language`, `name`, `kind`, `location`. `kind` is tagged by
32//!   `category`; `location` is `null` or tagged by `kind` as `file` or `span`.
33//! - `containment`: `parent` and `child`, sorted by child then parent.
34//! - `references`: `id`, `source`, `language`, `kind`, `text`, `span`, `gaps`,
35//!   `edges`, in mint order.
36//! - `edges`: `id`, `source`, `target`, `kind`, `certainty`, `origin`, in mint
37//!   order. `origin` is tagged by `kind` as `reference` or `dependency`.
38//!
39//! Every identity is an integer equal to the record's position in its own
40//! slice, and every graph-owned enum is one lower-snake-case string. No key
41//! states a coordinate, a size, a color, or any other layout choice.
42
43#![deny(missing_docs)]
44
45/// The logical hierarchy relation.
46mod containment;
47/// Graph edges, their certainty, and their evidence.
48mod edge;
49/// Why a graph build refused.
50mod error;
51/// The immutable graph value and its checked record store.
52mod graph;
53/// Dense typed identities into one graph's collections.
54mod id;
55/// The configured ceilings a build refuses at.
56mod limits;
57/// Graph nodes, their categories, and their source locations.
58mod node;
59/// Reference records and what they denote.
60mod reference;
61/// The Rust projection adapter.
62mod rust;
63
64pub use containment::ContainmentEdge;
65pub use edge::{
66    DependencyEvidence, GraphCertainty, GraphDependencyKind, GraphEdge, GraphEdgeKind,
67    GraphEdgeOrigin,
68};
69pub use error::GraphBuildError;
70pub use graph::CodeGraph;
71pub use id::{
72    EdgeIdKind, GraphEdgeId, GraphId, GraphNodeId, GraphReferenceId, NodeIdKind, ReferenceIdKind,
73};
74pub use limits::{GraphCollection, GraphLimits};
75pub use node::{GraphNode, GraphNodeKind, GraphNodeLocation};
76pub use reference::{GraphReference, GraphReferenceKind};
77pub use rust::{build_rust_graph, build_rust_graph_with_limits};