pub struct Agenda { /* private fields */ }harness-kernel only.Expand description
The agenda of a kernel (spec 3.2 §7.5): proposals, approvals and the processes items
become. Kernel::agenda returns it; cloning shares it.
| Call | Effect |
|---|---|
propose | Checks the ProactivityPolicy, records the item Proposed, and routes it: held, to the inbox, or — in an Auto partition following its mode — approved and scheduled |
approve | Proposed → Approved → Scheduled: a ProcessKind::Proposed process whose parent is the proposing run; for a question, Proposed → Done, confirmed |
reject | Proposed or Approved → Rejected |
schedule | Puts the item’s process to sleep on a wake set, approving a proposed item first; refused for a question |
Every change is published as a KernelEvent::Agenda and
audited as kernel.agenda.*. Inbox decisions, expiry and finished processes are applied
on every scheduler tick.
§Example
use adk_core::principal::SubjectRef;
use adk_kernel::{AgendaItem, AgendaOrigin, Kernel, PartitionMode, ProposalOutcome};
let item = AgendaItem::new(
"item-1",
SubjectRef::human("alice"),
"Re-run the tests",
"The dependency bump lands tonight",
AgendaOrigin::User,
chrono::Utc::now(),
);
if let ProposalOutcome::AwaitingApproval { request_id, .. } = kernel.agenda().propose(item, PartitionMode::Ask).await? {
println!("approve {request_id} in the inbox");
}Implementations§
Source§impl Agenda
impl Agenda
Sourcepub fn store(&self) -> &Arc<dyn AgendaStore> ⓘ
pub fn store(&self) -> &Arc<dyn AgendaStore> ⓘ
The store the items live in.
Sourcepub fn policy(&self) -> &ProactivityPolicy
pub fn policy(&self) -> &ProactivityPolicy
Every partition’s proactivity limits.
Sourcepub async fn get(&self, id: &str) -> Result<Option<AgendaItem>, KernelError>
pub async fn get(&self, id: &str) -> Result<Option<AgendaItem>, KernelError>
Sourcepub async fn list(
&self,
filter: &AgendaFilter,
) -> Result<Vec<AgendaItem>, KernelError>
pub async fn list( &self, filter: &AgendaFilter, ) -> Result<Vec<AgendaItem>, KernelError>
Sourcepub async fn propose(
&self,
item: AgendaItem,
mode: PartitionMode,
) -> Result<ProposalOutcome, KernelError>
pub async fn propose( &self, item: AgendaItem, mode: PartitionMode, ) -> Result<ProposalOutcome, KernelError>
Proposes item from a partition in mode (spec 3.2 §7.5, §9.1 runaway
proactivity).
The policy refuses a proposal — published proposed → rejected with the reason
and audited, nothing stored — past max_proposed_open open items in the partition,
once the day’s proactive budget is spent, or whose own budget exceeds the daily one.
Otherwise the item is stored Proposed and routed by ProactiveApproval: held in
ReadOnly and Plan, put to the inbox in Ask, approved and scheduled in Auto. An item
of AgendaOrigin::Consolidation or AgendaOrigin::Observation goes to the inbox
in Auto too (K-I23, spec 3.2 §7.10); a question costs no budget, so only the open-item
limit refuses one. Without an approval service an Ask proposal is held.
§Errors
Returns KernelError::Config for an empty title or an item not Proposed, or a
store error.
Sourcepub async fn approve(
&self,
id: &str,
by: &SubjectRef,
) -> Result<AgendaItem, KernelError>
pub async fn approve( &self, id: &str, by: &SubjectRef, ) -> Result<AgendaItem, KernelError>
Approves the proposed item id as by, then schedules it: Proposed → Approved →
Scheduled (spec 3.2 §7.5, K-I10). An item of AgendaOrigin::Consolidation needs
a person (K-I23). A pending inbox request for the item is withdrawn.
A question (AgendaOrigin::is_question) is confirmed instead, by a person only:
the partition’s ObservationAudience records its statement as a Known fact, and
the item is Done with the AgendaAnswer; no process is created (spec 3.2 §7.10).
Returns the item as it stands: Scheduled, or Approved when its process could not
be created yet (a freeze, a full queue), which the next tick retries; Done for a
confirmed question.
§Errors
Returns KernelError::AgendaNotFound, KernelError::AgendaState when the item is
not Proposed, KernelError::Unauthorized when by is not a person and the item
needs one, the audience’s error, or a store error.
Sourcepub async fn reject(
&self,
id: &str,
by: &SubjectRef,
reason: Option<&str>,
) -> Result<AgendaItem, KernelError>
pub async fn reject( &self, id: &str, by: &SubjectRef, reason: Option<&str>, ) -> Result<AgendaItem, KernelError>
Rejects item id as by: a Proposed or Approved item becomes Rejected, and a
pending inbox request for it is withdrawn. A question is closed with by’s
AgendaAnswer, and nothing is remembered (spec 3.2 §7.10).
§Errors
Returns KernelError::AgendaNotFound, KernelError::AgendaState when the item is
past approval, or a store error.
Sourcepub async fn schedule(
&self,
id: &str,
wake: WakeSet,
by: &SubjectRef,
) -> Result<AgendaItem, KernelError>
pub async fn schedule( &self, id: &str, wake: WakeSet, by: &SubjectRef, ) -> Result<AgendaItem, KernelError>
Schedules item id on wake as by (spec 3.2 §7.5, §8.1 adk-rust agenda schedule ID --at|--cron): a Proposed item is approved as by approve and
its process created asleep on wake; an Approved one gets its process asleep on
wake; a Scheduled one whose process has not started sleeps on wake instead —
a queued process parks on it when it is claimed, and one a worker claimed only to
park it on its wake set parks on wake (K-I2).
§Errors
Returns KernelError::AgendaNotFound, KernelError::AgendaState for an item that
is past scheduling or whose process already started, and for a question, which is
answered and never scheduled (spec 3.2 §7.10), KernelError::Unauthorized when by
is not a person and the item needs one, or a store error.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Agenda
impl !UnwindSafe for Agenda
impl Forget for Agenda
impl Freeze for Agenda
impl Move for Agenda
impl Send for Agenda
impl Sync for Agenda
impl Unpin for Agenda
impl UnsafeUnpin for Agendawhere
*const ArcInner<AgendaInner> is !null: UnsafeUnpin,
PhantomData<ArcInner<AgendaInner>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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 moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§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
Source§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
Source§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.Source§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.Source§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.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.