Skip to main content

Module chat_notify

Module chat_notify 

Source
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. sweep looks 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_matching]). 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 post comes 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 RunFacts from <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.