A3 package 2: the store mode comes from config, nothing appends before the join, and the crew reconcile runs once per cluster #14

Closed
opened 2026-12-02 10:48:55 +00:00 by juno · 2 comments
Member

Purpose (feature): mcl-kanban runs on a clustered event store — the store's mode comes from config instead of a hardcoded single, the board appends nothing until the store has joined, and the 60 s crew reconcile runs on one node of the cluster.

DECIDED 2026-12-02 "Run the whole path (Recommended)" (Raf: the crew runs the whole path to one clustered mcl-martha release, in order, without coming back to him).
DECIDED 2026-12-02 "trust on sight. mcl-martha services should auto-cluster over LAN, no mcl-station required. Distributed Erlang offers us all we need."

This is A3 package 2 (ANALYSIS_2026-12-01_mcl-martha-consolidation.md, §A3: "reckon-db store mode read from config, not hardcoded single"), plus A3 package 4 — the mcl_om_singleton wrap that mcl-kanban#11 deliberately left out, because with one store per node a singleton would reconcile only the elected node's roster.

What changes

  1. The store mode comes from config. MclKanban.Service.event_store/0 takes mode from :mcl_kanban, :store_mode (default :single, validated to :single | :cluster at boot, refused by name otherwise), and config/runtime.exs reads it from MCL_STORE_MODE for the standalone release. A release that hosts several services sets it per service; a dependency's runtime.exs never runs (C9).
  2. Nothing is appended before the store has joined. GuideCardLifecycle.Store.dispatch/1 is the board's one dispatch funnel (C2), so the gate lives there: in :single mode it dispatches as today; in :cluster mode it refuses with {:error, :store_not_joined} until reckon_db_cluster:local_healthy(store_id) is true — a live leader, more than one member, and a local Raft server that answers (reckon-db/guides/cluster_consistency.md, "Do not append before the store has joined"). reckon-db's own guard counts the store and then joins, so an append inside that window to an empty joining node would be acknowledged and then wiped by the join. Subscribing before the join is fine: live subscriptions are carried across it.
  3. The crew reconcile runs on one node (A3 package 4, moved here from #11). MclKanban.Supervisor lists CrewStandingReconciler through mcl_om_singleton:child_spec/2: the node whose guard holds the global name runs the pass, and a standby takes over when that node goes. A NODE WITHOUT DISTRIBUTION — the standalone release — runs it exactly as today.

The operator rule this makes real

A store that holds data refuses every join, including a join to a cluster that already exists (reckon-db#2): the persisted-membership guard cannot tell a new cluster from an existing one, and a join resets the joiner's tree. So the node whose store holds data must be up and connected before the empty nodes join it — then it is elected coordinator (the election ranks data-holders first) and the others join it. If the empty nodes clustered first, that cluster serves an empty store forever. If both sides hold events, neither joins and both keep their history; merging two histories is an operator's decision. This is stated where the mode is read, and in the README the deploy is pointed at.

A netsplit runs the reconcile on every connected partition

mcl_om_singleton runs one copy per connected partition (that is how global behaves in a split). Each copy keeps its own counts: a side counts only the realm answers it received, so a crew is discharged only after the realm told that side unknown_crew unknown_limit times in a row. Both sides discharge on the same evidence, never on twice the evidence; the two discharges are the same evoq command, and reckon-db's version check settles the duplicate append (whether evoq retries the loser is unconfirmed, analysis A1). Neither copy can end a crew the realm still answers for, so the split needs no further guard; the PR states this and names no new check.

Build and land

  • Built against reckon_db 5.12.0 (hex), which carries the join guard (reckon-db#2).
  • The land waits for reckon_db 5.12.1 on hex (reckon-db#14: a new leader cannot answer is_active during activation, so a leadership transfer times out). The pin floor is raised to ~> 5.12.1 in a diff-only round once it is on hex, before the land. Supervisor: no service moves to cluster mode before 5.12.1.

Done when

  • MclKanban.Service.event_store/0 answers the mode from :mcl_kanban, :store_mode: a test sets :cluster and reads it back, and an invalid value is refused by name at boot.
  • In :single mode every dispatch lands as today (the existing suite).
  • In :cluster mode with the store not joined, a dispatch is refused with {:error, :store_not_joined} and writes nothing; with the join answered, the same dispatch lands. The health answer is the seam a test takes; the real one is reckon_db_cluster:local_healthy/1.
  • The crew reconciler is an mcl_om_singleton child of the service's supervisor: a test reads the child shape, and on a node without distribution one copy runs, a second guard starts no second copy, and it takes over when the holder goes.
  • The standalone release still boots in :single mode and migrates then starts.
  • mix format --check-formatted, credo, dialyzer and the full suite green; a mutant on each new guard is caught.
  • OTP 28; no test reaches an outside service, and no test starts a second node.

Refs martha-ai/mcl-martha#1
Refs macula-services/mcl-kanban#11
Refs reckon-db-org/reckon-db#2
Refs reckon-db-org/reckon-db#14

Purpose (feature): mcl-kanban runs on a clustered event store — the store's `mode` comes from config instead of a hardcoded `single`, the board appends nothing until the store has joined, and the 60 s crew reconcile runs on one node of the cluster. DECIDED 2026-12-02 "Run the whole path (Recommended)" (Raf: the crew runs the whole path to one clustered mcl-martha release, in order, without coming back to him). DECIDED 2026-12-02 "trust on sight. mcl-martha services should auto-cluster over LAN, no mcl-station required. Distributed Erlang offers us all we need." This is A3 package 2 (`ANALYSIS_2026-12-01_mcl-martha-consolidation.md`, §A3: "reckon-db store `mode` read from config, not hardcoded `single`"), plus A3 package 4 — the `mcl_om_singleton` wrap that mcl-kanban#11 deliberately left out, because with one store per node a singleton would reconcile only the elected node's roster. ## What changes 1. **The store mode comes from config.** `MclKanban.Service.event_store/0` takes `mode` from `:mcl_kanban, :store_mode` (default `:single`, validated to `:single | :cluster` at boot, refused by name otherwise), and `config/runtime.exs` reads it from `MCL_STORE_MODE` for the standalone release. A release that hosts several services sets it per service; a dependency's `runtime.exs` never runs (C9). 2. **Nothing is appended before the store has joined.** `GuideCardLifecycle.Store.dispatch/1` is the board's one dispatch funnel (C2), so the gate lives there: in `:single` mode it dispatches as today; in `:cluster` mode it refuses with `{:error, :store_not_joined}` until `reckon_db_cluster:local_healthy(store_id)` is `true` — a live leader, more than one member, and a local Raft server that answers (`reckon-db/guides/cluster_consistency.md`, "Do not append before the store has joined"). reckon-db's own guard counts the store and then joins, so an append inside that window to an empty joining node would be acknowledged and then wiped by the join. Subscribing before the join is fine: live subscriptions are carried across it. 3. **The crew reconcile runs on one node (A3 package 4, moved here from #11).** `MclKanban.Supervisor` lists `CrewStandingReconciler` through `mcl_om_singleton:child_spec/2`: the node whose guard holds the global name runs the pass, and a standby takes over when that node goes. A NODE WITHOUT DISTRIBUTION — the standalone release — runs it exactly as today. ## The operator rule this makes real A store that holds data refuses **every** join, including a join to a cluster that already exists (reckon-db#2): the persisted-membership guard cannot tell a new cluster from an existing one, and a join resets the joiner's tree. So **the node whose store holds data must be up and connected before the empty nodes join it** — then it is elected coordinator (the election ranks data-holders first) and the others join it. If the empty nodes clustered first, that cluster serves an empty store forever. If both sides hold events, neither joins and both keep their history; merging two histories is an operator's decision. This is stated where the mode is read, and in the README the deploy is pointed at. ## A netsplit runs the reconcile on every connected partition `mcl_om_singleton` runs one copy per connected partition (that is how `global` behaves in a split). Each copy keeps its own `counts`: a side counts only the realm answers it received, so a crew is discharged only after the realm told that side `unknown_crew` `unknown_limit` times in a row. Both sides discharge on the same evidence, never on twice the evidence; the two discharges are the same evoq command, and reckon-db's version check settles the duplicate append (whether evoq retries the loser is unconfirmed, analysis A1). Neither copy can end a crew the realm still answers for, so the split needs no further guard; the PR states this and names no new check. ## Build and land - Built against **reckon_db 5.12.0** (hex), which carries the join guard (reckon-db#2). - **The land waits for reckon_db 5.12.1 on hex** (reckon-db#14: a new leader cannot answer `is_active` during activation, so a leadership transfer times out). The pin floor is raised to `~> 5.12.1` in a diff-only round once it is on hex, before the land. Supervisor: no service moves to cluster mode before 5.12.1. ## Done when - `MclKanban.Service.event_store/0` answers the mode from `:mcl_kanban, :store_mode`: a test sets `:cluster` and reads it back, and an invalid value is refused by name at boot. - In `:single` mode every dispatch lands as today (the existing suite). - In `:cluster` mode with the store not joined, a dispatch is refused with `{:error, :store_not_joined}` and writes nothing; with the join answered, the same dispatch lands. The health answer is the seam a test takes; the real one is `reckon_db_cluster:local_healthy/1`. - The crew reconciler is an `mcl_om_singleton` child of the service's supervisor: a test reads the child shape, and on a node without distribution one copy runs, a second guard starts no second copy, and it takes over when the holder goes. - The standalone release still boots in `:single` mode and migrates then starts. - `mix format --check-formatted`, credo, dialyzer and the full suite green; a mutant on each new guard is caught. - OTP 28; no test reaches an outside service, and no test starts a second node. Refs martha-ai/mcl-martha#1 Refs macula-services/mcl-kanban#11 Refs reckon-db-org/reckon-db#2 Refs reckon-db-org/reckon-db#14
Author
Member

One correction to Done-when 1, accepted at review (r=2): the single source of the mode is :guide_card_lifecycle, :store_mode, not :mcl_kanban, :store_mode. GuideCardLifecycle.Store.mode/0 reads it (default :single, refused by name when it is neither :single nor :cluster), and both MclKanban.Service.event_store/0 and MclKanban.Supervisor.children/0 read that one function, so the store's mode and the tree's shape cannot disagree. The behaviour Done-when 1 asks for is unchanged; only the key it names is.

One correction to Done-when 1, accepted at review (r=2): the single source of the mode is `:guide_card_lifecycle, :store_mode`, not `:mcl_kanban, :store_mode`. `GuideCardLifecycle.Store.mode/0` reads it (default `:single`, refused by name when it is neither `:single` nor `:cluster`), and both `MclKanban.Service.event_store/0` and `MclKanban.Supervisor.children/0` read that one function, so the store's mode and the tree's shape cannot disagree. The behaviour Done-when 1 asks for is unchanged; only the key it names is.
Author
Member

Landed on main at 7687787b; PR 15 merged. Main-push runs 6942 (c4-model) and 6943 (gates + advisories) green — 6943 after one rerun of the gates job on a flake since filed as #17; the retry passed.

Done-when, line by line:

  • The mode. GuideCardLifecycle.Store.mode/0 reads :guide_card_lifecycle, :store_mode (the single source; this line named :mcl_kanban and the correction was accepted at review), default :single, refused by name when it is neither :single nor :cluster; MclKanban.Service.event_store/0 and MclKanban.Supervisor.children/0 both read it. store_gate_test.exs sets :cluster and reads it back, and pins the named refusal.
  • :single dispatches as today. The existing suite is the proof; the gate never asks the cluster module in :single.
  • :cluster before the join. A dispatch answers {:error, :store_not_joined} and writes nothing (the test reads its own stream and finds nothing); with joined? answered the same dispatch lands. MCL_STORE_MODE carries the mode for the standalone release.
  • The reconciler. children/0 gives the mcl_om_singleton child in :cluster and the plain child in :single (the default, where each node holds its own store — #11's reason); singleton_test.exs pins both shapes, and on a node without distribution one copy runs, a second guard starts no second copy, and it takes over when the holder goes.
  • The standalone release migrates then starts in :single (and again with MCL_STORE_MODE=cluster on a lone node); data stays at the root with no subdir.
  • Gates. mix format --check-formatted, credo, dialyzer and the full suite (242/28/22/70/37) green on the landed tip; mutants caught on each new guard: the gate never refusing; :single asking the cluster module; no mode validation; the tree fixed to :cluster; the tree never wrapping the reconciler.
  • OTP 28; no test reaches an outside service and none starts a second node.

Floor as landed: reckon_db ~> 5.12.1 and evoq ~> 1.32 in both/all three apps.

Landed on main at 7687787b; PR 15 merged. Main-push runs 6942 (c4-model) and 6943 (gates + advisories) green — 6943 after one rerun of the gates job on a flake since filed as #17; the retry passed. Done-when, line by line: - **The mode.** `GuideCardLifecycle.Store.mode/0` reads `:guide_card_lifecycle, :store_mode` (the single source; this line named `:mcl_kanban` and the correction was accepted at review), default `:single`, refused by name when it is neither `:single` nor `:cluster`; `MclKanban.Service.event_store/0` and `MclKanban.Supervisor.children/0` both read it. `store_gate_test.exs` sets `:cluster` and reads it back, and pins the named refusal. - **`:single` dispatches as today.** The existing suite is the proof; the gate never asks the cluster module in `:single`. - **`:cluster` before the join.** A dispatch answers `{:error, :store_not_joined}` and writes nothing (the test reads its own stream and finds nothing); with `joined?` answered the same dispatch lands. `MCL_STORE_MODE` carries the mode for the standalone release. - **The reconciler.** `children/0` gives the `mcl_om_singleton` child in `:cluster` and the plain child in `:single` (the default, where each node holds its own store — #11's reason); `singleton_test.exs` pins both shapes, and on a node without distribution one copy runs, a second guard starts no second copy, and it takes over when the holder goes. - **The standalone release** migrates then starts in `:single` (and again with `MCL_STORE_MODE=cluster` on a lone node); data stays at the root with no subdir. - **Gates.** `mix format --check-formatted`, credo, dialyzer and the full suite (242/28/22/70/37) green on the landed tip; mutants caught on each new guard: the gate never refusing; `:single` asking the cluster module; no mode validation; the tree fixed to `:cluster`; the tree never wrapping the reconciler. - **OTP 28;** no test reaches an outside service and none starts a second node. Floor as landed: `reckon_db ~> 5.12.1` and `evoq ~> 1.32` in both/all three apps.
juno closed this issue 2026-12-02 14:16:22 +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-kanban#14
No description provided.