Skip to main content

IdentityRuntime

Struct IdentityRuntime 

Source
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

Source

pub fn new(config: IdentityRuntimeConfig) -> Self

Create a new identity runtime with the given configuration.

Source

pub fn with_runtime_services( self, runtime_services: AgentRuntimeServices, ) -> Self

Source

pub fn with_reset_roster_provider( self, provider: Arc<dyn RosterProvider>, ) -> Self

Source

pub fn with_reset_roster_provider_context( self, provider: Arc<dyn RosterProvider>, mob_definition: Option<MobDefinition>, ) -> Self

Source

pub async fn set_agent_customizer( &self, customizer: Option<Arc<dyn AgentCustomizer>>, )

Source

pub async fn set_agent_memory( &self, injector: Option<AgentMemoryRuntimeInjector>, )

Source

pub async fn agent_memory_supports_recall(&self) -> bool

Source

pub async fn agent_memory_supports_remember(&self) -> bool

Source

pub async fn agent_memory_supports_forget(&self) -> bool

Source

pub async fn agent_memory_supports_update(&self) -> bool

Source

pub async fn agent_memory_supports_manifest(&self) -> bool

Source

pub async fn remember_agent_memory( &self, realm: &str, identity: &AgentIdentity, memory: NewAgentMemory, ) -> Result<AgentMemoryRecord, AgentMemoryError>

Source

pub async fn forget_agent_memory( &self, realm: &str, identity: &AgentIdentity, memory_id: &str, ) -> Result<AgentMemoryForgetResult, AgentMemoryError>

Source

pub async fn update_agent_memory( &self, realm: &str, identity: &AgentIdentity, memory_id: &str, memory: NewAgentMemory, ) -> Result<MemoryId, AgentMemoryError>

Supersede memory_id within its lineage (the D4 fix): the new title/body/tags become the active record; the prior stays retrievable with provenance.

Source

pub async fn manifest_agent_memory( &self, realm: &str, identity: &AgentIdentity, tier: ManifestTier, ) -> Result<Vec<RecordMeta>, AgentMemoryError>

Tiered metadata manifest for the identity’s own scope (§8.3).

Source

pub async fn recall_agent_memory( &self, request: AgentMemoryRecallRequest, ) -> Result<Vec<AgentMemoryRecord>, AgentMemoryError>

Source

pub fn set_reset_roster_provider( &self, provider: Option<Arc<dyn RosterProvider>>, )

Attach the roster provider reset should consult for current specs.

Source

pub fn set_reset_roster_provider_context( &self, provider: Option<Arc<dyn RosterProvider>>, mob_definition: Option<MobDefinition>, )

Attach the roster provider and context reset should consult for current specs.

Source

pub fn set_error_hook(&self, hook: Option<ErrorHook>)

Attach a best-effort operational error hook used for alerting.

Source

pub fn spawn_lease_renewal_task(self: Arc<Self>) -> JoinHandle<()>

Spawn a background supervisor that renews active identity leases before they reach their TTL deadline.

Source

pub fn spawn_lease_renewal_task_with_poll_interval( self: Arc<Self>, max_poll_interval: Duration, ) -> JoinHandle<()>

Spawn a lease renewal supervisor with a caller-provided maximum poll interval. Embedders can use this for shorter external lease TTLs; tests use it to exercise renewal without waiting on wall-clock TTLs.

Source

pub async fn renew_due_leases_once(&self) -> Result<usize, IdentityRuntimeError>

Renew every active lease that has entered the runtime’s renewal window.

Source

pub async fn set_desired_peer_edges(&self, edges: Vec<ManagedPeerEdge>)

Source

pub async fn desired_peer_edges(&self) -> Vec<ManagedPeerEdge>

Source

pub fn has_session_bridge(&self) -> bool

Source

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.

Source

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).

Source

pub async fn materialize( &self, identity: &AgentIdentity, ) -> Result<ContinuityRecord, IdentityRuntimeError>

Materialize a dormant identity into a concrete mob member/session.

This is the lazy counterpart to eager restore_flow: it performs the expensive bridge create/resume and snapshot load only when an identity is actually touched. Parallel calls for one identity coalesce on a per-identity lock and re-check state after acquiring it.

Source

pub async fn materialize_all( &self, ) -> Result<Vec<ContinuityRecord>, IdentityRuntimeError>

Materialize all identities currently registered with the runtime.

Fleet hydration is best-effort: one member that cannot build is skipped and surfaced through logs/error hooks rather than aborting unrelated members.

Source

pub async fn materialize_all_required( &self, ) -> Result<Vec<ContinuityRecord>, IdentityRuntimeError>

Materialize all identities and fail if any registered identity cannot hydrate. Flow admission uses this strict variant so a run is not accepted with a partially materialized identity-first fleet.

Source

pub async fn materialize_reachable_peers( &self, identity: &AgentIdentity, ) -> Result<Vec<ContinuityRecord>, IdentityRuntimeError>

Ensure an active identity’s desired peer neighborhood exists in the concrete mob graph before ordinary communication starts.

Source

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.

Source

pub async fn update_spec( &self, spec: DurableAgentSpec, ) -> Result<(), IdentityRuntimeError>

Update the spec for an existing identity (used during reconciliation).

Source

pub async fn adopt_roster_spec( &self, roster_provider: &Arc<dyn RosterProvider>, identity: &AgentIdentity, )

Adopt the roster’s CURRENT spec for identity into the in-memory entry, so a subsequent reset rebuilds the regenerated session on the current profile instead of carrying the stored one forward.

Best-effort: logs and leaves the stored spec in place if the roster can’t be resolved or no longer lists the identity (reset’s primary job — the destructive continuity reset — must not fail because the roster provider hiccuped). The runtime stays roster-agnostic; the provider is supplied by the caller (the reset RPC handler), which owns it.

Source

pub async fn update_lease( &self, identity: &AgentIdentity, grant: LeaseGrant, ) -> Result<(), IdentityRuntimeError>

Update the lease for an identity.

Source

pub async fn mark_lease_lost( &self, identity: &AgentIdentity, ) -> Result<(), IdentityRuntimeError>

Mark a lease as lost for an identity (INV-02).

Source

pub async fn set_state( &self, identity: &AgentIdentity, state: IdentityLifecycleState, ) -> Result<(), IdentityRuntimeError>

Set the lifecycle state for an identity.

Source

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).

Source

pub async fn send_with_mode( &self, identity: &AgentIdentity, content: &ContentInput, handling_mode: HandlingMode, ) -> Result<FencingToken, IdentityRuntimeError>

Send conversational content using an explicit turn handling mode.

This is the identity-first counterpart to the mob member send path used by the console. Ordinary API callers can keep using Self::send, which preserves queue semantics.

Source

pub async fn send_with_mode_and_interaction( &self, identity: &AgentIdentity, content: &ContentInput, handling_mode: HandlingMode, interaction_id: Option<&str>, ) -> Result<FencingToken, IdentityRuntimeError>

Self::send_with_mode with a host-minted interaction id (meerkat 0.7.25 ask 15 addendum). The id rides WorkSpec into runtime admission, so the turn’s live events and its committed transcript messages carry the same identity the console stamped on its frames — the exact live↔history join the console dedup needs. Only UUID-form ids thread; others are delivered without one.

Source

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).

Source

pub async fn status( &self, identity: &AgentIdentity, ) -> Result<IdentityStatus, IdentityRuntimeError>

Return the full identity status for the given identity.

Source

pub async fn statuses(&self) -> Vec<IdentityStatus>

Return statuses for every registered identity without materializing dormant members.

Source

pub async fn retire( &self, identity: &AgentIdentity, ) -> Result<FencingToken, IdentityRuntimeError>

Retire an identity. Validates lease ownership and retires the mob member.

Source

pub async fn respawn( &self, identity: &AgentIdentity, ) -> Result<ContinuityRecord, IdentityRuntimeError>

Respawn: non-destructive recovery.

  1. Fence the current owner
  2. Attempt final checkpoint
  3. Reactivate from authoritative continuity with same record + runtime ID
  4. ContinuityGeneration does NOT advance
Source

pub async fn rebind_session_after_live_respawn( &self, identity: &AgentIdentity, session_id: SessionId, ) -> Result<ContinuityRecord, IdentityRuntimeError>

Rebind continuity to the concrete session created by a lower-level member respawn. This keeps identity-first status aligned when a control surface refreshes the mob member outside the identity runtime bridge.

Source

pub async fn reset( &self, identity: &AgentIdentity, ) -> Result<ContinuityRecord, IdentityRuntimeError>

Reset: destructive continuity reset.

  1. Fence old owner
  2. Advance ContinuityGeneration
  3. Create fresh continuity under the same AgentIdentity
  4. Old-owner late writes rejected by stale fencing token
Source

pub async fn delete_identity( &self, identity: &AgentIdentity, ) -> Result<(), IdentityRuntimeError>

Delete an identity: removes continuity record.

  1. Fence old owner
  2. Remove ContinuityRecord
  3. Future bootstrap treats identity as Uninitialized
Source

pub async fn checkpoint( &self, identity: &AgentIdentity, snapshot: &SessionSnapshot, ) -> Result<CheckpointVersion, IdentityRuntimeError>

Save a checkpoint snapshot. Enforces version ordering and fencing.

Source

pub async fn roster_inspect( &self, ) -> BTreeMap<AgentIdentity, (DurableAgentSpec, IdentityStatus)>

Return all active identities with their specs and status.

Source

pub fn validate_roster_uniqueness( specs: &[DurableAgentSpec], ) -> Result<(), IdentityRuntimeError>

Validate that a roster contains no duplicate identities.

Source

pub async fn contains(&self, identity: &AgentIdentity) -> bool

Check if an identity is registered.

Source

pub async fn is_active(&self, identity: &AgentIdentity) -> bool

Check if an identity is registered AND in Active state.

Source

pub async fn owned_identity_for_member_alias( &self, alias: &str, ) -> Option<AgentIdentity>

Resolve a member alias to the durable identity that OWNS it, if any.

Accepts both a generated runtime alias (rt:<identity>:<generation>) and a plain identity string; returns the identity only when it is actually registered in this runtime. Member-scoped RPCs use this to route lifecycle mutations of identity-owned members through the identity authority — a classic handle.retire()/respawn() on such a member would mutate it behind the IdentityRuntime’s back (stale continuity binding, generation drift), which is the doctrine’s “mob plane must not mangle durables” rule.

Source

pub async fn broken_identities(&self) -> Vec<AgentIdentity>

Identities currently in the Broken lifecycle state.

Source

pub fn continuity_store(&self) -> &Arc<dyn ContinuityStore>

Get the continuity store reference.

Source

pub fn lease_provider(&self) -> &Arc<dyn LeaseProvider>

Get the lease provider reference.

Source

pub fn runtime_instance_id(&self) -> &str

Get the runtime instance ID.

Source

pub fn durability_policy(&self) -> &DurabilityPolicy

Get the durability policy.

Source

pub fn has_runtime_store(&self) -> bool

Get whether a runtime store is configured.

Source

pub fn bridge(&self) -> Option<&Arc<dyn SessionBridge>>

Get the session bridge reference, if configured.

Source

pub async fn send_text( &self, identity: &AgentIdentity, text: impl Into<String>, ) -> Result<FencingToken, IdentityRuntimeError>

Send plain text to an addressable identity.

Source

pub async fn dispatch_text( &self, identity: &AgentIdentity, text: impl Into<String>, ) -> Result<(FencingToken, bool), IdentityRuntimeError>

Dispatch plain text with system origin.

Source

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.

Source

pub async fn runtime_id_for( &self, identity: &AgentIdentity, ) -> Result<AgentRuntimeId, IdentityRuntimeError>

Resolve the AgentRuntimeId for a registered identity.

Source

pub async fn inspect( &self, identity: &AgentIdentity, ) -> Result<MemberInspection, IdentityRuntimeError>

Inspect the current execution state of an identity via the bridge.

Source

pub fn default_timeout(&self) -> Duration

The configured default timeout for wait operations.

Source

pub async fn wait_for_output( &self, identity: &AgentIdentity, timeout: Duration, ) -> Result<String, IdentityRuntimeError>

Poll until the identity produces an output_preview, or timeout.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more