openpay/ (+3 crates, ~8400 LOC, 162 tests)
op-iso8583/ ISO 8583 messages for direct acquirer / card-network
connectivity. MTIs, primary+secondary bitmaps, full
DE catalogue, BCD/ASCII/EBCDIC/LLVAR/LLLVAR codecs,
five dialects (Visa Base I, Mastercard MDS, Amex GNS,
Discover, JCB), network-management messages
(sign-on/echo/cutover), DE 55 EMV TLV.
op-mobile-wallets/ Apple Pay (ECDH-P256 + AES-256-GCM), Google Pay ECv2
(ECDH + HKDF + AES-256-CTR + HMAC), Samsung Pay. PAN
never leaves the decryption boundary as a String;
lands in VaultRef. No-PAN-leakage assertions per
wallet.
op-routing/ Least-cost routing + MCC-aware routing + intelligent
retry / soft-decline recovery. 231-MCC catalogue.
Real ISO 8583 DE-39 soft/hard decline taxonomies.
smart-byte/smart-byte-rs/ (+3 crates, ~7100 LOC, 96 tests)
smart-byte-vc/ W3C Verifiable Credentials 2.0: VCDM, presentations,
Data Integrity proofs (eddsa-jcs-2022), VC-JWT,
SD-JWT (selective disclosure), Bitstring Status
List 2021. Cargo-bridge maps VCs to Smart Byte
envelopes with SAID stability.
smart-byte-did/ W3C DID resolution: did:key (Ed25519/P-256/secp256k1),
did:web (HTTPS), did:peer (numalgo 2+4), did:jwk,
did:ion (feature-gated stub). DID URL dereferencer.
smart-byte-pq/ Post-quantum signatures: ML-DSA-44/65/87 (FIPS 204),
SLH-DSA across 12 parameter sets (FIPS 205), FN-DSA
(draft FIPS 206, feature-gated). Hybrid Ed25519 +
ML-DSA pattern for the transition. Secret-key
zeroize-on-drop.
eoc/eoc-rs/ (+3 crates, ~6450 LOC, 76 tests)
eoc-vendor-api/ NeuralBackend implementations: Anthropic, OpenAI,
Google, Mistral, Cohere, Groq, Together, Fireworks.
SSE streaming. Prompt-caching where supported.
Joule estimates per published energy coefficient
(12-model curated table).
eoc-embeddings/ 21 embedding models behind one Embedder trait:
OpenAI v3 (3), Cohere v3 (3), Voyage (5), Mistral,
Jina, plus local ONNX (BGE x3, nomic, mxbai, GTE,
E5) behind 'local' feature. Matryoshka-style
dimension projection. Per-content-hash cache.
eoc-route-learned/ RouteLLM-style matrix-factorisation router +
multinomial-logreg classifier + LinUCB / Thompson
bandits for online learning. LearnedCascade wraps
the rule-based cascade with a confidence-threshold
skip policy. Synthetic-eval accuracy: MF 0.935,
LogReg 0.980.
Quality:
- cargo check across all three workspaces: clean
- cargo clippy --all-targets -- -D warnings on every new crate: clean
- 334 new tests total; all passing
- #![forbid(unsafe_code)] across every new crate
- No unwrap/expect outside #[cfg(test)]
Rust 1.95.0 edition 2024 (inherited via root rust-toolchain.toml).
63 lines
2.6 KiB
Rust
63 lines
2.6 KiB
Rust
//! EOC learned router — predictive stage selection for the four-stage cascade.
|
|
//!
|
|
//! The default `eoc_cascade::Cascade` walks `cache → kv → graph → neural` in
|
|
//! strict order. That's optimal when most queries land in the cheap stages.
|
|
//! For workloads where many queries unavoidably need the neural stage, walking
|
|
//! the cheaper stages first is wasted joules. A *learned router* predicts the
|
|
//! cheapest stage that is likely to satisfy the query and lets us **skip
|
|
//! ahead** when the prediction is confident.
|
|
//!
|
|
//! This crate ships three orthogonal router families plus a threshold policy
|
|
//! and an end-to-end cascade extension:
|
|
//!
|
|
//! - [`matrix_factorization::MfRouter`] — RouteLLM-style latent factor model
|
|
//! (ICLR 2025). Each query cluster gets a `k`-dim latent vector; each stage
|
|
//! gets a `k`-dim latent vector; the dot product predicts success
|
|
//! probability. Trained by SGD on `(query_embedding, stage, success)`.
|
|
//! - [`classifier::LogRegRouter`] — multinomial logistic regression over query
|
|
//! embeddings, outputting a softmax over the four stages.
|
|
//! - [`bandit::LinUcbRouter`] / [`bandit::ThompsonSamplingRouter`] — online
|
|
//! bandit learners for the regime where ground-truth labels arrive late
|
|
//! (downstream feedback).
|
|
//! - [`threshold::ThresholdPolicy`] — turn a `StagePrediction` into a concrete
|
|
//! "skip-ahead to stage X" decision.
|
|
//! - [`inference::LearnedCascade`] — wraps an `eoc_cascade::Cascade` and
|
|
//! consults the router before dispatching.
|
|
//!
|
|
//! Everything is `nalgebra`-only — no Burn, no Candle, no ONNX, WASM-ready.
|
|
//!
|
|
//! ```no_run
|
|
//! use eoc_route_learned::{
|
|
//! classifier::LogRegRouter,
|
|
//! training::{Example, TrainingConfig, train_logreg},
|
|
//! };
|
|
//! use eoc_core::Stage;
|
|
//!
|
|
//! let examples: Vec<Example> = vec![]; // load from JSONL
|
|
//! let cfg = TrainingConfig::default();
|
|
//! let router = train_logreg(&examples, cfg);
|
|
//! let _ = router; // wire into a LearnedCascade
|
|
//! ```
|
|
|
|
#![forbid(unsafe_code)]
|
|
#![deny(missing_docs)]
|
|
|
|
pub mod bandit;
|
|
pub mod classifier;
|
|
pub mod error;
|
|
pub mod evaluation;
|
|
pub mod inference;
|
|
pub mod matrix_factorization;
|
|
pub mod router;
|
|
pub mod threshold;
|
|
pub mod training;
|
|
|
|
pub use bandit::{LinUcbArm, LinUcbRouter, ThompsonSamplingRouter};
|
|
pub use classifier::LogRegRouter;
|
|
pub use error::{Error, Result};
|
|
pub use evaluation::{RouterMetrics, evaluate};
|
|
pub use inference::LearnedCascade;
|
|
pub use matrix_factorization::MfRouter;
|
|
pub use router::{LearnedRouter, RouterState, StagePrediction};
|
|
pub use threshold::{ThresholdDecision, ThresholdPolicy};
|
|
pub use training::{Example, TrainingConfig, train_logreg, train_mf};
|