pub struct TaskRuntime { /* private fields */ }Expand description
Task lifecycle reducer. Drive it from one control lane or a deterministic replay. At most one invocation is pending per activation; different tasks may execute concurrently. All commands finish synchronously, including approval requests.
Implementations§
Source§impl TaskRuntime
impl TaskRuntime
Sourcepub fn new(skills: Vec<CompiledSkill>) -> Result<TaskRuntime, TaskError>
pub fn new(skills: Vec<CompiledSkill>) -> Result<TaskRuntime, TaskError>
Install a finite catalog. Duplicate names/tool names are rejected.
Sourcepub fn with_clock(self, clock: Arc<dyn Clock>) -> TaskRuntime
pub fn with_clock(self, clock: Arc<dyn Clock>) -> TaskRuntime
Use an injected clock for future task activations and deterministic replay.
Sourcepub fn command(
&mut self,
command: TaskCommand,
) -> Result<Option<OwnedInvocation>, TaskError>
pub fn command( &mut self, command: TaskCommand, ) -> Result<Option<OwnedInvocation>, TaskError>
Apply a command. An executable ticket is returned only after admission and, for a commit, an explicit trusted decision about its exact proposal.
Sourcepub fn complete(&mut self, completion: InvocationCompletion) -> TaskDelivery
pub fn complete(&mut self, completion: InvocationCompletion) -> TaskDelivery
Commit the result to its captured owner, never whichever task is now foreground. External commit receipts survive cancellation/revision even when state is stale.
Sourcepub fn catalog(&self) -> Vec<SkillSummary>
pub fn catalog(&self) -> Vec<SkillSummary>
Observe the pinned catalog without exposing factories or raw state.
Sourcepub fn snapshot(&self) -> TaskSessionSnapshot
pub fn snapshot(&self) -> TaskSessionSnapshot
Observe all activation and operation lifecycles. Not a restore checkpoint.
Sourcepub fn foreground_instruction(&self) -> Option<String>
pub fn foreground_instruction(&self) -> Option<String>
Foreground skill instructions and current governed posture/grounding:
foreground_brief followed by
foreground_context.
Sourcepub fn foreground_brief(&self) -> Option<String>
pub fn foreground_brief(&self) -> Option<String>
The part of the foreground instruction that changes only when the
foreground task or its revision does: the task’s identity and its
skill’s instruction. Under contextUpdate it rides the system
instruction, which an update replaces, rather than a context turn,
which stays in the conversation.
Sourcepub fn skill_code(&self, name: &str) -> Option<&CodeMode>
pub fn skill_code(&self, name: &str) -> Option<&CodeMode>
The code tool of the skill name, if it has one.
Sourcepub fn foreground_offer(&self) -> Option<(String, Vec<String>)>
pub fn foreground_offer(&self) -> Option<(String, Vec<String>)>
The foreground task’s skill and the tools it offers the model now:
those its flow would admit once their never(..).until(..) guards
hold, as FlowStack::offers_tool decides, or every tool of a skill
without a flow. None with no foreground task.
Sourcepub fn foreground_context(&self) -> Option<String>
pub fn foreground_context(&self) -> Option<String>
The part of the foreground instruction that changes as the task runs: service contexts, extracted, computed and remembered values, active postures and grounds, input and results. Empty when there is none.
Sourcepub fn on_turn(&mut self)
pub fn on_turn(&mut self)
Advance current foreground governance. Hosts with transcript ownership
should prefer on_turn_for.
Sourcepub fn on_turn_for(&mut self, id: &TaskId, revision: u64)
pub fn on_turn_for(&mut self, id: &TaskId, revision: u64)
Advance a turn belonging to the captured task/revision, even if another task is now speaking. Stale and terminal owners are ignored. While work is unresolved, events queue so its snapshot cannot overwrite repair writes.
Sourcepub fn on_interrupted(&mut self)
pub fn on_interrupted(&mut self)
Attribute an interruption to the current foreground task.
Sourcepub fn on_interrupted_for(&mut self, id: &TaskId, revision: u64)
pub fn on_interrupted_for(&mut self, id: &TaskId, revision: u64)
Attribute an interruption to its captured owner without cancelling unrelated tasks or claiming an external commit has been undone.
Sourcepub fn needs_service_timer(&self) -> bool
pub fn needs_service_timer(&self) -> bool
Whether the foreground task has a detector requiring timer observations.
Sourcepub fn observe(
&mut self,
id: &TaskId,
revision: u64,
event: TaskObservation,
) -> Result<(), TaskError>
pub fn observe( &mut self, id: &TaskId, revision: u64, event: TaskObservation, ) -> Result<(), TaskError>
Enqueue an observation captured for this task revision, never the current speaker by inference.
Sourcepub fn take_ready_services(&mut self) -> Vec<OwnedTaskServiceWork>
pub fn take_ready_services(&mut self) -> Vec<OwnedTaskServiceWork>
Take runnable service tickets prepared by the same reducer as tool invocations.
Sourcepub fn take_service_effects(&mut self) -> Vec<AcceptedTaskEffect>
pub fn take_service_effects(&mut self) -> Vec<AcceptedTaskEffect>
Take accepted owner-labelled effects. Speaking delivery must recheck foreground ownership.
Sourcepub fn complete_services(&mut self, completion: TaskServiceCompletion) -> bool
pub fn complete_services(&mut self, completion: TaskServiceCompletion) -> bool
Accept a service result only once and only in its original live task revision.
Trait Implementations§
Source§impl Drop for TaskRuntime
impl Drop for TaskRuntime
Auto Trait Implementations§
impl !RefUnwindSafe for TaskRuntime
impl !UnwindSafe for TaskRuntime
impl Freeze for TaskRuntime
impl Send for TaskRuntime
impl Sync for TaskRuntime
impl Unpin for TaskRuntime
impl UnsafeUnpin for TaskRuntime
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Conv for T
impl<T> Conv for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.