pub struct ContextView<'a> { /* private fields */ }Expand description
Routing view implementing ContextAccess over (&mut World, &mut FlowLocal).
This is what the VM’s drive path receives as its impl ContextAccess.
Every op computes an effective scope for its unit — see
ContextView::effective_scope — and then routes exactly as before:
World-scoped: always routes straight toWorld— reads and writes are immediately visible to every flow sharing thatWorld.Local-scoped, read: chain read-through — walks theFlowLocal’s own overrides, then its frozenbase(recursively, seeFlowLocal::chain_get_globaland friends), then falls back toWorld’s current value on a total miss (so a flow that has never written a Local unit, nor inherited one from a base, sees the shared default until its first local write).Local-scoped, write: lands in theFlowLocal’s own top-layer overrides only;World(and any frozenbase) is untouched.Local-scoped, increment (increment_visit,increment_turn_index): copy-on-write from the chain read-through value — read the current value (own override, else base chain, else World fallback), add one, store the result as the new top-layer override. This is what makes a flow’s first local increment start from the chain’s (or World’s) count rather than 0.
The effective scope, not the raw policy scope, drives all of the
above. In Mode::Normal (every construction path before F3.2, and
every non-forked flow today) the effective scope of a unit is its
ResolvedPolicy scope — unchanged from F2.2/F3.1. In Mode::Sandbox
the effective scope of every unit is Local, no matter what the
policy says: a sandboxed flow’s reads still chain-read-through to
World’s live value on a miss (so it observes current shared state),
but its writes — including to units the policy homes to World — land
only in its own FlowLocal overrides. World is therefore a read-only
base from a sandboxed flow’s perspective: nothing it does can mutate the
shared world.
Because the all-World policy (the only policy the oracle corpus
exercises) takes the World branch on every op and no existing
construction path ever sets Mode::Sandbox, this is byte-identical to
the F1.3 all-World passthrough for every existing single-flow
construction path.
Implementations§
Trait Implementations§
Source§impl ContextAccess for ContextView<'_>
impl ContextAccess for ContextView<'_>
fn global(&self, idx: u32) -> &Value
fn set_global(&mut self, idx: u32, value: Value)
fn visit_count(&self, id: DefinitionId) -> u32
fn increment_visit(&mut self, id: DefinitionId)
Source§fn set_visit_count(&mut self, id: DefinitionId, count: u32)
fn set_visit_count(&mut self, id: DefinitionId, count: u32)
crate::load_state to reconcile a durable save, whose entries carry
absolute counts rather than deltas.fn turn_count(&self, id: DefinitionId) -> Option<u32>
fn set_turn_count(&mut self, id: DefinitionId, turn: u32)
fn turn_index(&self) -> u32
fn increment_turn_index(&mut self)
Source§fn set_turn_index(&mut self, index: u32)
fn set_turn_index(&mut self, index: u32)
crate::load_state to restore a saved turn index.