Files
Amicitia-Tabellarius/.agents/features/block-and-receipts.md
T

4.4 KiB

F24 — Block, unblock, and delivered

Analysis, 2026-11-17. Issues Amicitia #52 (F24). It builds on F21/F22a (client.md, client-state.md). PROTOCOL.md §3 already says what block is: the owner rotates the post token; the old one is refused. The blocked person is not told. The relay route exists (§8, PUT …/post-token); the client never used it.

1. Why and what

  • Block: someone who turns hostile can no longer put anything in your mailbox. Nothing is sent to them, so they are not told. What they posted before the block, and what you already fetched, is dropped and never shown.
  • Unblock: a mistake can be undone. A fresh post token goes to them inside MLS, and their client switches to it, including for what waited in their outbox.
  • Delivered: you see when your message reached the other person's app (fetched and saved there). Each text carries a sequence number; the receiving client answers with a receipt upto = n once it has saved them. Reciprocal and switchable: with receipts off, a client neither sends them nor reports the other side's. The cost is said where the switch is: a receipt tells the sender roughly when your app was open.

2. Design

Everything is a staged step

F22a's rule holds: nothing reaches the relay before the app has saved. So Outgoing grows from "one blob to post" to one relay operation: post a blob, or rotate a post token.

Call Local change Returned for the app to deliver after saving
block(contact) marks the contact blocked a rotate to the hash of a fresh random token, which nobody gets
unblock(contact) clears the mark a rotate to a new token, then a post of inbox {postToken} to them, inside MLS
compose seq + 1 for that contact the text, now with its seq
receive texts from a blocked contact dropped; the highest seq received per contact a receipt per contact that sent texts (receipts on, not blocked)
  • deliver performs either operation. A rotate delivered twice is harmless: the same hash again.
  • readdress(&Outgoing): a post waiting in an app's outbox carries the token it was sealed with. After an inbox payload changed the token, readdress swaps in the current one. The sealed blob does not change. Apps call it before delivering from the outbox.
  • An app learns a message's seq from sent_seq(contact) right after compose.

Payloads inside MLS (documented in PROTOCOL.md §4, new: seq, receipt, inbox)

{"kind":"hello","mailbox":"…","postToken":"…","name":"…"}
{"kind":"text","body":"…","seq":7}
{"kind":"receipt","upto":7}
{"kind":"inbox","postToken":"…"}
  • inbox changes only the token for the mailbox we already know: the sender cannot redirect us to another mailbox (F21's second hello rule still holds). MLS authenticates that it is theirs.
  • A receipt with upto above what we sent is capped to what we sent; it cannot mark the future.
  • The relay sees none of this: all of it is MLS ciphertext, and a rotate is §8's existing route.

What the blocked person can tell

Their posts get 404: the same answer as any wrong token. Their app keeps the message as not sent yet and retries. Nothing in the protocol tells them it was a block rather than, say, an expired mailbox. Their client cannot ask. Stated: someone whose messages never leave the outbox may guess.

3. Tests — written first

  1. Block: the blocked side's next post is refused (404); nothing reaches us; what they posted just before the block, still waiting, is fetched, dropped, never shown, and acknowledged.
  2. Block works offline: the rotate waits as an Outgoing, and after a restart from the snapshot it still applies.
  3. Unblock: they get the new token, their waiting outbox post is readdressed and arrives, and new texts flow both ways.
  4. Receipts: Eva sends 3, Jan receives, Eva gets Delivered{upto: 3}. Receipts off on Jan: none sent. Off on Eva: Jan's receipts are ignored. A receipt upto above what was sent is capped.
  5. A snapshot from before F24 (no blocked, seq, receipts) still restores, with receipts on.
  6. inbox cannot change the mailbox, only the token.

Planted bugs: block that also posts something to the blocked person; texts from a blocked contact shown; the rotate done inside block (not staged); receipts sent while off; a receipt marking beyond what was sent; readdress leaving the old token.