Skip to main content

WorldPolicy

Struct WorldPolicy 

Source
pub struct WorldPolicy {
    pub default: Scope,
    pub overrides: BTreeMap<String, Scope>,
    pub turn_index: Scope,
    pub rng: Scope,
}
Expand description

Host-facing, name-based declaration of the world/local split.

Resolved once (via ResolvedPolicy::resolve) against a linked Program’s symbol table into a fast id/slot-based ResolvedPolicy. Unlisted variables and knots/stitches fall back to default.

The all-World default (via WorldPolicy::default) is the degenerate, oracle-safety-anchoring policy: every unit homed to World, no overrides — identical to today’s single-flow behavior.

Name precedence: a name in overrides is tried as a global variable first, then as a knot/stitch path (see ResolvedPolicy::resolve). If a name is (unusually) both a declared global VAR and a resolvable knot/ stitch path, the override resolves against the variable, never the knot — the knot path is not consulted once a variable of the same name is found.

Knot/stitch overrides are subtree-inclusive (F6.1c — docs/scoped-flow-state-spec.md’s F6 AMENDMENT, ruling 3): a knot override covers the knot’s own visit/turn count, every stitch nested directly under it, and every interior container (weave/sequence/choice container) nested anywhere under the knot or one of its stitches — not just the knot’s own DefinitionId. This matters because ink’s sequence/cycle/stopping machinery ({ Halt! | Back again? }) keys its counter off the sequence’s own interior container id, not the enclosing knot’s id; without subtree inclusion, a knot marked Local would leave those interior counters silently World-scoped.

Most-specific override wins. If both a knot and one of its stitches appear in overrides (e.g. knot a is Local, stitch a.b is World), every interior container nested under a.b resolves World; the rest of a’s subtree (the knot’s own id, its other stitches, and any interior container not under a.b) resolves Local. A stitch’s override always wins over its enclosing knot’s for the stitch’s own subtree, regardless of which name appears earlier in overrides (see ResolvedPolicy::resolve for how this is implemented).

Fields§

§default: Scope

Scope for any variable or knot/stitch not named in overrides.

§overrides: BTreeMap<String, Scope>

Per-name exceptions to default, for global variables (matched against Program::global_index’s name grammar) and knot/stitch paths (matched against Program::find_path_target’s path grammar). A name may appear in only one of the two — the resolver tries variables first, then knot paths. Knot/stitch overrides are subtree-inclusive with most-specific-wins precedence — see the type docs above.

§turn_index: Scope

Scope of the turn index (a single scalar field).

§rng: Scope

Scope of the RNG stream (rng_seed + previous_random, a single scalar stream). See the spec’s determinism caveat: a World-scoped RNG interleaves draws from every flow sharing the world by execution order.

Trait Implementations§

Source§

impl Clone for WorldPolicy

Source§

fn clone(&self) -> WorldPolicy

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 WorldPolicy

Source§

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

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

impl Default for WorldPolicy

Source§

fn default() -> WorldPolicy

Returns the “default value” for a type. 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.