openpay/ (+3 crates)
op-bnpl/ Affirm + Klarna + Afterpay/Clearpay rails. Full lifecycle
typestate (Initiated→Approved→Captured→Settled→Refunded).
Per-provider sandbox+production base URLs, regions (NA/EU/OC
for Klarna; US/AuNz/Gb/Ca/Eu for Afterpay). HMAC-SHA256
webhook verification with constant-time compare. 61 tests.
op-batch/ NACHA ACH (94-char records, PPD/CCD/WEB/TEL/CTX, R01-R99
return codes, Same-Day ACH cutoffs); SEPA pain.001.001.09
(CT) + pain.008.001.08 (DD) with SCT-Inst flagging; Fedwire
MT103/MT202/CHIPS + pacs.008.001.12 / pacs.009.001.10 +
UETR; Bacs Standard 18. Per-rail cutoff scheduler. Exception
taxonomy unified across rails. 51 tests.
op-screening/ OFAC SDN + EU consolidated + UN consolidated + HMT UK
consolidated + Australia DFAT + Canada SEMA + Japan MOF.
Levenshtein + Jaro-Winkler + Soundex + Metaphone + token
Jaccard scoring. Unicode NFKD normalisation + Cyrillic /
Arabic transliteration. Ed25519-signed BLAKE3-chained
audit log. BSA helpers: CTR + SAR pattern detection
(structuring, round-dollar, rapid-in-out). 43 tests.
smart-byte/smart-byte-rs/ (+3 crates)
smart-byte-bbs/ BBS+ signatures (IETF draft-irtf-cfrg-bbs-signatures-08).
BLS12-381 keys, signatures, disclosure proofs with
cryptographic unlinkability. bbs-2023 Data Integrity
cryptosuite. AnonCreds-shaped link secrets +
predicate proofs. SecretKey zeroize-on-drop. 49 tests.
smart-byte-didcomm/ DIDComm v2 messaging per DIF spec. Pack-encrypted
(ECDH-1PU + ECDH-ES via X25519), pack-signed (JWS),
pack-plaintext. Aries protocols: issue-credential v3,
present-proof v3, basic-message, trust-ping, discover-
features, out-of-band, coordinate-mediation, message-
pickup. Mediator role with pluggable storage. 23 tests.
smart-byte-mdl/ ISO/IEC 18013-5 mobile driver's licence + 18013-7
online presentment. mDoc + MSO with salted-hash
selective disclosure (per item; SHA-256 digest tree).
org.iso.18013.5.1 namespace + AAMVA add-on. ES256
device-auth + issuer-auth. QR-code device-engagement
scaffolding. 28 tests.
eoc/eoc-rs/ (+3 crates)
eoc-local/ Local-inference backends behind one NeuralBackend:
llama.cpp (GGUF, Q4/Q5/Q6/Q8/F16/F32 quantisation),
MLX (Apple Silicon, feature-gated), MLC-LLM (TVM, feature-
gated marker), ONNX Runtime. GGUF file-format reader.
HuggingFace tokenizers. Greedy / top-k / top-p / temperature /
Mirostat samplers. Model registry scanning ~/.eoc/models/.
Joule attribution via eoc-meter. 39 tests.
eoc-rerank/ BM25 sparse + HNSW dense + RRF + min-max hybrid fusion.
Cohere v3.5 + Voyage v2 + bge-reranker v2-m3 + ms-marco
MiniLM + ColBERT v2 rerankers. Two-stage pipeline:
retrieve top-K hybrid → cross-encoder rerank → top-N.
KV-stage recovery shim into the cascade. 31 tests.
eoc-eval/ 15 canonical eval harnesses: MMLU, MMLU-Pro, GPQA,
HumanEval (pass@1 with python3 sandbox), BBH, IFEval (25
verifiable constraints), AlpacaEval, AGIEval, HellaSwag,
ARC (Easy + Challenge), TruthfulQA (MC1+MC2), BoolQ,
GSM8K, MATH (boxed-answer equivalence), Winogrande. Real
questions in BuiltinSamples. EvalRunner emits joules-per-
correct alongside accuracy. 49 tests.
Quality:
- cargo check across all three workspaces: clean
- cargo clippy --all-targets -- -D warnings on every new crate: clean
- 374 new tests, 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).
149 lines
4.6 KiB
Rust
149 lines
4.6 KiB
Rust
//! Integration tests for the vendor re-rank HTTP backends.
|
|
|
|
use eoc_rerank::reranker::{Candidate, Reranker};
|
|
use eoc_rerank::{CohereReranker, VoyageReranker};
|
|
use eoc_rerank::error::RerankError;
|
|
use serde_json::json;
|
|
use wiremock::matchers::{body_partial_json, header, method, path};
|
|
use wiremock::{Mock, MockServer, ResponseTemplate};
|
|
|
|
fn cohere_body() -> serde_json::Value {
|
|
json!({
|
|
"id": "x",
|
|
"results": [
|
|
{"index": 1, "relevance_score": 0.95},
|
|
{"index": 0, "relevance_score": 0.20},
|
|
],
|
|
"meta": {}
|
|
})
|
|
}
|
|
|
|
fn voyage_body() -> serde_json::Value {
|
|
json!({
|
|
"object": "list",
|
|
"data": [
|
|
{"index": 1, "relevance_score": 0.99},
|
|
{"index": 0, "relevance_score": 0.10},
|
|
],
|
|
"model": "rerank-2",
|
|
"usage": {"total_tokens": 1}
|
|
})
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn cohere_happy_path_reorders_candidates() {
|
|
let server = MockServer::start().await;
|
|
Mock::given(method("POST"))
|
|
.and(path("/v2/rerank"))
|
|
.and(header("authorization", "Bearer sk-test"))
|
|
.and(body_partial_json(json!({
|
|
"model": "rerank-english-v3.0",
|
|
"query": "what is EOC?",
|
|
"documents": ["irrelevant filler", "Energy-optimized compute"]
|
|
})))
|
|
.respond_with(ResponseTemplate::new(200).set_body_json(cohere_body()))
|
|
.mount(&server)
|
|
.await;
|
|
|
|
let r = CohereReranker::new("sk-test", "rerank-english-v3.0")
|
|
.expect("ok")
|
|
.with_endpoint(format!("{}/v2/rerank", server.uri()));
|
|
|
|
let scored = r
|
|
.rerank(
|
|
"what is EOC?",
|
|
&[
|
|
Candidate::new("a", "irrelevant filler"),
|
|
Candidate::new("b", "Energy-optimized compute"),
|
|
],
|
|
)
|
|
.await
|
|
.expect("rerank ok");
|
|
|
|
assert_eq!(scored.len(), 2);
|
|
assert_eq!(scored[0].candidate.id, "b");
|
|
assert_eq!(scored[0].rank, 1);
|
|
assert!(scored[0].score > scored[1].score);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn cohere_401_no_retry() {
|
|
let server = MockServer::start().await;
|
|
Mock::given(method("POST"))
|
|
.and(path("/v2/rerank"))
|
|
.respond_with(ResponseTemplate::new(401))
|
|
.expect(1)
|
|
.mount(&server)
|
|
.await;
|
|
let r = CohereReranker::new("sk-bad", "rerank-english-v3.0")
|
|
.expect("ok")
|
|
.with_endpoint(format!("{}/v2/rerank", server.uri()));
|
|
let res = r.rerank("q", &[Candidate::new("a", "x")]).await;
|
|
assert!(matches!(res, Err(RerankError::InvalidApiKey)));
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn cohere_429_then_succeeds() {
|
|
let server = MockServer::start().await;
|
|
Mock::given(method("POST"))
|
|
.and(path("/v2/rerank"))
|
|
.respond_with(ResponseTemplate::new(429).insert_header("retry-after", "0"))
|
|
.up_to_n_times(1)
|
|
.mount(&server)
|
|
.await;
|
|
Mock::given(method("POST"))
|
|
.and(path("/v2/rerank"))
|
|
.respond_with(ResponseTemplate::new(200).set_body_json(cohere_body()))
|
|
.mount(&server)
|
|
.await;
|
|
let r = CohereReranker::new("k", "rerank-english-v3.0")
|
|
.expect("ok")
|
|
.with_endpoint(format!("{}/v2/rerank", server.uri()))
|
|
.with_max_retries(3);
|
|
let scored = r
|
|
.rerank(
|
|
"q",
|
|
&[Candidate::new("a", "x"), Candidate::new("b", "y")],
|
|
)
|
|
.await
|
|
.expect("eventually ok");
|
|
assert_eq!(scored.len(), 2);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn voyage_happy_path() {
|
|
let server = MockServer::start().await;
|
|
Mock::given(method("POST"))
|
|
.and(path("/v1/rerank"))
|
|
.respond_with(ResponseTemplate::new(200).set_body_json(voyage_body()))
|
|
.mount(&server)
|
|
.await;
|
|
let r = VoyageReranker::new("k", "rerank-2")
|
|
.expect("ok")
|
|
.with_endpoint(format!("{}/v1/rerank", server.uri()));
|
|
let scored = r
|
|
.rerank(
|
|
"q",
|
|
&[Candidate::new("a", "x"), Candidate::new("b", "y")],
|
|
)
|
|
.await
|
|
.expect("ok");
|
|
assert_eq!(scored[0].candidate.id, "b");
|
|
assert_eq!(scored[0].rank, 1);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn voyage_429_exhausts_budget() {
|
|
let server = MockServer::start().await;
|
|
Mock::given(method("POST"))
|
|
.and(path("/v1/rerank"))
|
|
.respond_with(ResponseTemplate::new(429).insert_header("retry-after", "0"))
|
|
.mount(&server)
|
|
.await;
|
|
let r = VoyageReranker::new("k", "rerank-2")
|
|
.expect("ok")
|
|
.with_endpoint(format!("{}/v1/rerank", server.uri()))
|
|
.with_max_retries(1);
|
|
let res = r.rerank("q", &[Candidate::new("a", "x")]).await;
|
|
assert!(matches!(res, Err(RerankError::RateLimited { .. })));
|
|
}
|