pub struct IdentityRuntime { /* private fields */ }Expand description
The identity-first runtime tracks active identities and enforces delivery, ownership, and lifecycle invariants.
Implementations§
Source§impl IdentityRuntime
impl IdentityRuntime
Sourcepub fn new(config: IdentityRuntimeConfig) -> Self
pub fn new(config: IdentityRuntimeConfig) -> Self
Create a new identity runtime with the given configuration.
pub fn with_runtime_services( self, runtime_services: AgentRuntimeServices, ) -> Self
pub fn has_session_bridge(&self) -> bool
Sourcepub async fn reconcile_managed_peer_edges(
&self,
desired_edges: &[ManagedPeerEdge],
) -> Result<(), IdentityRuntimeError>
pub async fn reconcile_managed_peer_edges( &self, desired_edges: &[ManagedPeerEdge], ) -> Result<(), IdentityRuntimeError>
Apply identity-first managed topology to the concrete mob graph.
Topology providers return stable logical identities. The mob comms graph is keyed by active runtime member IDs, so this resolves each endpoint through continuity records before calling the same-mob bridge wire APIs.
Sourcepub async fn register(
&self,
spec: DurableAgentSpec,
state: IdentityLifecycleState,
continuity: Option<ContinuityRecord>,
lease: Option<LeaseGrant>,
)
pub async fn register( &self, spec: DurableAgentSpec, state: IdentityLifecycleState, continuity: Option<ContinuityRecord>, lease: Option<LeaseGrant>, )
Register an identity entry in the runtime (called during restore flow).
Sourcepub async fn subscribe(
&self,
identity: &AgentIdentity,
) -> Result<Receiver<IdentityEvent>, IdentityRuntimeError>
pub async fn subscribe( &self, identity: &AgentIdentity, ) -> Result<Receiver<IdentityEvent>, IdentityRuntimeError>
Subscribe to identity-scoped events.
Returns a broadcast receiver that yields IdentityEvent items for
state changes, lease updates, lease loss, and checkpoint completions.
Sourcepub async fn update_spec(
&self,
spec: DurableAgentSpec,
) -> Result<(), IdentityRuntimeError>
pub async fn update_spec( &self, spec: DurableAgentSpec, ) -> Result<(), IdentityRuntimeError>
Update the spec for an existing identity (used during reconciliation).
Sourcepub async fn update_lease(
&self,
identity: &AgentIdentity,
grant: LeaseGrant,
) -> Result<(), IdentityRuntimeError>
pub async fn update_lease( &self, identity: &AgentIdentity, grant: LeaseGrant, ) -> Result<(), IdentityRuntimeError>
Update the lease for an identity.
Sourcepub async fn mark_lease_lost(
&self,
identity: &AgentIdentity,
) -> Result<(), IdentityRuntimeError>
pub async fn mark_lease_lost( &self, identity: &AgentIdentity, ) -> Result<(), IdentityRuntimeError>
Mark a lease as lost for an identity (INV-02).
Sourcepub async fn set_state(
&self,
identity: &AgentIdentity,
state: IdentityLifecycleState,
) -> Result<(), IdentityRuntimeError>
pub async fn set_state( &self, identity: &AgentIdentity, state: IdentityLifecycleState, ) -> Result<(), IdentityRuntimeError>
Set the lifecycle state for an identity.
Sourcepub async fn send(
&self,
identity: &AgentIdentity,
content: &ContentInput,
) -> Result<FencingToken, IdentityRuntimeError>
pub async fn send( &self, identity: &AgentIdentity, content: &ContentInput, ) -> Result<FencingToken, IdentityRuntimeError>
Send conversational content to an addressable identity.
Enforces:
- Identity must be registered and active
- Identity must be Addressable (REQ-03)
- Lease must be held (INV-01)
- Lease must not be lost (INV-02)
Returns the fencing token for the delivery (caller uses it for checkpoint).
Sourcepub async fn dispatch(
&self,
identity: &AgentIdentity,
input: &DispatchInput,
) -> Result<(FencingToken, bool), IdentityRuntimeError>
pub async fn dispatch( &self, identity: &AgentIdentity, input: &DispatchInput, ) -> Result<(FencingToken, bool), IdentityRuntimeError>
Dispatch internal content to any identity (Addressable or InternalOnly).
Enforces:
- Identity must be registered and active
- Lease must be held (INV-01)
- Lease must not be lost (INV-02)
Returns (fencing_token, is_durable) where is_durable indicates whether the dispatch is backed by a runtime_store (REQ-04).
Sourcepub async fn status(
&self,
identity: &AgentIdentity,
) -> Result<IdentityStatus, IdentityRuntimeError>
pub async fn status( &self, identity: &AgentIdentity, ) -> Result<IdentityStatus, IdentityRuntimeError>
Return the full identity status for the given identity.
Sourcepub async fn retire(
&self,
identity: &AgentIdentity,
) -> Result<FencingToken, IdentityRuntimeError>
pub async fn retire( &self, identity: &AgentIdentity, ) -> Result<FencingToken, IdentityRuntimeError>
Retire an identity. Validates lease ownership and retires the mob member.
Sourcepub async fn respawn(
&self,
identity: &AgentIdentity,
) -> Result<ContinuityRecord, IdentityRuntimeError>
pub async fn respawn( &self, identity: &AgentIdentity, ) -> Result<ContinuityRecord, IdentityRuntimeError>
Respawn: non-destructive recovery.
- Fence the current owner
- Attempt final checkpoint
- Reactivate from authoritative continuity with same record + runtime ID
- ContinuityGeneration does NOT advance
Sourcepub async fn reset(
&self,
identity: &AgentIdentity,
) -> Result<ContinuityRecord, IdentityRuntimeError>
pub async fn reset( &self, identity: &AgentIdentity, ) -> Result<ContinuityRecord, IdentityRuntimeError>
Reset: destructive continuity reset.
- Fence old owner
- Advance ContinuityGeneration
- Create fresh continuity under the same AgentIdentity
- Old-owner late writes rejected by stale fencing token
Sourcepub async fn delete_identity(
&self,
identity: &AgentIdentity,
) -> Result<(), IdentityRuntimeError>
pub async fn delete_identity( &self, identity: &AgentIdentity, ) -> Result<(), IdentityRuntimeError>
Delete an identity: removes continuity record.
- Fence old owner
- Remove ContinuityRecord
- Future bootstrap treats identity as Uninitialized
Sourcepub async fn checkpoint(
&self,
identity: &AgentIdentity,
snapshot: &SessionSnapshot,
) -> Result<CheckpointVersion, IdentityRuntimeError>
pub async fn checkpoint( &self, identity: &AgentIdentity, snapshot: &SessionSnapshot, ) -> Result<CheckpointVersion, IdentityRuntimeError>
Save a checkpoint snapshot. Enforces version ordering and fencing.
Sourcepub async fn roster_inspect(
&self,
) -> BTreeMap<AgentIdentity, (DurableAgentSpec, IdentityStatus)>
pub async fn roster_inspect( &self, ) -> BTreeMap<AgentIdentity, (DurableAgentSpec, IdentityStatus)>
Return all active identities with their specs and status.
Sourcepub fn validate_roster_uniqueness(
specs: &[DurableAgentSpec],
) -> Result<(), IdentityRuntimeError>
pub fn validate_roster_uniqueness( specs: &[DurableAgentSpec], ) -> Result<(), IdentityRuntimeError>
Validate that a roster contains no duplicate identities.
Sourcepub async fn contains(&self, identity: &AgentIdentity) -> bool
pub async fn contains(&self, identity: &AgentIdentity) -> bool
Check if an identity is registered.
Sourcepub async fn is_active(&self, identity: &AgentIdentity) -> bool
pub async fn is_active(&self, identity: &AgentIdentity) -> bool
Check if an identity is registered AND in Active state.
Sourcepub fn continuity_store(&self) -> &Arc<dyn ContinuityStore> ⓘ
pub fn continuity_store(&self) -> &Arc<dyn ContinuityStore> ⓘ
Get the continuity store reference.
Sourcepub fn lease_provider(&self) -> &Arc<dyn LeaseProvider> ⓘ
pub fn lease_provider(&self) -> &Arc<dyn LeaseProvider> ⓘ
Get the lease provider reference.
Sourcepub fn runtime_instance_id(&self) -> &str
pub fn runtime_instance_id(&self) -> &str
Get the runtime instance ID.
Sourcepub fn durability_policy(&self) -> &DurabilityPolicy
pub fn durability_policy(&self) -> &DurabilityPolicy
Get the durability policy.
Sourcepub fn has_runtime_store(&self) -> bool
pub fn has_runtime_store(&self) -> bool
Get whether a runtime store is configured.
Sourcepub fn bridge(&self) -> Option<&Arc<dyn SessionBridge>>
pub fn bridge(&self) -> Option<&Arc<dyn SessionBridge>>
Get the session bridge reference, if configured.
Sourcepub async fn send_text(
&self,
identity: &AgentIdentity,
text: impl Into<String>,
) -> Result<FencingToken, IdentityRuntimeError>
pub async fn send_text( &self, identity: &AgentIdentity, text: impl Into<String>, ) -> Result<FencingToken, IdentityRuntimeError>
Send plain text to an addressable identity.
Sourcepub async fn dispatch_text(
&self,
identity: &AgentIdentity,
text: impl Into<String>,
) -> Result<(FencingToken, bool), IdentityRuntimeError>
pub async fn dispatch_text( &self, identity: &AgentIdentity, text: impl Into<String>, ) -> Result<(FencingToken, bool), IdentityRuntimeError>
Dispatch plain text with system origin.
Sourcepub async fn restore_flow(
&self,
roster: &[DurableAgentSpec],
topology_provider: Option<&dyn TopologyProvider>,
customizer: Option<&dyn AgentCustomizer>,
) -> Result<RestoreFlowResult, IdentityRuntimeError>
pub async fn restore_flow( &self, roster: &[DurableAgentSpec], topology_provider: Option<&dyn TopologyProvider>, customizer: Option<&dyn AgentCustomizer>, ) -> Result<RestoreFlowResult, IdentityRuntimeError>
Execute the restore flow for the given roster.
Sourcepub async fn runtime_id_for(
&self,
identity: &AgentIdentity,
) -> Result<AgentRuntimeId, IdentityRuntimeError>
pub async fn runtime_id_for( &self, identity: &AgentIdentity, ) -> Result<AgentRuntimeId, IdentityRuntimeError>
Resolve the AgentRuntimeId for a registered identity.
Sourcepub async fn inspect(
&self,
identity: &AgentIdentity,
) -> Result<MemberInspection, IdentityRuntimeError>
pub async fn inspect( &self, identity: &AgentIdentity, ) -> Result<MemberInspection, IdentityRuntimeError>
Inspect the current execution state of an identity via the bridge.
Sourcepub fn default_timeout(&self) -> Duration
pub fn default_timeout(&self) -> Duration
The configured default timeout for wait operations.
Sourcepub async fn wait_for_output(
&self,
identity: &AgentIdentity,
timeout: Duration,
) -> Result<String, IdentityRuntimeError>
pub async fn wait_for_output( &self, identity: &AgentIdentity, timeout: Duration, ) -> Result<String, IdentityRuntimeError>
Poll until the identity produces an output_preview, or timeout.
Sourcepub async fn wait_for_output_containing(
&self,
identity: &AgentIdentity,
needle: &str,
timeout: Duration,
) -> Result<String, IdentityRuntimeError>
pub async fn wait_for_output_containing( &self, identity: &AgentIdentity, needle: &str, timeout: Duration, ) -> Result<String, IdentityRuntimeError>
Poll until output_preview contains the given substring, or timeout.
Auto Trait Implementations§
impl !Freeze for IdentityRuntime
impl !RefUnwindSafe for IdentityRuntime
impl Send for IdentityRuntime
impl Sync for IdentityRuntime
impl Unpin for IdentityRuntime
impl UnsafeUnpin for IdentityRuntime
impl !UnwindSafe for IdentityRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more