Skip to main content

Crate sdivi_core

Crate sdivi_core 

Source
Expand description

§sdivi-core

Pure-compute facade for the Structural Divergence Indexer (sdivi-rust).

This crate is the stable, WASM-compatible public surface for embedding the analysis pipeline in Rust programs, WASM bindings, and language bindings. It has no I/O, no clock, no tree-sitter, and no std::fs — callers supply pre-extracted data via the *Input struct family and receive plain serde result types.

Embedders that need the full FS-orchestrated pipeline (parsing, snapshot writes, retention) should use sdivi-pipeline instead.

§Quick start

use sdivi_core::ExitCode;

assert_eq!(ExitCode::Success as i32, 0);

§Pure-compute example

use sdivi_core::compute::coupling::compute_coupling_topology;
use sdivi_core::input::DependencyGraphInput;

let g = DependencyGraphInput { nodes: vec![], edges: vec![] };
let result = compute_coupling_topology(&g).unwrap();
assert_eq!(result.node_count, 0);

Re-exports§

pub use categories::list_categories;
pub use categories::CategoryCatalog;
pub use categories::CategoryInfo;
pub use categories::CATEGORIES;
pub use error::AnalysisError;
pub use exit_code::ExitCode;
pub use input::edge_weight_key;
pub use input::split_edge_weight_key;
pub use input::validate_node_id;
pub use input::BoundaryDefInput;
pub use input::BoundarySpecInput;
pub use input::ChangeCouplingConfigInput;
pub use input::CoChangeEventInput;
pub use input::DependencyGraphInput;
pub use input::EdgeInput;
pub use input::LeidenConfigInput;
pub use input::NodeInput;
pub use input::NormalizeNode;
pub use input::PatternInstanceInput;
pub use input::PatternLocationInput;
pub use input::PriorPartition;
pub use input::QualityFunctionInput;
pub use input::ThresholdOverrideInput;
pub use input::ThresholdsInput;
pub use compute::boundaries::compute_boundary_violations;
pub use compute::boundaries::detect_boundaries;
pub use compute::boundaries::BoundaryDetectionResult;
pub use compute::boundaries::BoundaryViolationResult;
pub use compute::change_coupling::compute_change_coupling;
pub use compute::coupling::compute_coupling_topology;
pub use compute::coupling::CouplingTopologyResult;
pub use compute::normalize::normalize_and_hash;
pub use compute::patterns::compute_pattern_metrics;
pub use compute::patterns::compute_pattern_metrics_from_catalog;
pub use compute::thresholds::compute_thresholds_check;
pub use compute::thresholds::AppliedOverrideInfo;
pub use compute::thresholds::ThresholdBreachInfo;
pub use compute::thresholds::ThresholdCheckResult;
pub use compute::thresholds::THRESHOLD_EPSILON;

Modules§

categories
Pattern category contract — canonical category list and runtime discovery via list_categories. Canonical pattern-category contract for sdivi-rust snapshot_version "1.0".
compute
Pure-compute functions over input structs. Pure-compute functions — all referentially transparent, WASM-compatible.
error
Errors produced by the sdivi-core pure-compute API.
exit_code
Exit codes for the sdivi binary — public API, adding variants is a breaking change.
facade
Re-exports of snapshot assembly, delta, trend, and boundary inference from sdivi-snapshot. Re-exports of snapshot-layer functions for convenience.
input
Input structs for the pure-compute API (WASM-safe serde types). Input structs for the pure-compute API.
prelude
Commonly-imported items from sdivi-core.

Structs§

BoundaryInferenceResult
Result of infer_boundaries.
BoundaryProposal
A proposed boundary derived from consecutive-snapshot community stability.
ChangeCouplingResult
Result of the change-coupling analysis for one snapshot.
CoChangePair
A single file-pair that co-changes above the configured minimum frequency.
DivergenceSummary
Per-dimension divergence between two consecutive Snapshots.
GraphMetrics
Graph metrics summary — re-exported from sdivi-graph for WASM embedders. Summary metrics for a DependencyGraph.
IntentDivergenceInfo
Intent-divergence summary derived from the caller’s boundary representation.
LeidenPartition
Leiden community detection result — re-exported from sdivi-detection for WASM embedders. The result of a Leiden community detection run.
PatternCatalog
Pattern fingerprint catalog — re-exported from sdivi-patterns for WASM embedders. Per-category pattern catalog keyed by PatternFingerprint.
PatternFingerprint
Pattern fingerprint type — re-exported from sdivi-patterns for WASM embedders. A keyed blake3 digest representing the structural shape of a pattern.
PatternHintInput
Input struct for classify_hint — re-exported from sdivi-patterns for WASM embedders.
PatternMetricsResult
Pattern metrics derived from the catalog — carried in every snapshot.
PatternStats
Pattern fingerprint catalog — re-exported from sdivi-patterns for WASM embedders. Aggregated statistics for a single pattern fingerprint within one category.
Snapshot
A versioned snapshot of all pipeline stage outputs for one point in time.
SnapshotPriorPartition
A prior partition supplied to boundary inference.
TrendResult
Per-dimension trend data over a window of consecutive snapshots.

Constants§

FINGERPRINT_KEY
The fixed blake3 key used for all pattern fingerprints.
SNAPSHOT_VERSION
Snapshot schema version emitted by sdivi-rust.

Functions§

assemble_snapshot
Assemble a crate::Snapshot from pipeline stage outputs.
classify_hint
Callee-text-aware classification — re-exported from sdivi-patterns::queries.
compute_delta
Compute per-dimension divergence between two snapshots.
compute_trend
Compute trend statistics over a slice of snapshots.
infer_boundaries
Infer boundary proposals from a sequence of prior partitions.
null_summary
Return a crate::DivergenceSummary with all fields None (first-snapshot path).