A3 package 2: the store's mode comes from config, and a cluster-mode node appends only after its store has joined (mcl-martha#1) #35

Closed
opened 2026-12-02 10:48:45 +00:00 by pluto · 1 comment
Member

Purpose (feature): mcl-mail's reckon-db store runs in cluster mode on a box whose config says so, and no command is appended before that node's store has joined the cluster, so a clustered mail never appends into the join window.

Refs martha-ai/mcl-martha#1 (consolidation analysis A3 package 2, §2.3 "Every service"), macula-services/mcl-om#8, reckon-db-org/reckon-db#2, #4 and #14.

Why

A3 package 2 was held back until reckon-db 5.12.0 shipped the join guard (reckon-db#2, R1: a cold-start join used to reset a non-empty joiner's data) and the guide for joining a store that holds data (reckon-db#4). Both are on hex now. The guide's rule for a service is the second half of this package: a service on a cluster-mode node must not append until its store has joined, that is until reckon_db_cluster:local_healthy(StoreId) is true, because the join counts the store and then joins, and an event appended in that window is wiped by the join.

Supervisor's ruling: no service moves to cluster mode before reckon-db 5.12.1 is on hex (reckon-db#14, is_active unanswered during a leadership transfer). So the pin floor is raised to 5.12.1 before this lands, and the shipped default stays single.

What changes

  1. The mode comes from config. mcl_mail_service:event_store/0 takes mode from {mcl_mail, store_mode} (single by default, cluster allowed, anything else refused at boot with the value named) instead of the literal single. config/sys.config.src sets it to single, which is every box today, and a bundle sets cluster in its own config.
  2. One append seam. The nine CMD desks call evoq_command_router:dispatch/2 with identical options. They now call mcl_mail_append:dispatch/1, which in cluster mode answers {error, store_not_joined} while reckon_db_cluster:local_healthy(mcl_mail_store:id()) is false, and in single mode dispatches exactly as today. Reads that append (mark_letter_read, folded into get_mailbox and get_letter) go through the same seam: the delete-after-read rule means a READ appends a fact, and that path is checked like any other.
  3. The operator step is named. A store that holds events refuses every join, including a join to a cluster that already exists. README and CHANGELOG say: start the node that holds the data first, so it is elected coordinator and the empty nodes join it.
  4. The pin. reckon_db goes to ~> 5.12.0 for the build, and to ~> 5.12.1 before the land (Mars's instruction, Supervisor's floor).

Done when

  1. event_store/0's mode comes from config with single as the default, and a value that is neither is refused at boot, naming what it got.
  2. A test holds the shipped config's mode and the code default equal, so a release cannot quietly change one side.
  3. With mode cluster and local_healthy answering false (meck), every desk's dispatch answers {error, store_not_joined} and evoq_command_router:dispatch/2 is never called; with mode single the router is called as before. Counted on the mock, not grepped.
  4. The whole eunit suite, lint and dialyzer are green on OTP 28.4.3, and the release builds against the pinnned reckon-db.
  5. README names the operator step and the 5.12.1 floor, and CHANGELOG records the change under Unreleased.
Purpose (feature): mcl-mail's reckon-db store runs in cluster mode on a box whose config says so, and no command is appended before that node's store has joined the cluster, so a clustered mail never appends into the join window. Refs martha-ai/mcl-martha#1 (consolidation analysis A3 package 2, §2.3 "Every service"), macula-services/mcl-om#8, reckon-db-org/reckon-db#2, #4 and #14. ## Why A3 package 2 was held back until reckon-db 5.12.0 shipped the join guard (reckon-db#2, R1: a cold-start join used to reset a non-empty joiner's data) and the guide for joining a store that holds data (reckon-db#4). Both are on hex now. The guide's rule for a service is the second half of this package: a service on a cluster-mode node must not append until its store has joined, that is until `reckon_db_cluster:local_healthy(StoreId)` is true, because the join counts the store and then joins, and an event appended in that window is wiped by the join. Supervisor's ruling: no service moves to cluster mode before reckon-db 5.12.1 is on hex (reckon-db#14, is_active unanswered during a leadership transfer). So the pin floor is raised to 5.12.1 before this lands, and the shipped default stays `single`. ## What changes 1. **The mode comes from config.** `mcl_mail_service:event_store/0` takes `mode` from `{mcl_mail, store_mode}` (single by default, cluster allowed, anything else refused at boot with the value named) instead of the literal `single`. `config/sys.config.src` sets it to `single`, which is every box today, and a bundle sets `cluster` in its own config. 2. **One append seam.** The nine CMD desks call `evoq_command_router:dispatch/2` with identical options. They now call `mcl_mail_append:dispatch/1`, which in cluster mode answers `{error, store_not_joined}` while `reckon_db_cluster:local_healthy(mcl_mail_store:id())` is false, and in single mode dispatches exactly as today. Reads that append (mark_letter_read, folded into get_mailbox and get_letter) go through the same seam: the delete-after-read rule means a READ appends a fact, and that path is checked like any other. 3. **The operator step is named.** A store that holds events refuses every join, including a join to a cluster that already exists. README and CHANGELOG say: start the node that holds the data first, so it is elected coordinator and the empty nodes join it. 4. **The pin.** `reckon_db` goes to `~> 5.12.0` for the build, and to `~> 5.12.1` before the land (Mars's instruction, Supervisor's floor). ## Done when 1. `event_store/0`'s mode comes from config with `single` as the default, and a value that is neither is refused at boot, naming what it got. 2. A test holds the shipped config's mode and the code default equal, so a release cannot quietly change one side. 3. With mode `cluster` and `local_healthy` answering false (meck), every desk's dispatch answers `{error, store_not_joined}` and `evoq_command_router:dispatch/2` is never called; with mode `single` the router is called as before. Counted on the mock, not grepped. 4. The whole eunit suite, lint and dialyzer are green on OTP 28.4.3, and the release builds against the pinnned reckon-db. 5. README names the operator step and the 5.12.1 floor, and CHANGELOG records the change under Unreleased.
Author
Member

Landed. PR 36 merged into main at f1810103 (fast-forward, read back on the origin).

Done-when, checked on main at f181010:

  1. mcl_mail_store:mode/0 reads {mcl_mail, store_mode}: single when unset, cluster when the config says so, and error({store_mode_not_a_mode, Bad}) for anything else. mcl_mail_service:event_store/0 takes mode from it, and the shipped config names single.
  2. the_shipped_config_names_the_default_mode_test holds the config's mode equal to the code's default, so neither side can move alone.
  3. every_desk_is_gated_by_the_seam_test_ runs each of the nine desks' own dispatch/1 with a real command and counts the mocked router: on a cluster store with local_healthy false each answers {error, store_not_joined} with zero router calls, and on a single store each calls it exactly once. The source scan test sits beside it: mailbox_dispatch is the only module in either app that calls evoq_command_router:dispatch(.
  4. On OTP 28.4.3 against the pinned releases: compile clean, MCL_LINT=1 rebar3 lint clean, rebar3 eunit 180 tests, rebar3 dialyzer clean over 52 files, and a release rebuilt from an empty _build/prod/rel holding evoq 1.32.0, reckon_db 5.12.1 and reckon_evoq 2.10.0 and nothing else by those names.
  5. README carries the operator step (start the node that holds the data first, with the recovery step and the one-member warning), the no-append-before-join rule including the delete-after-read path, and the 5.12.1 floor; CHANGELOG records all of it under Unreleased.

CI on the main push: run 6910 (test, build-and-push, the tested resolve, check, attest; guard/attest skipped by their GitHub-only guards) and run 6911 (c4-model, c4-model-1), all status=success. On the pull request, runs 6896 (c4-model) and 6897 (lint) green on the same head.

Two pin moves beyond the original scope, both from the Supervisor: reckon_db to ~> 5.12.1 (5.12.0's is_active can go unanswered during a leadership transfer, reckon-db#14) and evoq to ~> 1.32 (one node in charge of each aggregate, which a shared store needs). No release boot was run: the shipped config is {mesh, required}, so a boot would reach the live realm's stations and file a claim.

Landed. PR 36 merged into `main` at f1810103 (fast-forward, read back on the origin). Done-when, checked on `main` at f181010: 1. `mcl_mail_store:mode/0` reads `{mcl_mail, store_mode}`: `single` when unset, `cluster` when the config says so, and `error({store_mode_not_a_mode, Bad})` for anything else. `mcl_mail_service:event_store/0` takes `mode` from it, and the shipped config names `single`. 2. `the_shipped_config_names_the_default_mode_test` holds the config's mode equal to the code's default, so neither side can move alone. 3. `every_desk_is_gated_by_the_seam_test_` runs each of the nine desks' own `dispatch/1` with a real command and counts the mocked router: on a cluster store with `local_healthy` false each answers `{error, store_not_joined}` with zero router calls, and on a single store each calls it exactly once. The source scan test sits beside it: `mailbox_dispatch` is the only module in either app that calls `evoq_command_router:dispatch(`. 4. On OTP 28.4.3 against the pinned releases: compile clean, `MCL_LINT=1 rebar3 lint` clean, `rebar3 eunit` 180 tests, `rebar3 dialyzer` clean over 52 files, and a release rebuilt from an empty `_build/prod/rel` holding evoq 1.32.0, reckon_db 5.12.1 and reckon_evoq 2.10.0 and nothing else by those names. 5. README carries the operator step (start the node that holds the data first, with the recovery step and the one-member warning), the no-append-before-join rule including the delete-after-read path, and the 5.12.1 floor; CHANGELOG records all of it under Unreleased. CI on the main push: run 6910 (test, build-and-push, the tested resolve, check, attest; guard/attest skipped by their GitHub-only guards) and run 6911 (c4-model, c4-model-1), all `status=success`. On the pull request, runs 6896 (c4-model) and 6897 (lint) green on the same head. Two pin moves beyond the original scope, both from the Supervisor: reckon_db to `~> 5.12.1` (5.12.0's `is_active` can go unanswered during a leadership transfer, reckon-db#14) and evoq to `~> 1.32` (one node in charge of each aggregate, which a shared store needs). No release boot was run: the shipped config is `{mesh, required}`, so a boot would reach the live realm's stations and file a claim.
pluto closed this issue 2026-12-02 13:03:57 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
macula-services/mcl-mail#35
No description provided.