uor_addr/codemodule/mod.rs
1//! **`uor_addr::codemodule` — the code-module AST realization of
2//! UOR-ADDR** (ARCHITECTURE.md "Format-specific realizations" §
3//! `uor-addr-codemodule`).
4//!
5//! Code-module AST typed-input content-addressing under the
6//! Canonical Code-Module AST Serialization (CCMAS) — a
7//! S-expression-shaped canonical AST grammar pinned by this crate
8//! and serialized through Rivest 1997's canonical S-expression form.
9//!
10//! ## Authoritative sources
11//!
12//! - **Canonical Code-Module AST Serialization (CCMAS)** — pinned
13//! inline below; the grammar's normative source is this module
14//! plus the conformance fixtures under `crate::codemodule::value`'s
15//! `#[cfg(test)]` mod.
16//! - **Canonical S-expressions** — Rivest 1997 *S-expressions*
17//! (<https://people.csail.mit.edu/rivest/Sexp.txt>) supplies the
18//! byte-output discipline CCMAS extends with AST-shaped term
19//! constructors.
20//! - **SHA-256 σ-projection** — NIST FIPS 180-4
21//! (<https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf>).
22//!
23//! ## CCMAS grammar
24//!
25//! The Canonical Code-Module AST Serialization (CCMAS) is a
26//! S-expression-shaped grammar over five AST cases:
27//!
28//! ```text
29//! CodeModuleValue ::= Module(name, items)
30//! | Function(name, parameters, return_type, body)
31//! | TypeDeclaration(name, fields)
32//! | ConstDeclaration(name, type, value)
33//! | Expression(literal | variable | call)
34//! ```
35//!
36//! Each AST node serializes to a structurally-tagged byte form
37//! whose canonical-form output is a Rivest canonical S-expression
38//! shaped as:
39//!
40//! ```text
41//! Module(name, [items]) → (3:mod <n:name> <item_1> <item_2> ... <item_k>)
42//! Function(name, params, ret, body)
43//! → (3:fun <n:name> (<param_1> ... <param_p>) <ret_type> <body_expr>)
44//! TypeDeclaration(name, fields) → (3:type <n:name> (<field_1> ... <field_f>))
45//! ConstDeclaration(name, ty, v) → (3:const <n:name> <ty> <v>)
46//! Expression → format-specific case (atom for literal, atom for variable, (3:call ...) for call)
47//! ```
48//!
49//! The CCMAS canonical form is byte-output-equivalent to
50//! [`crate::sexp::canonicalize`] applied to the tagged surface AST —
51//! the canonicalization composes Rivest §4.2/§4.3 over the AST's
52//! grammar cases.
53
54pub mod model;
55pub mod pipeline;
56pub mod value;
57pub mod verbs;
58
59pub use model::{
60 AddressModel, AddressModelBlake3, AddressModelKeccak256, AddressModelSha3_256,
61 AddressModelSha512, AddressRoute,
62};
63pub use pipeline::{
64 address, address_blake3, address_keccak256, address_sha3_256, address_sha512, AddressFailure,
65 AddressOutcome, AddressWitness, VerifyError,
66};
67pub use value::CodeModuleCarrier;
68#[cfg(feature = "alloc")]
69pub use value::{canonicalize, CodeModuleValue};
70pub use verbs::{address_inference, VERB_TERMS_ADDRESS_INFERENCE};
71
72/// The shared, format-independent ψ-tower (re-exported for convenience;
73/// canonical path is [`crate::resolvers::AddressResolverTuple`]).
74pub use crate::resolvers::AddressResolverTuple;