Repository navigation
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’s `pipeline::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’s `mint_datumprimitive (called from inside theGroundingimpl); subsequent UOR-domain admissions (Triad,Derivation,FreeRank) are produced byuor-foundation’s mint primitives, called from inside `pipeline::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) dispatches through the application’sAxisTupleselection to the right axis impl’s kernel (forHashAxis, the prism-crypto-declared axis per ADR-031, this delegates to the application’s selected hash impl);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 (each resolver’s uniformfn resolve(&self, input: &[u8], out: &mut [u8]) → Result<usize, ShapeViolation>writes the next ψ-stage’s byte serialization into the catamorphism’s byte buffer with no per-stage allocation), 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 verb body’s ψ-residuals discipline per ADR-035 forbidsTerm::FirstAdmit,Term::AxisInvocation, and byte-comparison/concat PrimitiveOp emissions in verb-body terms; 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 via `output_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 by `prism’s seal regime. -
The
Hasherimpl (now declared asHashAxisby the prism-crypto standard-library sub-crate per ADR-031, consumed through theAxisTuplemechanism per ADR-030) is invoked exactly once during the pipeline execution, at the certificate emission stage, to compute theContentFingerprintcarried by theGroundingCertificate. (Note:Term::AxisInvocationevaluations are part of the catamorphism’s structural fold and are distinct from the certificate-emissionHasherinvocation; route bodies that includehash(input)calls invoke the application’s chosenHashAxisimpl perAxisInvocationevaluation in addition to 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.
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 in `prism’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
Hasher(nowHashAxisper ADR-031, consumed throughAxisTupleper ADR-030) is invoked exactly once at the certificate-emission stage to compute theContentFingerprintcarried by theGroundingCertificate. Routes whose closure body containshash(input)invocations emitTerm::AxisInvocationvariants (ADR-026 G19, generalized per ADR-030); these are evaluated by the catamorphism per ADR-029’s fold-rule and constitute additional axis invocations within the structural fold (the verb’s body lives in the application’s chosen axis impl within the AxisTuple). The certificate-emission invocation remains exactly once;AxisInvocationinvocations are domain-logic invocations the route author requested explicitly. -
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 to `prism-verify’s re-exported `certify_from_trace, whose implementation lives inprism’s `replaycomponent. The function reads wire-format type definitions (Trace,TraceEvent,Certificate,Hasher) fromuor-foundation’s `bridgecomponent. -
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 produces `ReplayError::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 a `Certified<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 in `uor-foundation’s internal proc-macro sub-crate, reached through `prism’s vocabulary re-exports) emit absolute-path references into `uor-foundation’s surface. -
The toolchain checks the author’s
ConstrainedTypeShapeimpls,Groundingimpls, and substitution-axis selections against `prism’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 satisfy `prism’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 by `pipeline::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 public `mint_*primitives that `prism’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).
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.