Files
hermes-agent/apps/shared
unsupportedpastels be842aa2fd fix(gateway): a Bot Chat DM refused while another writer holds the chat is a definite no-send
A pre-upgrade Desktop backend (classic tui_gateway prompt path) can still
hold a 'desktop' lease on a legacy Bot Chat. The owner's first delivery
adopts that chat through resolve_local_target, whose liveness guard
correctly refuses runtime_coordination_required (one writer per
transcript). message_agent had already fsynced its live-delivery intent,
so it answered "ambiguous ... Do not resend" and kept the pinned intent
for a replay, though nothing was admitted.

The owner's bot_relay.deliver door marks that refusal admitted=false
(field session_writer) when the delivery id has no receipt. That marker
proves absence only while the request holds the mailbox lock: a same-id
attempt (the runner retrying the pinned intent) can admit right after.
So it is a hint, not the verdict. Before the tool says "NOT sent" it
calls the new bot_relay.settle verb with the same identity. Under the
same mailbox lock _admit holds, settle either writes the id's terminal
not-sent receipt (refuse_pin's refused/failed shape, reason
runtime_coordination_required, full identity) or answers with the
admission that won. deliver answers a refused id with that receipt
before anything else, so a not-sent answer and an admission of the same
id can't coexist. Only the tool calls settle: cron's same-id retry of a
refused record still admits once the writer closes.

The tool raises LiveTargetHeldError ("held by another session writer
... NOT sent; safe to resend after that session closes") only for that
settled receipt. A replayed intent that meets it gets the same answer.
_start_delivery and _run_delivery share _settled_no_send, which removes
the intent and the payload. If either file survives the unlink, the
answer is the unknown outcome instead. Any other refusal, an older owner
without the marker, or a failed settle call stays ambiguous. The
refusal itself and the one-writer rule are unchanged.

Refs #134889 (MSG-19)
Refs #140208
2026-10-17 14:11:42 -04:00
..