uor-foundation 0.1.3

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

//! `conformance/` namespace — SHACL-equivalent constraint shapes defining what a Prism implementation must provide at each extension point. Machine-verifiable contracts..
//!
//! Space: Bridge

use crate::Primitives;

/// A constraint shape that a Prism-declared extension must satisfy. Analogous to sh:NodeShape in SHACL.
pub trait Shape<P: Primitives> {
    /// The OWL class that instances of this shape must belong to.
    fn target_class(&self) -> &P::String;
    /// Associated type for `PropertyConstraint`.
    type PropertyConstraint: PropertyConstraint<P>;
    /// A required property in this shape.
    fn required_property(&self) -> &[Self::PropertyConstraint];
}

/// A single required property within a shape: the property URI, its expected range, minimum and maximum cardinality.
pub trait PropertyConstraint<P: Primitives> {
    /// The property URI that must be present.
    fn constraint_property(&self) -> &P::String;
    /// The expected range of the required property.
    fn constraint_range(&self) -> &P::String;
    /// Minimum cardinality of the required property.
    fn min_count(&self) -> P::NonNegativeInteger;
    /// Maximum cardinality (0 = unbounded).
    fn max_count(&self) -> P::NonNegativeInteger;
}

/// Shape for declaring a new QuantumLevel beyond Q3.
pub trait QuantumLevelShape<P: Primitives>: Shape<P> {}

/// Shape for declaring an ExternalEffect.
pub trait EffectShape<P: Primitives>: Shape<P> {}

/// Shape for declaring a ParallelProduct.
pub trait ParallelShape<P: Primitives>: Shape<P> {}

/// Shape for declaring a ProductiveStream (targets stream:Unfold, the coinductive constructor).
pub trait StreamShape<P: Primitives>: Shape<P> {}

/// Shape for declaring a new DispatchRule in a DispatchTable.
pub trait DispatchShape<P: Primitives>: Shape<P> {}

/// Shape for declaring a Lease with LinearFiber allocation.
pub trait LeaseShape<P: Primitives>: Shape<P> {}

/// Shape for declaring a GroundingMap from surface data to the ring.
pub trait GroundingShape<P: Primitives>: Shape<P> {}

/// The result of validating an extension against a shape: conforms (boolean), and violation details if non-conformant.
pub trait ValidationResult<P: Primitives> {
    /// Associated type for `Shape`.
    type Shape: Shape<P>;
    /// The shape that was validated against.
    fn validation_shape(&self) -> &Self::Shape;
    /// The instance that was validated.
    fn validation_target(&self) -> &P::String;
    /// True iff the target satisfies all constraints of the shape.
    fn conforms(&self) -> P::Boolean;
}

/// Shape for user-declared predicates. Requires a bounded evaluator (termination witness) and input type declaration.
pub trait PredicateShape<P: Primitives>: Shape<P> {}

/// Shape validating that a CompileUnit carries all required properties before cascade admission. The unitAddress property is NOT required — it is computed by stage_initialization after shape validation passes.
pub mod compile_unit_shape {
    /// `requiredProperty`
    pub const REQUIRED_PROPERTY: &[&str] = &[
        "https://uor.foundation/conformance/compileUnit_rootTerm_constraint",
        "https://uor.foundation/conformance/compileUnit_unitQuantumLevel_constraint",
        "https://uor.foundation/conformance/compileUnit_thermodynamicBudget_constraint",
        "https://uor.foundation/conformance/compileUnit_targetDomains_constraint",
    ];
    /// `targetClass` -> `CompileUnit`
    pub const TARGET_CLASS: &str = "https://uor.foundation/cascade/CompileUnit";
}

/// Exactly one root term is required. Range is schema:Term.
pub mod compile_unit_root_term_constraint {
    /// `constraintProperty` -> `rootTerm`
    pub const CONSTRAINT_PROPERTY: &str = "https://uor.foundation/cascade/rootTerm";
    /// `constraintRange` -> `Term`
    pub const CONSTRAINT_RANGE: &str = "https://uor.foundation/schema/Term";
    /// `maxCount`
    pub const MAX_COUNT: i64 = 1;
    /// `minCount`
    pub const MIN_COUNT: i64 = 1;
}

/// Exactly one quantum level is required. Range is schema:QuantumLevel.
pub mod compile_unit_unit_quantum_level_constraint {
    /// `constraintProperty` -> `unitQuantumLevel`
    pub const CONSTRAINT_PROPERTY: &str = "https://uor.foundation/cascade/unitQuantumLevel";
    /// `constraintRange` -> `QuantumLevel`
    pub const CONSTRAINT_RANGE: &str = "https://uor.foundation/schema/QuantumLevel";
    /// `maxCount`
    pub const MAX_COUNT: i64 = 1;
    /// `minCount`
    pub const MIN_COUNT: i64 = 1;
}

/// Exactly one thermodynamic budget is required. Shape validates presence and type; the BudgetSolvencyCheck preflight validates the value against the Landauer bound.
pub mod compile_unit_thermodynamic_budget_constraint {
    /// `constraintProperty` -> `thermodynamicBudget`
    pub const CONSTRAINT_PROPERTY: &str = "https://uor.foundation/cascade/thermodynamicBudget";
    /// `constraintRange` -> `decimal`
    pub const CONSTRAINT_RANGE: &str = "http://www.w3.org/2001/XMLSchema#decimal";
    /// `maxCount`
    pub const MAX_COUNT: i64 = 1;
    /// `minCount`
    pub const MIN_COUNT: i64 = 1;
}

/// At least one target verification domain is required. maxCount 0 means unbounded.
pub mod compile_unit_target_domains_constraint {
    /// `constraintProperty` -> `targetDomains`
    pub const CONSTRAINT_PROPERTY: &str = "https://uor.foundation/cascade/targetDomains";
    /// `constraintRange` -> `VerificationDomain`
    pub const CONSTRAINT_RANGE: &str = "https://uor.foundation/op/VerificationDomain";
    /// `maxCount`
    pub const MAX_COUNT: i64 = 0;
    /// `minCount`
    pub const MIN_COUNT: i64 = 1;
}