open-standards/eoc/eoc-rs/crates/eoc-rag/tests/naive_pipeline.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

52 lines
1.8 KiB
Rust

//! Integration test: naive RAG returns the most overlap-rich chunk
//! and records joule accounting in its trace.
use std::sync::Arc;
use eoc_rag::{
Chunk, CitationPolicy, DocumentStore, InMemoryStore, NaivePipeline, Pipeline, RagRequest,
Stage,
};
fn corpus() -> Arc<dyn DocumentStore> {
Arc::new(InMemoryStore::from_chunks(
"naive-test",
vec![
Chunk::new(
"rfc-eoc",
0,
"Energy-optimized compute measures joules per byte across the cascade.",
),
Chunk::new(
"rfc-misc",
0,
"Bicycles have wheels and frames, often made of aluminium.",
),
Chunk::new(
"rfc-rag",
0,
"Retrieval augmented generation embeds the query and stuffs top-k chunks.",
),
],
))
}
#[tokio::test]
async fn naive_pipeline_finds_eoc_chunk() {
let p = NaivePipeline::new(corpus()).with_citation_policy(CitationPolicy::Optional);
let req = RagRequest::new("joules per byte energy-optimized compute", 3);
let ans = p.answer(&req).await.expect("pipeline ok");
assert!(ans.text.contains("joules"));
assert!(ans.trace.events.iter().any(|e| e.stage == Stage::Retrieve));
assert!(ans.trace.events.iter().any(|e| e.stage == Stage::Generate));
assert!(ans.trace.total_microjoules() > 0);
}
#[tokio::test]
async fn naive_pipeline_no_match_returns_err() {
let p = NaivePipeline::new(corpus()).with_citation_policy(CitationPolicy::Optional);
let req = RagRequest::new("quantum chromodynamics gluon strong force", 3);
let res = p.answer(&req).await;
// The corpus has no overlap; jaccard yields zero -> NoChunks.
assert!(res.is_err());
}