Skip to main content

cea_core/
lib.rs

1//! Causal edit attribution for structured code patches.
2//!
3//! This crate converts a [`typed_patch::StructuredPatch`] plus a
4//! [`check_runner::CheckResult`] into weighted cause/effect attribution triples,
5//! learns edge weights in a causal graph, and predicts future edit risk without
6//! requiring heavyweight ML dependencies.
7//!
8//! Key properties:
9//! - Deterministic attribution and run hashing.
10//! - Multi-cause proportional attribution instead of nearest-neighbor collapse.
11//! - Beta-distribution confidence tracking for edge reliability.
12//! - Compact graph persistence with versioned binary snapshots.
13
14mod attribution;
15mod calibration;
16mod error;
17mod graph;
18mod predict;
19mod scope;
20mod types;
21
22pub use attribution::{
23    attribute_effects, attribute_effects_with_config, attribution_score,
24    attribution_score_with_confidence, build_edit_op_signature, compute_run_hash, edit_op_node_id,
25    effect_node_id, global_pass_effect_signature, AttributedRunResult, AttributionConfig,
26    AttributionTriple,
27};
28pub use calibration::{
29    advisory_confidence, conservative_reliability, effective_sample_size, posterior_mean,
30    posterior_variance, sample_factor, sample_sufficiency_factor, ConfidenceEnvelope,
31    MIN_SAMPLES_PER_SIGNATURE,
32};
33pub use error::CeaCoreError;
34pub use graph::{CausalEdge, CausalGraph, CausalNode, CoverageSummary, EdgeStats};
35pub use predict::{predict, predict_with_config, PredictionConfig};
36pub use types::{
37    AnchorKind, CausalPrediction, EditOpKind, EditOpSignature, FileIndex, OpIndex, RiskFlag,
38    ScopeTag,
39};
40
41#[cfg(test)]
42mod tests;