Mouth: a v3 send may say resend, honoured only for an id the mouth attempted; else ResendUnknown #90

Merged
eureka merged 3 commits from hands/mouth-resend-skips-basis into main 2026-11-28 03:52:24 +00:00
Owner

Request shape and refusal (for Huginn)

Kind: gamecult.persona.chat_send_request.v3. Tuple, 6 fields, msgpack array:

[request_id: str, persona: str, room_alias: str, text: str,
 basis: nil | [seen_event_id: str|nil, since_unix_ms: uint],
 resend: bool]

The first five are exactly the v2 request. Answer: the existing gamecult.persona.chat_send_receipt.v2 [request_id, event_id|nil, refusal|nil, newer].

New refusal: ResendUnknown (in the v2 receipt only; the v1 receipt and the typed refusal document do not know it; newer is empty). It means the mouth cannot vouch for the earlier send, and it posted nothing. Record the line as unknown (not sent, not known to have gone out) and tell her.

The mouth honours resend: true only when it attempted that request_id itself, for the same Persona and the same room, less than 25 minutes ago (measured from the first PUT attempt; a resend does not renew it). Otherwise ResendUnknown: a forgotten id, one older than 25 minutes, one attempted for another room or Persona, one lost to a mouth restart. The record is in memory only, at most 500 ids per Persona, oldest forgotten first (which only turns a resend into ResendUnknown).

Golden bytes: tests/fixtures/persona-chat-v2/gamecult.persona.chat_send_request.v3.resend.msgpack and .first-try.msgpack.

Behaviour

  • Honoured resend: skips the basis check, reads no head, PUTs the same txn id; Synapse's answer is the receipt (the original event id if the first try posted, a new one if not).
  • Everything else as before: PersonaMismatch, Brake, EmptyText, UnknownRoom, the room gate. basis is ignored on a resend. A non-resend still gets RoomMoved.
  • New kind rather than a sixth field on v2: the v2 parser is strict on arity and the scheme is one kind per tuple shape.
  • Fixes Soul's hold on the first attempt: resend was an unowned bypass (high) and had no age bound (medium).

Tests

tests/persona-matrix-mouth-send-gate.test.mjs (fake homeserver that dedupes txn ids like Synapse; injected clock):

  • remembered id, first try posted (slow PUT, SendFailed, someone answered): same event, no head read, nothing new;
  • remembered id, first try never posted (homeserver 500): posts once though the room moved;
  • id never attempted: ResendUnknown, no PUT;
  • 24 min honoured, 26 min ResendUnknown;
  • other Persona, other room: ResendUnknown, no PUT;
  • non-resend after a room move: RoomMoved; resend still answers PersonaMismatch/UnknownRoom/Brake;
  • the record is bounded (501 sends: the first id is forgotten, the newest is not).

Runtime test: v3 golden fixtures, arity and boolean checks, ResendUnknown round-trips the v2 receipt and is refused by v1, the RUDP endpoint answers v3 with the v2 receipt.

Suite (Yggdrasil, CultLib 286a9af3 with cultcache-ts and cultnet-ts built): node --test tests/persona-*.test.mjs tests/*mouth*.test.mjs: 342 tests, 341 pass, 1 fail: the file tests/persona-feedback-cli.test.mjs, which needs cultmesh-ts (does not build at that CultLib commit); Soul found it fails identically on base 5d9fc14.

Docs: "Send requests" in docs/bridge.md. JS only, no new targets or dependencies.

🤖 Generated with Claude Code

## Request shape and refusal (for Huginn) Kind: `gamecult.persona.chat_send_request.v3`. Tuple, 6 fields, msgpack array: ``` [request_id: str, persona: str, room_alias: str, text: str, basis: nil | [seen_event_id: str|nil, since_unix_ms: uint], resend: bool] ``` The first five are exactly the v2 request. Answer: the existing `gamecult.persona.chat_send_receipt.v2` `[request_id, event_id|nil, refusal|nil, newer]`. **New refusal: `ResendUnknown`** (in the v2 receipt only; the v1 receipt and the typed refusal document do not know it; `newer` is empty). It means the mouth cannot vouch for the earlier send, and **it posted nothing**. Record the line as unknown (not sent, not known to have gone out) and tell her. The mouth honours `resend: true` only when it attempted that `request_id` itself, for the same Persona and the same room, less than 25 minutes ago (measured from the first PUT attempt; a resend does not renew it). Otherwise `ResendUnknown`: a forgotten id, one older than 25 minutes, one attempted for another room or Persona, one lost to a mouth restart. The record is in memory only, at most 500 ids per Persona, oldest forgotten first (which only turns a resend into `ResendUnknown`). Golden bytes: `tests/fixtures/persona-chat-v2/gamecult.persona.chat_send_request.v3.resend.msgpack` and `.first-try.msgpack`. ## Behaviour - Honoured resend: skips the basis check, reads no head, PUTs the same txn id; Synapse's answer is the receipt (the original event id if the first try posted, a new one if not). - Everything else as before: `PersonaMismatch`, `Brake`, `EmptyText`, `UnknownRoom`, the room gate. `basis` is ignored on a resend. A non-resend still gets `RoomMoved`. - New kind rather than a sixth field on v2: the v2 parser is strict on arity and the scheme is one kind per tuple shape. - Fixes Soul's hold on the first attempt: `resend` was an unowned bypass (high) and had no age bound (medium). ## Tests `tests/persona-matrix-mouth-send-gate.test.mjs` (fake homeserver that dedupes txn ids like Synapse; injected clock): - remembered id, first try posted (slow PUT, `SendFailed`, someone answered): same event, no head read, nothing new; - remembered id, first try never posted (homeserver 500): posts once though the room moved; - id never attempted: `ResendUnknown`, no PUT; - 24 min honoured, 26 min `ResendUnknown`; - other Persona, other room: `ResendUnknown`, no PUT; - non-resend after a room move: `RoomMoved`; resend still answers `PersonaMismatch`/`UnknownRoom`/`Brake`; - the record is bounded (501 sends: the first id is forgotten, the newest is not). Runtime test: v3 golden fixtures, arity and boolean checks, `ResendUnknown` round-trips the v2 receipt and is refused by v1, the RUDP endpoint answers v3 with the v2 receipt. Suite (Yggdrasil, CultLib 286a9af3 with cultcache-ts and cultnet-ts built): `node --test tests/persona-*.test.mjs tests/*mouth*.test.mjs`: 342 tests, 341 pass, 1 fail: the file `tests/persona-feedback-cli.test.mjs`, which needs `cultmesh-ts` (does not build at that CultLib commit); Soul found it fails identically on base `5d9fc14`. Docs: "Send requests" in `docs/bridge.md`. JS only, no new targets or dependencies. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eureka changed title from Mouth: a v3 send may say resend; a resend skips the basis check to Mouth: a v3 send may say resend, honoured only for an id the mouth attempted; else ResendUnknown 2026-11-28 03:51:28 +00:00
eureka merged commit 343d09f985 into main 2026-11-28 03:52:24 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
GameCult/Bifrost!90
No description provided.