Skip to main content

Module ledger

Module ledger 

Source
Expand description

The open windows, one per agent. A window is read and changed under the lock and nowhere else, and its closure is taken out under the same lock by the window’s task alone, so it runs exactly once however Agents ready, “Switch now”, a cancel and the deadline race.

Structs§

Answer
What an agent answers with Agents ready.
Closing 🔒
Held while a window’s closure runs; the agent is open until it is dropped.
Entry 🔒
Opened
An open window.

Statics§

CLOSING 🔒
Agents whose window has ended and whose closure is still running. They count as open, so apply_pending doesn’t apply the same switch a second time while the closure does.
LEDGER 🔒

Functions§

answer 🔒
The agent def_id (its slug slug) answers the window open for it. The handoff is stored at once, so it is kept even if the window runs out; a request for more time moves the deadline, once.
audit 🔒
One audit row for the request id, recorded as actor.
cancel
The change is not going to happen (the person chose the account the agent is on): end the window without running the closure, take back what the agent left and tell it to carry on. BLOCKING.
clear_meta 🔒
Clear the chip on the agent’s panes.
finish_row 🔒
The prep.answered row of a window that ended as how: who it is recorded as (the agent when it answered, whoever pressed “Switch now” (the person, or the agent that did), AgentMux otherwise) and why.
is_open
Whether a window is open for the agent, or its closure is still running: the account change it waited on is the window’s to apply, not apply_pending’s.
ledger 🔒
open
Open the window for prep and ask the agent; proceed runs once when it ends. Asking again for the same target changes nothing; for another one replaces the closure and keeps the window and its deadline. BLOCKING (store writes); needs a tokio runtime for the window’s task.
open_with
open, running record (the choice the closure acts on) before the window can end: with the window already open it runs under the ledger lock, so the window cannot end between the two, and for a new window it runs before the window’s task starts. The closure therefore always finds record’s write already made, never one that outlives it.
person_says_now
“Switch now” for the agent def_id, pressed by the window (caller empty: the person) or by the agent caller: the window ends and the closure runs. BLOCKING.
refs 🔒
take 🔒
Take the window id of def_id out of the ledger: whoever gets it runs its closure.
with 🔒
Read or change the window id of def_id; None when it is gone (it ended, or was replaced).