[client] F24: block and unblock as staged rotates, delivery receipts, payloads documented #18

Closed
mnovak wants to merge 0 commits from feature/block-receipts into main
Owner

F24 in the client: block, unblock, and delivered (Amicitia #52). Analysis: .agents/features/block-and-receipts.md.

  • block(contact) is staged: the contact is marked, and the returned Outgoing is a rotate of our mailbox's post token to the hash of a token nobody gets. Nothing is sent to them; their posts get the ordinary 404. Texts from them that still arrive are dropped and never shown.
  • unblock(contact): a rotate to a new token, and that token to them in an inbox payload. readdress swaps the new token into a post waiting in their app's outbox.
  • Receipts: texts carry seq, and the receiver answers receipt {upto} after the app has saved them (Event::Delivered). They are reciprocal: off means none are sent and none are reported. On by default; the snapshot keeps the setting.
  • Outgoing is now one relay operation (a post or a rotate), so block and unblock follow the same save, then send rule. Transport gains rotate_post_token (section 8's existing route).
  • finish skips a post refused with 404, so a blocked person's client still acknowledges what it fetched (found by a test).
  • PROTOCOL.md section 4: the payloads inside MLS are written down. The relay is unchanged.
**F24 in the client: block, unblock, and *delivered*** (Amicitia #52). Analysis: `.agents/features/block-and-receipts.md`. - `block(contact)` is staged: the contact is marked, and the returned `Outgoing` is a **rotate** of our mailbox's post token to the hash of a token nobody gets. Nothing is sent to them; their posts get the ordinary 404. Texts from them that still arrive are dropped and never shown. - `unblock(contact)`: a rotate to a new token, and that token to them in an `inbox` payload. `readdress` swaps the new token into a post waiting in their app's outbox. - **Receipts:** texts carry `seq`, and the receiver answers `receipt {upto}` after the app has saved them (`Event::Delivered`). They are reciprocal: off means none are sent and none are reported. On by default; the snapshot keeps the setting. - `Outgoing` is now one relay operation (a post or a rotate), so block and unblock follow the same *save, then send* rule. `Transport` gains `rotate_post_token` (section 8's existing route). - `finish` skips a post refused with 404, so a blocked person's client still acknowledges what it fetched (found by a test). - `PROTOCOL.md` section 4: the payloads inside MLS are written down. The relay is unchanged.
mnovak added 1 commit 2026-11-17 12:02:47 +01:00
mnovak reviewed 2026-11-17 12:02:47 +01:00
mnovak left a comment
Author
Owner

Adversarial self-review — F24, block and receipts

Evidence

What Result
cargo test --workspace --locked (Windows) client 34 (4 unit + 7 block + 8 pairing + 1 real relay + 14 state), protocol 14, relay 25: 73 passed, 0 failed
The client tests on the Android emulator (amicitia_test, Android 15, x86_64) 34 passed, 0 failed
Clippy (-D warnings), fmt, check-deps.sh clean / ok / ok
Planted bugs (mutate_block.py) 9/9 caught
Planted bug Caught by
block also posts to the blocked person a blocked contact reaches us no more and is not told
texts from a blocked contact shown the same
the rotate done inside block, not staged a block made offline waits and survives a restart (Jan can still post until it is delivered)
receipts sent while off the four pre-F24 tests that switch receipts off
a receipt marking beyond what was sent unit a receipt is capped at what was sent
readdress leaves the old token unblocking readdresses what waited…
finish stops at a refused post a refused receipt does not keep the blocked side from acknowledging
unblock sends the token but does not rotate unblocking…
unblock leaves the contact marked blocked unblocking…

Found while building

finish delivered a blocked person's receipt, got 404, and returned before acknowledging anything. Their client would have fetched the same messages for ever. Fixed (B4), with its own test.

Not verified

  • Receipts across a real relay: tested with the in-memory transport only; the real-relay test runs with receipts off.
  • An old peer (a client from before F24) talking to a new one: deny_unknown_fields on payloads means it would refuse a text with seq. No such client exists outside this repository (pre-release); stated in B5.

Verdict

Merging; B1–B7 are on their lines.

## Adversarial self-review — F24, block and receipts ### Evidence | What | Result | |:--|:--| | `cargo test --workspace --locked` (Windows) | client **34** (4 unit + 7 block + 8 pairing + 1 real relay + 14 state), protocol **14**, relay **25**: **73 passed, 0 failed** | | The client tests on the Android emulator (`amicitia_test`, Android 15, x86_64) | **34 passed, 0 failed** | | Clippy (`-D warnings`), fmt, `check-deps.sh` | clean / ok / ok | | Planted bugs (`mutate_block.py`) | **9/9 caught** | | Planted bug | Caught by | |:--|:--| | block also posts to the blocked person | *a blocked contact reaches us no more and is not told* | | texts from a blocked contact shown | the same | | the rotate done inside `block`, not staged | *a block made offline waits and survives a restart* (Jan can still post until it is delivered) | | receipts sent while off | the four pre-F24 tests that switch receipts off | | a receipt marking beyond what was sent | unit *a receipt is capped at what was sent* | | `readdress` leaves the old token | *unblocking readdresses what waited…* | | `finish` stops at a refused post | *a refused receipt does not keep the blocked side from acknowledging* | | unblock sends the token but does not rotate | *unblocking…* | | unblock leaves the contact marked blocked | *unblocking…* | ### Found while building `finish` delivered a blocked person's receipt, got 404, and returned before acknowledging anything. Their client would have fetched the same messages for ever. Fixed (B4), with its own test. ### Not verified - Receipts across a real relay: tested with the in-memory transport only; the real-relay test runs with receipts off. - An old *peer* (a client from before F24) talking to a new one: `deny_unknown_fields` on payloads means it would refuse a `text` with `seq`. No such client exists outside this repository (pre-release); stated in B5. ### Verdict Merging; B1–B7 are on their lines.
@@ -117,3 +122,1 @@
to: MailboxId,
post: Token,
blob: Bytes,
#[serde(transparent)]
Author
Owner

B5 — compatibility. Outgoing is now {op: post|rotate, …}. An app's outbox rows from before F24 have no op and no longer parse (Amicitia drops unparseable rows, its R8). Payloads gained seq and two kinds; with deny_unknown_fields, a client from before F24 would refuse them. Both are acceptable before the first release, and wrong after it. From the first release, a payload change needs a version.

**B5 — compatibility.** `Outgoing` is now `{op: post|rotate, …}`. An app's outbox rows from before F24 have no `op` and no longer parse (Amicitia drops unparseable rows, its R8). Payloads gained `seq` and two kinds; with `deny_unknown_fields`, a client from before F24 would refuse them. Both are acceptable before the first release, and wrong after it. From the first release, a payload change needs a version.
@@ -453,0 +526,4 @@
/// Blocks a contact, staged: they are marked, and their way into our mailbox is closed by a
/// rotate to the hash of a fresh token that nobody gets. Nothing is sent to them. Save the
/// snapshot, then deliver the result.
pub fn block(&mut self, contact: ContactId) -> Result<Outgoing, ClientError> {
Author
Owner

B1 — privacy: the blocked person is not told. Block sends nothing to them and changes nothing they can see, except that their posts now get 404. That is section 8's answer for any wrong token, so the protocol does not say blocked. A person whose messages never leave their outbox may still guess. Stated in the analysis.

**B1 — privacy: the blocked person is not told.** Block sends nothing to them and changes nothing they can see, except that their posts now get 404. That is section 8's answer for any wrong token, so the protocol does not say *blocked*. A person whose messages never leave their outbox may still guess. Stated in the analysis.
@@ -543,1 +676,4 @@
}
// Receipts, for every contact whose texts arrived now. Delivered by `finish`, so only
// after the app has saved the texts.
if self.receipts {
Author
Owner

B3 — privacy: receipts tell the sender when your app was open. They are reciprocal: off means you send none and see none. That is the usual fair rule, and it stops someone from seeing others' receipts while hiding their own. On by default [decided by default]; the app must say what it costs where the switch is.

**B3 — privacy: receipts tell the sender when your app was open.** They are reciprocal: off means you send none and see none. That is the usual fair rule, and it stops someone from seeing others' receipts while hiding their own. On by default *[decided by default]*; the app must say what it costs where the switch is.
@@ -555,2 +711,3 @@
for out in &received.outgoing {
self.deliver(out)?;
match self.deliver(out) {
Ok(()) | Err(ClientError::Transport(TransportError::NotFound)) => {}
Author
Owner

B4 — found by a test. A blocked person's client delivered a receipt, got 404, and finish returned before acknowledging. Their app would have refetched the same blobs for ever. A 404 cannot succeed on retry, so it is skipped; other failures still stop finish so it can be retried.

**B4 — found by a test.** A blocked person's client delivered a receipt, got 404, and `finish` returned before acknowledging. Their app would have refetched the same blobs for ever. A 404 cannot succeed on retry, so it is skipped; other failures still stop `finish` so it can be retried.
@@ -659,3 +818,4 @@
// Text before hello: not from a conversation that has been set up.
return Err(ClientError::Mls);
}
if c.blocked {
Author
Owner

B2 — what was in flight. Texts they posted before the block, or that arrive in the same fetch, are dropped and never shown, and still acknowledged, so they leave the relay. No receipt is sent for them (a blocked contact gets no receipt).

**B2 — what was in flight.** Texts they posted before the block, or that arrive in the same fetch, are dropped and never shown, and still acknowledged, so they leave the relay. No receipt is sent for them (*a blocked contact gets no receipt*).
@@ -667,0 +839,4 @@
upto: upto.min(c.sent_seq),
}))
}
Payload::Inbox { post_token } => {
Author
Owner

B6 — inbox is narrow. It replaces the token for the mailbox their hello named, never the mailbox. A contact cannot use it to redirect our posts elsewhere (unit test). MLS authenticates that it comes from them.

**B6 — `inbox` is narrow.** It replaces the token for the mailbox their `hello` named, never the mailbox. A contact cannot use it to redirect our posts elsewhere (unit test). MLS authenticates that it comes from them.
@@ -46,6 +46,19 @@ MLS**. To the relay, the welcome mailbox is an ordinary mailbox.
*(Changed 2026-11-14, approved by Mark, from "the invitee replies with their own KeyPackage": the
invitee needs no KeyPackage, because it creates the group itself.)*
### Payloads inside MLS *(added 2026-11-17, F24; `.agents/features/block-and-receipts.md`)*
Author
Owner

B7 — the payloads are now in the protocol. Another app needs them to talk to this one. Dated, with the reason. The relay's part (sections 5 and 8) is unchanged: block uses the existing rotate route.

**B7 — the payloads are now in the protocol.** Another app needs them to talk to this one. Dated, with the reason. The relay's part (sections 5 and 8) is unchanged: block uses the existing rotate route.
Author
Owner

Merged into main with --no-ff as dff1bec275 (remote hash verified). The self-review is on this PR.

Merged into `main` with `--no-ff` as dff1bec275be02cac58739b38461c4a7cee31c73 (remote hash verified). The self-review is on this PR.
mnovak closed this pull request 2026-11-17 12:02:51 +01:00
Some checks are pending
ci / check (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.