Struct MessageEnvelope
pub struct MessageEnvelope {
pub header: MessageHeader,
pub payload: Vec<u8>,
pub provenance: Option<ProvenanceHeader>,
pub tenant_id: u64,
pub audit_tag: AuditTag,
}Expand description
Envelope containing header and serialized payload.
The optional provenance slot carries PROV-O attribution metadata for
NSAI reasoning chains (see crate::provenance). When None, the field
is a single discriminant byte - zero cost for the common case. When
populated, it adds a fixed-size ProvenanceHeader (see that type for
size details).
The tenant_id field is the primary multi-tenant isolation key — it
defaults to 0 (the unspecified tenant) which preserves single-tenant
fast-path behavior and is free of HashMap lookups in the K2K broker.
The audit_tag field carries billable-unit attribution (org_id +
engagement_id) and defaults to AuditTag::default (both fields zero).
The K2K broker stamps the sender’s tag into outgoing envelopes when the
caller leaves this as the default.
Neither the provenance, tenant_id, nor audit_tag fields are included
in the legacy MessageEnvelope::to_bytes / MessageEnvelope::from_bytes
wire format, which is defined by MessageHeader + raw payload for
backwards compatibility. These travel separately (e.g. as part of
rkyv-encoded envelope transfer on GPU) or are reattached by the router.
Fields§
§header: MessageHeaderMessage header.
payload: Vec<u8>Serialized payload.
provenance: Option<ProvenanceHeader>Optional PROV-O attribution metadata. Defaults to None; only
populated when the message participates in an audited reasoning
chain (e.g. VynGraph NSAI pipelines).
tenant_id: u64Multi-tenant isolation key. Defaults to 0 (unspecified tenant),
matching single-tenant deployments that never opt in to isolation.
audit_tag: AuditTagBillable-unit attribution: {org_id, engagement_id}. Defaults to
AuditTag::default() (both fields zero). The K2K broker stamps the
sending kernel’s tag into envelopes whose tag is still the default.
Implementations§
§impl MessageEnvelope
impl MessageEnvelope
pub fn new<M>(
message: &M,
source_kernel: u64,
dest_kernel: u64,
timestamp: HlcTimestamp,
) -> MessageEnvelopewhere
M: RingMessage,
pub fn new<M>(
message: &M,
source_kernel: u64,
dest_kernel: u64,
timestamp: HlcTimestamp,
) -> MessageEnvelopewhere
M: RingMessage,
Create a new envelope from a message.
pub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Get total size (header + payload).
pub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize to contiguous bytes.
NOTE: the provenance metadata is intentionally not serialised here. This method keeps the historical wire format unchanged; provenance is transported out-of-band or via rkyv-encoded transfer.
pub fn from_bytes(bytes: &[u8]) -> Result<MessageEnvelope, RingKernelError>
pub fn from_bytes(bytes: &[u8]) -> Result<MessageEnvelope, RingKernelError>
Deserialize from bytes.
Reconstructs an envelope with provenance: None and default
tenant/audit fields. Callers that need provenance must reattach it via
MessageEnvelope::with_provenance; callers that need tenant
attribution must stamp it via MessageEnvelope::with_tenant_id /
MessageEnvelope::with_audit_tag.
pub fn empty(
source_kernel: u64,
dest_kernel: u64,
timestamp: HlcTimestamp,
) -> MessageEnvelope
pub fn empty( source_kernel: u64, dest_kernel: u64, timestamp: HlcTimestamp, ) -> MessageEnvelope
Create an empty envelope (for testing).
pub fn with_provenance(self, provenance: ProvenanceHeader) -> MessageEnvelope
pub fn with_provenance(self, provenance: ProvenanceHeader) -> MessageEnvelope
Attach a PROV-O provenance header (builder-style).
pub fn without_provenance(self) -> MessageEnvelope
pub fn without_provenance(self) -> MessageEnvelope
Strip provenance (builder-style). Useful when routing a message into an untrusted tenant boundary where attribution must not leak.
pub fn with_tenant_id(self, tenant_id: u64) -> MessageEnvelope
pub fn with_tenant_id(self, tenant_id: u64) -> MessageEnvelope
Stamp the envelope with a tenant ID (builder-style).
In the two-tier tenancy model the tenant ID is the primary isolation
key; the K2K broker uses it to route the message into the correct
per-tenant sub-broker. Defaults to 0 (unspecified tenant).
pub fn with_audit_tag(self, audit_tag: AuditTag) -> MessageEnvelope
pub fn with_audit_tag(self, audit_tag: AuditTag) -> MessageEnvelope
Attach an audit tag (builder-style).
The audit tag carries billable-unit attribution (org_id + engagement_id). The K2K broker preserves this tag across delivery
so downstream cost accounting can attribute GPU-seconds back to the
specific engagement.
Trait Implementations§
§impl Clone for MessageEnvelope
impl Clone for MessageEnvelope
§fn clone(&self) -> MessageEnvelope
fn clone(&self) -> MessageEnvelope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for MessageEnvelope
impl Debug for MessageEnvelope
§impl Default for MessageEnvelope
impl Default for MessageEnvelope
§fn default() -> MessageEnvelope
fn default() -> MessageEnvelope
Auto Trait Implementations§
impl Freeze for MessageEnvelope
impl RefUnwindSafe for MessageEnvelope
impl Send for MessageEnvelope
impl Sync for MessageEnvelope
impl Unpin for MessageEnvelope
impl UnwindSafe for MessageEnvelope
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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