Skip to main content

telltale_machine/
bridge.rs

1//! Cross-domain bridge traits for ProtocolMachine domain composition.
2//!
3//! These bridge traits are intentionally narrow translation layers. They should
4//! be implemented as pure metadata lookups or deterministic projections, not as
5//! places that mutate session-local ProtocolMachine state or perform async work. Host-side
6//! mutation belongs behind the explicit ownership/ingress contract instead.
7
8use crate::guard::{GuardLayer, LayerId};
9use crate::identity::IdentityModel;
10use crate::verification::VerificationModel;
11
12/// Bridge from identity participants to guard layers.
13pub trait IdentityGuardBridge<I: IdentityModel, G: GuardLayer> {
14    /// Resolve guard layer for a participant without mutating runtime state.
15    fn guard_layer_for_participant(&self, participant: &I::ParticipantId) -> LayerId;
16}
17
18/// Bridge from effect actions to guard costs/resources.
19pub trait EffectGuardBridge<E, G: GuardLayer> {
20    /// Cost label for one effect action without side effects.
21    fn guard_cost_for_effect(&self, action: &E) -> G::Resource;
22}
23
24/// Bridge from effect actions to persistence deltas.
25pub trait PersistenceEffectBridge<P, E> {
26    /// Persistence delta derived from effect action without applying it.
27    fn persistence_delta_for_effect(&self, action: &E) -> P;
28}
29
30/// Bridge from identity participants to persistence keys.
31pub trait IdentityPersistenceBridge<I: IdentityModel, K> {
32    /// Persistence key for participant without mutating storage.
33    fn persistence_key_for_participant(&self, participant: &I::ParticipantId) -> K;
34}
35
36/// Bridge from identity participants to verification keys.
37pub trait IdentityVerificationBridge<I: IdentityModel, V: VerificationModel> {
38    /// Verification key for participant without mutating verification state.
39    fn verification_key_for_participant(&self, participant: &I::ParticipantId) -> V::VerifyingKey;
40}