bcx-model 0.4.0

BCX causal operation model types.
Documentation

bcx-model

Causal model primitives for the main bcx crate.

This crate belongs to the BCX workspace. It is published separately so the main crate can keep small internal modules and precise dependency boundaries, but it is not meant to be used as a standalone protocol product. Prefer depending on bcx unless you are working on BCX internals.

Example

use bcx_core::{Digest, EventId, StatementId, SubjectId};
use bcx_model::{
    CauseCapsule, CauseCapsuleParts, CauseKind, Intent, OperationAction, RelationshipKind,
};
use bcx_wire::WireLimits;

let event_id = EventId::new(Digest::new([1; Digest::LEN])).unwrap();
let parent = EventId::new(Digest::new([2; Digest::LEN])).unwrap();
let parents = [parent];

let capsule = CauseCapsule::new(
    CauseCapsuleParts {
        event_id,
        parents: &parents,
        relationship: RelationshipKind::CausedBy,
        cause_kind: CauseKind::ApplicationAction,
        action: OperationAction::Execute,
        authority: None,
        policy_epoch: None,
    },
    WireLimits::new(64 * 1024, 16, 5, 100).unwrap(),
)
.unwrap();

assert_eq!(capsule.parents().len(), 1);

let intent = Intent::new(
    StatementId::new(&[3; Digest::LEN]).unwrap(),
    SubjectId::new(b"subject:invoice:123").unwrap(),
    OperationAction::Create,
);

assert_eq!(intent.action(), OperationAction::Create);

Notes

  • no_std by default.
  • Model constructors enforce current BCX shape and bound rules.
  • Canonical encoding and statement envelopes are future milestones.