Expand description
FlowStack — the runtime above the DAG: a main flow plus its digressions.
A FlowMonitor governs one Flow. Real conversations
leave the main task temporarily — a side question, a cancel, a hand-off —
and expect to come back to it. A FlowStack holds the main monitor
plus a set of Overlays (digressions): when an overlay’s trigger holds,
the main flow is suspended untouched, the overlay’s own monitor drives the
session until it completes, and the main flow then continues per the
overlay’s Resume policy.
This is the only governance object the Live control plane drives. A session governed by a bare flow is a stack with no overlays, so every execution path — the simulator, a live session, a replay — advances the same type with the same semantics. The authoring layer lowers a conversation into a stack; it does not implement one.
Digressions nest: a digression can itself be interrupted by another (one
not already on the active path), which drives until it completes and then
resumes the one beneath it per its own Resume policy.
Structs§
- Flow
Stack - The main flow plus its digressions, with push-on-trigger and resume-on-completion.
- Overlay
- A digression the runtime can enter: its trigger, governed flow and resume policy. Built from a compiled flow so it carries proof of compilation.
- Repair
Policy - A step’s repair policy for the weird paths (silence, no-match, the user
stalling). The stack sets
repair:{step}:repromptonce the step has been activereprompt_afterturns without completing, andrepair:{step}:escalateafterescalate_after. Whenescalate_tois set, the authoring layer lowers an extra edge gated on the escalate signal — a deterministic “give up and hand off”.
Enums§
- Resume
- How the main flow continues after a digression (overlay) completes.
Constants§
- OVERLAY_
STATE_ KEY - The state key that names the active digression (
nullwhen the main flow is driving). Published by the control plane at every turn boundary. - TERMINATED_
STATE_ KEY - The state key raised (
true) once aResume::Terminatedigression has ended the conversation. Governance is inert from then on: no postures, no admitted tools. The runtime does not hang up by itself — the application decides how a call ends — so watch this key (orFlowStack::is_terminated) and close the session. Published by the control plane at every turn boundary. - TOOL_
CALL_ KEY - Written when the governed flow admits a tool call, before it runs:
{"tool": name, "id": call id}. WithTOOL_DENIED_KEYandTOOL_RESULT_KEYit puts every governance decision about a tool in the mutation journal, in order, which is what makes a recorded session replayable as a scenario. - TOOL_
DENIED_ KEY - Written when the governed flow refuses a tool call:
{"tool": name, "id": call id, "reason": why}. - TOOL_
RESULT_ KEY - Written when an admitted tool call completes:
{"tool": name, "id": call id, "ok": succeeded}.
Functions§
- correction_
flag - The state key raised for one turn when the user corrects
slot: its value changed from one captured value to another. SeeFlowStack::with_correction. - escalate_
flag - The state key raised when a stage’s repair policy escalates.
- reprompt_
flag - The state key raised when a stage’s repair policy asks for a reprompt.
Type Aliases§
- Shared
Flow Stack - A shared, lock-protected
FlowStack— the form in which the Live control plane owns governance, so runtime surfaces (e.g.LiveHandle::explain) can snapshot it concurrently. All methods are synchronous: lock briefly and never hold the guard across anawait.