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: ContentHashThe target message this bundle is the causal closure of.
thread: ThreadIdThe 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
impl CausalClosureBundle
Sourcepub fn extract<S: MessageStore>(
target: &ContentHash,
thread: &ThreadId,
store: &S,
) -> Result<Self, ClosureError>
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.
Sourcepub fn verify_completeness(&self) -> Result<(), Vec<BundleVerificationError>>
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.
Sourcepub fn verify_hashes<F>(
&self,
hasher: F,
) -> Result<(), Vec<BundleVerificationError>>
pub fn verify_hashes<F>( &self, hasher: F, ) -> Result<(), Vec<BundleVerificationError>>
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).
Sourcepub fn verify_causal(
&self,
protocol: &CausalProtocol,
) -> Result<(), Vec<BundleVerificationError>>
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.
Sourcepub fn verify_full<F>(
&self,
hasher: F,
protocol: &CausalProtocol,
) -> Result<(), Vec<BundleVerificationError>>
pub fn verify_full<F>( &self, hasher: F, protocol: &CausalProtocol, ) -> Result<(), Vec<BundleVerificationError>>
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.
Sourcepub fn merge<S: MessageStore>(&self, store: &mut S) -> MergeResult
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.
Sourcepub fn to_sexpr(&self) -> SExpr
pub fn to_sexpr(&self) -> SExpr
Serialize this bundle to a (meta (causal-closure ...)) S-expression (REQ-311).
Sourcepub fn hashes(&self) -> Vec<&ContentHash>
pub fn hashes(&self) -> Vec<&ContentHash>
Returns the content hashes of all messages in the bundle, in topological order.