Skip to main content

ResolvedPolicy

Struct ResolvedPolicy 

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

Fast, id/slot-based resolution of a WorldPolicy against a specific Program. Built once at World creation via ResolvedPolicy::resolve; consulted on every state access (from F2.2 on) with O(1) lookups — no string matching on the hot path.

Implementations§

Source§

impl ResolvedPolicy

Source

pub fn all_world() -> Self

The all-World resolved policy — no name lookups needed. This is the fast path for WorldPolicy::default() and the only policy exercised by the oracle-anchored single-flow path.

Source

pub fn resolve( program: &Program, policy: &WorldPolicy, ) -> Result<Self, PolicyError>

Resolve a host-facing WorldPolicy against a linked Program’s symbol table.

Variable names are resolved via Program::global_index; knot/ stitch paths via Program’s path-to-DefinitionId resolution (the same table find_address/find_path_target use). A name is tried as a variable first, then as a knot/stitch path; a name matching neither is a PolicyError::UnknownName.

Subtree expansion (F6.1c). Every knot/stitch override is expanded here, once, into every DefinitionId in its definition subtree — see [expand_knot_scope] for the containment mechanism (Program::scope_ids, the nearest-enclosing-scope table every interior container carries, plus Program::address_by_path‘s dotted knot/stitch grammar for the one-level knot→stitch link that scope_ids alone doesn’t carry). overrides is a BTreeMap, so this loop’s iteration order is deterministic (sorted by name) — and because a knot’s name is always a proper prefix of (and therefore sorts lexicographically before) any of its stitches’ names, a knot override’s subtree expansion always runs before a same-subtree stitch override in this same pass, so the stitch override’s own inserts (which land later) win — implementing “most-specific override wins” as a natural consequence of processing order, no separate precedence pass needed.

Compiled base layer. Before host overrides apply, resolve seeds scopes from the Program’s compiled #@local defaults (docs/directive-annotations-spec.md): globals the compiler marked flow-private seed Local, and every #@local knot/stitch expands over its subtree exactly like a host override would. Host overrides then layer on top — base ⊕ host-overrides — so a host name always beats the compiled bit for that name’s subtree.

The all-World default (empty overrides, no compiled #@local bits) resolves without any name lookups (see all_world) — this is the fast path every unannotated single-flow program takes.

Source

pub fn scope_of_global(&self, slot: u32) -> Scope

Scope of a global variable by slot index.

Source

pub fn scope_of_knot(&self, id: DefinitionId) -> Scope

Scope of a knot/stitch — or of an interior weave/sequence/choice container nested under one — by its defining DefinitionId. See the knot_scopes field docs and resolve for how a knot/stitch override is expanded, at resolve time, to cover every id in its definition subtree.

Source

pub fn turn_index_scope(&self) -> Scope

Scope of the turn index.

Source

pub fn rng_scope(&self) -> Scope

Scope of the RNG stream.

Trait Implementations§

Source§

impl Clone for ResolvedPolicy

Source§

fn clone(&self) -> ResolvedPolicy

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 ResolvedPolicy

Source§

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

Formats the value using the given formatter. Read more

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