GenAI.Approval.Runner (GenAI Approval v0.1.0)

Copy Markdown View Source

One interactive approval run (PRD §6): a GenServer holding the run state machine. Steps execute in supervised tasks so control commands (halt above all) stay responsive while a call is in flight.

States: :paused:awaiting_permission:executing → … → :completed | :halted | :failed.

Commands (see command/2): :step, :next, :run_all, {:halt, reason}, :approve, :decline, {:grant, effect, scope}, {:grant, effect, scope, pattern}, :retry, :skip, {:edit, target, value}, {:set_breakpoint, id}, {:clear_breakpoint, id}, {:annotate, target, text}.

Events are sent to the subscriber as {:genai_approval, run_id, event} maps with a monotonic :seq.

Summary

Functions

Block until the run reaches a terminal state; returns the §9 result.

Returns a specification to start this module under a supervisor.

Full UI-facing state snapshot (feeds GenAI.Approval.Render.model/1).

Add a live event subscriber (defaults to the caller).

Functions

await(run, timeout \\ :infinity)

Block until the run reaches a terminal state; returns the §9 result.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

command(run, cmd)

events(run)

info(run)

snapshot(run)

Full UI-facing state snapshot (feeds GenAI.Approval.Render.model/1).

start_link(opts)

subscribe(run, pid \\ self())

Add a live event subscriber (defaults to the caller).