open-standards/smart-byte/smart-byte-rs/crates/smart-byte-acdc/tests/edge_graph.rs
Transaction Science 68b8a2dbee ingest wave F: 3 crates · op-crypto-extra + smart-byte-acdc + eoc-memory
OpenPay (1 crate, 3751 LOC, 83 tests)
  op-crypto-extra      Extended crypto rails. Stablecoin catalog (USDC, USDT,
                       PYUSD, DAI, RLUSD, EURC, FDUSD — 26 deployments). L2
                       catalog (12 chains incl. Optimism, Arbitrum, Base,
                       zkSync Era, Polygon zkEVM, Linea, Scroll, Starknet).
                       CCTP v2 BurnMessage encode/decode + domain ids +
                       attestation. ERC-4337 UserOperation v0.7 +
                       PackedUserOperation. EIP-7702 set-EOA-code with RLP
                       signing preimage. Uniswap Permit2 single + batch
                       transfer EIP-712 hashes. EIP-2612 ERC-20 permit.
                       BOLT-11 bech32 invoices + LNURL decode. Bitcoin
                       PSBT v2 (BIP-370). Atomic-swap HTLC. Solana SPL /
                       Aleo / Aztec confidential-transfer sketches.

Smart Byte (1 crate, 2304 LOC, 30 tests)
  smart-byte-acdc      Authentic Chained Data Containers (KERI ecosystem).
                       Acdc + AcdcBuilder (targeted + untargeted) with SAID
                       derivation. JSON Schema 2020-12 validator with
                       oneOf partial-disclosure. TEL (RIP/VRT/ISS/REV)
                       with hash-chained verification. IPEX (apply/offer/
                       agree/grant/admit/spurn) chained by SAID. Edge
                       records (I2I/NI2I/DI2I) + EdgeGraph BFS traversal
                       with cycle detection. Selective disclosure with
                       full/none/subset plans + compact packing.
                       CredentialRegistry trait + InMemoryRegistry over
                       TEL. Composes with smart-byte-core + smart-byte-keri-witness.

EOC (1 crate, 1764 LOC, 16 tests)
  eoc-memory           Long-term memory primitives. Memory trait + MemoryKind +
                       EpisodeId. Episodic event log with TimeIndex range
                       queries. RDF-style Triple store with S/P/O indices.
                       Bounded attention-budget Scratchpad with
                       salience-weighted eviction. Rolling SummaryBuffer +
                       FIFO SlidingWindow. Dream-cycle consolidate()
                       (episodic → semantic). Ebbinghaus forgetting curve
                       with reinforcement. Retriever blending cosine
                       similarity + recency + saturating frequency.
                       MemGpt three-tier shape (Main/Recall/Archival).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
2026-05-24 17:28:24 -04:00

96 lines
2.5 KiB
Rust

//! Edge section: link multiple ACDCs into a DAG and traverse.
use serde_json::json;
use smart_byte_acdc::{
Acdc, AcdcBuilder, AttributeSection, Edge, EdgeGraph, EdgeOp, SchemaSection,
acdc::EdgeSection,
};
use smart_byte_core::Said;
fn mk(name: &str, edges: Vec<Edge>) -> Acdc {
let mut s = serde_json::Map::new();
s.insert("$id".into(), json!(name));
let mut a = serde_json::Map::new();
a.insert("name".into(), json!(name));
let mut section = EdgeSection::default();
for e in edges {
section.0.insert(e.label.clone(), e.to_json());
}
AcdcBuilder::new()
.issuer("Bissuer")
.schema(SchemaSection::Inline(s))
.attributes(AttributeSection::Inline(a))
.edges(section)
.build()
.expect("build")
}
#[test]
fn three_node_chain_traverses_in_order() {
let leaf = mk("leaf", vec![]);
let mid = mk(
"mid",
vec![Edge {
label: "down".into(),
target: leaf.d,
schema: None,
operator: EdgeOp::I2I,
}],
);
let root = mk(
"root",
vec![Edge {
label: "child".into(),
target: mid.d,
schema: None,
operator: EdgeOp::Ni2i,
}],
);
let root_id = root.d;
let mut g = EdgeGraph::new();
g.insert(leaf.clone()).expect("ins");
g.insert(mid.clone()).expect("ins");
g.insert(root).expect("ins");
let order = g.traverse(&root_id).expect("traverse");
assert_eq!(order.len(), 3);
assert_eq!(order[0], root_id);
assert_eq!(order[1], mid.d);
assert_eq!(order[2], leaf.d);
}
#[test]
fn missing_target_caught() {
let lonely = mk(
"lonely",
vec![Edge {
label: "phantom".into(),
target: Said([0xCDu8; 32]),
schema: None,
operator: EdgeOp::I2I,
}],
);
let id = lonely.d;
let mut g = EdgeGraph::new();
g.insert(lonely).expect("ins");
assert!(g.traverse(&id).is_err());
}
#[test]
fn edge_records_roundtrip() {
let leaf = mk("leaf", vec![]);
let parent = mk(
"parent",
vec![Edge {
label: "issued-by".into(),
target: leaf.d,
schema: Some(Said::hash(b"some-schema")),
operator: EdgeOp::Di2i,
}],
);
let edges = Edge::parse_section(&parent.e).expect("parse");
assert_eq!(edges.len(), 1);
assert_eq!(edges[0].operator, EdgeOp::Di2i);
assert!(edges[0].schema.is_some());
}