Purpose (change): a mailbox read carries each letter for two reads and deletes it at the third #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Purpose (change): a mailbox read carries each letter for two reads and deletes it at the third, so a box cannot fill up with letters already seen and a session that dies mid-handling still has them once more.
The owner's words (2026-11-23): "shouldnt mcl-mail just delete after read? / yes", then, on plain read-once being proposed: DECIDED 2026-11-23 "keep the safeguard, a little backlog is allowed, no?". So delete-after-read, with one read's grace: the safeguard stays.
What is built today (0.6.1, mcl-mail#1 and #2):
get_mailboxanswers one bounded page (20 letters, 20,000 bytes of encoded text) with anextcursor, letters newest first, oversized ones as envelopes (body_withheld: 1, not marked read), and the letters a page returns in full are marked read, with the read flag as fetched. The crew client (crew-code/exchange_crew_mail/mail.ts,readMail) asksget_mailboxwith no cursor, so a member sees the first page only, and a letter marked read stays in the box unseen.The defect that exposed it: a 65,769-character mailbox was refused by the host's result cap, and the HANDOFF letter in it was never delivered — while the server had already marked the page's letters read, so no later read could show them.
The rule to build (server,
macula-services/mcl-mail):nextstill handed out. An envelope (body_withheld: 1) was not delivered, so it is not counted as carried and is not deleted; it comes again as its envelope until a deposit bounds a letter's text (a later change).apps/project_mailboxes/src/mailboxes_read_model.erl): two flags per letter instead of a generation counter —delivered(carried once) andreread(carried twice). A read returnsdeliveredfalse, plusdeliveredtrue andrereadfalse; it setsrereadon the ones already delivered; and it deletes, at its start, every letter withrereadtrue. That is exactly read N returning N−1's letters and deleting N−2's, with no per-mailbox counter.get_letterby id is a delivery too: it returns the letter and setsdelivered, so the next mailbox read carries it once more and the third removes it.reply_to_letterreads the aggregate's state, which is built from the letter's events, never from this read model — a letter forgotten from the mailbox can still be replied to.Generation-0 purge (unchanged): every letter already marked read before this rule is treated as carried twice — it is deleted by each mailbox's first read and never handed out again. No letter that is unread today is touched. No separate purge script.
Client: needs no new call; its
readflag becomes always 0 for letters returned, soreadMailmay drop it from the rendered letter. Nothing else increw-codechanges.Refs macula-services/mcl-mail#1, macula-services/mcl-mail#2, macula-io/macula-sponsors#18. The release takes the old signer path one more time unless macula-io/macula-fleet#8 lands first (dispatcher, 2026-11-23).
Purpose (change): a mailbox read returns only unread letters and deletes the ones its previous read returnedto Purpose (change): a mailbox read carries each letter for two reads and deletes it at the thirdBuilding it as ruled here. PR: #11 (branch
ceres/10-delete-after-read, one commit).Three things the build had to decide that this text left open, recorded here so the issue stays the record:
mark_letter_read_v1on a letter used to be a no-op; it is now the second carry and produces a secondletter_read_v1, and a third produces nothing. Without that the projection would never learnreread, and a projection rebuilt from the stream would not reach the same mailbox.readflag counts as its first carry, so that delivery is its second and the next read deletes it. It is never handed out by a mailbox read.r=2 build decisions (review r=1, PR comment 1229 R1 + its same-root fold-in):
letter_read_v1must be a no-op. A letter keepscarried_by(the first fact's event id) andcarried_again_by(the second's); the projection passes the event's own id.find/2answersnot_foundfor a letter carried twice. Same root, other way round: a boot's replay of the deposit recreates a forgotten letter's document, andget_lettermust not hand it out a third time before the next read deletes it.carried_twice/1counts the old rule'sreadflag itself as the letter's second carry, so a letter read before the rule is purged by the first read whether or not the fact that set the flag has been replayed (r=1 N2).delivered/rereadbooleans are gone: the two carry ids are the one record of a letter's carries, read by the listing and byfind/2.Proof on
12b22b7: both review probes as cases, red on1b877a5and green here (eunit 149, lint, dialyzer in the pinned image), three mutants each killed by name. — CeresLanded
PR 11 merged at
12b22b7a(review: Venus, Opus, PASS r=2 at 2026-11-23T06:20Z; merge 07:03Z). The purpose holds on the merged code: a read carries each letter twice and the third removes it, with Venus's restart probes in the suite and both his mutants killed.Left open for the release, not for code: the release follows the old path one last time unless macula-io/macula-fleet#8 lands first (Mars, 2026-11-23). The close goes with the release, not with the merge.
Purpose met: landed at
12b22b7a, shipped in 0.6.2 — see the Landed comment of 2026-11-23 13:13Z above (Venus PASS r=2, restart probes in the suite, both mutants killed).