pub struct PlanRuntime {
inner: Arc<Mutex<HashMap<String, PlanRun>>>,
}Fields§
§inner: Arc<Mutex<HashMap<String, PlanRun>>>Implementations§
Source§impl PlanRuntime
impl PlanRuntime
Sourcepub async fn register_plan(&self, plan_id: &str)
pub async fn register_plan(&self, plan_id: &str)
Register a plan before execution starts.
If a stale entry with the same id exists it is replaced. Plan ids are UUIDs generated by Pilot, so replacement is only a defensive cleanup path.
Sourcepub async fn record_plan_ops(&self, plan: &Plan)
pub async fn record_plan_ops(&self, plan: &Plan)
Snapshot a plan’s op list (arena order) so get_plan_status can report
the op_ids/descriptions the LLM may target. Called right after
register_plan. No-op if the plan is not in the active table.
Sourcepub async fn record_op_state(&self, plan_id: &str, op_id: &str, state: u32)
pub async fn record_op_state(&self, plan_id: &str, op_id: &str, state: u32)
Record the latest observed RTDL state for an op. Called by the execution
loop / async poller alongside every node_state event it streams, so
get_plan_status reflects live progress. No-op for unknown plans.
Sourcepub async fn get_plan_status_builtin(
&self,
call: &CapabilityCall,
) -> CapabilityCallResult
pub async fn get_plan_status_builtin( &self, call: &CapabilityCall, ) -> CapabilityCallResult
Apply the get_plan_status builtin: return the plan’s ops as JSON, each
with op_id, kind, description, current state, and any armed
stop_point. Lets the LLM inspect a running plan before issuing a
stop_plan_at (inspect first, then act). Errors when the plan is not in
the active table (stale/wrong id, or already finished) — it is a query,
so “not found” is an error; use get_all_plans to check liveness.
Sourcepub async fn get_all_plans_builtin(
&self,
call: &CapabilityCall,
) -> CapabilityCallResult
pub async fn get_all_plans_builtin( &self, call: &CapabilityCall, ) -> CapabilityCallResult
Apply the get_all_plans builtin: list every active RTDL plan with its
op count, cancelled flag, and number of armed stop points. Lets the LLM
discover which plans are running before inspecting one with
get_plan_status. Takes no args.
Sourcepub async fn active_plans_json(&self) -> String
pub async fn active_plans_json(&self) -> String
Return Executor’s authoritative active-plan table for control-plane observers. Reading this snapshot does not register a query plan.
Sourcepub async fn complete_plan(&self, plan_id: &str)
pub async fn complete_plan(&self, plan_id: &str)
Mark a plan complete, remove it from the active table, and notify waiters.
Sourcepub async fn is_cancelled(&self, plan_id: &str) -> bool
pub async fn is_cancelled(&self, plan_id: &str) -> bool
Return whether a registered plan has been cancelled.
Sourcepub async fn register_or_cancel_async_call(
&self,
plan_id: &str,
call: RunningAsyncCall,
self_provider_id: &str,
atlas: &mut AtlasClient,
) -> bool
pub async fn register_or_cancel_async_call( &self, plan_id: &str, call: RunningAsyncCall, self_provider_id: &str, atlas: &mut AtlasClient, ) -> bool
Add one async capability call to the plan’s cancellation set, or cancel it immediately if the plan has already been marked cancelled.
Returns true when the call was registered for normal polling. Returns
false when the runtime sent the provider cancel contract instead.
Sourcepub async fn unregister_async_call(&self, plan_id: &str, call_id: &str)
pub async fn unregister_async_call(&self, plan_id: &str, call_id: &str)
Remove an async call once it reaches a terminal state.
Sourcepub async fn cancel_async_call_for_plan(
&self,
plan_id: &str,
call_id: &str,
self_provider_id: &str,
atlas: &mut AtlasClient,
)
pub async fn cancel_async_call_for_plan( &self, plan_id: &str, call_id: &str, self_provider_id: &str, atlas: &mut AtlasClient, )
If a cancelled plan still owns call_id, remove it and send its cancel
contract. Calls already claimed by cancel_plan become a no-op here.
Sourcepub async fn cancel_plan_builtin(
&self,
call: &CapabilityCall,
self_provider_id: &str,
atlas: &mut AtlasClient,
) -> CapabilityCallResult
pub async fn cancel_plan_builtin( &self, call: &CapabilityCall, self_provider_id: &str, atlas: &mut AtlasClient, ) -> CapabilityCallResult
Apply the cancel_plan builtin.
Cancellation is best-effort: future sequence children are skipped by the
executor loop, and currently running async capability calls receive their
required <contract_id>/cancel call. Synchronous calls already in
progress are allowed to return naturally.
Sourcepub async fn cancel_plan_control(
&self,
plan_id: &str,
wait_ms: u64,
self_provider_id: &str,
atlas: &mut AtlasClient,
) -> (bool, String)
pub async fn cancel_plan_control( &self, plan_id: &str, wait_ms: u64, self_provider_id: &str, atlas: &mut AtlasClient, ) -> (bool, String)
Out-of-band target cancellation used by Pilot meta ops and the legacy builtin wrapper. Returns whether the plan reached terminal state before the deadline plus a stable, idempotent message.
Sourcepub async fn stop_plan_at_control(
&self,
plan_id: &str,
op_id: &str,
when: &str,
) -> Result<String, String>
pub async fn stop_plan_at_control( &self, plan_id: &str, op_id: &str, when: &str, ) -> Result<String, String>
Arm a semantic stop boundary without creating a control RTDL tree.
Sourcepub async fn stop_plan_at_builtin(
&self,
call: &CapabilityCall,
) -> CapabilityCallResult
pub async fn stop_plan_at_builtin( &self, call: &CapabilityCall, ) -> CapabilityCallResult
Apply the stop_plan_at builtin: record a stop point so the plan is
cancelled when execution reaches the given op.
when selects the phase (on_enter before the op runs, on_complete
after it finishes; default on_complete). Setting a stop point on a
plan that is no longer active is a SUCCESS no-op — the intent (“don’t
run past op X”) is already satisfied, and returning an error would make
the planner retry forever (same policy as cancel_plan). The op_id is
not validated against the plan’s nodes here; an op_id that never
executes simply never fires.
Sourcepub async fn should_stop_at(
&self,
plan_id: &str,
op_id: &str,
when: StopWhen,
) -> bool
pub async fn should_stop_at( &self, plan_id: &str, op_id: &str, when: StopWhen, ) -> bool
Whether the plan has a stop point on op_id for the given phase.
Read by the execution loop at each do node entry and completion.
Sourcepub async fn trigger_stop(
&self,
plan_id: &str,
self_provider_id: &str,
atlas: &mut AtlasClient,
)
pub async fn trigger_stop( &self, plan_id: &str, self_provider_id: &str, atlas: &mut AtlasClient, )
Fire a stop point: mark the plan cancelled and best-effort cancel its
running async calls — the same teardown cancel_plan performs. After
this the execution loop’s is_cancelled checks halt the rest of the
plan. No-op if the plan already left the active table.
Sourcepub async fn cancel_all_plans(
&self,
self_provider_id: &str,
atlas: &mut AtlasClient,
) -> bool
pub async fn cancel_all_plans( &self, self_provider_id: &str, atlas: &mut AtlasClient, ) -> bool
Cancel every active plan and make best-effort cancel calls for running async work.
Sourcepub async fn cancel_all_plans_except(
&self,
self_provider_id: &str,
atlas: &mut AtlasClient,
except_plan_id: Option<&str>,
wait_ms: u64,
) -> (usize, bool)
pub async fn cancel_all_plans_except( &self, self_provider_id: &str, atlas: &mut AtlasClient, except_plan_id: Option<&str>, wait_ms: u64, ) -> (usize, bool)
Cancel every active plan except an optional control plan and wait for the targets to leave the active table.
Sourceasync fn begin_cancel(&self, plan_id: &str) -> Result<CancelSnapshot, String>
async fn begin_cancel(&self, plan_id: &str) -> Result<CancelSnapshot, String>
Mark a plan cancelled and return the state needed by cancel_plan.
This pure runtime step is separated from atlas/MCP cancel calls so tests can cover unknown-plan and cancellation-state behavior without a live atlas server.
Sourceasync fn begin_cancel_all(
&self,
except_plan_id: Option<&str>,
) -> CancelAllSnapshot
async fn begin_cancel_all( &self, except_plan_id: Option<&str>, ) -> CancelAllSnapshot
Mark every active plan cancelled and drain their async cancel sets into
one snapshot. Provider cancel calls happen after the runtime lock is
released by cancel_all_plans.
async fn wait_until_inactive(&self, plan_id: &str, wait_ms: u64) -> bool
Sourceasync fn wait_until_all_inactive(
&self,
plan_ids: &[String],
wait_ms: u64,
) -> bool
async fn wait_until_all_inactive( &self, plan_ids: &[String], wait_ms: u64, ) -> bool
Poll durable active-table state instead of awaiting Notify, whose
notification can race ahead of waiter registration.
Trait Implementations§
Source§impl Clone for PlanRuntime
impl Clone for PlanRuntime
Source§fn clone(&self) -> PlanRuntime
fn clone(&self) -> PlanRuntime
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for PlanRuntime
impl Default for PlanRuntime
Source§fn default() -> PlanRuntime
fn default() -> PlanRuntime
Auto Trait Implementations§
impl Freeze for PlanRuntime
impl !RefUnwindSafe for PlanRuntime
impl Send for PlanRuntime
impl Sync for PlanRuntime
impl Unpin for PlanRuntime
impl UnsafeUnpin for PlanRuntime
impl !UnwindSafe for PlanRuntime
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
§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].