Rust Core — briefcase-core
The Rust core (briefcase-core) is the high-performance foundation of the Briefcase platform. All language bindings and the HTTP server are built on top of it.
Modules
Decision Models
Core data structures for recording AI decisions:
- DecisionSnapshot — Complete record of an AI decision (inputs, outputs, model parameters, execution context)
- Input / Output — Typed data with confidence scores
- ModelParameters — Model name, version, provider, and configuration
- ExecutionContext — Environment and runtime metadata
Replay Engine
Deterministic replay of recorded decisions with three modes:
| Mode | Behavior |
|---|---|
| Strict | Byte-for-byte output match required |
| Tolerant | Allow formatting/whitespace differences |
| ValidationOnly | Validate context without re-execution |
The engine uses the ModelExecutor trait, which consumers implement to re-run their model during replay.
Drift Detection
Identifies when model behavior changes over time:
- String Similarity — Levenshtein distance comparison
- Consensus Analysis — Detect output divergence across runs
- Outlier Detection — Flag anomalous outputs
Cost Tracking
Model pricing, cost estimation, and budget enforcement.
PII Sanitizer
Detects and redacts sensitive data: SSN, credit card numbers, email addresses, phone numbers, API keys, and IP addresses.
Storage Backends
All backends implement the StorageBackend trait:
trait StorageBackend {
async fn save(&self, snapshot: DecisionSnapshot) -> Result<String>;
async fn load(&self, id: &str) -> Result<DecisionSnapshot>;
async fn query(&self, query: SnapshotQuery) -> Result<Vec<DecisionSnapshot>>;
async fn delete(&self, id: &str) -> Result<bool>;
async fn health_check(&self) -> Result<bool>;
}
| Backend | Description | Use Case |
|---|---|---|
| SqliteBackend | File or in-memory SQLite with compression | Production (single-node) |
| LakeFSBackend | Versioned storage with branching and commits | Production (versioned) |
| MemoryBackend | In-memory HashMap | Testing |
Feature Flags
[features]
default = ["async", "storage", "networking", "compression"]
async = ["tokio"]
storage = ["rusqlite"]
networking = ["reqwest"]
compression = ["flate2", "zstd"]
parallel = ["rayon"]
wasm = []
sync-only = []
Crate Dependencies
Core runtime, storage, and analysis dependencies used by briefcase-core.
Dependency groups:
- serialization:
serde,serde_json - runtime and I/O:
tokio,reqwest,rusqlite - model metadata:
chrono,uuid - analysis and validation:
regex,strsim,sha2 - performance:
flate2,zstd, optionalrayon