Expand description
Runtime context nodes (SRD 12 §“Runtime context nodes”).
These nodes project stable runtime surfaces — the current phase, the current cycle ordinal, the value of a dynamic control, the active rate-limiter target, the active fiber count — into GK-readable wires. They are the read-side of the reification principle (SRD 10 §“GK as the unified access surface”): any value a workload might want to read is reached through a Polydat binding, not a side channel.
Like the metric nodes (see metrics.rs), these are
non-deterministic context projections — their output changes
between cycles by definition, so the constant-folder is not
allowed to collapse them. They read from globals / thread
locals the runtime sets during bootstrap and on every cycle
tick.
Structs§
- Concurrency
- Sugar for
control("concurrency")— the current fiber count for the nearest phase. IntrinsicallyNondeterministic— see [control]. - Control
- Read a dynamic control’s current reified-gauge value as
f64, by walk-up from the live session root.0.0when there is no session root, the control is absent, or it has no reified gauge. - Control
Bool - Read a dynamic control’s current value as a boolean —
trueiff its reified-gauge value is non-zero. Missing / unreified controls →false. - Control
Set - Polydat write node: submit an f64 write against the named control via the
session root’s walk-up. Returns
1if dispatched,0if not — either no session root is installed (outside a running scenario / pure-kernel test) or the control already reads exactly the requested value (idempotent writes are elided; see the fixpoint check in the body). - Control
Str - Read a dynamic control’s current value as its human-readable string
(the erased-control
value_string()rendering). Missing controls →"". - Control
U64 - Read a dynamic control’s current value and cast to
u64. - Cycle
- Current cycle ordinal. Reads a thread-local set by the phase executor.
For bindings that already declare
cycleas a named input this is redundant; it exists so bindings which never namedcycleexplicitly can still reach it (SRD 10’s “cycle is not magic” rule — the node is context, not a privileged input). - Fiber
Context - Per-fiber execution context carried across the async call
chain via a
tokio::task_local!binding. Thread-locals are unsafe here because tokio’s work-stealing scheduler can migrate a task between worker threads at any.await; a task-local is bound to the task itself and survives migration. - Phase
- Current phase name. Reads a thread-local set by the phase executor;
""when unset (outside a cycle, or in tests that install no phase). - Phase
Elapsed Millis - Milliseconds elapsed since the CURRENT phase started;
0outside a phase. - Phase
Start Millis - Epoch millis at which the CURRENT phase started;
0outside a phase body. - Rate
- Sugar for
control("rate")— the current rate-limiter target (ops/sec). IntrinsicallyNondeterministic(live control read) — see [control].
Functions§
- empty_
controls - An empty
ControlMapfor fibers / call sites that have no component (the read then falls back to the session-root walk). - session_
root_ handle - Public accessor for the runner-installed session root.
- set_
session_ root - set_
task_ cycle - Update the cycle counter in the enclosing
FiberContext. Safe to call outside a scope — the update is a no-op if there is no active fiber context (e.g. when the node is evaluated from a unit test that didn’t install one). - snapshot_
controls - Snapshot the controls visible from
component(its own controls plus anySubtree-scoped ancestor control, nearest-wins) into a lock-freeControlMap. Deadlock-safe:Component::control_snapshotacquires one tier’s lock at a time, never nested — so it is safe on the cadence-contended component tree. Computed once per phase, shared across the phase’s fibers. - with_
fiber_ context - Wrap a fiber’s async body in a
FiberContextscope. Every runtime-context node read performed inside the future sees the phase name and cycle counter set here.
Type Aliases§
- Control
Map - A lock-free, shareable snapshot of resolved control handles (see
FiberContext::controls).