uor-foundation 0.1.5

UOR Foundation — typed Rust traits for the complete ontology. Import and implement.
Documentation
// @generated by uor-crate from uor-ontology — do not edit manually

//! UOR Foundation — typed Rust traits for the complete ontology.
//!
//! Version: 0.1.5
//!
//! This crate exports every ontology class as a trait, every property as a
//! method, and every named individual as a constant. Implementations (like
//! PRISM) import these traits and provide concrete types.
//!
//! # Primitives
//!
//! All traits are generic over [`Primitives`], a type family that lets
//! implementors choose their own concrete representations for XSD types.
//!
//! ```rust,ignore
//! struct MyImpl;
//! impl uor_foundation::Primitives for MyImpl {
//!     type String = str;
//!     type Integer = i64;
//!     type NonNegativeInteger = u64;
//!     type PositiveInteger = u64;
//!     type Decimal = f64;
//!     type Boolean = bool;
//! }
//! ```
//!
//! # Module Structure
//!
//! - [`kernel`] — Immutable foundation: addressing, schema, operations
//! - [`bridge`] — Kernel-computed, user-consumed: queries, resolution, partitions, proofs
//! - [`user`] — Runtime declarations: types, morphisms, state
//!
//! # Enforcement Layer
//!
//! The [`enforcement`] module provides concrete types (not generic over
//! `Primitives`) for declarative validation. These form a three-layer
//! pipeline:
//!
//! **Layer 1 — Opaque Witnesses.** [`enforcement::Datum`],
//! [`enforcement::Validated`], [`enforcement::Derivation`],
//! [`enforcement::FiberBudget`]: sealed types with private fields that
//! prove a value passed through the cascade evaluator or the two-phase
//! minting boundary. Prism code consumes these but cannot fabricate them.
//!
//! **Layer 2 — Declarative Builders.** [`enforcement::CompileUnitBuilder`]
//! and 8 others collect the declarations required by each conformance
//! shape, then call `validate()` to get a `Validated<T>` or a
//! [`enforcement::ShapeViolation`] with machine-readable IRIs.
//!
//! **Layer 3 — Term AST.** [`enforcement::Term`] and
//! [`enforcement::TermArena`]: stack-resident, `#![no_std]`-safe
//! expression trees. Builders accept `Term` references (not closures),
//! keeping Prism declarations within the term language.
//!
//! # The `uor!` Macro
//!
//! The re-exported [`uor!`] macro parses EBNF surface syntax at compile
//! time and produces typed `Term` ASTs. Ground assertions (no free
//! variables) are evaluated at compile time using the foundation's
//! `const fn` ring arithmetic.
//!
//! ```rust,ignore
//! use uor_foundation::uor;
//!
//! // Type declaration with constraints:
//! let pixel = uor! { type Pixel { residue: 255; hamming: 8; } };
//!
//! // Operation composition (produces a TermArena):
//! let expr = uor! { add(mul(3, 5), 7) };
//!
//! // Ground assertion — checked at compile time:
//! uor! { assert add(1, 2) = 3; };
//! ```
//!
//! # Getting Started
//!
//! 1. Implement [`Primitives`] for your concrete type family.
//! 2. Use the [`enforcement`] builders to declare your types, effects,
//!    and boundaries.
//! 3. Use the [`uor!`] macro for term-language expressions.
//! 4. The cascade evaluator validates and evaluates your declarations,
//!    producing [`enforcement::Datum`] and [`enforcement::Derivation`]
//!    witnesses.

#![no_std]

pub mod bridge;
pub mod enforcement;
pub mod enums;
pub mod kernel;
pub mod user;

pub use enums::*;
pub use uor_foundation_macros::uor;

/// XSD primitive type family.
/// Implementors choose concrete representations for each XSD type.
/// PRISM might use `u64` for integers at Q0, `u128` at higher quantum
/// levels, or a bignum library. The foundation does not constrain this choice.
pub trait Primitives {
    /// String type (`xsd:string`). Use `str` for borrowed, `String` for owned.
    type String: ?Sized;
    /// Integer type (`xsd:integer`).
    type Integer;
    /// Non-negative integer type (`xsd:nonNegativeInteger`).
    type NonNegativeInteger;
    /// Positive integer type (`xsd:positiveInteger`).
    type PositiveInteger;
    /// Decimal type (`xsd:decimal`).
    type Decimal;
    /// Boolean type (`xsd:boolean`).
    type Boolean;
}