pub struct Session { /* private fields */ }Expand description
The session owner: one per conversation, held by the harness.
Non-Clone by design — the owner is the lifecycle anchor. Cloneable
SessionHandles are the operation entries; they neither own the
lifecycle nor expose the writable state.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(
state: ConversationState,
runner: Arc<TurnRunner>,
options: TurnRunOptions,
config: SessionConfig,
) -> Result<Session, SessionBuildRejection>
pub fn new( state: ConversationState, runner: Arc<TurnRunner>, options: TurnRunOptions, config: SessionConfig, ) -> Result<Session, SessionBuildRejection>
Build an idle session from a validated ConversationState plus the
harness’s assembled runner and options.
Construction never calls the model or a tool and never starts work; a
work is admitted only by submit. A state with an active turn (or, by
the aggregate’s invariant, a leftover stamp) is rejected, and every
by-value input (state, runner, options, config) comes back in
SessionBuildRejection.
Every work runs through
TurnRunner::run_in_conversation,
which frames the lossless merged history plus the active turn;
TurnRunOptions::frame is deliberately inert on that entry (the driver
documents the same for its conversation entries), so per-work material
projection is not wired here.
§Errors
Returns SessionBuildRejection carrying
SessionError::InvalidInput when state is not idle.
Sourcepub fn handle(&self) -> SessionHandle
pub fn handle(&self) -> SessionHandle
A cloneable operation entry into this session.
Sourcepub fn checkpoint(&self) -> Result<SessionCheckpoint, SessionError>
pub fn checkpoint(&self) -> Result<SessionCheckpoint, SessionError>
Export the session’s versioned save envelope — the complete idle state or the complete paused outcome, every retained work, the request-key replay tables, the TurnId allocation progress, and the configuration description.
Only a quiescent session exports: while a work is accepted / running
(a cancel in progress included) the export is
SessionError::Busy, and a faulted session refuses — no complete
outcome exists to save. A closed session still exports, recording
closed, so restoring it yields a closed session that replays
accepted keys and accepts no new work. The envelope is a plain value:
whether and when to persist it stays with the harness, and
SessionCheckpoint::restore is the only way back in. Restore never
calls the model or a tool, and a restored pause still needs an
explicit resume under its remaining (not re-granted) deadline.
Sourcepub async fn shutdown(&self)
pub async fn shutdown(&self)
Shut the session down: stop accepting, then wait for the running work to wind down.
Stops acceptance and fires the active work’s stop signal, then waits
until no work is running. The session keeps its retrievable results
and paused material readable through surviving SessionHandles;
work submitted afterwards reports SessionError::Closed.
Trait Implementations§
Source§impl Drop for Session
impl Drop for Session
Source§fn drop(&mut self)
fn drop(&mut self)
Stops acceptance and sends the stop signal to the active work.
The worker keeps its own Arc<SessionCore>, so no strong reference
cycle exists and the in-flight run still publishes its terminal state
after the owner is gone. Drop cannot await that wind-down, nor persist
anything — an explicit shutdown covers those.