Skip to main content

weavatrix_rust/engine/
mod.rs

1//! In-memory repository state and the retargetable Weavatrix engine session.
2
3mod repository_state;
4mod session;
5
6use crate::analyzer::Analyzer;
7use crate::model::Snapshot;
8use blazingly_json::Value;
9use std::collections::BTreeMap;
10use std::path::PathBuf;
11use std::sync::{Arc, OnceLock};
12use std::time::{Duration, Instant};
13use weavatrix_graph::{Graph, NodeIndex};
14use weavatrix_scan::ScanReport;
15
16pub use repository_state::git_head;
17
18#[derive(Debug, Clone)]
19pub struct GraphCensus {
20    pub kinds: BTreeMap<String, u64>,
21    pub relations: BTreeMap<String, u64>,
22    pub evidence: BTreeMap<String, u64>,
23}
24
25#[derive(Debug, Clone)]
26pub struct RepositoryState {
27    root: PathBuf,
28    snapshot: Arc<Snapshot>,
29    graph: Arc<Graph>,
30    scan: Arc<ScanReport>,
31    build_time: Duration,
32    built_at: Instant,
33    weak_components: Arc<OnceLock<Vec<Vec<NodeIndex>>>>,
34    census: Arc<OnceLock<GraphCensus>>,
35}
36
37pub struct Weavatrix {
38    analyzer: Analyzer,
39    state: RepositoryState,
40    known_states: BTreeMap<PathBuf, RepositoryState>,
41    last_used: BTreeMap<PathBuf, Instant>,
42    tool_cache: BTreeMap<String, Value>,
43}