Expand description
Durable approvals: the pending tool calls of a run, and the answer when it arrives.
The approval gate is normally a question asked of whoever is driving the loop, and its answer exists only in that process. That is fine until the process is not there — a CLI run in a script, a dashboard tab that was closed, a shell that lost its terminal — and then a call the model made is neither approved nor denied: it is simply unrecorded, and the transcript repairs it on the next run as “interrupted”. The intent is lost.
This module is the small amount of state that fixes it, and deliberately nothing more: one row
per call the model made and the gate has not answered, keyed by the message that carried it
(seq, ord), with the answer written into the same row when it arrives. There is no second
state machine, no run registry and no job queue — a run is still just a transcript, and the
rows are only the answers that were not in it yet.
Three answers, not two:
Decision::Allowruns the call;Decision::Denyanswers it as declined, with the reason the model reads;Decision::Defermeans nobody has answered and the loop must not guess. The call is recorded and the turn stops. Fail-closed: an unanswered gate is never an approval, and it is no longer a silent denial either.
Defer is what makes the state durable without a daemon: the process that asked can exit, and
any later process can look at the same rows and answer them.
Structs§
- Pending
- One call the model made, as the gate sees it: enough to ask, enough to re-run it later.
- Pending
Call - One stored row: a call, and the answer if one arrived.
- Recorded
- The store’s answers, asked of the gate that replays a paused turn.
- Ruling
- One line of the append-only log: a call, its answer, and who gave it (
#340). - Waiting
- What a run left behind when it stopped on the gate.
Enums§
- Decision
- The gate’s answer to one call.
Constants§
- DECIDED_
BY_ JUDGE - The aux route in
smartmode (#340). - DECIDED_
BY_ USER - Who answered a waiting call, for the
bycolumn (#340).
Functions§
- answer
- Answer one waiting call by position, counting from 1 in the order
waitingprints them. - answer_
all - Answer every waiting call.
- decision_
for - The decision recorded for one call, if any. Used by the resumed run, which must run exactly what was approved and nothing else.
- record
- Record the calls of one assistant message as pending. An existing row is left alone: the same call re-recorded has the same answer or none, and overwriting it would lose a decision that arrived while the run was stopping.
- record_
at - Record
callsas pending, starting atord— the positioncalls[0]holds in the assistant message that carried it. - waiting
- The calls waiting for an answer, oldest first.