Mouth: a v3 send may say resend; a resend skips the basis check #92

Closed
eureka wants to merge 3 commits from hands/mouth-resend-skips-basis into main
Owner

Request shape (for Huginn)

Kind: gamecult.persona.chat_send_request.v3 (new). 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. resend is true when this repeats an earlier send by the same caller under the same request_id. resend must be a boolean (a non-bool or a 5-field tuple is refused as a malformed frame).

Answer: the existing gamecult.persona.chat_send_receipt.v2 [request_id, event_id|nil, refusal|nil, newer], unchanged. The v1 and v2 request kinds are unchanged.

Golden bytes (Huginn can pin them): tests/fixtures/persona-chat-v2/gamecult.persona.chat_send_request.v3.resend.msgpack and .first-try.msgpack.

Behaviour

  • resend: true skips the basis/newerThan check and reads no head; it PUTs /send/m.room.message/{request_id} under the same txn id. Synapse's answer is the receipt: the original event id if the first try posted, a new one if it did not.
  • Everything else is checked as before: PersonaMismatch, Brake (before and inside the gate), EmptyText, UnknownRoom, the per-room gate.
  • basis stays in the tuple for shape uniformity and is ignored on a resend. A non-resend still gets RoomMoved as before, including a retry that does not say it is a resend.
  • Why a new kind and not a sixth field on v2: the v2 parser is strict on arity (5), and the repo's scheme is one kind per tuple shape (pending v1..v4, send v1/v2). The receipt kind is reused, so nothing is added on the answer side.

Finding: eureka-body:finding:cut-cut-persona-live-drain.s7.mouth-no-answer-recorded-refused, mouth half. Huginn's half (map SendFailed to Lost, retry under the recorded id with resend) is a separate change.

Tests

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

  • resend whose first try posted (slow PUT, mouth timeout, SendFailed, event persisted, someone answered): same event id $sent-1, no head read, nothing new in the room;
  • resend whose first try never posted: one PUT, though the room moved;
  • non-resend retry under the same id after the room moved: RoomMoved naming the newer id, no second PUT;
  • resend still answers PersonaMismatch, UnknownRoom, Brake, no PUT.

tests/persona-matrix-mouth-runtime.test.mjs: v3 golden fixtures, strict arity and boolean checks, and the RUDP endpoint answers a v3 send with the v2 receipt and delivers resend to the mouth.

Suite (Yggdrasil, ygg-verify.sh host mode, CultLib 286a9af3 with cultcache-ts and cultnet-ts built): node --test tests/persona-*.test.mjs tests/*mouth*.test.mjs: 338 tests, 337 pass, 1 fail. The failure is the file tests/persona-feedback-cli.test.mjs, which loads cultmesh-ts; that package does not build at that CultLib commit, so it is not run, and it does not touch the send path. The mouth runtime and send-gate files pass in full (75 of 75).

Docs: new "Send requests" section in docs/bridge.md.

Build budget: JS only, no new targets, dependencies or schemas beyond one document kind; build host Yggdrasil, no .NET build (the C# suite is untouched).

🤖 Generated with Claude Code

## Request shape (for Huginn) Kind: `gamecult.persona.chat_send_request.v3` (new). 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. `resend` is `true` when this repeats an earlier send by the same caller under the same `request_id`. `resend` must be a boolean (a non-bool or a 5-field tuple is refused as a malformed frame). Answer: the existing `gamecult.persona.chat_send_receipt.v2` `[request_id, event_id|nil, refusal|nil, newer]`, unchanged. The v1 and v2 request kinds are unchanged. Golden bytes (Huginn can pin them): `tests/fixtures/persona-chat-v2/gamecult.persona.chat_send_request.v3.resend.msgpack` and `.first-try.msgpack`. ## Behaviour - `resend: true` skips the basis/newerThan check and reads no head; it PUTs `/send/m.room.message/{request_id}` under the same txn id. Synapse's answer is the receipt: the original event id if the first try posted, a new one if it did not. - Everything else is checked as before: `PersonaMismatch`, `Brake` (before and inside the gate), `EmptyText`, `UnknownRoom`, the per-room gate. - `basis` stays in the tuple for shape uniformity and is ignored on a resend. A non-resend still gets `RoomMoved` as before, including a retry that does not say it is a resend. - Why a new kind and not a sixth field on v2: the v2 parser is strict on arity (5), and the repo's scheme is one kind per tuple shape (pending v1..v4, send v1/v2). The receipt kind is reused, so nothing is added on the answer side. Finding: `eureka-body:finding:cut-cut-persona-live-drain.s7.mouth-no-answer-recorded-refused`, mouth half. Huginn's half (map SendFailed to Lost, retry under the recorded id with resend) is a separate change. ## Tests New in `tests/persona-matrix-mouth-send-gate.test.mjs` (fake homeserver that dedupes txn ids like Synapse): - resend whose first try posted (slow PUT, mouth timeout, `SendFailed`, event persisted, someone answered): same event id `$sent-1`, no head read, nothing new in the room; - resend whose first try never posted: one PUT, though the room moved; - non-resend retry under the same id after the room moved: `RoomMoved` naming the newer id, no second PUT; - resend still answers `PersonaMismatch`, `UnknownRoom`, `Brake`, no PUT. `tests/persona-matrix-mouth-runtime.test.mjs`: v3 golden fixtures, strict arity and boolean checks, and the RUDP endpoint answers a v3 send with the v2 receipt and delivers `resend` to the mouth. Suite (Yggdrasil, `ygg-verify.sh` host mode, CultLib 286a9af3 with cultcache-ts and cultnet-ts built): `node --test tests/persona-*.test.mjs tests/*mouth*.test.mjs`: 338 tests, 337 pass, 1 fail. The failure is the file `tests/persona-feedback-cli.test.mjs`, which loads `cultmesh-ts`; that package does not build at that CultLib commit, so it is not run, and it does not touch the send path. The mouth runtime and send-gate files pass in full (75 of 75). Docs: new "Send requests" section in `docs/bridge.md`. Build budget: JS only, no new targets, dependencies or schemas beyond one document kind; build host Yggdrasil, no .NET build (the C# suite is untouched). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
eureka closed this pull request 2026-11-29 20:41:08 +00:00

Pull request closed

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!92
No description provided.