evidence-chain 0.1.0

Builder for explainable evidence chains — link observations to decisions with quantitative thresholds and pass/fail tracking
Documentation
  • Coverage
  • 100%
    29 out of 29 items documented3 out of 11 items with examples
  • Size
  • Source code size: 27.23 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 594.26 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • rodrigoescorsim/evidence-chain
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rodrigoescorsim

evidence-chain

Crates.io Docs.rs CI License: MIT

Builder for explainable evidence chains in Rust.

An EvidenceChain is an ordered list of verifiable observations (EvidenceLinks), each with an optional numeric metric and a pass/fail threshold. Calling finalize() computes an aggregate pass ratio across all links.

Domain-agnostic — the same types work for fraud detection, trading signals, compliance checks, on-chain analysis, or any system where decisions must be auditable and explainable.

Installation

[dependencies]
evidence-chain = "0.1"

Usage

use evidence_chain::{EvidenceChain, EvidenceLink, EvidenceCategory};

let mut chain = EvidenceChain::new("fraud-detector", "1.0.0");

chain.add_link(
    EvidenceLink::new(EvidenceCategory::Value, "Amount above daily limit", "tx:8f3a")
        .with_metric(15_000.0, "USD")
        .with_threshold(10_000.0, true),
);
chain.add_link(
    EvidenceLink::new(EvidenceCategory::Behavioral, "New device fingerprint", "device:c91b")
        .with_threshold(1.0, true),
);
chain.add_link(
    EvidenceLink::new(EvidenceCategory::Temporal, "Outside normal hours", "2024-03-15T03:42Z")
        .with_threshold(1.0, false),
);

chain.finalize();

println!("{}/{} checks passed", chain.strength.passed_checks, chain.strength.total_checks);
// → 2/3 checks passed

Core types

Type Description
EvidenceChain Ordered list of links + aggregate strength
EvidenceLink Single observation with metric and threshold
EvidenceCategory Structural / Temporal / Value / Behavioral
EvidenceStrength total_checks, passed_checks, ratio

Serialization

All types implement serde::Serialize and serde::Deserialize:

let json = serde_json::to_string(&chain)?;
let decoded: EvidenceChain = serde_json::from_str(&json)?;

Examples

cargo run --example fraud_detection
cargo run --example trading_signal

License

MIT — see LICENSE.

Author

Rodrigo Escorsim · cachesnap.com