pub struct FlowEnvelope {
pub ontological_type: String,
pub result: Value,
pub certainty: f64,
pub epistemic_envelopes: Vec<EpistemicEnvelope>,
pub provenance_chain: Vec<String>,
pub step_audit: StepAuditTrail,
pub audit_chain_hash: String,
pub blame_attribution: Option<BlameContext>,
pub execution_metrics: ExecutionMetrics,
pub trace_id: String,
}Expand description
§Fase 39 (D1, D2, D5) — the wire payload of every transport: json
axonendpoint response (HTTP 2xx) and every legacy
POST /v1/execute invocation.
Fields are organized by Pillar (see module docs). At wire
emission, result carries a serde_json::Value (monomorphic at
runtime); D5 validation (Fase 32.d) — once simplified in 39.d —
will type-check this slot against the declared inner T of the
adopter’s output: FlowEnvelope<T> declaration.
Fields§
§ontological_type: StringThe ontological type declared at the endpoint surface (the
inner T of output: FlowEnvelope<T>). Slug form:
TenantRecord, List<PatientRecord>, Stream<Token>.
For legacy /v1/execute invocations (no endpoint
declaration), this is the runtime-inferred type slug.
result: ValueThe typed payload — member of ontological_type.
serde_json::Value at the wire layer because the runtime
is monomorphic; D5 (when simplified in 39.d) validates the
inner shape against the declared T.
certainty: f64Certainty c ∈ [0.0, 1.0], bounded by Theorem 5.1:
c ≤ 0.99 whenever derived_status = true. In Fase 39.b
the bound is enforced by FlowEnvelope::seal’s Rust
fallback; in Fase 39.c the bound moves to the C23 kernel
axon-csys::effects::envelope::validate_epistemic_degradation,
making it structurally unbypassable.
epistemic_envelopes: Vec<EpistemicEnvelope>§Fase 55.b — the Theorem 5.1 (base, scope, confidence) triple of
every flow-level use <Tool> dispatch whose tool declares an
epistemic:<level> effect. Surfaces the epistemic degradation on
the wire — the §50.i.4 parity gate, promoted (the competitive
differential: an adopter sees a query routed through an
epistemic:speculate tool decay to confidence ≤ 0.80). Empty —
and elided from the JSON — for flows with no epistemic tool (D5
backward-compat: byte-identical wire for every pre-55.b flow).
provenance_chain: Vec<String>Ordered list of kind:identifier tuples capturing the
lineage of result. Examples:
["flow:FetchTenants", "retrieve:tenants", "backend:stub"]["step:Triage", "shield:Hipaa", "backend:anthropic"]Empty for endpoints with no derived state (singular literal returns); populated byFlowEnvelope::from_execution_result.
step_audit: StepAuditTrailPer-step audit trail. Survives from v1.x as the canonical
observability surface; here it is structured (not just
Vec<String>). Step results are TYPED Value post-39.b
(pre-v2.0.0 they were stringified — the typed form is a D5
simplification dividend).
audit_chain_hash: StringHMAC-SHA256 hex of the canonical form of provenance_chain || step_audit. Computed by FlowEnvelope::seal; in
Fase 39.c the hash moves to the C23 kernel for byte-
deterministic cross-deployment verification.
blame_attribution: Option<BlameContext>Populated only when the flow’s success path produced a
degraded posture (anchor breach, shield rejection, backend
soft-fail, store breach, type-mismatch on recoverable path).
None on the clean happy path.
execution_metrics: ExecutionMetricsExecution metrics — latency, tokens, backend identity. Always populated.
trace_id: StringCorrelation anchor (matches X-Axon-Trace-Id header).
String form for cross-stack compat (the v1.x trace_id: u64
is reborn here as Uuid v4 hex string).
Implementations§
Source§impl FlowEnvelope
impl FlowEnvelope
Sourcepub fn from_execution_result(
exec_result: ServerExecutionResult,
ontological_type: String,
) -> Self
pub fn from_execution_result( exec_result: ServerExecutionResult, ontological_type: String, ) -> Self
§Fase 39.b — convert a v1.x crate::axon_server::ServerExecutionResult
into a v2.0.0 envelope. Total: every legacy field maps to a
pillar-organized slot; no information loss.
Epistemic field defaults applied here (refined in 39.c):
certainty = 1.0whenanchor_breaches == 0anderrors == 0(clean happy path; no derived posture).certainty = 0.99whenanchor_breaches > 0 || errors > 0(Theorem 5.1: derived states bounded ≤ 0.99).provenance_chainbuilt fromflow_name + step_names + backend.blame_attribution = Nonealways at this layer (the soft- degradation surface is populated by the runtime when it detects anchor/shield/store/backend events — 39.c lands that wiring).
The result slot is populated from the LAST step’s typed
output (step_results.last() parsed as Value). For flows
with no steps (degenerate) the result is Value::Null.
trace_id is converted from the legacy u64 to a Uuid v4
hex string. When the legacy id is 0 (pre-record), a fresh
Uuid is minted.
Source§impl FlowEnvelope
impl FlowEnvelope
Sourcepub fn seal(self) -> Self
pub fn seal(self) -> Self
§Fase 39.b — apply epistemic enforcement + compute the
audit_chain_hash before wire serialization. This is the
ONLY public sealing surface; the wire bytes emitted by
axon_server MUST pass through this method (the seal()
invariant — Fase 39.b establishes it; 39.h grep gate locks
it structurally).
§Fase 39.c.x implementation (C23 kernel canonical)
- Theorem 5.1 enforcement DELEGATES to the C23 kernel
axon-csys::envelope::validate_degradation. The kernel: a. Defensively normalises NaN / Inf / out-of-range certainty into[0.0, 1.0]. b. Clampscertainty ≤ 0.99whenderived_status = true. c. Returns the envelope withderived_status+epistemic_kindpassed through unchanged. The C23 kernel is the SINGLE point of structural truth — no Rust path bypasses it for production code paths. derived_statusalgebra (Rust-side, matches the producer inFlowEnvelope::from_execution_resultverbatim):derived = step_audit.anchor_breaches > 0 || step_audit.errors > 0. The Rust side decides WHO is derived (semantic); the C23 kernel enforces WHAT the ceiling looks like (structural).audit_chain_hash= SHA-256 hex of the canonical-JSON serialization of[provenance_chain, step_audit]. Deterministic on identical inputs; tamper-evident. (39.c.x leaves the SHA-256 in Rust pending a future sub-fase that moves it to axon-csys::crypto for true silicon-grounded tamper-evidence.)
Trait Implementations§
Source§impl Clone for FlowEnvelope
impl Clone for FlowEnvelope
Source§fn clone(&self) -> FlowEnvelope
fn clone(&self) -> FlowEnvelope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FlowEnvelope
impl Debug for FlowEnvelope
Source§impl<'de> Deserialize<'de> for FlowEnvelope
impl<'de> Deserialize<'de> for FlowEnvelope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for FlowEnvelope
impl RefUnwindSafe for FlowEnvelope
impl Send for FlowEnvelope
impl Sync for FlowEnvelope
impl Unpin for FlowEnvelope
impl UnsafeUnpin for FlowEnvelope
impl UnwindSafe for FlowEnvelope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more