OpenPay (1 crate, 2487 LOC, 33 tests)
op-fraud-graph Graph-based fraud detection. EntityKind (card/email/
device/IP/address/phone/BIN+last4/account) with
canonicalization + hashed EntityKey + billing↔shipping
mismatch detection. Adjacency-list FraudGraph with
idempotent upsert + edge-merge. Double-hashing Bloom
filter (capacity+FPR-sized). Union-find connected
components. PageRank with dangling-sink handling.
Louvain community detection. Shared-instrument hub
rings. Sliding ring-buffer velocity counters. Synthetic
identity heuristics (freshness + heavy-use + mail-drop).
Structuring / smurfing / mule-chain DFS. EntityRisk +
TransactionRisk + RiskBand combiner.
Smart Byte (1 crate, ~1844 LOC, 44 tests)
smart-byte-ilp Interledger Protocol v4. OER codec (length-determinant,
var-octet-string, BE u32/u64). Prepare/Fulfill/Reject
packet roundtrip with all 19 IL-RFC-27 reject codes.
SHA-256 Condition + Fulfillment with constant-time
verify. ILP address validator (7 schemes, 1-128 char
segments, 1023-byte cap, segment-aligned prefix match).
STREAM (15 frame types). BTP. SPSP payment-pointer
resolver. Open Payments API. Longest-prefix routing
Connector with fixed-point quote conversion + balance +
rate-limit checks.
EOC (1 crate, 1921 LOC, 36 tests)
eoc-quantize Quantization primitives. int8 (symmetric/asymmetric
with zero-inclusion fix), int4 (GPTQ + AWQ group quant),
int2 (BitNet), fp8 (E4M3/E5M2), nf4 (QLoRA). GGUF v3
header parse. safetensors read sketch. Calibration
datasets + per-channel scales. KV-cache quant. Energy
tradeoff curves (joules-per-token across schemes).
Co-Authored-By: Claude Opus 4.7 <[email protected]>
66 lines
2.4 KiB
Rust
66 lines
2.4 KiB
Rust
//! Typed errors for the ILP adapter.
|
|
|
|
use thiserror::Error;
|
|
|
|
/// All ILP-side errors collapse into a single typed enum so callers can
|
|
/// match on the kind without depending on intermediate modules.
|
|
#[derive(Debug, Error)]
|
|
pub enum IlpError {
|
|
/// OER decode failed — input was truncated, length-determinant was
|
|
/// malformed, or a fixed-size field was the wrong size.
|
|
#[error("oer decode error: {0}")]
|
|
Oer(String),
|
|
/// Packet type byte was not one of `12` / `13` / `14`.
|
|
#[error("unknown packet type: {0}")]
|
|
UnknownPacketType(u8),
|
|
/// A field that was decoded was syntactically valid but semantically
|
|
/// out of range (e.g. a `Prepare` with an empty destination).
|
|
#[error("invalid packet: {0}")]
|
|
InvalidPacket(String),
|
|
/// An ILP address failed scheme / segment / length validation.
|
|
#[error("invalid address: {0}")]
|
|
InvalidAddress(String),
|
|
/// The hashlock condition did not match its fulfillment.
|
|
#[error("condition mismatch")]
|
|
ConditionMismatch,
|
|
/// A STREAM frame referred to an unknown frame type.
|
|
#[error("unknown stream frame: {0}")]
|
|
UnknownStreamFrame(u8),
|
|
/// A BTP packet referenced an unknown packet type.
|
|
#[error("unknown btp packet type: {0}")]
|
|
UnknownBtpPacketType(u8),
|
|
/// An SPSP receiver document was malformed or missing required fields.
|
|
#[error("spsp error: {0}")]
|
|
Spsp(String),
|
|
/// An Open Payments request was malformed or referenced an unknown
|
|
/// resource.
|
|
#[error("open payments error: {0}")]
|
|
OpenPayments(String),
|
|
/// The connector could not find a route for the given destination.
|
|
#[error("no route to {0}")]
|
|
NoRoute(String),
|
|
/// The forwarding decision was blocked by a balance or rate-limit
|
|
/// invariant.
|
|
#[error("balance/rate-limit: {0}")]
|
|
Balance(String),
|
|
/// A currency-conversion step lacked a quote for the given pair.
|
|
#[error("no quote for {from}/{to}")]
|
|
NoQuote {
|
|
/// Source asset code (e.g. `USD`).
|
|
from: String,
|
|
/// Destination asset code (e.g. `XRP`).
|
|
to: String,
|
|
},
|
|
/// JSON encode / decode failed (used by SPSP and Open Payments).
|
|
#[error("json error: {0}")]
|
|
Json(String),
|
|
}
|
|
|
|
impl From<serde_json::Error> for IlpError {
|
|
fn from(e: serde_json::Error) -> Self {
|
|
IlpError::Json(e.to_string())
|
|
}
|
|
}
|
|
|
|
/// Convenience result alias.
|
|
pub type Result<T> = core::result::Result<T, IlpError>;
|