Expand description
Telling a chat how a task it filed ended.
A chat is single-turn: it speaks only when the operator writes, so “I will
tell you when it finishes” cannot be kept by the agent. This module keeps
it for the agent. When a task filed by a chat (Task::filed_by_chat)
reaches a final state, a fixed English notice is queued as a draft of the
originating talk, and the talk’s own turn machinery (its session, its
lease) runs it. No new seat and no new waiter: the same shape as
crate::consult.
- A reconciler, not a hook.
sweeplooks at the queue on every daemon tick, so whoever put the task in its final state (the loop,magi task done, the web UI, a restart) is covered the same way. - Once. The task records what was reported (
Task::chat_notice); the talk records the accepted key in the same write as the draft (talk::queue_once). A crash between the two writes is repaired by the next sweep, which finds the key in the talk and only fixes the task. Lock order is task, then talk. - Closed or gone is skipped, never reopened (unlike a consult).
- A parking upgrade starts nothing. The draft stays durable.
Structs§
- RunFacts
- Facts about a task’s latest run, read tolerantly: an unreadable record only leaves them out of the notice.
Functions§
- authorize_
post - The task a
magi talk postcomes from:run(the posting seat’s run id) must belong to a task filed by exactly this talk. - notice_
text - The notice text for
task, built from what magi recorded. - run_
facts - Read
RunFactsfrom<home>/runs/<id>/run.json. - start_
turns - Start the chat’s turn for every talk owed a notice, under the talk’s own
lease, each spawned into
turns(the daemon’s in-flight set, which its exit waits for).parking(an upgrade is parking) starts nothing. Returns how many turns were started; a talk whose lease is held elsewhere is left to its holder, who drains the draft before letting go. - sweep
- Report every chat-filed task whose final state has not been reported. Returns the talk ids that got a new draft.
- talks_
to_ start - Open talks holding a completion notice in their draft. Only these are started on the daemon’s own initiative: an operator’s unsent draft is not.