1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
//! Standard type library.
//!
//! `std_types` is `prism`'s realization of the wiki's
//! [Building Block View § Whitebox `prism`](https://github.com/UOR-Foundation/UOR-Framework/wiki/05-Building-Block-View#whitebox-prism)
//! component named "standard type library" — the catalog of pre-declared
//! types built from `uor-foundation`'s vocabulary, available so
//! application authors do not have to derive common shape patterns
//! from first principles. Per ADR-017 the catalog is **canonical**: it
//! is the addressing surface that schema-import tools and applications
//! target so traces and certificates address consistently across the
//! ecosystem.
//!
//! The catalog is layered:
//!
//! - **Foundation-supplied surface (re-exports).** The ten morphism
//! kinds (`BinaryGroundingMap`, …, `Utf8ProjectionMap`), the
//! structural marker traits (`Total`, `Invertible`,
//! `PreservesStructure`, `PreservesMetric`), the sealed
//! `GroundedValue`/`GroundedShape` family, `ConstrainedTypeInput`,
//! `CartesianProductShape` and its `kunneth_compose` helper, the
//! partition-algebra families (`*Witness`, `*Evidence`,
//! `*MintInputs`, `PartitionResolver`, `PartitionHandle`,
//! `NullPartition`, `VerifiedMint`), and the `OntologyVerifiedMint`
//! sealed mint trait.
//! - **First-class prism-defined surface.** [`FixedSites<N>`],
//! [`Bytes<N>`], and the byte-aligned numeric / character / boolean
//! primitives (`U8` … `I256`, `F32`, `F64`, `Bool`, `Char`).
//!
//! ## IRI rule (closure under `uor-foundation`)
//!
//! The IRI of every prism-defined stdlib type is **derived from its
//! constraint declaration, not from the Rust type name** — this is the
//! direct quote from
//! [Concepts § Closure Under uor-foundation][08-closure]
//! and the binding rule of ADR-017. Concretely: every prism stdlib
//! type with empty `CONSTRAINTS` shares the same IRI
//! (`https://uor.foundation/type/ConstrainedType`, the foundation's
//! ontology class for `ConstrainedTypeShape` instances). Instance
//! identity flows through `(SITE_COUNT, CONSTRAINTS)`, so distinct
//! site counts produce distinct content-addresses while same-shape
//! Rust types (e.g., `U32` and `I32`) produce **identical**
//! content-addresses by design — the Rust name is for the developer,
//! the IRI is for content-addressing.
//!
//! See [AGENTS.md § 11](../../../AGENTS.md#11-standard-type-library-policy)
//! for the inclusion / exclusion criteria, the catalog growth tracks
//! (baseline vs. specialized), and the implementation pattern every
//! stdlib type follows.
//!
//! [08-closure]: https://github.com/UOR-Foundation/UOR-Framework/wiki/08-Concepts#closure-under-uor-foundation
//!
//! # See also
//!
//! - [Wiki: 05 Building Block View § Whitebox `prism`](https://github.com/UOR-Foundation/UOR-Framework/wiki/05-Building-Block-View#whitebox-prism)
//! - [Wiki: 09 Architecture Decisions § ADR-017](https://github.com/UOR-Foundation/UOR-Framework/wiki/09-Architecture-Decisions)
//! - [Wiki: 12 Glossary § Term Definitions](https://github.com/UOR-Foundation/UOR-Framework/wiki/12-Glossary#term-definitions)
//!
//! # Constraints
//!
//! - **TC-02** — the morphism-kind traits are sealed by foundation; no
//! downstream extension is permitted
//! - **TC-04** — the kind classification participates in compile-time
//! UORassembly enforcement (a `Grounding` impl whose `Map` does not
//! inhabit [`GroundingMapKind`] fails to compile)
//! - **ADR-017** — addresses are content-deterministic; the catalog is
//! operational, not declarative
//!
//! # C4 placement
//!
//! Component `standard type library` (Level 3) inside container `prism`
//! (Level 2). It is consumed by application authors implementing
//! [`uor_foundation::enforcement::Grounding`] or
//! [`uor_foundation::enforcement::Sinking`].
//!
//! # Behavior
//!
//! ```rust
//! // Given: the ten morphism-kind marker types
//! // When: each is used as a phantom type parameter
//! // Then: the foundation's sealed trait family classifies them
//! // identically to the foundation's own use sites
//! use prism::std_types::{
//! BinaryGroundingMap, BinaryProjectionMap, DigestGroundingMap,
//! DigestProjectionMap, IntegerGroundingMap, IntegerProjectionMap,
//! JsonGroundingMap, JsonProjectionMap, Utf8GroundingMap,
//! Utf8ProjectionMap,
//! };
//! fn _accepts_grounding<M: prism::std_types::GroundingMapKind>() {}
//! fn _accepts_projection<M: prism::std_types::ProjectionMapKind>() {}
//! _accepts_grounding::<BinaryGroundingMap>();
//! _accepts_grounding::<DigestGroundingMap>();
//! _accepts_grounding::<IntegerGroundingMap>();
//! _accepts_grounding::<JsonGroundingMap>();
//! _accepts_grounding::<Utf8GroundingMap>();
//! _accepts_projection::<BinaryProjectionMap>();
//! _accepts_projection::<DigestProjectionMap>();
//! _accepts_projection::<IntegerProjectionMap>();
//! _accepts_projection::<JsonProjectionMap>();
//! _accepts_projection::<Utf8ProjectionMap>();
//!
//! // And: the structural marker traits classify each kind as the
//! // ontology declares. `BinaryGroundingMap` is total and invertible;
//! // `IntegerGroundingMap` additionally preserves structure; the
//! // foundation rejects (at compile time) any attempt to claim a
//! // structural property a kind does not carry.
//! use prism::std_types::{Invertible, PreservesStructure, Total};
//! fn _total_invertible<M: prism::std_types::GroundingMapKind + Total + Invertible>() {}
//! fn _preserves_structure<M: prism::std_types::GroundingMapKind + PreservesStructure>() {}
//! _total_invertible::<BinaryGroundingMap>();
//! _total_invertible::<IntegerGroundingMap>();
//! _preserves_structure::<IntegerGroundingMap>();
//! _preserves_structure::<JsonGroundingMap>();
//! _preserves_structure::<Utf8GroundingMap>();
//! ```
pub use ;
// Sealed structural marker traits that classify morphism kinds. Authors
// use these in trait bounds to require, for example, an invertible
// grounding map without naming the concrete kind. The traits are
// foundation-sealed; downstream cannot add new structural classes.
pub use ;
// The two sealed `GroundedValue` variants returned by `Grounding` impls,
// plus their sealed marker traits. `GroundedValue` is the closed set
// of permitted intermediates (`GroundedCoord` and `GroundedTuple<N>`);
// `GroundedShape` is the closed-set bound on the `T` of `Grounded<T>`.
pub use ;
// `ConstrainedTypeInput` is the foundation's pre-declared canonical
// constrained-type shape: a built-in `ConstrainedTypeShape` impl that
// participates in the principal data path without the application
// author having to declare a fresh shape. It is the closest thing the
// standard type library has to a "prelude" type and is the canonical
// example used in the trace-replay round-trip scenario.
pub use ConstrainedTypeInput;
// `CartesianProductShape` is the foundation's canonical
// `ConstrainedTypeShape` for products of two component shapes (added in
// uor-foundation 0.3.1). It routes nerve-Betti computation through
// Künneth composition of component Betti profiles rather than flat
// pair-enumeration. Selecting it in a `result_type::<P>()` call admits
// a CartesianPartitionProduct unit through the principal data path.
pub use kunneth_compose;
pub use CartesianProductShape;
// Partition-algebra evidence, witness, and mint-input families. These
// are the cross-crate construction inputs and outputs for product,
// coproduct, and Cartesian-product partitions added by foundation
// 0.3.1's Product/Coproduct Completion Amendment. `PartitionResolver`,
// `PartitionRecord`, `PartitionHandle`, and `NullPartition` are the
// runtime-side carriers; `*Evidence`, `*Witness`, and `*MintInputs`
// classify the verified-mint bundles.
pub use ;
// `OntologyVerifiedMint` is the sealed mint trait introduced in 0.3.1
// for ontology-derived Path-2 witnesses. It carries a `HostTypes`-
// parameterized GAT `Inputs<H>` so witness inputs can hold
// host-decimal and handle fields without leaking concrete types.
pub use OntologyVerifiedMint;
// ---- First-class stdlib types (§ 11 of AGENTS.md) ----
use ;
/// `FixedSites<N>` — admit exactly `N` sites, unconstrained per-site.
///
/// The simplest non-trivial standard-type-library citizen: a generic
/// `ConstrainedTypeShape` that fixes a site count and imposes no
/// per-site constraint. It is the parametric building block under any
/// downstream shape that wants "this many sites, my own grounding
/// admission decides what each site contains" — for example, a 32-byte
/// hash output (32 sites at `WittLevel::W8`), an 80-byte Bitcoin block
/// header (80 sites at `WittLevel::W8`), or a 16-element
/// integer-vector at `WittLevel::W64`.
///
/// At any instantiation, `<FixedSites<N> as ConstrainedTypeShape>::SITE_COUNT == N`
/// and `<FixedSites<N> as ConstrainedTypeShape>::CONSTRAINTS` is the empty
/// slice (foundation reads "empty `CONSTRAINTS`" as "unconstrained" per
/// the trait's normative documentation). The IRI is the foundation's
/// `ConstrainedType` class IRI — shared across every empty-constraint
/// stdlib type per [ADR-017][09-adr-017] and the closure rule documented
/// in this module's header — so instance identity flows entirely
/// through `(SITE_COUNT, CONSTRAINTS)`.
///
/// [09-adr-017]: https://github.com/UOR-Foundation/UOR-Framework/wiki/09-Architecture-Decisions
///
/// # See also
///
/// - [Wiki: 05 Building Block View § Whitebox `prism`](https://github.com/UOR-Foundation/UOR-Framework/wiki/05-Building-Block-View#whitebox-prism)
/// - [Wiki: 09 Architecture Decisions § ADR-017](https://github.com/UOR-Foundation/UOR-Framework/wiki/09-Architecture-Decisions)
///
/// # Constraints
///
/// - **TC-01** — admission is a compile-time activity; `SITE_COUNT` and
/// `CONSTRAINTS` are `const`-evaluable
/// - **TC-04** — bilateral compile-time enforcement: a downstream
/// author who consumes `FixedSites<N>` cannot violate the contract
/// without the toolchain rejecting their program
/// - **ADR-013** — closure under `uor-foundation`: the body uses only
/// foundation vocabulary (`ConstrainedTypeShape`, `ConstraintRef`)
/// - **ADR-017** — content-addressed identity: the
/// `(IRI, SITE_COUNT, CONSTRAINTS)` triple deterministically encodes
/// each instantiation
///
/// # Behavior
///
/// ```rust
/// // Given: a fixed-32-sites shape
/// // When: its trait constants are read
/// // Then: SITE_COUNT reflects N and CONSTRAINTS is empty
/// use prism::pipeline::ConstrainedTypeShape;
/// use prism::std_types::FixedSites;
/// assert_eq!(<FixedSites<32> as ConstrainedTypeShape>::SITE_COUNT, 32);
/// assert!(<FixedSites<32> as ConstrainedTypeShape>::CONSTRAINTS.is_empty());
/// assert_eq!(
/// <FixedSites<32> as ConstrainedTypeShape>::IRI,
/// "https://uor.foundation/type/ConstrainedType",
/// );
/// // And: a different N produces a distinct content-address — same
/// // IRI, different SITE_COUNT — so the (IRI, SITE_COUNT, CONSTRAINTS)
/// // triple distinguishes the two instantiations.
/// assert_eq!(<FixedSites<80> as ConstrainedTypeShape>::SITE_COUNT, 80);
/// assert_eq!(
/// <FixedSites<80> as ConstrainedTypeShape>::IRI,
/// <FixedSites<32> as ConstrainedTypeShape>::IRI,
/// );
/// ```
;
/// `Bytes<N>` — byte-buffer admission intent of width `N`.
///
/// Structurally identical to [`FixedSites<N>`] and content-address-
/// identical at equal `N` (closure rule: same constraint declaration ⇒
/// same IRI ⇒ same UOR address). Use `Bytes<N>` when the unit's intent
/// is "this is a byte sequence" and `FixedSites<N>` when the intent is
/// "this is a generic site container of width N"; the Rust type name
/// distinguishes intent at the call site, the IRI does not.
///
/// # See also
///
/// - [`crate::std_types`] — the family contract and IRI namespace
/// - [Wiki: 05 Building Block View § Whitebox `prism`](https://github.com/UOR-Foundation/UOR-Framework/wiki/05-Building-Block-View#whitebox-prism)
/// - [AGENTS.md § 11](../../../AGENTS.md#11-standard-type-library-policy)
///
/// # Constraints
///
/// - **TC-01** — admission is compile-time
/// - **TC-04** — bilateral compile-time enforcement
/// - **ADR-013** — closure under `uor-foundation`
/// - **ADR-017** — content-addressed identity via the IRI
///
/// # Behavior
///
/// ```rust
/// use prism::pipeline::ConstrainedTypeShape;
/// use prism::std_types::{Bytes, FixedSites};
/// // Same SITE_COUNT and same IRI as FixedSites<N> per closure.
/// assert_eq!(<Bytes<32> as ConstrainedTypeShape>::SITE_COUNT, 32);
/// assert_eq!(
/// <Bytes<32> as ConstrainedTypeShape>::IRI,
/// "https://uor.foundation/type/ConstrainedType",
/// );
/// assert_eq!(
/// <Bytes<32> as ConstrainedTypeShape>::IRI,
/// <FixedSites<32> as ConstrainedTypeShape>::IRI,
/// );
/// ```
;
// ---- Typed primitives (baseline per AGENTS.md § 11.4) ----
//
// Each typed primitive is a unit struct that impls `ConstrainedTypeShape`
// with a stable IRI under `uor.foundation/prism/std_types/<TypeName>`,
// `SITE_COUNT` set to its byte width when used at `WittLevel::W8`, and
// empty `CONSTRAINTS`. Value-level invariants (IEEE 754 well-formedness,
// `Bool ∈ {0, 1}`, UTF-32 codepoint validity) are host-side decisions
// enforced by the application's `Grounding` impl per the family contract
// laid out in this module's docs and in AGENTS.md § 11.
// Unsigned integers — byte-aligned widths from 8 to 256 bits.
typed_primitive!;
typed_primitive!;
typed_primitive!;
typed_primitive!;
typed_primitive!;
typed_primitive!;
// Signed integers — same byte widths, distinct IRIs to self-document
// signed admission intent.
typed_primitive!;
typed_primitive!;
typed_primitive!;
typed_primitive!;
typed_primitive!;
typed_primitive!;
// IEEE 754 floating-point — IEEE well-formedness (NaN, subnormal
// handling) is the application's `Grounding` impl's responsibility.
typed_primitive!;
typed_primitive!;
// Boolean — value-in-{0, 1} contract is enforced host-side; the
// distinct IRI separates `Bool` from `U8` at the content-address level.
typed_primitive!;
// Character — UTF-32 codepoint width; Unicode validity is host-side.
typed_primitive!;