Skip to main content

Module consult

Module consult 

Source
Expand description

Handing an open question to the chat conversation its task came from.

A task filed by the standing chat (Source::Agent with crate::queue::CHAT_NODE, whose run is the conversation’s id) can raise a question the owner would rather talk through where the task started. The owner passes it on; the chat agent carries out the owner’s decision with magi answer, or puts the decision points to the owner in the conversation.

Three rules, each with a reason:

  • One place decides. origin_talk is the only judge of “does this question have a chat to ask”; the web view and both entry points use it. associated_talk resolves typed ownership links for navigation, independently of consultation eligibility.
  • Not a choice. The hand-over never goes into Question::choices and never touches Question::answer: the question stays Open, its validation and the choice actions stay as they were.
  • No new seat, no new waiter. The text is queued as a draft of the existing talk, so the chat’s own turn machinery (its session, its turn gate) runs it exactly as if the owner had typed it.

Structs§

ConsultOutcome
A non-answer never wakes a waiter or executes a choice action.

Enums§

Started
What start_turn did.

Functions§

active_consult
Consultation activity is separate from the question’s waiting state.
associated_talk
The existing conversation associated with a question, regardless of whether the question is still eligible for consultation.
begin
Record the hand-over and queue the question as the chat’s next message.
chat_talk_of
The talk start descends from: the id recorded on a task (Task::chat_talk) wins, so deleted ancestors do not matter; tasks written before it existed are resolved by walking the ancestry.
drain_turns
Run the talk’s turns under lease until no draft is owed.
origin_talk
The conversation q may be handed to, if any.
pending_consults
Is any question handed to talk talk_id still open?
publication_guard
Serialize queue/record -> worker acknowledgement against a drainer’s generation scan + promotion. Never hold this fence across an agent call.
record_other
Store the owner’s alternative as a note and end only the consultation: the question stays open and its waiter stays held.
reply_other
magi answer --reply-other on question id (a full id): record_other under the store’s lock, then what to print. Shared by the terminal’s direct path and a chat turn’s control bridge.
run_service_worker
One leased service tick. Existing question leases, seat records, and release receipts remain the only authorities for delivery and once-only effects.
run_turn_worker
Hidden worker entry point. The original talk/session and cross-process lease stay authoritative even when an older worker is still responding.
spawn_recorded_turn
Continue an operator turn already persisted by the HTTP admission path. Reserve this job before releasing the caller’s turn lease.
spawn_turn
Reserve and launch a detached drainer for an explicitly submitted draft.
start_services
Finite service work outlives the scheduler, but never pins a service host to an obsolete executable. Its next tick is started by the new scheduler.
start_turn
begin, then run the chat’s turn here, under the talk’s own lease.
try_publication_guard
Try the short cross-process draft-publication fence for one talk.
turn_worker_active
Includes startup reservations, before the child acquires the turn lease.