Skip to main content

Module std_types

Module std_types 

Source
Expand description

Standard type library.

std_types is prism’s realization of the wiki’s 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 (U8I256, 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 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 for the inclusion / exclusion criteria, the catalog growth tracks (baseline vs. specialized), and the implementation pattern every stdlib type follows.

§See also

§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

// 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>();

Structs§

BinaryGroundingMap
v0.2.2 W4: kind for raw byte ingestion. Total and invertible; preserves bit identity only.
BinaryProjectionMap
Target §3: kind for raw byte projections. Total and invertible; preserves bit identity only.
Bool
Boolean (1 byte at WittLevel::W8). The value-in-{0, 1} contract is enforced host-side by the application’s Grounding impl; the distinct IRI separates Bool from U8 at the content-address level.
Bytes
Bytes<N> — byte-buffer admission intent of width N.
CartesianProductEvidence
Evidence bundle for CartesianProductWitness. Carries the CPT_1 / CPT_3 / CPT_4 / CPT_5 input values used at mint time, plus combined_entropy_nats — the CartesianProductWitness itself does not store entropy (see §1a), so the evidence sidecar preserves the verification target value for re-audit.
CartesianProductMintInputs
Inputs to CartesianProductWitness::mint_verified. Matches the CartesianProduct mint primitive’s parameter list.
CartesianProductWitness
Sealed CartesianPartitionProduct witness — content-addressed assertion that a shape is CartesianPartitionProduct(left, right) per CPT_2a. Minting verifies CPT_1, CPT_3, CPT_4, CPT_5, and the foundation CartesianLayoutWidth invariant. The witness stores a snapshot of the combined topological invariants (χ, Betti profile) because the construction is axiomatic at the invariant level per §3c. Entropy is not stored here (f64 has no Eq/Hash); use the paired CartesianProductEvidence for entropy re-audit.
Char
Unicode codepoint (4 bytes at WittLevel::W8, UTF-32 width). Unicode validity (codepoint range, surrogate exclusion) is enforced host-side by the application’s Grounding impl.
ConstrainedTypeInput
Input shim for type:ConstrainedType. Used as Certify::Input for InhabitanceResolver, TowerCompletenessResolver, and IncrementalCompletenessResolver.
DigestGroundingMap
v0.2.2 W4: kind for one-way digest functions (e.g., SHA-256). Total but not invertible; preserves no structure.
DigestProjectionMap
Target §3: kind for fixed-size digests projected outward. Total but not invertible; preserves no structure.
F32
IEEE 754 binary32 floating-point (4 bytes at WittLevel::W8). Well-formedness (NaN, subnormal, and infinity policy) is enforced host-side by the application’s Grounding impl.
F64
IEEE 754 binary64 floating-point (8 bytes at WittLevel::W8). Well-formedness is enforced host-side.
FixedSites
FixedSites<N> — admit exactly N sites, unconstrained per-site.
GroundedCoord
A single grounded coordinate value. Not a Datum [this is the narrow intermediate that a Grounding impl produces]. The foundation validates and mints it into a Datum. Uses the same closed level-tagged family as Datum, ensuring that coordinate width matches the target Witt level.
GroundedTuple
A grounded tuple: a fixed-size array of GroundedCoord values. Represents a structured type (e.g., the 8 coordinates of an E8 lattice point). Not a Datum until the foundation validates and mints it. Stack-resident, no heap allocation.
I8
Signed 8-bit integer (1 byte at WittLevel::W8).
I16
Signed 16-bit integer (2 bytes at WittLevel::W8).
I32
Signed 32-bit integer (4 bytes at WittLevel::W8).
I64
Signed 64-bit integer (8 bytes at WittLevel::W8).
I128
Signed 128-bit integer (16 bytes at WittLevel::W8).
I256
Signed 256-bit integer (32 bytes at WittLevel::W8).
IntegerGroundingMap
v0.2.2 W4: kind for integer surface symbols. Total, invertible, structure-preserving.
IntegerProjectionMap
Target §3: kind for integer surface symbols projected outward. Invertible, structure-preserving.
JsonGroundingMap
v0.2.2 W4: kind for JSON host strings. Invertible on its image, structure-preserving.
JsonProjectionMap
Target §3: kind for JSON host strings projected outward. Invertible, structure-preserving.
NullPartition
Resolver-absent default Partition<H>. Embeds inline stubs for every sub-trait associated type so Partition<H> accessors return references to fields rather than to statics. The only meaningful state is the fingerprint; everything else uses HostTypes::EMPTY_* defaults. Returned by the three witness trait impls’ left_factor / right_factor / left_summand / etc. accessors as the resolver-absent value pathway. Consumers needing real partition data pair the sibling PartitionHandle with a PartitionResolver instead.
PartitionCoproductEvidence
Evidence bundle for PartitionCoproductWitness. Carries the ST_1 / ST_2 / ST_9 / ST_10 input values used at mint time.
PartitionCoproductMintInputs
Inputs to PartitionCoproductWitness::mint_verified. Adds three structural fields beyond the other two MintInputs: the combined constraint array, the boundary index between L and R regions, and the tag site layout index. These feed validate_coproduct_structure at mint time so ST_6 / ST_7 / ST_8 are verified numerically rather than trusted from the caller. Derives Debug, Clone, Copy only — no PartialEq. ConstraintRef does not implement PartialEq, so deriving equality on a struct with a &[ConstraintRef] field would not compile. MintInputs is not used as an equality target in practice; downstream consumers compare the minted witness (which derives Eq + Hash) instead.
PartitionCoproductWitness
Sealed PartitionCoproduct witness — content-addressed assertion that a partition decomposes as PartitionCoproduct(left, right) per PT_2b. Minting verifies ST_1, ST_2, ST_6, ST_7, ST_8, ST_9, ST_10, the foundation CoproductLayoutWidth invariant, and — for ST_6/ST_7/ST_8 — walks the supplied constraint array through validate_coproduct_structure.
PartitionHandle
Content-addressed identity token for a partition. Carries only a fingerprint; partition data is recovered by pairing the handle with a PartitionResolver via resolve_with. Handles compare and hash by fingerprint, so they can serve as keys in content-addressed indices without resolver access.
PartitionProductEvidence
Evidence bundle for PartitionProductWitness. Carries the PT_1 / PT_3 / PT_4 input values used at mint time. Derives PartialEq only because f64 entropy fields exclude Eq / Hash; this is the auditing surface, not a hash-map key.
PartitionProductMintInputs
Inputs to PartitionProductWitness::mint_verified. Mirrors the underlying primitive’s parameter list; each field is supplied by the caller (typically a product_shape! macro expansion or a manual construction following the amendment’s Gap 2 pattern). Derives PartialEq only because of the f64 entropy fields.
PartitionProductWitness
Sealed PartitionProduct witness — content-addressed assertion that a partition decomposes as PartitionProduct(left, right) per PT_2a. Minting is gated on PT_1, PT_3, PT_4, and the foundation ProductLayoutWidth invariant being verified against component shapes. Existence of an instance is the attestation — there is no partial or unverified form.
PartitionRecord
Data record of a partition’s runtime-queried properties. Produced at witness-mint time and consulted by consumer code that holds a PartitionHandle and a PartitionResolver. Phase 9 stores entropy as the IEEE-754 u64 bit-pattern (entropy_nats_bits) so the record derives Eq + Hash cleanly; consumers project to H::Decimal via <H::Decimal as DecimalTranscendental>::from_bits.
U8
Unsigned 8-bit integer (1 byte at WittLevel::W8).
U16
Unsigned 16-bit integer (2 bytes at WittLevel::W8).
U32
Unsigned 32-bit integer (4 bytes at WittLevel::W8). Width of a Bitcoin block-header nonce.
U64
Unsigned 64-bit integer (8 bytes at WittLevel::W8).
U128
Unsigned 128-bit integer (16 bytes at WittLevel::W8).
U256
Unsigned 256-bit integer (32 bytes at WittLevel::W8). Width of a SHA-256 output and a Bitcoin difficulty target.
Utf8GroundingMap
v0.2.2 W4: kind for UTF-8 host strings. Invertible on its image, structure-preserving.
Utf8ProjectionMap
Target §3: kind for UTF-8 host strings projected outward. Invertible, structure-preserving.

Traits§

CartesianProductShape
Marker for a ConstrainedTypeShape that is the Cartesian product of two component shapes. Selecting this trait routes nerve-Betti computation through Künneth composition of component Betti profiles rather than flat enumeration of (constraint, constraint) pairs. Introduced by the Product/Coproduct Completion Amendment §3c for CartesianPartitionProduct (CPT_1–CPT_6).
GroundedShape
Sealed marker trait identifying type:ConstrainedType subclasses that may appear as the parameter of Grounded<T>. Per wiki ADR-027, the seal is the same __sdk_seal::Sealed supertrait foundation uses for FoundationClosed, PrismModel, and IntoBindingValue: only foundation and the SDK shape macros emit impls. The foundation-sanctioned identity output ConstrainedTypeInput retains its direct impl; application authors declaring custom Output shapes invoke the output_shape! SDK macro, which emits __sdk_seal::Sealed, GroundedShape, IntoBindingValue, and ConstrainedTypeShape together.
GroundedValue
Sealed marker trait for grounded intermediates. Implemented only for GroundedCoord and GroundedTuple<N>. Prism code cannot implement this [the sealed module pattern prevents it].
GroundingMapKind
v0.2.2 W4: sealed marker trait for the kind of a Grounding map. Implemented by exactly the morphism:GroundingMap individuals declared in the ontology; downstream cannot extend the kind set.
Invertible
v0.2.2 W4: kinds whose map is injective and admits an inverse on its image.
MorphismKind
Target §3: sealed marker trait shared by all morphism kinds. GroundingMapKind (inbound) and ProjectionMapKind (outbound) both extend this trait; the four structural markers (Total, Invertible, PreservesStructure, PreservesMetric) are bounded on MorphismKind.
OntologyVerifiedMint
Phase 10 — sealed mint trait for ontology-derived Path-2 witnesses. Distinct from VerifiedMint (used by the partition-algebra amendment): the new trait carries a HostTypes-parameterized GAT Inputs<H> so witness inputs can hold H::Decimal / {Range}Handle<H> fields without leaking f64 into the trait shape. Sealed via the Certificate supertrait.
PartitionResolver
Resolver mapping content fingerprints to PartitionRecords. Provided by the host application — typically a persistent store, an in-memory registry populated from witness mint-time data, or a chain-of-witnesses trail that can reconstruct properties.
PreservesMetric
v0.2.2 W4: kinds whose map preserves the metric of the source domain (isometry-like).
PreservesStructure
v0.2.2 W4: kinds whose map preserves the algebraic structure of the source domain (homomorphism-like).
ProjectionMapKind
Target §3: sealed marker trait for the kind of a Sinking projection. Implemented by exactly the morphism:ProjectionMap individuals declared in the ontology; downstream cannot extend the kind set.
Total
v0.2.2 W4: kinds whose image is total over the input domain (every input maps successfully).
VerifiedMint
Sealed mint path for certificates that require multi-theorem verification before minting. Introduced by the Product/Coproduct Completion Amendment §1c; distinct from MintWithLevelFingerprint (which is the generic partial-mint path for sealed shims). VerifiedMint implementors are the three partition-algebra witnesses, each routing through a foundation-internal mint primitive that verifies the relevant theorems. The trait is public so external callers can invoke mint_verified directly, but the Certificate supertrait’s certificate_sealed::Sealed bound keeps the implementor set closed to this crate.

Functions§

kunneth_compose
Künneth composition of two Betti profiles. Computes out[k] = Σ_{i + j = k} a[i] · b[j] over [0, MAX_BETTI_DIMENSION). All arithmetic uses saturating operations so the function is total on [u32; MAX_BETTI_DIMENSION] inputs without panicking.