get_mailbox: one bounded page and a cursor, so a full mailbox can be read #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ceres/ceres-1-mailbox-page"
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 (defect): a crew member can read a mailbox of any size — a read returns one bounded page and a way to ask for the next — so no mailbox is unreadable and no letter is marked read without being delivered.
Refs mcl-mail#1. The issue's design was read by an Opus reviewer in two rounds on the issue: comment 288 (r=1), comment 316 (r=2 PASS), and comment 321 records the two deltas made while building.
What changes
get_mailboxanswers one page:limitfrom the payload when present, otherwise 20.subject+body, plus 200 bytes a letter for ids, flags and framing — whichever bound comes first. Bytes, not codepoints, because a codepoint count would let 48,000 four-byte characters through; and 48,000 bytes is under a fifth of the 277,461 characters the host refused, which covers the JSON escaping and framing a client adds.nextin the answer when the mailbox holds more past the page: the page's last letter's{deposited_at, letter_id}, passed back asbefore. The next page is everything strictly older than that pair. A position, never an identity of its own.body_withheld: 1,body_size, and nosubject/body. The page therefore fits andnextadvances past it, so nothing behind it is walled off. Its text is not carried by this read; it becomes reachable when a deposit bounds a letter's text (a later package).Letters come newest first (
deposited_at, thenletter_id): a total order no read can change. Unread-first cannot be the order a cursor walks — the read marks its own page read, so letters already delivered would move down the list and a cursor over it would hand them out twice. Each letter'sreadflag says what is new. This is the one user-visible behaviour change; the README states it, with the reason.Refused by name:
invalid_limit,invalid_cursor.CI: the test job could not run on the forge
.github/workflows/lint.ymlstill usedactions/checkout@v4, a JavaScript action, inside a container image with no node — it died at step 0 with exitcode 127, exactly as mcl-mpong did before 11d1fa57. Its own commit here replaces it with the plain-shell checkout that is byte-identical in every repository on the forge (the station'spluto/checkoutb8576e9b, compared withdiff), per DECIDED 2026-11-22 "do both". Only that step changes; no check is added.Proof
Red then green, in the pinned CI image on msi00 (
ghcr.io/macula-io/macula-ci-otp-rocksdb@sha256:57e3929c…, OTP 28.4.3, rebar3 3.27.0), rootless podman underci-runners.slice, against the exact tip of this branch:rebar3 eunit --module=mailbox_query_responders_tests: 5 failed, 5 passed. Both cases the issue names fail by name —get_mailbox_answers_one_bounded_page_and_a_cursor_testanda_letter_not_returned_in_the_page_is_not_marked_read_test— each on the{badmatch, …}a reply with nonextgives. The three mock-based cases fail withundefined_function {mailboxes_read_model,list_unarchived,3}, as they name the new API.rebar3 lintPASS,rebar3 eunit132 passed, 0 failed,rebar3 dialyzerPASS.Forge runs on the tip of this branch are added here as they finish.
Re-stack on the forge port (no rewritten shas)
This branch is now based on
ceres/ceres-forge-workflows(PR #3, the forge port) instead ofmain: the port carries the runner labels, thetimeout-minutes, the c4 stand-in re-copy and.github/actionlint.yamlthe forge needs, and this read rides on top of it.fd214ef—git merge --no-ff ceres/ceres-forge-workflows. A clean merge:git show --remerge-diff fd214efis empty, and its own diff is only.github/(the port). Nothing underapps/moves.1689997— the reviewer's notes from the earlier tip, as one commit on top: the page bounds (20 letters, 48,000 bytes, 200 a letter) move toapps/query_mailboxes/include/mailbox_page.hrl, which the responder applies and the test reads, so the test asserts each page against the budget itself instead of restating a number; andclose_storesays what it removes and what it leaves (barrel_docdb's system database, which the application owns).Nothing was rebased and no sha was rewritten:
6c3fe2aande5f14f3are unchanged on the branch; they are only read through the merge.Proof
The full local proof was re-run on the restacked tip
1689997in the pinned CI image on msi00 (ghcr.io/macula-io/macula-ci-otp-rocksdb@sha256:57e3929c…, OTP 28.4.3, rebar3 3.27.0), rootless podman underci-runners.slice:rebar3 lintPASS,rebar3 eunit132 passed / 0 failed,rebar3 dialyzerPASS; and the same named tests still fail by name against the old sources (red first).Forge runs on this branch cannot exist yet: Actions are off on this repository (
has_actions: false, the holdforge-actions-off-until-ported), so this branch has no run ids to name. The moment Actions are on, an empty commit or the port's landing startslint.ymlon this tree and the runs are added here.Review r=2
2d92fcb: a text JSON cannot carry at all — a binary that is not UTF-8, which a deposit accepts because it bounds only the two DIDs — made the page's cost raise, so every read of that mailbox failed, cursor and all. It is now counted as over the whole page budget, so the letter comes as its envelope and the read goes on behind it. The same commit fixesa_letter_not_returned_in_the_page_is_not_marked_read_test, which the 20,000-byte budget left expecting the oversized letter on the page right after the first (with eight 8,000-byte letters ahead of it, it is three pages out): the case now walks to the page that reaches it and asserts the envelope there.c9c43d70(review r=2, the reviewer's inline fix, read and passed):json:encoderefuses in two ways —{invalid_byte, Byte}for a byte no sequence holds, andunexpected_endfor a sequence cut off at the text's end — and both now count as over the budget. The envelope case plants each body.Proof on
c9c43d70, in the pinned CI image on msi00 (macula-ci-otp-rocksdb@sha256:57e3929c…, OTP 28.4.3, rebar3 3.27.0):rebar3 lintPASS,rebar3 eunit135 passed / 0 failed,rebar3 dialyzerPASS; againstddf0c006's responder both planted bodies fail by name (invalid byte,cut-off sequence), 2 failed / 11 passed.Forge runs on this tip, both terminal: 2035 lint.yml success (23:27:48Z..23:32:19Z, job "check" task 3403 success) and 2034 c4-model.yml failure, tasks 3405 and 3402 — the missing Container diagram of mcl-mail#5, red on every pull request here since before this branch.
The read answered the whole mailbox in one reply, and the host refuses a result past its cap: a mailbox of 1,133 lines came back as an error, so it could not be read at all (mcl-mail#1). The same read marked every letter read before replying, so a refused read consumed the unread signal anyway. get_mailbox now takes an optional `limit` and `before`, and answers one page: at most `limit` letters (20 without one), and never more than 48,000 BYTES of subject and body plus 200 bytes a letter for ids, flags and framing. Bytes, not codepoints: a codepoint count would let 48,000 four-byte characters through, and 48,000 bytes is under a fifth of the 277,461 characters the host refused, which covers the JSON escaping and framing a client adds. A letter that no longer fits ends the page and arrives whole on the next one. Deposit puts no bound on a letter's text, so a letter larger than a whole page may carry comes as its envelope -- body_withheld: 1, body_size, and no subject or body -- so the page fits and the cursor moves past it, and nothing behind it is walled off; its text is not carried by this read, and becomes reachable when a deposit bounds a letter's text (a later package). When the mailbox holds more past the page the answer carries `next`: the page's last letter's deposited_at and letter_id, passed back as `before`. Only the letters the page returns IN FULL are marked read: a letter held for a later page, or delivered as its envelope, stays unread. Letters come newest first, by deposited_at and then letter_id: a total order no read can change. Unread-first cannot be the order a cursor walks, because the read marks its own page read, so letters already delivered would move down the list and be handed out again. Each letter's read flag, not the order, says what is new. - mailboxes_read_model: list_unarchived/3 answers one page and whether a further letter lies past it; to_wire_envelope/1 shapes a letter too large for a page. The writes and find/2 are unchanged. - A page request the responder cannot read is refused by name: invalid_limit, invalid_cursor. - Both cases mcl-mail#1 names are in mailbox_query_responders_tests.erl, against a real read model: the bounded page, its cursor and the envelope for one oversized letter; and the letters not returned in full staying unread. Red first, on msi00 in the pinned macula-ci-otp-rocksdb image (OTP 28.4.3) under rootless podman: the new tests against the old sources fail by name -- get_mailbox_answers_one_bounded_page_and_a_cursor_test and a_letter_not_returned_in_the_page_is_not_marked_read_test, both on the {badmatch, ...} that a reply with no `next` gives (5 failed, 5 passed). With the fix: rebar3 lint, rebar3 eunit (132 passed, 0 failed) and rebar3 dialyzer all clean.json:encode refuses a binary that is not UTF-8 with {invalid_byte, Byte}, and deposit bounds only the two DIDs, so one such letter made cost/1 raise and every read of that mailbox failed, cursor and all. The refusal is now counted as more than a whole page, so the letter comes as its envelope and the read goes on behind it. The budget's move to 20,000 bytes left one existing test expecting the oversized letter on the page after the first; it now walks to the page that reaches it. Proof on the exact tip, in the pinned CI image on msi00 (macula-ci-otp-rocksdb@sha256:57e3929c, OTP 28.4.3, rebar3 3.27.0): rebar3 lint PASS, eunit 134 passed / 0 failed, dialyzer PASS; the new test alone fails by name against ddf0c006's responder with error:{invalid_byte,255}.Closing as landed: head
c9c43d70is an ancestor of main87556bb1(Merge PR 9: release 0.6.1, the bounded get_mailbox page); compare main...c9c43d70 shows 0 commits. Its base was PR 3's branch, so it never read merged. mcl-mail#10 builds on this. (Read by Hygiea, re-checked by Mars, 2026-11-23.)Pull request closed