Expand description
§graph
Graph-based analysis and validation for AgentScript ASTs.
This module provides tools to build a reference graph from a parsed AgentScript AST, enabling validation, analysis, and querying of relationships between definitions.
§Features
- Reference Resolution: Validate that all
@variables.*,@actions.*,@topic.*references resolve - Cycle Detection: Ensure topic transitions form a DAG (no cycles)
- Reachability Analysis: Find unreachable topics from
start_agent - Usage Queries: Find all usages of a definition, or all dependencies of a node
- Dead Code Detection: Identify unused actions and variables
§Example
ⓘ
use busbar_sf_agentscript::parse;
use busbar_sf_agentscript::graph::RefGraph;
let source = r#"
config:
agent_name: "MyAgent"
"#;
let ast = parse(source).unwrap();
let graph = RefGraph::from_ast(&ast).unwrap();
// Validate all references
let errors = graph.validate();
for error in errors {
println!("Validation error: {:?}", error);
}
// Check for cycles
if let Some(cycle) = graph.find_cycles().first() {
println!("Cycle detected: {:?}", cycle);
}Re-exports§
pub use dependencies::extract_dependencies;pub use dependencies::Dependency;pub use dependencies::DependencyReport;pub use dependencies::DependencyType;pub use export::EdgeRepr;pub use export::GraphExport;pub use export::GraphRepr;pub use export::NodeRepr;pub use export::ValidationResultRepr;pub use render::render_actions_view;pub use render::render_full_view;pub use render::render_graphml;pub use render::render_topic_flow;
Modules§
- dependencies
- Dependency extraction and analysis for AgentScript files.
- export
- Serialization types for graph export.
- render
- Graph rendering utilities.
- wasm
- WebAssembly bindings for the AgentScript graph analysis library.
Structs§
- Query
Result - Result of a query operation.
- RefGraph
- A reference graph built from an AgentScript AST.
- RefGraph
Builder - Builder for constructing a reference graph from an AST.
- Validation
Result - Result of validating a reference graph.
Enums§
- Graph
Build Error - Errors that can occur when building a reference graph from an AST.
- RefEdge
- An edge in the reference graph representing a relationship between nodes.
- RefNode
- A node in the reference graph representing a definition.
- Validation
Error - Validation errors found in the reference graph.