open-standards/eoc/eoc-rs/crates/eoc-rag/tests/rag_fusion_rrf.rs
Transaction Science e11c20b1eb ingest wave A3: 3 crates · op-ewallets-asia + smart-byte-zk + eoc-rag
OpenPay (1 crate, 3277 LOC, 18 tests)
  op-ewallets-asia    APAC e-wallet rail adapters. Alipay Cross-Border v3,
                      WeChat Pay (JSAPI/Native/H5/MicroPay) with constant-time
                      HMAC notify, UPI 2.0 (collect/intent/mandate/VPA),
                      Paytm, GrabPay, GoPay (Midtrans), Touch'n Go.
                      EMVCo MPM TLV + CRC-16/CCITT-FALSE encoder for
                      PromptPay (TH), PayNow (SG), DuitNow (MY), QRIS (ID).
                      Transport-free traits — operators inject HTTP + RSA-SHA256
                      signers (keeps POS firmware / WASM consumers reqwest-free).

Smart Byte (1 crate, 1310 LOC, 15 tests)
  smart-byte-zk       Selective-disclosure ZK primitives.
                      Real: Bulletproofs over Ristretto255 (range proofs at
                      8/16/32/64-bit), RangePredicate / InequalityPredicate /
                      SetMembershipPredicate all delegating to Bulletproofs.
                      Stubs (documented): Groth16, PLONK — deterministic
                      placeholder proofs satisfying ZkScheme trait for future
                      arkworks integration. AnonCred sketch + VerifiablePresentation
                      builder.

EOC (1 crate, ~3000 LOC, 36 tests)
  eoc-rag             RAG orchestrator. Naive (Lewis 2020), HyDE (Gao 2022),
                      RAG-Fusion + RRF (Cormack 2009), Self-RAG (Asai 2023)
                      with Retrieve/ISREL/ISSUP/ISUSE critique tokens,
                      Corrective RAG (Yan 2024) with retrieval evaluator
                      + external fallback, Adaptive RAG (Jeong 2024)
                      complexity router. Chunking: sentence-window, semantic,
                      recursive, late-chunking. Span-backed citations with
                      3-mode enforcement. SelfCheckGPT consistency guard.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-05-24 12:08:49 -04:00

43 lines
1.2 KiB
Rust

//! Integration test: RAG-Fusion's RRF promotes chunks that appear
//! across multiple rewrites.
use eoc_rag::{Chunk, RetrievedChunk, reciprocal_rank_fusion};
fn rc(doc: &str, text: &str, score: f32, rank: usize) -> RetrievedChunk {
RetrievedChunk {
chunk: Chunk::new(doc, 0, text),
score,
rank,
}
}
#[test]
fn rrf_consensus_wins() {
// Three rewrite rankings. `consensus` is top-3 in all three;
// `solo` is top-1 in only one. RRF should promote `consensus`.
let r1 = vec![
rc("solo", "x", 0.99, 1),
rc("consensus", "x", 0.50, 2),
rc("filler1", "x", 0.10, 3),
];
let r2 = vec![
rc("consensus", "x", 0.90, 1),
rc("filler2", "x", 0.40, 2),
rc("solo", "x", 0.05, 3),
];
let r3 = vec![
rc("consensus", "x", 0.80, 1),
rc("filler3", "x", 0.30, 2),
rc("filler1", "x", 0.20, 3),
];
let fused = reciprocal_rank_fusion(&[r1, r2, r3], 60.0, 5);
assert_eq!(fused[0].chunk.doc_id, "consensus");
// 1-based rank populated.
assert_eq!(fused[0].rank, 1);
}
#[test]
fn rrf_empty_input_safe() {
let fused: Vec<RetrievedChunk> = reciprocal_rank_fusion(&[], 60.0, 5);
assert!(fused.is_empty());
}