Skip to main content

LashSession

Struct LashSession 

Source
pub struct LashSession { /* private fields */ }

Implementations§

Source§

impl LashSession

Source

pub async fn close(self) -> Result<()>

Durably close this session, then release its in-memory runtime.

close is the honest teardown verb: a persistent session flushes its dirty state (via a fresh-lease commit) so the store reflects the final transcript, its in-memory plugin session is unregistered, and the live runtime is dropped. A store-less (ephemeral) session has nothing to persist, so closing it is exactly the plugin-session unregister plus dropping the runtime.

This consumes the session and requires exclusive ownership: any cloned LashSession handle or in-flight turn keeps a live reference to the same runtime, so close returns EmbedError::SessionStillInUse until those are dropped or finished. Cancel running turns first with cancel_running_turns if needed.

To keep a handle for later resumption instead of discarding the session, use park.

Source

pub async fn park(self) -> Result<ParkedSession>

Quiesce this session for later resumption, returning a lightweight ParkedSession handle.

Parking flushes dirty state to the store (a fresh-lease commit), drops the live runtime and its plugin session, and hands back a cheap handle the host can cache and later rebuild with LashCore::resume. This is the quiesce/handoff lever for webserver embedders that hold many idle sessions: it bounds resident memory per session without deleting durable state.

Contract:

  • Persistent runtime required. Parking flushes to the store, so a store-less session cannot be parked and returns an error. Use close to tear down an ephemeral session.
  • Exclusive ownership required. park consumes the session and drops the in-memory runtime, so it needs the sole live reference. A cloned LashSession or an in-flight turn holds another reference and makes park return EmbedError::SessionStillInUse. Because an executing turn holds such a reference, parking is effectively an idle-session operation: finish or cancel_running_turns first. The store commit itself does not observe an active turn; the exclusive-ownership guard is what makes mid-turn parking an explicit error rather than a silent partial flush.
Source

pub fn session_id(&self) -> String

Source

pub fn policy_snapshot(&self) -> SessionPolicy

Source

pub fn observe(&self) -> ObservableSession

Source

pub fn parent_session_id(&self) -> Option<&str>

Source

pub fn effect_host(&self) -> Arc<dyn EffectHost>

Source

pub fn turn(&self, input: TurnInput) -> TurnBuilder

Source

pub fn queued_turn(&self) -> QueuedTurnBuilder

Source

pub fn cancel_running_turns(&self) -> usize

Cancel every turn currently executing through this opened session (including its clones) and report how many were signalled.

This is the affordance behind a UI “stop” control: hold a clone of the session wherever the stop arrives and call this, instead of threading a CancellationToken into every turn call (TurnBuilder::cancel remains the per-turn hook when you need one). A cancelled turn finishes with TurnOutcome::Stopped(TurnStop::Cancelled) and commits like any other turn; the session stays usable.

Scope: turns started from this LashSession instance and its clones. A handle opened separately for the same session id has its own registry and is not reached.

Source

pub fn admin(&self) -> SessionAdmin

Source

pub async fn configure(&self, patch: SessionConfigPatch) -> Result<()>

Source

pub fn tools(&self) -> ToolAdmin

Source

pub fn commands(&self) -> SessionCommandAdmin

Source

pub fn triggers(&self) -> SessionTriggerAdmin

Source

pub fn processes(&self) -> SessionProcessAdmin

Source

pub async fn refresh_background_graph(&self) -> Result<()>

Refresh the session graph from any background process that signalled it changed. This is the honest name for the former processes().await_all() misnomer (ADR 0019 grill): a session-graph resync, not a terminal wait on background work — wait on a process with SessionProcessAdmin::await_output. It lives on the session surface because it refreshes the session graph, not the global process registry.

Source

pub fn plugin_operations(&self) -> PluginOperations

Source

pub fn enqueue(&self, input: TurnInput) -> EnqueueTurnBuilder<'_>

Source

pub async fn queued_work(&self) -> Result<Vec<QueuedWorkBatch>>

Return all pending durable queued-work batches for this session.

This is an admin/introspection view for non-user queued work such as process wakes and session commands. User-visible model input is stored separately as pending turn input and is exposed by pending_turn_inputs.

Source

pub async fn pending_turn_inputs(&self) -> Result<Vec<PendingTurnInput>>

Source

pub async fn cancel_pending_turn_input( &self, input_id: &str, ) -> Result<PendingTurnInputCancelOutcome>

Source

pub async fn cancel_pending_turn_inputs( &self, targets: impl IntoIterator<Item = PendingTurnInputCancelTarget>, ) -> Result<Vec<PendingTurnInputCancelResult>>

Atomically cancel a set of pending user inputs by runtime input id or app source key.

This is the app reconciliation path for explicit selections such as “remove these pending drafts”. Returned outcomes distinguish newly cancelled input from input that was already claimed, completed, cancelled, or missing.

Source

pub async fn cancel_pending_turn_input_suffix( &self, anchor: PendingTurnInputCancelTarget, ) -> Result<PendingTurnInputSuffixCancelOutcome>

Atomically cancel the same-session pending-input suffix from anchor.

Apps that let users edit previously submitted product messages should map the edited message to the stored pending-input input_id or source_key, call this method, and only restore/edit drafts that return PendingTurnInputCancelOutcome::Cancelled. Claimed or completed inputs have already crossed the runtime boundary and should be treated as reconciliation state, not local editable drafts.

Source

pub async fn cancel_queued_work_batch( &self, batch_id: &str, ) -> Result<Option<QueuedWorkBatch>>

Source

pub async fn abandon_queued_work_claim( &self, claim: &QueuedWorkClaim, ) -> Result<()>

Release a held queued-work claim without completing it, returning its batches to the pending queue immediately.

A host stopping an external queued-work driver mid-claim calls this with the claims that driver still holds so the work becomes claimable again at once instead of waiting out the claim’s lease TTL.

Source

pub async fn abandon_turn_input_claim( &self, claim: &TurnInputClaim, ) -> Result<()>

Release a held pending-turn-input claim without completing it, returning its inputs to the pending queue immediately. The turn-input counterpart of abandon_queued_work_claim.

Source

pub async fn revoke_durable_waits(&self) -> Result<()>

Cancel every outstanding durable wait for this session without deleting the session.

Each waiter receives a terminal Resolution::Cancelled instead of hanging until an external completion arrives, and late resolves observe that terminal. The session itself stays usable: new durable waits registered afterwards behave normally, unlike the tombstoning revocation LashCore::delete_session performs.

Source

pub async fn await_queued_work_batch(&self, batch_id: &str) -> Result<()>

Resolve once batch_id is no longer pending in the queue store — drained by whoever runs queued work (a queued-work runner, a durable worker, or another handle’s queued_turn) or cancelled. This is the enqueue-and-observe side of the queue: the caller never claims the work itself.

Completion is read from the persistent queue store, so it observes drains performed by other session handles and other processes alike. There is no built-in deadline — nothing resolves if nothing drains the queue, so bound it with tokio::time::timeout when the worker may be unavailable. A batch id the store has never seen resolves immediately.

Source

pub fn read_view(&self) -> SessionReadView

Source

pub fn usage_report(&self) -> SessionUsageReport

Source

pub async fn set_turn_phase_probe(&self, probe: Arc<dyn RuntimeTurnPhaseProbe>)

Trait Implementations§

Source§

impl Clone for LashSession

Source§

fn clone(&self) -> LashSession

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<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