Skip to main content

ExecutionPlan

Struct ExecutionPlan 

Source
pub struct ExecutionPlan {
    pub spec_name: String,
    pub commentary: Option<String>,
    pub data: IndexMap<DataPath, DataDefinition>,
    pub rules: Vec<ExecutableRule>,
    pub max_register_count: u16,
    pub reference_evaluation_order: Vec<DataPath>,
    pub meta: HashMap<String, MetaValue>,
    pub resolved_types: ResolvedSpecTypes,
    pub signature_index: HashMap<Vec<(String, i32)>, (String, Arc<LemmaType>)>,
    pub effective: EffectiveDate,
    pub sources: Vec<SpecSource>,
}
Expand description

A complete execution plan ready for the evaluator

Contains the topologically sorted list of rules to execute, along with all data. Self-contained structure - no spec lookups required during evaluation.

Fields§

§spec_name: String

Main spec name

§commentary: Option<String>

Optional commentary from the """...""" block in the spec source.

§data: IndexMap<DataPath, DataDefinition>

Per-data data in definition order: value, type-only, or spec reference.

§rules: Vec<ExecutableRule>

Rules to execute in topological order (sorted by dependencies)

§max_register_count: u16

Maximum register file size across all rules; sizes [EvaluationContext::register_values].

§reference_evaluation_order: Vec<DataPath>

Order in which DataDefinition::Reference entries must be resolved at evaluation time so that chained references (reference → reference → data) copy values in the correct sequence. Empty when the plan has no references.

§meta: HashMap<String, MetaValue>

Spec metadata

§resolved_types: ResolvedSpecTypes

Main-spec types from planning. [ResolvedSpecTypes::unit_index] is expression-scope units (local types plus direct uses imports). Rule-result units live on each [ExecutableRule::rule_type], not in this index.

§signature_index: HashMap<Vec<(String, i32)>, (String, Arc<LemmaType>)>

Reverse index: canonical-form unit signature Vec<(unit_name, exponent)> → (unit_name, owning type). Built from expression-scope units during planning so cross-type Multiply/Divide arithmetic can deterministically resolve a combined signature back to a single named unit. Ambiguous signatures (the same key matched by units in two distinct types) are rejected at planning time.

§effective: EffectiveDate§sources: Vec<SpecSource>

Canonical source for all specs in this plan (one entry per spec, includes repository). Reconstructed from AST — not raw file content.

Implementations§

Source§

impl ExecutionPlan

Source

pub fn local_rule_names(&self) -> Vec<String>

Build a SpecSchema describing this plan’s public IO contract.

Only data transitively reachable from live branches of at least one local rule is included. Spec-reference data (which have no schema type) are also excluded. Only local rules (no cross-spec segments) are included. Data are sorted local-first, then by source position within each depth.

If the caller supplies a DataOverlay, branches whose conditions are definitively false given those values are pruned, reducing the returned data set to only what is still needed. Names of local (main-spec) rules in plan topological order.

Source

pub fn schema(&self, overlay: &DataOverlay) -> SpecSchema

Source

pub fn interface_schema(&self, overlay: &DataOverlay) -> SpecSchema

Every typed data input and local rule — the full spec surface.

Excludes DataDefinition::Reference (with bindings) and imports; those are not caller inputs.

Source

pub fn schema_for_rules( &self, rule_names: &[String], overlay: &DataOverlay, ) -> Result<SpecSchema, Error>

Build a SpecSchema scoped to specific rules.

The returned schema contains only the data needed by the given rules (transitively, through live arms of normalized expressions) and only those rules. This is the “what do I need to evaluate these rules?” view. DataDefinition::Reference entries (with bindings) are omitted — their values are fixed in the spec.

When the caller supplies a DataOverlay, branches whose conditions are definitively false given those values are pruned, reducing the returned data set to only what is still needed.

Data are sorted local-first, then by source position within each depth.

Returns Err if any rule name is not found in the plan.

Source

pub fn get_data_path_by_str(&self, name: &str) -> Option<&DataPath>

Look up a data by its input key (e.g., “age” or “rules.base_price”).

Source

pub fn validated_response_rule_names( &self, rules: Option<&[String]>, ) -> Result<HashSet<String>, Error>

Validate caller-requested rule names and return canonical local rule names.

None means all local rules. Some(&[]) is an error. Unknown names in Some slice error.

Source

pub fn get_rule(&self, name: &str) -> Option<&ExecutableRule>

Look up a local rule by its name (rule in the main spec).

Source

pub fn collect_needed_data_paths( &self, rule_names: &[String], overlay: &DataOverlay, ) -> Result<HashSet<DataPath>, Error>

Collect the data paths statically referenced by the named local rules.

Walks the live branches of each named rule transitively: rule-target data references extend the walk to the referenced rules. Branches whose conditions are definitively decided by overlay-known values are pruned, mirroring ExecutionPlan::schema_for_rules.

Returns Err if any rule name is not found in the plan.

Source

pub fn get_rule_by_path(&self, rule_path: &RulePath) -> Option<&ExecutableRule>

Look up a rule by its full path.

Source

pub fn get_data_value(&self, path: &DataPath) -> Option<&LiteralValue>

Get the literal value for a data path, if it exists and has a literal value.

Trait Implementations§

Source§

impl Clone for ExecutionPlan

Source§

fn clone(&self) -> ExecutionPlan

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 ExecutionPlan

Source§

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

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

impl From<&ExecutionPlan> for ExecutionPlanSerialized

Source§

fn from(plan: &ExecutionPlan) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<ExecutionPlanSerialized> for ExecutionPlan

Source§

type Error = Error

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

fn try_from(serialized: ExecutionPlanSerialized) -> Result<Self, Self::Error>

Performs the conversion.

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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