Skip to main content

Workflows

Struct Workflows 

Source
pub struct Workflows { /* private fields */ }
Expand description

The workflow observer over a host’s graph agents (spec 3.3 §12). Cheap to clone.

§Example

use std::sync::Arc;
use adk_surface::workflow::Workflows;

let workflows = Workflows::new("adk-rust").graph(graph).runner(runner);
assert_eq!(workflows.graphs().len(), 1);

Implementations§

Source§

impl Workflows

Source

pub fn new(app: impl Into<String>) -> Self

An observer for the graph agents a runner of application app runs (spec 3.3 §12).

Source

pub fn graph(self, graph: Arc<GraphAgent>) -> Self

Observes graph, a graph agent with a checkpointer that the host’s runner runs.

Source

pub fn runner(self, runner: Arc<Runner>) -> Self

Starts a fork’s run through runner, the runner whose root agent is the graph.

Source

pub fn sessions(self, sessions: Arc<dyn SessionService>) -> Self

Reads and creates sessions through sessions; the runner’s when unset.

Source

pub fn hide_keys( self, keys: impl IntoIterator<Item = impl Into<String>>, ) -> Self

Shows the values of these state keys, at any depth, as [hidden].

Source

pub fn utc_offset(self, offset: FixedOffset) -> Self

Shows times at offset east of UTC instead of the host’s time zone.

Source

pub fn app_name(&self) -> &str

The application whose sessions this observer reads.

Source

pub fn graphs(&self) -> Vec<GraphView>

Every graph agent observed, with its nodes, edges and channels.

Source

pub async fn runs( &self, caller: &Caller, session: &str, graph: Option<&str>, ) -> Result<RunsResponse>

Every run of session, from the checkpoints’ records only (spec 3.3 §12).

§Errors

Returns surface.not_found for a session that is not the caller’s (S-I8), or for a workflow graph does not name; the checkpointer’s error otherwise.

Source

pub async fn run( &self, engine: &SurfaceEngine, caller: &Caller, session: &str, graph: Option<&str>, ) -> Result<WorkflowRun>

The latest run of session, as the Runs tab shows it (spec 3.3 §12): each node’s state, the steps, the lineage and forks, and the decision each waiting node waits on, matched in the inbox by origin and node.

§Errors

Returns surface.not_found for a session that is not the caller’s (S-I8), or for a workflow graph does not name; the checkpointer’s or the source’s error otherwise.

Source

pub async fn step( &self, engine: &SurfaceEngine, caller: &Caller, session: &str, checkpoint: &str, ) -> Result<StepDetail>

One step of session, from the checkpoint checkpoint (spec 3.3 §12): its nodes, “What changed” since the checkpoint before it, its state, and what a fork from it would do. Reading it changes nothing.

§Errors

Returns surface.not_found for a session that is not the caller’s, or a checkpoint that is not of the session’s thread (S-I8); the checkpointer’s error otherwise.

Source

pub async fn version( &self, caller: &Caller, session: &str, ) -> Result<Option<u64>>

The newest checkpoint version of session’s thread, which the Runs tab’s feed watches; None before the first checkpoint.

§Errors

Returns surface.not_found for a session that is not the caller’s (S-I8).

Source

pub async fn fork( &self, engine: &SurfaceEngine, caller: &Caller, session: &str, request: ForkRequest, ) -> Result<ForkOutcome>

Forks session at the completed checkpoint request.from into a new session of the caller, with request.set written over whole channels, and starts it when request.start is set (spec 3.3 §12).

RefusedWith
A paired device, or any surface but the web home403 surface.not_here
A session that is not the caller’s, or a checkpoint not of its thread404 surface.not_found (S-I8)
A decision of the session waits409 workflow.decision_waiting: “Answer the waiting decision first”
A pause, a step with nothing after it, an edit of a key the graph does not declare, a value over FORK_VALUE_LIMIT400 with the fork’s fork.* code

The original thread is never written; a governed call the fork makes unchanged is answered from its record. While Stop all is on the fork is made and not started. The fork is recorded as SURFACE_AUDIT_WORKFLOW_FORK with the session, the checkpoint, the fork’s session, the edited keys and the caller’s surface and origin.

§Errors

As the table says, and the stores’ errors.

Source

pub async fn start( &self, engine: &SurfaceEngine, caller: &Caller, session: &str, ) -> Result<ForkOutcome>

Starts a fork made and not started, such as one made while everything was stopped.

§Errors

Returns 403 surface.not_here from a paired device or another surface, 404 surface.not_found for a session that is not the caller’s, 409 workflow.stopped while everything is stopped, and 400 workflow.started for a run that already started.

Source

pub fn approval_router( &self, fallback: impl ApprovalRouter + 'static, ) -> WorkflowRouter

An approval router that keeps fallback’s route and raises the risk of a call from a governed node that spends money to high, so chat, voice and the kernel’s own routes treat it as money (spec 3.3 §7.2, §7.4 rule 4).

§Example
use adk_core::{ApprovalPolicy, ApproverSelector};
use adk_surface::workflow::Workflows;

let router = Workflows::new("adk-rust")
    .approval_router(ApprovalPolicy::new([ApproverSelector::group("owner")]));

Trait Implementations§

Source§

impl CardHints for Workflows

Source§

fn hint<'life0, 'life1, 'async_trait>( &'life0 self, request: &'life1 ApprovalRequest, ) -> Pin<Box<dyn Future<Output = Option<CardHint>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

A governed node’s card (spec 3.3 §7.1, §12): never Always allow, money for a node that spends it, “Can’t be undone” for a non-idempotent one, and “From the invoice-run workflow · Open in Runs”.

Source§

fn names<'life0, 'life1, 'async_trait>( &'life0 self, _request: &'life1 ApprovalRequest, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

What request’s call acts on, as the person knows it — “News digest” — which the record of an answer to it names beside the card’s summary (spec 3.3 §8, §11). None, the default, for a call that names nothing a person knows or that is not this feature’s.
Source§

impl Clone for Workflows

Source§

fn clone(&self) -> Self

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
Source§

impl Debug for Workflows

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Workflows

§

impl !UnwindSafe for Workflows

§

impl Forget for Workflows

§

impl Freeze for Workflows
where *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze,

§

impl Move for Workflows

§

impl Send for Workflows
where Arc<Inner>: Send,

§

impl Sync for Workflows
where Arc<Inner>: Sync,

§

impl Unpin for Workflows
where Arc<Inner>: Unpin,

§

impl UnsafeUnpin for Workflows
where *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin,

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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