pub struct ModuleGraph { /* private fields */ }Expand description
Explicit file/plugin dependency graph over registered modules.
Keys are typically the watched file stem (agents/foo.toon → "foo") or
the module URL; edges point from a module to the keys it declares in
dependencies. Storage is a BTreeMap, so propagation order is
deterministic across runs regardless of registration order.
Implementations§
Source§impl ModuleGraph
impl ModuleGraph
pub fn new() -> Self
Sourcepub fn with_reloader(reloader: Arc<dyn ModuleReload>) -> Self
pub fn with_reloader(reloader: Arc<dyn ModuleReload>) -> Self
Graph wired to a concrete apply seam.
Sourcepub fn set_reloader(&self, reloader: Arc<dyn ModuleReload>)
pub fn set_reloader(&self, reloader: Arc<dyn ModuleReload>)
Swap the apply seam (e.g. install the production reloader after boot).
Sourcepub fn register_module(
&self,
key: impl Into<String>,
dependencies: Vec<String>,
plugin_name: impl Into<String>,
)
pub fn register_module( &self, key: impl Into<String>, dependencies: Vec<String>, plugin_name: impl Into<String>, )
Register (or replace) module key — the URL/file-stem identifier —
with its declared dependencies and implementing plugin_name.
Sourcepub fn get(&self, key: &str) -> Option<ModuleEntry>
pub fn get(&self, key: &str) -> Option<ModuleEntry>
Snapshot of one module entry, if registered.
Sourcepub fn module_keys(&self) -> Vec<String>
pub fn module_keys(&self) -> Vec<String>
All registered module keys, ascending.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn depends_on(&self, key: &str) -> Vec<String>
pub fn depends_on(&self, key: &str) -> Vec<String>
Transitive dependents of key, INCLUDING key itself, in
breadth-first propagation order.
The DFS carries a visited set, so cyclic declarations (A depends on
B, B depends on A) terminate after visiting each module once
while still propagating to everything reachable around the cycle.
Sourcepub fn change_many(&self, ctx: &Arc<Context>, keys: &[String]) -> ChangeOutcome
pub fn change_many(&self, ctx: &Arc<Context>, keys: &[String]) -> ChangeOutcome
Transaction over one settled batch of changed keys.
Phase 1 (read-only) computes the transitive affected plugin set across
ALL input keys — shared visited set, so a plugin reachable from several
inputs appears exactly once. If no input key matches a registered
module the transaction ends ChangeOutcome::Ignored before any
mutation. Phase 2 applies the affected plugins sequentially; the first
failure rolls that plugin back to its previous state and stops the
batch, leaving earlier successes Active and reporting
ChangeOutcome::RolledBack.