Skip to main content

Module scene_tree

Module scene_tree 

Source
Expand description

Scene tree — the runtime hierarchy as it’s surfaced to renderers.

Distinct from crate::scope_tree::ScopeTree: the scope tree mirrors the static scenario AST 1:1 (one node per ScenarioNode), while the scene tree is what’s actually shown to the user — for_each iterations are unrolled into per-iteration phase children under a single for_each scope header, and any phases that aren’t reachable until runtime resolution still appear under a fallback parent.

Renderers (TUI, web API, post-run summary) walk this tree by parent / children pointers rather than by depth tags, so:

  • Per-scope status aggregation (for_each is “running” if any child phase is running) becomes a tree walk.
  • Web GET /api/scope-tree can serialize the structure directly.
  • TUI features that want collapse / expand / scope-level summary have the structural information they need.

Status carried here is the small lifecycle enum (PhaseStatus). Renderers that want richer per-phase metrics (the TUI’s PhaseSummary with sparkline buffer, percentiles, etc.) keep a parallel side-map keyed by SceneNodeId — the scene tree stays cheap to clone and serialize.

Structs§

DfsIter
Depth-first iterator over a SceneTree.
PhaseFilterStats
Counters returned by SceneTree::apply_phase_filter so the runner can log how many phases the filter selected vs the total available.
SceneNode
One node in the scene tree.
SceneTree
The scene tree itself. nodes[0] is always the synthetic root.

Enums§

NodeKind
What kind of node this scene entry represents.
PhaseStatus
Phase lifecycle state. Only carries meaning on Phase nodes; Scope nodes always start (and stay) Pending, with their effective status derived from descendants.

Functions§

current
Snapshot the active scene tree, if installed. Returns None outside an active session — e.g. standalone nmbrs web.
install_global
Install the session’s scene tree. Replaces any previously- installed tree (e.g. from a prior in-process runner invocation by the integration-test harness). The runner itself only installs once per session, so production behaviour is unchanged.
running_phase_indent
Indent prefix (single-space repeats) for log lines whose visual nesting should match the executing phase’s scope depth. Empty string when no scene tree is installed.
with_global
Read-only access to the active scene tree, if installed. Returns None when no session has published one. Mirrors with_global_mut for callers that just need to inspect (e.g. SRD-77 execution-end disposition computation).
with_global_mut
Apply a mutation to the active tree, if installed. No-op when no session has published one. Used by the runner’s lifecycle emit sites so the tree mirrors the observer’s view.

Type Aliases§

SceneNodeId
Stable index into SceneTree::nodes. Indices never change for a given tree instance; renderers can hold onto them across status updates.