Skip to content
LogoLogo

Core types

pub trait Phase {}                    // marker
pub struct Initiate; pub struct Accept; pub struct Reject;
impl Phase for Initiate {} ...
 
pub struct Ctx<P: Phase> { /* private: opened regions + verified root */ }
 
pub struct Verdict { /* fixed-capacity list of (bool, assert id) */ }
impl Verdict {
    pub fn ok() -> Self;
    pub fn require(cond: bool, id: str<N>) -> Self;
    pub fn and(self, other: Self) -> Self;      // all must hold
    pub fn or(self, other: Self) -> Self;       // at least one must hold
    pub fn implies(cond: bool, then: Self) -> Self;
}
 
pub trait Rule<Params> {
    fn on_initiate(p: Params, ctx: Ctx<Initiate>) -> (Verdict, Attest) { (Verdict::ok(), Attest::none()) }
    fn on_accept  (p: Params, ctx: Ctx<Accept>)   -> (Verdict, Attest) { (Verdict::ok(), Attest::none()) }
    fn on_reject  (p: Params, ctx: Ctx<Reject>)   -> (Verdict, Attest) { (Verdict::ok(), Attest::none()) }
}
 
pub trait StatefulRule<Params, S: StateSchema> {
    fn on_initiate(p: Params, ctx: Ctx<Initiate>, s: State<S>) -> (State<S>, Verdict, Attest);
    ...
}

Accessors exist only where the region is knowable:

AccessorInitiateAcceptReject
recipient_note(), payload(), deadline_bucket(), time_bucket(), registry_root(), schema_id()✓✓✓
change_note(), inputs(), has_change(), refund_note()✓✗ (does not compile)✗
attestation_in()✗✓✓
counterparty_fi() (opens the other FI's leaf under registry_root, using the pool-welded counterparty_fi_index)✓✓✓

Every accessor returns values already welded to context_root. There is no API that returns an unwelded value.