Skip to main content

uor_addr/sexp/
verbs.rs

1//! S-expression realization's ψ-chain content-address derivation verb
2//! (wiki ADR-024 + ADR-035 + ADR-036 + ARCHITECTURE.md "Common verb
3//! arena").
4//!
5//! The verb body is **identical at the term-arena level** to every other
6//! UOR-ADDR realization — the canonical k-invariants branch
7//! (ψ₁ → ψ₇ → ψ₈ → ψ₉). Only the input handle type varies; the structural
8//! shape of the term arena is the same across every realization.
9
10use crate::label::{
11    AddressLabelBlake3, AddressLabelKeccak256, AddressLabelSha256, AddressLabelSha3_256,
12    AddressLabelSha512,
13};
14use crate::sexp::value::SExprValue;
15
16addr_verbs! {
17    input: SExprValue<'_>,
18    { shape: AddressLabelSha256, verb: address_inference },
19    { shape: AddressLabelBlake3, verb: address_inference_blake3 },
20    { shape: AddressLabelSha3_256, verb: address_inference_sha3_256 },
21    { shape: AddressLabelKeccak256, verb: address_inference_keccak256 },
22    { shape: AddressLabelSha512, verb: address_inference_sha512 },
23}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28    use prism::operation::Term;
29
30    #[test]
31    fn verb_term_arena_is_emitted_and_nonempty() {
32        let arena = address_inference_term_arena::<{ crate::ADDR_INLINE_BYTES }>();
33        assert!(!arena.is_empty());
34    }
35
36    #[test]
37    fn verb_arena_contains_psi_1_nerve() {
38        let arena = address_inference_term_arena::<{ crate::ADDR_INLINE_BYTES }>();
39        assert!(arena.iter().any(|t| matches!(t, Term::Nerve { .. })));
40    }
41
42    #[test]
43    fn verb_arena_contains_psi_7_postnikov_tower() {
44        let arena = address_inference_term_arena::<{ crate::ADDR_INLINE_BYTES }>();
45        assert!(arena
46            .iter()
47            .any(|t| matches!(t, Term::PostnikovTower { .. })));
48    }
49
50    #[test]
51    fn verb_arena_contains_psi_8_homotopy_groups() {
52        let arena = address_inference_term_arena::<{ crate::ADDR_INLINE_BYTES }>();
53        assert!(arena
54            .iter()
55            .any(|t| matches!(t, Term::HomotopyGroups { .. })));
56    }
57
58    #[test]
59    fn verb_arena_contains_psi_9_k_invariants() {
60        let arena = address_inference_term_arena::<{ crate::ADDR_INLINE_BYTES }>();
61        assert!(arena.iter().any(|t| matches!(t, Term::KInvariants { .. })));
62    }
63
64    #[test]
65    fn verb_arena_contains_no_sigma_residuals() {
66        let arena = address_inference_term_arena::<{ crate::ADDR_INLINE_BYTES }>();
67        assert!(!arena.iter().any(|t| matches!(t, Term::FirstAdmit { .. })));
68        assert!(!arena
69            .iter()
70            .any(|t| matches!(t, Term::AxisInvocation { .. })));
71    }
72}