pub struct Snapshot {
pub snapshot_version: String,
pub timestamp: String,
pub commit: Option<String>,
pub graph: GraphMetrics,
pub partition: LeidenPartition,
pub catalog: PatternCatalog,
pub pattern_metrics: PatternMetricsResult,
pub intent_divergence: Option<IntentDivergenceInfo>,
pub path_partition: BTreeMap<String, u32>,
pub change_coupling: Option<ChangeCouplingResult>,
}Expand description
A versioned snapshot of all pipeline stage outputs for one point in time.
§Examples
use std::collections::BTreeMap;
use sdivi_snapshot::snapshot::{assemble_snapshot, PatternMetricsResult, SNAPSHOT_VERSION};
use sdivi_graph::metrics::GraphMetrics;
use sdivi_detection::partition::LeidenPartition;
use sdivi_patterns::PatternCatalog;
let graph = GraphMetrics {
node_count: 0, edge_count: 0, density: 0.0,
cycle_count: 0, top_hubs: vec![], component_count: 0,
};
let partition = LeidenPartition {
assignments: BTreeMap::new(), stability: BTreeMap::new(),
modularity: 0.0, seed: 42,
};
let snap = assemble_snapshot(
graph, partition, PatternCatalog::default(),
PatternMetricsResult::default(), None,
"2026-04-29T00:00:00Z", None, None, 0,
);
assert_eq!(snap.snapshot_version, SNAPSHOT_VERSION);Fields§
§snapshot_version: StringAlways "1.0" for sdivi-rust output.
timestamp: StringISO 8601 UTC timestamp at which the snapshot was taken.
commit: Option<String>Git commit SHA at the time of the snapshot, when available.
graph: GraphMetricsGraph metrics computed from the dependency graph.
partition: LeidenPartitionLeiden community detection result.
catalog: PatternCatalogPattern fingerprint catalog with per-category entropy.
pattern_metrics: PatternMetricsResultPattern metrics (entropy, convention drift) for this snapshot.
intent_divergence: Option<IntentDivergenceInfo>Intent divergence against the caller-declared boundaries.
None (omitted from JSON) when no boundary count was supplied to
assemble_snapshot (typically because .sdivi/boundaries.yaml was
not present).
path_partition: BTreeMap<String, u32>File-path → community-ID assignments for boundary inference.
Maps each source file’s repo-relative path to its community ID from the
Leiden partition at snapshot time. Populated by sdivi-pipeline from the
DependencyGraph + LeidenPartition. Absent (empty) in snapshots
produced without path context (e.g., pure-compute path); boundary
inference from such snapshots yields no proposals.
change_coupling: Option<ChangeCouplingResult>Change-coupling analysis result.
None when the repo has no git history or history_depth = 0.
#[serde(default)] ensures M14-era snapshots deserialize as None.