Skip to main content

Module loops_gateway

Module loops_gateway 

Source
Expand description

#173 in the dashboard: the gateway owns the timer.

A loop started from the browser is not owned by the browser. The tab can be closed, the page reloaded, the laptop shut — the record lives in <root>/state/loops/<session>.json, and this module is the thing that reads it on a clock and sends the prompt back into the session. That is the whole difference from the terminal: there, the timer dies with the process that owns the conversation, which is the honest answer for a CLI. Here the process outlives the window.

Two rules shape it.

A tick has nobody watching its stream. The chat route streams a turn to a browser tab over SSE; a tick fires while no tab is listening, so it runs with a sink that drops its events and its reply lands in the store, where the page shows it on the next load. That is stated on the row /loop answers with rather than left to be discovered.

A tick cannot ask for an approval. WebApprover parks a call until a browser answers it, and there is no browser; parking forever would be worse than refusing. So a tick runs under [Unattended], which denies every call that would have needed a card — with the reason, so the model can say what it could not do instead of failing silently.

Functions§

manage
The row /loop … answers with, from the record: the same verb handling the terminal gets, with Owner::Gateway so the record names the process that will actually drive it.
spawn
Start the sweeper. Called once, by whatever serves the dashboard, and it runs for the life of the process: an ended loop writes Ended to its record, so there is nothing to cancel per loop.