Skip to main content

ReductionPlan

Struct ReductionPlan 

Source
pub struct ReductionPlan {
Show 13 fields pub turn_id: TurnId, pub acts: Vec<PlannedAct>, pub batches: Vec<CommandBatch<Value>>, pub policy_decisions: Vec<PolicyDecision>, pub answer_tasks: Vec<AnswerTask>, pub constraints_applied: Vec<ConstraintKind>, pub notices: Vec<ServerNotice>, pub pre_execution_interactions: Vec<InteractionSpec>, pub plan_hash: Digest, pub superseded_operations: Vec<OperationKey>, pub refusals: Vec<NarratableFact>, pub changed_nothing: Vec<NarratableFact>, pub awaiting_confirmation: Vec<NarratableFact>,
}
Expand description

The reducer’s output (spec §13).

Fields§

§turn_id: TurnId

The turn.

§acts: Vec<PlannedAct>

One entry per input act, by index (I11).

§batches: Vec<CommandBatch<Value>>

Command batches ready for execution, grouped by atomicity scope. Commands are erased to JSON; the registry converts them at the boundary.

§policy_decisions: Vec<PolicyDecision>

Policy decisions for every command.

§answer_tasks: Vec<AnswerTask>

Questions to answer.

§constraints_applied: Vec<ConstraintKind>

Constraints that were applied.

§notices: Vec<ServerNotice>

Notices to show (e.g. “Nothing has been submitted”).

§pre_execution_interactions: Vec<InteractionSpec>

Interactions to persist before any command executes (clarifications and confirmations). Deduplicated by InteractionSpec::key.

§plan_hash: Digest

Digest of everything above (see Self::compute_hash).

§superseded_operations: Vec<OperationKey>

Operations of acts a correction or a cancel in the same message replaced.

Supersession is the one reduction rule that makes a turn do less than its plan said, and until it was counted a message carrying four data that produced one command was only discoverable by reading the conversation that followed. One entry per dropped act, in plan order.

§refusals: Vec<NarratableFact>

Domain refusals, as facts the narration stage may rest on.

The notice beside them tells the user deterministically; these tell the narrator, so its prose does not ask for something else as though the refusal had not happened.

§changed_nothing: Vec<NarratableFact>

Acts that were accepted and changed nothing, as facts the narration stage may rest on.

Beside Self::refusals and not inside it, because the two are different outcomes and one of them is counted: the runtime raises its refusal signal once per entry there, and a no-op filed among them would be a refusal in every dashboard that reads it. They travel together only at the point where both become facts for the writer.

§awaiting_confirmation: Vec<NarratableFact>

Acts this turn prepared and held behind a confirmation card, as facts the narration stage may rest on.

Separate from Self::refusals and not folded into it, because these are not refusals: that list is counted as Signal::ActRefused, and an act waiting for a click is one the server intends to run. See NarratableFact::ActAwaitingConfirmation.

Implementations§

Source§

impl ReductionPlan

Source

pub fn compute_hash(&self) -> Result<Digest, HashError>

Computes the digest of every field except plan_hash.

Source

pub fn with_hash(self) -> Result<Self, HashError>

Sets plan_hash from the current content.

Source

pub fn verify_hash(&self) -> Result<bool, HashError>

Returns true when plan_hash matches the content.

Source

pub fn validate(&self, understood: &[ActId]) -> Result<(), ReductionError>

Structural consistency checks.

Everything here is a property a correct reducer already has; the point is that a plan which fails one of them must never reach execution, so a reducer bug becomes a refused turn instead of an unauthorized command:

  • every act of the understanding appears exactly once (I11);
  • every ReadyToExecute command reference points at a batch command;
  • a ReadyToExecute act resolved its target exactly, unless it starts a workflow or picks a target (spec §12.2, I8), and its commands run on the case it resolved to;
  • every batched command has exactly one PolicyDecision, that decision allows it, and its origin satisfies the policy the decision recorded (origin_satisfies, I9, I12);
  • no refused decision names a command that is nevertheless batched;
  • every spec embedded in an act result is listed in pre_execution_interactions (by key);
  • PerCase batches target a single case.
Source

pub fn command_refs(&self) -> Vec<CommandRef>

All command references in batch order.

Source

pub fn has_no_effects(&self) -> bool

Returns true when nothing will execute this turn.

Trait Implementations§

Source§

impl Clone for ReductionPlan

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 ReductionPlan

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ReductionPlan

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ReductionPlan

Source§

impl PartialEq for ReductionPlan

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ReductionPlan

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ReductionPlan

Auto Trait Implementations§

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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.