[client] Polls: poll, vote and pollClose inside MLS — a poll is a message, only the asker closes, the close carries the final votes #22
Reference in New Issue
Block a user
Delete Branch "feature/polls"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Polls: three payloads inside MLS. Amicitia F28 (step 3 of its full-chat plan). Analysis:
.agents/features/polls.md.docs/PROTOCOL.md§4 and §7 updated. The relay does not change: no route, no column.poll{seq, question, options, multiple}is a message: it sharesseqwithtext, so it can be replied to, reacted to and covered by a receipt. 1–300 characters of question, 2–10 different answers of 1–100, none blank, no control characters.vote{poll, choices}: indexes, ascending, each once, at most one unlessmultiple; it replaces the sender's earlier vote,[]takes it back. Noseq.pollClose{poll, ballots}: only the poll's author. It carries the final votes as the author's client accepted them, so a vote that crosses the close counts nowhere and both devices show the same result.polls, absent in older snapshots;SNAPSHOT_VERSIONstays 1), so it decides which votes and closes make sense, and the close's ballots come from what it accepted, not from the app.compose_poll,vote,close_poll;Event::Poll,Event::Vote,Event::PollClosed,Ballot;ClientError::BadPoll,ClientError::PollClosed; limits as constants.seq): F27's rule.Adversarial self-review — polls
Evidence
cargo test --workspace--workspace --all-targets -D warningscargo fmt --all --checkpollClosemissing from the known kindsreal_relay.rs)Findings
F1–F6 are on their lines.
Not verified
peer_author), as F27's references.Verdict
Merging. Next: Amicitia F28 (create, vote, results, close) pins the merge.
@@ -214,0 +266,4 @@/// A poll in a conversation, as this client accepted it (`.agents/features/polls.md` §2.3).#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase", deny_unknown_fields)]pub(crate) struct PollState {F4 — scope / growth. One
PollStateper poll, kept as long as the conversation (a few dozen bytes, plus up to two ballots in 1:1). No pruning: a closed poll is still needed to refuse a late vote.forget_contactdrops them with the contact.@@ -576,0 +783,4 @@&mut c.group,&Payload::PollClose {poll,ballots: c.polls[p].ballots.clone(),F1 — correctness (designed, not a bug found late). Without the ballots, a vote and a close that cross leave the two devices disagreeing for ever: the asker's client drops the late vote, the voter's app counted it. The close carries what the asker's client accepted, and the receiver replaces its votes with them. Test:
a_vote_that_crosses_the_close_is_counted_nowhere; planted our close carries no ballots and the close's ballots not taken are caught.@@ -1058,0 +1298,4 @@};let name = MessageRef { author, seq };let c = &mut self.contacts[index];let fits = question.chars().count() <= MAX_QUESTION_CHARSF3 — correctness, accepted. A malformed poll is dropped and its
seqdoes not count, so a receipt for it waits until their next message. Same as a blob that does not parse. The sender's app shows it not delivered until then, not lost.@@ -1058,0 +1306,4 @@|| seq == 0|| !fits|| !poll_ok(&question, &options)|| c.polls.iter().any(|p| p.poll == name)F2 — correctness, accepted. A poll is refused under a name a poll already has, but not under the
seqof an earlier text: a misbehaving peer (MLS-authenticated, so only the other member) could reuse aseqand make one name point at two messages. Texts have the same property today. The fix belongs to every kind with aseqat once (seq>received_seq), with care for blobs fetched again after a crash; recorded in the analysis §4 as later work.@@ -1058,0 +1361,4 @@/// The contact closed their own poll: its votes become the close's ballots, if each is a/// member's, once, and a valid vote.fn receive_close(F5 — integrity. Only the poll's author closes (
poll.author == peer), and each ballot must be by a member, once, non-empty, and a valid vote for that poll. A peer cannot close our poll or put words in our mouth beyond our own accepted vote… except that the close names our choices as they saw them: a peer could report our vote differently in their close. It is their poll's result as they show it; our own app also shows it. Accepted for 1:1; F32 should show your vote was counted as … if it differs.@@ -55,1 +55,4 @@| `reaction` *(2026-11-21)* | `to`, `emoji`? | the sender's reaction to the message `to`: `emoji` (1–32 bytes of UTF-8, no control characters) sets it, replacing their earlier one; absent removes it. No `seq` || `poll` *(2026-11-22)* | `seq`, `question`, `options`, `multiple` | a message (it shares `seq` with `text`): a question of 1–300 characters and 2–10 different options of 1–100, none blank, no control characters; `multiple` allows several choices in a vote || `vote` *(2026-11-22)* | `poll`, `choices` | the sender's choices in the poll `poll` names, replacing their earlier ones: indexes into `options`, ascending, each once, at most one unless `multiple`; `[]` takes the vote back. Refused once the poll is closed. No `seq` || `pollClose` *(2026-11-22)* | `poll`, `ballots` | sent by the poll's author only: the poll is closed, and `ballots` (`{author, choices}`, one per member with a non-empty vote) are **the final votes**, as the author's client had accepted them, so a vote that crossed the close counts nowhere. No `seq` |F6 — privacy. Members learn who voted for what: there is no anonymous poll (MLS authenticates every sender), and the app says so on every poll. The relay sees three more kinds of blob, sized like short texts; a close grows with the number of ballots (at most two in 1:1), which G41's padding covers later.
Merged into
mainwith--no-ffas4d0dac0591(remote hash verified).Pull request closed