-
Notifications
You must be signed in to change notification settings - Fork 16
06 Runtime View
This chapter specifies Prism’s behavior at runtime through four scenarios. The scenarios are normative: a conforming Prism implementation MUST exhibit the behavior each scenario describes. The scenarios collectively cover every cross-boundary interaction enumerated in section 3 (Context and Scope) and every component interaction relevant to constraints TC-01 through TC-06 (section 2).
The scenarios are:
-
Principal Data Path Execution — what happens at runtime when the application author’s compiled executable processes input through
pipeline::run. -
Trace-Replay Verification — what happens when the application user invokes
certify_from_traceagainst aTracethey received. -
Compile-Time UORassembly Enforcement — what happens when the Rust toolchain compiles the application author’s source against
prism; not a runtime scenario in the conventional sense, but a deterministic interaction whose specification is necessary for the wiki’s normative completeness. -
Distribute and Run — what happens between the application author finishing compilation and the user obtaining the final output of the executable.
This scenario specifies the runtime behavior of the application author’s
compiled executable when it invokes pipeline::run. The interaction is
internal to the executable; no external system is contacted, no service
is reached, no I/O occurs beyond what the application author’s domain
code performs.
-
The application’s domain code obtains host bytes from its input source (a file, a stream, a memory buffer — the source is not Prism’s concern).
-
The application invokes the author’s
Groundingimpl on the host bytes. TheGroundingimpl is the author’s specification of how host bytes are interpreted as a candidate for admission to the principal data path. -
The
Groundingimpl returns either aDatum(the input is admitted) or a typed impossibility witness (the input is rejected at the admission stage). If a witness is returned, this scenario terminates here; the application receives the witness and processes it according to its domain logic. -
Given a
Datum, the application invokesCompileUnitBuilderwith the author’sConstrainedTypeShapeimpl. The builder accumulates the constraints declared by the shape impl and produces aValidated<CompileUnit, Phase>at intermediate phases. -
The builder transitions through the validation phases. Each phase confirms a subset of the
ConstrainedTypeShapeconstraints. Failure at any phase produces a typedShapeViolationand this scenario terminates; the application receives the violation. -
When all phases succeed, the builder produces
Validated<CompileUnit, FinalPhase>. -
The application invokes
prism'spipeline::run(or higher-levelpipeline::run_route) with theValidated<CompileUnit, FinalPhase>and the substrate parameters per ADR-030 + ADR-036:H: HostTypes,B: HostBounds,A: AxisTuple + Hasher(the substitution-axis tuple with the canonical hash axis bound — for the canonical first axis,HashAxisfrom prism-crypto per ADR-031), andR: ResolverTuple(defaulting toNullResolverTuplefor verb bodies that emit no resolver-bound ψ-Term variants; otherwise carrying application-provided per-value content).H/B/Aflow as type parameters only (axis methods are type-associated and invoked through<A as Hasher>::initial());Rflows as a value reference (resolvers: &R). TheDatumadmission in step 3 was produced byuor-foundation'smint_datumprimitive (called from inside theGroundingimpl); subsequent UOR-domain admissions (Triad,Derivation,FreeRank) are produced byuor-foundation's mint primitives, called from insidepipeline::runat the corresponding stages. -
pipeline::runexecutes the principal data path’sPipelineRunstage. It evaluates the route’s Term tree as a structural fold (the catamorphism per ADR-029), applying the per-variant fold-rules across all twenty-oneTermvariants:Term::Literalemits a constant byte sequence at its declared Witt level;Term::Variablelooks up the binding identified byname_index(name_index = 0resolves to the route input value serialized viaIntoBindingValueper ADR-023; other indices resolve tolet-introduced bindings);Term::Applicationapplies aPrimitiveOpto the recursively-folded args (per the canonical catalog at the snapshot per ADR-013/TR-08, including byte-level comparison and concatenation per the foundation 0.3.5+ catalog);Term::Lift/Projectperform Witt-level transitions;Term::Matchdispatches on the scrutinee against the arm patterns;Term::Recurseperforms well-founded recursion guarded by the descent measure with the iteration counter bound through the foundation-fixedRECURSE_IDX_NAME_INDEXper ADR-034;Term::Unfoldperforms the coalgebraic step;Term::Trypropagates failures through the outer Result or routes them through a handler;Term::AxisInvocation(the substitution-axis-realized verb form per ADR-026 G19, generalized per ADR-030) routes through the application’sAxisTupleselection to the right axis impl; per ADR-055’s universal substrate-Term verb body discipline, the fold-rule then recursively folds the axis impl’sSubstrateTermBody::body_arena()static Term slice rather than calling an opaque kernel function, extending fold-fusion’s structural reach to the leaf level across every axis surface for every axis impl (standard-library AND application-author custom);Term::ProjectField(per ADR-033) slices a byte range from a recursively-folded source value to extract a product-shape field;Term::FirstAdmit(per ADR-034) iteratesidxascending across[0, <domain>::CYCLE_SIZE)with the candidate bound through the foundation-fixedFIRST_ADMIT_IDX_NAME_INDEX, structurally short-circuiting at the first admitting candidate and emitting a coproduct-shaped TermValue ((0x01, idx_bytes)for found,(0x00, padding)for not-found); the nine ψ-chain Term variants per ADR-035 (Nerve,ChainComplex,HomologyGroups,Betti,CochainComplex,CohomologyGroups,PostnikovTower,HomotopyGroups,KInvariants) lower from closure-body grammar forms G21-G29 and parallel the ontology-defined ψ-maps (ψ_1..ψ_9) — eight of the variants are resolver-bound, dispatching through theHas<Category>Resolver<A>marker-trait accessors on the model’sR: ResolverTupleper ADR-036 at evaluation time (per ADR-060 each resolver returns aTermValuedirectly —fn resolve(&self, input: TermValue<'a, {carrier_inline_bytes::<B>()}>) → Result<TermValue<'a, {carrier_inline_bytes::<B>()}>, ShapeViolation>— constructing whichever carrier variantInline/Borrowed/Streamits ψ-stage output requires, rather than the pre-0.5.0 writer-style form that wrote into a caller-supplied&mut [u8]and returned a byte count; per-ψ-stage carrier widths derive from foundationconst fnand no per-stage allocation occurs forInline/Borrowedoutputs; per ADR-057, the ψ_1 NerveResolver additionally resolvesConstraintRef::Recursereferences encountered while walking the typed-feature-hierarchy’s CONSTRAINTS array, consulting foundation’sshape_iri_registryvialookup_shape(shape_iri)and unrolling the referenced shape’s CONSTRAINTS up to the descent budget — the simplicial complex N© emerges from the dynamically-unrolled constraint set with the descent decrement bottoming out at the typed feature hierarchy’s irreducible leaves), and the resolver-free variantBettiextracts the Betti-number array directly from the HomologyGroups byte serialization; resolver shape-violations (RESOLVER_ABSENTforNullResolverTuple's Null* impls,CAPACITY_EXCEEDEDfor oversized outputs) propagate throughTerm::Tryper ADR-022 D3 G9. The ψ-residuals discipline per ADR-035 + ADR-056 forbids direct syntactic emissions ofTerm::FirstAdmit,Term::AxisInvocation, and byte-comparison/concat PrimitiveOps from the route body’s syntactic surface (theprism_model!-declaredrouteclosure body); compound verbs per ADR-024, axis impl bodies per ADR-055, and resolver bodies per ADR-046 may compose the full substrate vocabulary internally — fold-fusion per ADR-054 inlines them through the catamorphism at evaluation time without exposing residual forms at the route surface. The canonical compiled form is the k-invariants branch ψ_1 → ψ_7 → ψ_8 → ψ_9 producing a constant-width κ-label that classifies the value’s homotopy type up to weak equivalence. The catamorphism produces output bytes, populated into theGrounded's value payload (per ADR-028, accessible viaoutput_bytes()). The stage produces aGrounded<Output>(carrying both the metadata fingerprint and the value payload) and aTracesimultaneously, constructed from the same data so that replayability (constraint TC-05) holds by construction.Validated,Grounded, andCertifiedare constructed byprism's seal regime. -
The canonical hash axis (
HashAxisfrom prism-crypto per ADR-031, consumed type-associatedly through theA: AxisTuple + Hashersubstrate parameter per ADR-030 + ADR-036 via<A as Hasher>::initial()) is invoked exactly once during pipeline execution — at the certificate emission stage, to compute theContentFingerprintcarried by theGroundingCertificate. The route body’s syntactic surface contains no axis-method invocations (the ψ-residuals discipline per ADR-035 + ADR-056 forbids directTerm::AxisInvocationemissions from the route closure body); compound verbs declared viaverb!per ADR-024 and axis impl bodies per ADR-055 may invoke axis methods internally through the substrate-Term verb body discipline (fold-fusion per ADR-054 inlines them at the catamorphism without exposing residual forms at the route surface), and resolver impls invoked by resolver-bound ψ-Term fold-rules may internally call the canonical hash axis as part of producing per-value structural witnesses; those calls are resolver- or fold-fusion-internal and conceptually distinct from the certificate-emission invocation. -
The application receives
(Grounded<Output>, Trace)and proceeds with its domain logic. The output value is read from the Grounded viaoutput_bytes()(ADR-028); the metadata fingerprint andunit_addressremain accessible for path attestation and content addressing. For typed feature hierarchies whose admission relations are inhabitance questions, the application consumesGrounded<Output>as thecert:InhabitanceCertificateenvelope per ADR-039 + ADR-042 via the foundation-provided typed view Grounded::as_inhabitance_certificate(&self) -> InhabitanceCertificate<'_, Output>. The view’s accessors expose the κ-label viakappa_label()(theTerm::KInvariantsemission at ψ_9 per ADR-035, returned as KInvariantsBytes<'_> per ADR-041), the concretecert:witnessValueTuple viawitness()(derivable fromTerm::Nerve's 0-simplices at ψ_1), thecert:searchTraceviasearch_trace()(the recoverableTraceper ADR-019’s anamorphism dual), and thecert:certifiedTypeIRI viacertified_type(). A catamorphism failureErr(PipelineFailure)whose structural cause is "the constraint nerve has empty Kan completion" yields acert:InhabitanceImpossibilityCertificateenvelope viaPipelineFailure::as_inhabitance_impossibility_certificate(&self) → Option<…>, withcontradiction_proof()exposing the canonical-form failure trace (theproof:InhabitanceImpossibilityWitnesspayload).
This scenario satisfies the following normative properties:
-
No code outside
uor-foundationandprismis invoked during steps 4 through 9. The interaction is contained within the application’s compiled executable plus both crates' compiled code. (The pipeline runtime is inprism; the four UOR-domain mint primitives are inuor-foundation; the three Prism-mechanism sealed-type constructors are inprism's seal regime.) -
No allocation occurs in the default-feature build (the
#![no_std]posture, section 8). With theallocfeature enabled, allocation is bounded by theHostBoundsselection. -
No runtime dispatch occurs (constraint TC-01). All trait method calls are resolved by the Rust toolchain at the application author’s compile time.
-
The canonical hash axis (
HashAxisfrom prism-crypto per ADR-031, consumed type-associatedly through theA: AxisTuple + Hashersubstrate parameter) is invoked exactly once at the certificate-emission stage to compute theContentFingerprintcarried by theGroundingCertificate. Verb bodies emit noTerm::AxisInvocation(forbidden per ADR-035’s ψ-residuals discipline); resolver impls invoked by resolver-bound ψ-Term fold-rules may invoke the canonical hash axis internally as part of producing per-value structural witnesses, but those are resolver-internal calls distinct from the certificate-emission invocation. The certificate-emission invocation remains exactly once. -
The
Traceis constructed from the same intermediate values that produced theGrounded<T>. The trace is not a separate computation; it is a record of the principal data path’s traversal.
This scenario specifies the runtime behavior when the application user
invokes certify_from_trace against a Trace they received from the
application author. The interaction is internal to the user’s
verification executable; no external system is contacted, the
application author is not reached, no decider is invoked.
-
The application user (or a third party they trust) obtains a
Tracevalue through whatever channel they share with the application author. The trace is a byte sequence; the user deserializes it through the wire format specified in section 8. -
The user instantiates a
Hasherwhose identifier matches thehasher_identifiercarried in the trace. If no matchingHasheris available, this scenario terminates: the verifier cannot proceed without the matching hasher. -
The user invokes
certify_from_trace(trace, hasher_instance)throughprism-verify's re-export. Control transfers from the user’s code toprism-verify's re-exportedcertify_from_trace, whose implementation lives inprism'sreplaycomponent. The function reads wire-format type definitions (Trace,TraceEvent,Certificate,Hasher) fromuor-foundation'sbridgecomponent. -
certify_from_tracevalidates the trace’sformat_versionagainstTRACE_REPLAY_FORMAT_VERSION. Mismatch producesReplayError::FormatVersionand this scenario terminates. -
certify_from_tracevalidates the trace’shasher_identifieragainst the suppliedhasher_instance's identifier. Mismatch producesReplayError::HasherMismatchand this scenario terminates. -
certify_from_tracewalks the trace’s event sequence in order. For eachTraceEvent, it applies the variant-specific structural validation specified in section 8. -
certify_from_tracedoes not invoke thehasher_instance. The hasher is provided so that its identifier can be confirmed; the function never calls its hashing method. -
certify_from_tracedoes not invoke any decider from the application author’s code. Specifically, the function does not invokeGrounding,ConstrainedTypeShape,pipeline::run, or anyPrimitiveOp. It walks the trace structurally. -
Upon successful walk completion,
certify_from_traceconstructsCertified<GroundingCertificate>from the trace’sContentFingerprint(carried unchanged from the trace) and the certificate-emission event’s recorded data. -
The user receives
Certified<GroundingCertificate>and treats it as the verification’s positive outcome. If any step in the walk failed, the user receives a structuredReplayErrorinstead and treats it as the negative outcome.
This scenario satisfies the following normative properties:
-
No invocation of the application author’s deciders occurs (constraint TC-05). The verifier walks the trace’s recorded data; it does not re-run the operations the trace records.
-
No invocation of any cryptographic hash function occurs (constraint TC-05). The
ContentFingerprintis data carried by the trace. -
No external system is contacted. The verification is entirely local.
-
The verification time scales with the trace size, not with the original input size. A trace’s event count is bounded by the trace event-count ceiling carried by the application’s selected
HostBounds, so verification has a bounded upper time complexity. -
The round-trip property holds: for every
Grounded<T>value produced through Scenario 1 with hasherH, applying Scenario 2 to the trace using aHasherinstance withH's identifier returns aCertified<GroundingCertificate>whoseCertificateis bit-identical to the certificate the originalGrounded<T>carried.
This scenario specifies the deterministic interaction that occurs when the Rust toolchain compiles the application author’s source. The interaction is not "runtime" in the sense of the application’s execution; however, constraint TC-04 makes UORassembly enforcement a normative compile-time event whose specification is part of Prism’s architecture.
-
The application author invokes
cargo build(or equivalent) on their crate. The Rust toolchain begins resolving the crate’s dependency graph. -
The toolchain compiles
uor-foundation(or retrieves it pre-compiled from cache). The foundation’s compilation succeeds; the foundation’s published surface includes the trait surfaces, sealed types, and constantsprismreferences. -
The toolchain compiles
prismagainstuor-foundation.prism's source declares trait bounds against the foundation’s surface (e.g.,where T: ConstrainedTypeShape<H>,where H: HostTypes + HostBounds + Hasher). The toolchain checks each bound. Ifuor-foundationdoes not satisfy any bound, theprismcompilation fails; the application author’s compilation halts with a type error pointing at the foundation’s missing or non-conforming surface. -
With
prismcompiled successfully, the toolchain compiles the application author’s crate. The crate importsprism; expansions ofproduct_shape!,coproduct_shape!, andcartesian_product_shape!macros (which live inuor-foundation's internal proc-macro sub-crate, reached throughprism's vocabulary re-exports) emit absolute-path references intouor-foundation's surface. -
The toolchain checks the author’s
ConstrainedTypeShapeimpls,Groundingimpls, and substitution-axis selections againstprism's bounds. Each bound check is mechanical: the type system either confirms the bound is satisfied or rejects the source with a typed error. -
If any bound check fails, compilation halts. The author receives a
rustcerror pointing at the specific clause of the UORassembly contract (section 8) that was violated. The error is a typed bound failure, not a panic, not a warning. -
If all bound checks succeed, the toolchain emits the compiled executable. The executable contains
prism's pipeline runtime as compiled code; the executable contains no UORassembly enforcement code (the contract has been fully discharged at this scenario’s time).
This scenario satisfies the following normative properties:
-
The enforcement is bilateral. Step 3 enforces UORassembly against
uor-foundation; step 5 enforces it against the application author’s crate. Both must satisfyprism's bounds (constraint TC-04, ADR-006). -
The enforcement is exclusively at compile time. No runtime check is performed; the produced executable contains no UORassembly assertions, no type-tag inspections, no validation calls (constraint TC-01).
-
The enforcement is exclusively through the Rust type system. No external linter, no code-generation step beyond proc-macro expansion, no separate validation tool participates (ADR-006, rejected alternative 3).
-
Compilation is deterministic. The same source against the same toolchain version produces the same compiled executable, modulo timestamps the toolchain itself injects.
This scenario specifies the interaction between the application author and the application user that brings the executable from the author’s compilation environment to the user’s hardware. The interaction is mediated by a distribution channel of the author’s choosing; Prism is silent on the channel mechanism (ADR-004).
-
The application author completes Scenario 3 successfully and obtains a compiled executable.
-
The application author publishes the executable to a distribution channel of their choosing. Possibilities include: a release page, a package registry, a peer-to-peer network, a signed Git repository, removable media. Prism does not participate in this step.
-
The application user obtains the executable from the distribution channel. The mechanism is the same one the author used; the user’s role is to retrieve, not to negotiate. Prism does not participate in this step.
-
The application user runs the executable on local hardware. The executable processes input the user provides through whatever interface the application’s domain logic exposes (CLI, GUI, batch input, embedded sensor — the domain logic is the author’s, not Prism’s).
-
The executable performs Scenario 1 internally. It produces sealed outputs (
Grounded<T>,Trace,Certified<GroundingCertificate>) and surfaces whichever of these the application’s domain logic exposes to the user. -
The user, optionally, invokes Scenario 2 against any
Tracethe application produced, using a verification executable they obtained through the same distribution channel (or a different one — Prism does not participate).
This scenario satisfies the following normative properties:
-
No infrastructure operated by the application author is required for steps 3 through 6 (constraint TC-06). The author’s role ends at step 2; the author is not contacted thereafter.
-
The user’s verification (step 6) requires only the trace and a verification executable. The author’s source code, the author’s deciders, and the author’s hasher implementation are not required.
-
The distribution channel does not participate in the application’s correctness. A compromised channel can deliver a different executable, but the user can detect this by computing the executable’s content address against an out-of-band reference (e.g., a signed release manifest the author publishes alongside the executable). The wiki is silent on this mechanism; it is the application author’s choice of supply-chain integrity.
-
The user’s verification of an output is independent of the executable’s authenticity. Verification confirms the output’s claims given the trace; it does not confirm that the executable producing the trace was the one the author published. These are orthogonal properties; Prism specifies the former, leaves the latter to whatever distribution-channel integrity mechanism the application author selects.
The four scenarios above compose to satisfy the system-level properties enumerated in section 1 (Quality Goals) and section 2 (Architecture Constraints). The composition properties:
-
Sealed types never leave their owning crate’s construction discipline. Across all four scenarios, the three Prism-mechanism types (
Validated,Grounded,Certified) are produced byprism's crate-internal constructors (in Scenario 1 bypipeline::run, in Scenario 2 bycertify_from_trace). The four UOR-domain types (Triad,Derivation,FreeRank,Datum) are produced byuor-foundation's crate-internal constructors via the publicmint_*primitives thatprism's pipeline calls. The application author’s code and the user’s code receive these values but cannot construct them (constraint TC-02). -
The principal data path is exercised exactly once per produced output. Scenario 1 invokes the path; Scenario 2 walks the trace produced by Scenario 1 without re-invoking the path. There is no second path through which a
Grounded<T>can arise (constraint TC-03). -
No cryptographic hashing occurs at verification time. Scenario 1 invokes the
Hasherexactly once at certificate emission. Scenario 2 confirms theHasheridentifier matches but never invokes the hasher’s hashing method (constraint TC-05). -
No author infrastructure mediates any scenario. Scenarios 1 and 2 are local to the user’s hardware. Scenario 3 is local to the author’s compilation environment. Scenario 4 transits a distribution channel that Prism does not participate in (constraint TC-06).
Resolved by Scenario 1 above: Principal Data Path Execution — what
happens at runtime when the application author’s compiled executable
processes input through pipeline::run.
Resolved by Scenario 2 above: Trace-Replay Verification — what
happens when the application user invokes certify_from_trace against a
Trace they received.
Resolved by Scenario 3 above: Compile-Time UORassembly Enforcement —
the deterministic toolchain interaction during the application author’s
cargo build that enforces the UORassembly contract bilaterally at
compile time.
Resolved by Scenario 4 above: Distribute and Run — what happens between the application author finishing compilation and the user obtaining the final output. The four numbered scenarios above are exhaustive; the chapter specifies no further runtime scenarios.
Generated from sources at UOR-Framework.wiki. Do not edit pages directly via the GitHub web UI — edits are overwritten by the next build. See README for the authoring workflow.