Skip to main content

uor_addr/
lib.rs

1//! `uor-addr` — UOR-ADDR, the typed reference vocabulary for typed
2//! content-addressing across recursively-grammared formats.
3//!
4//! UOR-ADDR sits at the standard-library layer per ADR-031: every
5//! format-specific addressing realization shares the [`common`]
6//! architectural surface — the [`AddressInput`] trait, the single
7//! [`AddrBounds`] capacity profile, the single [`AddressLabel`] output
8//! shape, and the single format-independent [`AddressResolverTuple`]
9//! ψ-tower — while supplying its own concrete `prism_model!` + `verb!`
10//! plus a canonical-form input handle (ADR-060: the handle's
11//! `as_binding_value` produces the canonical bytes as a source-
12//! polymorphic [`prism::operation::TermValue`] carrier, so the ψ-tower is
13//! shared verbatim and there is no fixed input buffer or size cap).
14//!
15//! ## Authoritative sources
16//!
17//! Every realization shipped in this crate cites the authoritative
18//! standard for the canonical form it implements. The complete index
19//! lives in [`STANDARDS.md`](https://github.com/UOR-Foundation/uor-addr/blob/main/STANDARDS.md);
20//! each module's docstring carries the same citation inline.
21//!
22//! - JSON realization — RFC 8259 (syntax), RFC 8785 (canonical form),
23//!   UAX #15 (NFC), FIPS 180-4 (SHA-256).
24//! - S-expression realization — Rivest 1997 canonical S-expressions
25//!   (`Sexp.txt`), RFC 2693 §3 (SPKI canonical form citation),
26//!   FIPS 180-4 (SHA-256).
27//! - Storage cost-model variant — ADR-048 typed-commitment surface,
28//!   ADR-047 U6 bandwidth-additivity, QS-06 storage-tier admission
29//!   exemplar.
30//!
31//! ## Module layout
32//!
33//! - [`common`] — the shared architectural surface (trait, V&V
34//!   framing).
35//! - [`hash`] — the pluggable σ-axis family (`AddrHash`): sha256
36//!   (default), blake3, sha3-256, keccak256, sha512 — every realization's
37//!   `address_<algorithm>` entry points.
38//! - [`label`] — the per-axis `AddressLabel*` output shapes
39//!   (`https://uor.foundation/addr/AddressLabel/<algorithm>`) and the
40//!   width-generic [`KappaLabel`] κ-label carrier.
41//! - **Format-specific realizations** — [`json`] (JCS-RFC8785 + NFC),
42//!   [`sexp`] (Rivest 1997), [`xml`] (W3C XML-C14N 1.1 subset),
43//!   [`asn1`] (X.690 DER), [`ring`] (UOR-Framework Amendment 43 §2),
44//!   [`codemodule`] (CCMAS), [`cbor`] (RFC 8949 §4.2).
45//! - **Schema-pinned descendants** — [`schema::photo`],
46//!   [`schema::document`], [`schema::codemodule_signed`].
47//! - **Cost-model-bearing variants** — [`variant::storage`]
48//!   (`AndCommitment<…, LexicographicLessEqThreshold>`),
49//!   [`variant::signed`] (`SingletonCommitment<UltrametricCloseTo<2>>`).
50//! - **Categorical composition** — [`composition`] (ADR-061): the five
51//!   operations on the Atlas image inside E₈ — `g2` (commutative binary
52//!   product), `f4` (± involution quotient), `e6` (degree-partition
53//!   filtration), `e7` (S₄-orbit augmentation), `e8` (direct embedding) —
54//!   each on all five σ-axes, composing operand κ-labels into a new one.
55//!
56//! ## What's shipped
57//!
58//! The full UOR-ADDR architectural surface — common trait + a pluggable
59//! σ-axis family (sha256 / blake3 / sha3-256 / keccak256 / sha512) + seven
60//! format-specific realizations + three schema-pinned descendants +
61//! two cost-model-bearing variants. See
62//! [`ARCHITECTURE.md`](https://github.com/UOR-Foundation/uor-addr/blob/main/ARCHITECTURE.md)
63//! for the architectural commitments each realization upholds and
64//! [`STANDARDS.md`](https://github.com/UOR-Foundation/uor-addr/blob/main/STANDARDS.md)
65//! for the authoritative-source citations.
66//!
67//! ## Validation & verification against the wiki specification
68//!
69//! Each architectural commitment names the wiki ADR or concept it
70//! satisfies. The wiki at
71//! `https://github.com/UOR-Foundation/UOR-Framework/wiki` is the
72//! normative source.
73//!
74//! | Wiki commitment                                            | Crate realisation                                                  |
75//! |------------------------------------------------------------|--------------------------------------------------------------------|
76//! | ADR-007 / ADR-010 pluggable Hasher (substrate ships none)  | [`hash::AddrHash`] — sha256 / blake3 / sha3-256 / keccak256 (`prism::crypto`) |
77//! | ADR-031 Prism standard library (`uor-prism` façade)        | `prism::pipeline` / `vocabulary` / `seal` / `crypto`                |
78//! | ADR-018 / ADR-037 HostBounds capacity profile              | the single shared [`AddrBounds`] (every realization binds it)       |
79//! | ADR-020 PrismModel<H, B, A, R, C> declaration              | [`json::AddressModel`] (and one per realization)                    |
80//! | ADR-023 typed-iso input shape                              | [`json::JsonValue`] (and one per format)                            |
81//! | ADR-024 implementation closure (verb!-emitted bodies)      | [`json::address_inference`] (one per realization)                   |
82//! | ADR-027 sealed Output shape (output_shape!-emitted)        | [`AddressLabel`] + per-axis `AddressLabel{Blake3,Sha3_256,Keccak256}` |
83//! | ADR-035 canonical k-invariants branch ψ_1 → ψ_7 → ψ_8 → ψ_9 | every realization's `address_inference` body                       |
84//! | ADR-035 verb-body ψ-residuals discipline                   | `verb_arena_contains_no_sigma_residuals` test per realization       |
85//! | ADR-036 ResolverTuple (eight resolver categories)          | the single shared [`AddressResolverTuple`] (format-independent)     |
86//! | ADR-046 canonicalization at carrier production             | each input handle's `as_binding_value` (host boundary, not ψ_9)     |
87//! | ADR-048 TypedCommitment (5th model parameter)              | [`EmptyCommitment`] default; [`variant::storage`] non-default       |
88//! | ADR-057 bounded recursive structural typing                | the recursive parsers' native-stack depth guards (`MAX_*_DEPTH`)    |
89//! | ADR-060 source-polymorphic value carrier (no fixed buffer) | input handles yield `Inline`/`Borrowed`/`Stream` [`prism::operation::TermValue`] |
90//! | TC-02 mechanism sealing                                    | [`AddressWitness`] owns the replayable `Trace<256>` + fingerprint   |
91//! | TC-05 replay round-trip (anamorphism)                      | [`AddressWitness::verify`] via `prism::replay::certify_from_trace`   |
92//! | Algebraic closure (ADR-024 / ADR-026)                      | `SITE_COUNT` disjoint `Site` constraints; χ(N(C)) = SITE_COUNT (71 sha256/blake3, 73 sha3-256, 74 keccak256, 135 sha512) |
93//!
94//! ## Quick reference
95//!
96//! - [`json::address`] — the JSON entry point: canonicalizes raw JSON
97//!   bytes (JCS-RFC8785 + NFC) and folds the borrowed canonical form
98//!   through the model's `forward()` method.
99//! - [`sexp::address`] — the S-expression entry point.
100//! - [`AddressInput`] — the common trait every realization implements.
101//! - [`AddressLabel`] — the default (sha256) ψ-pipeline output shape (71
102//!   sites — the wire-format `sha256:<64hex>` width); the other axes bind
103//!   `AddressLabel{Blake3,Sha3_256,Keccak256}`.
104
105#![cfg_attr(not(feature = "std"), no_std)]
106#![forbid(unsafe_code)]
107// Public docstrings link to crate-private symbols (UCD tables,
108// resolver-internal ShapeViolation constants) to keep the wiki-style
109// cross-references readable. These are intra-crate links, not broken
110// links — the doc-check axis still denies `broken-intra-doc-links`,
111// which catches actual rot.
112#![allow(rustdoc::private_intra_doc_links)]
113
114#[cfg(feature = "alloc")]
115extern crate alloc;
116
117// ── Shared architectural surface (ADR-060 single capacity profile +
118//    format-independent ψ-tower). ──
119pub mod bounds;
120pub mod canonical;
121pub mod common;
122pub mod hash;
123pub mod label;
124pub mod outcome;
125#[macro_use]
126mod realization;
127pub mod resolvers;
128
129// ── Format-specific realizations. ──
130// Each binds the shared `bounds::AddrBounds` + `resolvers` ψ-tower and
131// supplies a canonical-form input handle whose `as_binding_value`
132// produces the ADR-060 carrier (Inline / Borrowed / Stream). `gguf` and
133// `onnx` are feature-gated (they pull the `uor-prism-tensor` dtype dep
134// and need `alloc` for their skeleton buffers).
135pub mod asn1;
136pub mod cbor;
137pub mod codemodule;
138// Categorical composition of κ-labels (ADR-061): the five operations on
139// the Atlas image inside E₈. Builds `Vec` canonical forms from operand
140// digests, so the whole module is `alloc`-gated.
141#[cfg(feature = "alloc")]
142pub mod composition;
143#[cfg(feature = "gguf")]
144pub mod gguf;
145pub mod json;
146#[cfg(feature = "onnx")]
147pub mod onnx;
148pub mod ring;
149pub mod schema;
150pub mod sexp;
151pub mod variant;
152pub mod xml;
153
154// Common architectural surface re-exports.
155pub use bounds::{AddrBounds, AddrBounds64, ADDR_INLINE_BYTES, ADDR_INLINE_BYTES_64};
156pub use common::AddressInput;
157pub use hash::{AddrHash, MAX_DIGEST_BYTES, MAX_LABEL_BYTES};
158pub use label::{
159    AddressLabel, AddressLabelBlake3, AddressLabelKeccak256, AddressLabelSha256,
160    AddressLabelSha3_256, AddressLabelSha512, KappaLabel, LabelDecodeError, ADDRESS_LABEL_BYTES,
161};
162pub use outcome::{AddressOutcome, AddressWitness, VerifyError};
163pub use prism::pipeline::EmptyCommitment;
164pub use resolvers::AddressResolverTuple;
165
166/// The admissible σ-axes (re-exports of prism's hashers). Every realization
167/// binds [`Sha256Hasher`] by default and admits the others via its
168/// `address_<algorithm>` entry points. `Sha512Hasher` is a `Hasher<64>`
169/// (bound with [`AddrBounds64`]); the rest are `Hasher<32>`.
170pub use prism::crypto::{
171    Blake3Hasher, Keccak256Hasher, Sha256Hasher, Sha3_256Hasher, Sha512Hasher,
172};