Skip to content

contexts

contexts #

Recording contexts — the authoring layer that builds a procedure's structure.

A procedure body has no global state and never appends to a sequence by hand. Instead, constructing a node registers it with the active context; when a node is used as another node's input or substep it is caught; and at a context's exit the leftover roots (emitted but never caught), in construction order, become the recorded structure. Each leftover must be a side effect (return Void) — a value left dangling is an UncaughtDataError.

Each context wraps its leftover roots differently:

  • RootContext — the top of a @cg.procedure build; requires exactly one root.
  • cg.procedure_sequence() / cg.procedure_set() — run the block in order / concurrently.
  • cg.optional() / cg.when(condition) — wrap the block in an OptionalProcedure / an IfThenElse.
  • cg.while_repeat(condition, array_path) — wrap the block in a ProcedureWhile, appending one array_path element per iteration.
  • cg.detached() — allow standalone construction that is collected nowhere.

This package replaces the old fluent/authoring.py. Each context is its own module over the shared ProcedureContext; this __init__ is documentation only (public names re-export through the capturegraph root, leaf-by-leaf).