pub struct SpecGraph { /* private fields */ }Expand description
A directed graph of spec files, built from requires: references.
Resolves cross-file dependencies at construction time, rejects cycles, and provides topological ordering for downstream execution.
Implementations§
Source§impl SpecGraph
impl SpecGraph
Sourcepub fn from_roots(roots: &[PathBuf]) -> Result<Self, Vec<ParseError>>
pub fn from_roots(roots: &[PathBuf]) -> Result<Self, Vec<ParseError>>
Discover and parse every .ought.md file under the given roots using
the default OughtMdParser, then build the graph.
Sourcepub fn from_roots_with(
parser: &dyn Parser,
roots: &[PathBuf],
) -> Result<Self, Vec<ParseError>>
pub fn from_roots_with( parser: &dyn Parser, roots: &[PathBuf], ) -> Result<Self, Vec<ParseError>>
Same as SpecGraph::from_roots but parses with a caller-supplied
Parser. Useful for tests and for plugging in alternative spec
formats.
Sourcepub fn from_specs(specs: Vec<Spec>) -> Result<Self, Vec<ParseError>>
pub fn from_specs(specs: Vec<Spec>) -> Result<Self, Vec<ParseError>>
Build a graph from already-parsed specs. Validates that every
requires: entry resolves to a spec in the set and rejects cycles.
Prefer this when callers have their own parsing pipeline (tests, the viewer, any consumer that wants to inspect or transform specs before graph construction).
Sourcepub fn topological_order(&self) -> Vec<&Spec>
pub fn topological_order(&self) -> Vec<&Spec>
Specs in topological order (dependencies before dependents). Uses Kahn’s algorithm over the pre-resolved edges.
Sourcepub fn get_by_path(&self, path: &Path) -> Option<&Spec>
pub fn get_by_path(&self, path: &Path) -> Option<&Spec>
Look up a spec by its source file path.