Skip to main content

CausalClosureBundle

Struct CausalClosureBundle 

Source
pub struct CausalClosureBundle {
    pub target: ContentHash,
    pub thread: ThreadId,
    pub messages: Vec<(ContentHash, Message)>,
}
Expand description

A transferable, verifiable subset of the message store (REQ-311, CON-304).

Contains the principal ideal ↓target — all messages reachable by following :caused-by links from the target back to root(s). Messages are stored in topological order (predecessors before successors).

Fields§

§target: ContentHash

The target message this bundle is the causal closure of.

§thread: ThreadId

The thread this bundle belongs to.

§messages: Vec<(ContentHash, Message)>

All messages in ↓target, topologically sorted (predecessors first). Each entry is (content_hash, message).

Implementations§

Source§

impl CausalClosureBundle

Source

pub fn extract<S: MessageStore>( target: &ContentHash, thread: &ThreadId, store: &S, ) -> Result<Self, ClosureError>

Extract the causal closure (principal ideal ↓target) from a store (REQ-311).

Performs a DAG traversal following :caused-by links from target back to root(s). The resulting bundle is topologically sorted: every message appears after all of its predecessors.

Source

pub fn verify_completeness(&self) -> Result<(), Vec<BundleVerificationError>>

Verify bundle completeness — all :caused-by hashes resolve within the bundle.

This is the Tier 2 verification path (REQ-212): verify that the bundle is self-contained. No external store or protocol is needed.

Source

pub fn verify_hashes<F>( &self, hasher: F, ) -> Result<(), Vec<BundleVerificationError>>
where F: Fn(&Message) -> ContentHash,

Verify hash integrity using a caller-supplied hash function.

For each message in the bundle, recomputes the hash from the message content and verifies it matches the stored content hash. The hasher function receives a reference to a Message and should return the computed ContentHash (typically SHA-256 of the canonical serialisation).

Source

pub fn verify_causal( &self, protocol: &CausalProtocol, ) -> Result<(), Vec<BundleVerificationError>>

Verify causal validity against a protocol declaration (Tier 3, REQ-212).

Builds a temporary store from the bundle messages and runs causal verification (REQ-203) on each message against the given protocol.

Source

pub fn verify_full<F>( &self, hasher: F, protocol: &CausalProtocol, ) -> Result<(), Vec<BundleVerificationError>>
where F: Fn(&Message) -> ContentHash,

Full verification: completeness + hash integrity + causal validity (Tier 3, REQ-212).

Combines all three verification checks. The hasher function computes content hashes; the protocol is used for causal validity checking.

Source

pub fn merge<S: MessageStore>(&self, store: &mut S) -> MergeResult

Merge this bundle into a message store (set union with deduplication, REQ-300).

Messages already present in the store are skipped (REQ-310 deduplication). Returns counts of newly added and deduplicated messages.

Source

pub fn to_sexpr(&self) -> SExpr

Serialize this bundle to a (meta (causal-closure ...)) S-expression (REQ-311).

Source

pub fn len(&self) -> usize

Returns the number of messages in the bundle.

Source

pub fn is_empty(&self) -> bool

Returns true if the bundle contains no messages.

Source

pub fn hashes(&self) -> Vec<&ContentHash>

Returns the content hashes of all messages in the bundle, in topological order.

Trait Implementations§

Source§

impl Clone for CausalClosureBundle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CausalClosureBundle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CausalClosureBundle

Source§

impl PartialEq for CausalClosureBundle

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CausalClosureBundle

Auto Trait Implementations§

§

impl Forget for CausalClosureBundle

§

impl Freeze for CausalClosureBundle

§

impl Move for CausalClosureBundle

§

impl RefUnwindSafe for CausalClosureBundle

§

impl Send for CausalClosureBundle
where RawVecInner: Send, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Send, BoxRaw<(String, SetValZST)>: Send, BoxRaw<Message>: Send,

§

impl Sync for CausalClosureBundle
where RawVecInner: Sync, NodeRef<Owned, String, SetValZST, LeafOrInternal>: Sync, BoxRaw<(String, SetValZST)>: Sync, BoxRaw<Message>: Sync,

§

impl Unpin for CausalClosureBundle
where *const u8 is !null: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin, Box<Message>: Unpin,

§

impl UnsafeUnpin for CausalClosureBundle

§

impl UnwindSafe for CausalClosureBundle
where RawVecInner: UnwindSafe, BTreeMap<String, SetValZST>: UnwindSafe, BoxRaw<Message>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.