pub struct Session {
pub id: String,
pub workflow: Workflow,
pub identity: AgentIdentity,
pub loop_state: SessionLoopState,
pub chain: Mutex<EventChain>,
pub atif: Mutex<TrajectoryBuilder>,
pub totals: Totals,
pub last_activity_ms: AtomicU64,
pub closed: AtomicU64,
pub receipt: Mutex<Option<Receipt>>,
pub atif_path: Mutex<Option<PathBuf>>,
/* private fields */
}Expand description
A live session.
Fields§
§id: StringSession id.
workflow: WorkflowWorkflow kind.
identity: AgentIdentityAgent identity bound at open (from NHI validation).
loop_state: SessionLoopStateLoop-breaker state.
chain: Mutex<EventChain>Signed workflow: incremental event chain.
atif: Mutex<TrajectoryBuilder>Unsigned workflow: ATIF steps.
totals: TotalsAggregates for the receipt.
last_activity_ms: AtomicU64Last-activity timestamp (idle sweeping), epoch ms.
closed: AtomicU64Set once closed (idempotent close).
receipt: Mutex<Option<Receipt>>Issued signed or retroactive receipt.
atif_path: Mutex<Option<PathBuf>>Persisted unsigned ATIF artifact.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(
id: String,
workflow: Workflow,
identity: AgentIdentity,
breaker: BreakerConfig,
) -> Self
pub fn new( id: String, workflow: Workflow, identity: AgentIdentity, breaker: BreakerConfig, ) -> Self
Open a session.
Sourcepub fn try_close(&self) -> bool
pub fn try_close(&self) -> bool
Attempt to claim the close transition. Only one caller can hold the
claim at a time; a failed finalize resets it (reset_close) so the
close can be retried.
Sourcepub fn artifact_committed_flag(&self) -> bool
pub fn artifact_committed_flag(&self) -> bool
True once the receipt/ATIF artifact is durably persisted.
Sourcepub fn close_complete_flag(&self) -> bool
pub fn close_complete_flag(&self) -> bool
True once the close ran to full completion (journal removed).
Sourcepub fn try_promote(&self) -> bool
pub fn try_promote(&self) -> bool
Atomically claim promotion. Only one caller can hold the claim at a
time; failed receipt persistence resets it (reset_promotion) so
promotion can be retried.
Sourcepub fn is_promoted(&self) -> bool
pub fn is_promoted(&self) -> bool
True after promotion has completed (receipt persisted), not merely been claimed.
Sourcepub fn recover_unsigned(
id: String,
identity: AgentIdentity,
breaker: BreakerConfig,
path: PathBuf,
metrics: Option<&FinalMetrics>,
) -> Result<Self, String>
pub fn recover_unsigned( id: String, identity: AgentIdentity, breaker: BreakerConfig, path: PathBuf, metrics: Option<&FinalMetrics>, ) -> Result<Self, String>
Recreate a closed unsigned session from a persisted ATIF trajectory.
Sourcepub fn take_trajectory(&self) -> Trajectory
pub fn take_trajectory(&self) -> Trajectory
Consume the current ATIF builder and replace it with an empty one.
Sourcepub fn active_streams_count(&self) -> u64
pub fn active_streams_count(&self) -> u64
Number of forwarded chat responses currently streaming.
Sourcepub fn pending_jobs_count(&self) -> u64
pub fn pending_jobs_count(&self) -> u64
Number of worker jobs accepted but not yet fully captured.
Sourcepub fn refresh_identity(&self, identity: &AgentIdentity)
pub fn refresh_identity(&self, identity: &AgentIdentity)
Refresh token-derived fields after successful validation.
Sourcepub fn current_identity(&self) -> AgentIdentity
pub fn current_identity(&self) -> AgentIdentity
Current validated identity snapshot.
Sourcepub fn receipt_body(
&self,
subject: ReceiptSubject,
stop: StopReason,
) -> ReceiptBody
pub fn receipt_body( &self, subject: ReceiptSubject, stop: StopReason, ) -> ReceiptBody
Build the receipt body for this session (signed close or promotion).
Auto Trait Implementations§
impl !Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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