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: ScopeScope 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: ScopeScope of the turn index (a single scalar field).
rng: ScopeScope 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
impl Clone for WorldPolicy
Source§fn clone(&self) -> WorldPolicy
fn clone(&self) -> WorldPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more