pub struct DirectiveStore {
pub directives: Vec<Directive>,
}Expand description
<agents>/directives.json.
Fields§
§directives: Vec<Directive>Implementations§
Source§impl DirectiveStore
impl DirectiveStore
Sourcepub fn load_for_app() -> Self
pub fn load_for_app() -> Self
The records with the release id of each offered one: the app’s
read (cloud.plan.updates) only. Every other reader uses
Self::load, which never holds a release id.
Sourcepub fn mutate<T>(
f: impl FnOnce(&mut AgentRegistry, &mut DirectiveStore) -> Result<T, String>,
) -> Result<T, String>
pub fn mutate<T>( f: impl FnOnce(&mut AgentRegistry, &mut DirectiveStore) -> Result<T, String>, ) -> Result<T, String>
Change the registry and the records under the registry lock.
Sourcepub fn mutate_release(
release_id: &str,
body: Option<&ReleaseBody>,
) -> Result<(Release, Option<String>), ReleaseError>
pub fn mutate_release( release_id: &str, body: Option<&ReleaseBody>, ) -> Result<(Release, Option<String>), ReleaseError>
Self::release_offered for the CLI, so that its answer matches
what happened: the bus entry (registry) is written first, then the
records. A failed registry write delivered nothing (Err, the
directive stays offered). A failed record write after it does not
undo the delivery: the release is reported with the error as a
warning (a retry finds the keyed entry and changes nothing).
Sourcepub fn issue(
&mut self,
root: &str,
agent_id: &str,
issue: &DirectiveIssue,
) -> Result<bool, String>
pub fn issue( &mut self, root: &str, agent_id: &str, issue: &DirectiveIssue, ) -> Result<bool, String>
Record issue for agent_id in root as offered: nothing is
posted on the bus and the agent sees nothing until the person
releases it (Self::release_offered). Offering the same directive
to the same agent again changes nothing (a catch-up after a frame).
Offered directives of an older version of the same plan, or of the
same decision, are superseded (their release ids release nothing);
a released one stays as it is until the newer one is released.
True when a record was added.
Sourcepub fn deliver_decision(
&mut self,
registry: &mut AgentRegistry,
root: &str,
agent_id: &str,
issue: &DirectiveIssue,
) -> Result<bool, String>
pub fn deliver_decision( &mut self, registry: &mut AgentRegistry, root: &str, agent_id: &str, issue: &DirectiveIssue, ) -> Result<bool, String>
Issue a team decision directive to agent_id and post it at once.
Cloud announces a decision change (decision.changed) only after the
person’s confirmed “Send to agents” in LeanCTX Code, so the frame is
the release; the relay calls this only from that frame. The same
directive to the same agent again posts nothing (false), unless an
earlier frame recorded it but could not post it: a decision directive
still offered is released by the next frame. A plan directive is
refused: it waits for Self::release_offered.
Sourcepub fn release_offered(
&mut self,
registry: &mut AgentRegistry,
release_id: &str,
body: Option<&ReleaseBody>,
) -> Result<Release, ReleaseError>
pub fn release_offered( &mut self, registry: &mut AgentRegistry, release_id: &str, body: Option<&ReleaseBody>, ) -> Result<Release, ReleaseError>
Release the one offered directive release_id names, for the agent
it was offered to: post its bus entry and make it pending. Called
by the local CLI lean-ctx cloud plan release after the person’s
confirmed “Send to agents” in LeanCTX Code, and for a team decision by
Self::deliver_decision; no bus or Cloud handler reaches it for a
plan.
Per agent and version: the id releases nothing else. A plan entry is
exactly body’s goal and this agent’s brief (release_text); the
body must name the directive’s version and its brief must match the
slot’s signed digest. The same id again after its release changes
nothing (released: false); an id superseded before its release, an
unknown id, or anything that is no release id is an error.
Sourcepub fn ack(
&mut self,
registry: &mut AgentRegistry,
agent_id: &str,
directive_id: &str,
verdict: Verdict,
reason_code: Option<&str>,
reason: Option<&str>,
) -> Result<Directive, String>
pub fn ack( &mut self, registry: &mut AgentRegistry, agent_id: &str, directive_id: &str, verdict: Verdict, reason_code: Option<&str>, reason: Option<&str>, ) -> Result<Directive, String>
Record agent_id’s answer to directive_id. A refusal needs one of
REFUSE_REASONS; reason is kept locally. Answering again
replaces the earlier answer. The directive’s bus entry counts as read.
Sourcepub fn pending_for(&self, agent_id: &str) -> Vec<&Directive>
pub fn pending_for(&self, agent_id: &str) -> Vec<&Directive>
agent_id’s unanswered directives, by id.
Sourcepub fn unreported_plans(&self) -> Vec<&Directive>
pub fn unreported_plans(&self) -> Vec<&Directive>
Plan directives whose state Cloud has not recorded yet.
Sourcepub fn mark_reported(&mut self, done: &[(String, String, DirectiveState)])
pub fn mark_reported(&mut self, done: &[(String, String, DirectiveState)])
Note that Cloud recorded state for these (agent, directive)s; a
state that moved on since stays unreported.
Trait Implementations§
Source§impl Clone for DirectiveStore
impl Clone for DirectiveStore
Source§impl Debug for DirectiveStore
impl Debug for DirectiveStore
Source§impl Default for DirectiveStore
impl Default for DirectiveStore
Source§impl<'de> Deserialize<'de> for DirectiveStore
impl<'de> Deserialize<'de> for DirectiveStore
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for DirectiveStore
Source§impl PartialEq for DirectiveStore
impl PartialEq for DirectiveStore
Source§impl Serialize for DirectiveStore
impl Serialize for DirectiveStore
impl StructuralPartialEq for DirectiveStore
Auto Trait Implementations§
impl Forget for DirectiveStore
impl Freeze for DirectiveStore
impl Move for DirectiveStore
impl RefUnwindSafe for DirectiveStore
impl Send for DirectiveStore
impl Sync for DirectiveStore
impl Unpin for DirectiveStore
impl UnsafeUnpin for DirectiveStore
impl UnwindSafe for DirectiveStore
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more