Wave 2: kanban names its own store, org, keys and data root, and boots under the bundle #12

Manually merged
terra merged 11 commits from juno/11-wave2-bundle into main 2026-12-02 10:13:34 +00:00
Member

Wave 2 of the one mcl-martha release: mcl-kanban stops assuming it is alone in a VM.

Refs macula-services/mcl-kanban#11
Refs martha-ai/mcl-martha#1
Refs macula-services/mcl-om#8

What changed

  • C2, the store is named on every call. GuideCardLifecycle.Store is the one place this board's store is named: id/0 is the single definition, dispatch/1 is the one way the board dispatches, and LiveState names the same store when it starts an aggregate. All 16 dispatch sites go through it. The :evoq, :store_id env stays set -- evoq still falls back to it for a projection replay that carries no store -- but no read of the board's own goes through it.
  • C6, own org and own keys. MclKanban.Service.org/0 is the org's one definition, carried in info/0 (where mcl_om reads it from a2aa62e3 on) and set into the shared :mcl_om, :org env, which is what mcl_om 1.8.0 reads. The four crew keys move to :guide_card_lifecycle, with their defaults in that app's application/0 env.
  • C7, one boot shape bundled or not. The app always starts the service's tree; :mcl_kanban, :bundled only skips the app's own mcl_om:boot. MclKanban.Service.start/1 is idempotent: it starts the named supervisor and answers {:error, {:already_started, pid}} with {:ok, pid}, so the race is settled by the name and not by a check-then-start.
  • C8, one shared data root, one subdir per service. The root is MCL_DATA_DIR, published as :mcl_kanban, :data_root; the subdir comes from :mcl_kanban, :data_subdir, whose default (empty) lives in the app module. Empty is no subdir, so the standalone release's files stay exactly where they always were. The node's identity key and health socket stay at the root, shared by every service in a bundle.
  • C9, defaults into the app. The release-only defaults moved out of config/runtime.exs into the app modules and app env, which is what a dependency can carry.
  • The read model migrates from the app's start too, so a release that runs no bin/start of ours still migrates. bin/migrate and bin/start are untouched.

Not in this PR

  • A3 package 4, the singleton wrap of CrewStandingReconciler. mcl_om_singleton exists only from mcl-om a2aa62e3 (mcl-om#8), which is in no tag: hex serves 1.8.0 and 1.9.0 waits on a Raf yes. The wrap lands as the last commit here once the pin moves to ~> 1.9.
  • The reckon-db store mode, which stays :single (it must not ship before reckon-db#2).
  • Elixir stays 1.18.

Proof

  • Full suite: 242 / 28 / 22 / 62 / 37 tests, 0 failures. mix format --check-formatted, mix credo and mix dialyzer clean on the same tree.
  • Mutants caught by name, each on a real run: Store.dispatch ignoring the store; Store.id/0 falling back to the env; each of the four crew reads slid back to :mcl_om; data_path/0 ignoring the subdir; bundled? hardcoded; start/1 without the already_started clause; the migration switch ignored in either direction.
  • A real standalone release was built and booted: it migrated, /health answered ok with "org":"mcl-kanban", and its data landed at the root with no subdir (kanban.sqlite3, mcl_kanban_store/, identity/identity.key) -- the backward-compatibility check.
Wave 2 of the one mcl-martha release: mcl-kanban stops assuming it is alone in a VM. Refs macula-services/mcl-kanban#11 Refs martha-ai/mcl-martha#1 Refs macula-services/mcl-om#8 ## What changed - **C2, the store is named on every call.** `GuideCardLifecycle.Store` is the one place this board's store is named: `id/0` is the single definition, `dispatch/1` is the one way the board dispatches, and `LiveState` names the same store when it starts an aggregate. All 16 dispatch sites go through it. The `:evoq, :store_id` env stays set -- evoq still falls back to it for a projection replay that carries no store -- but no read of the board's own goes through it. - **C6, own org and own keys.** `MclKanban.Service.org/0` is the org's one definition, carried in `info/0` (where mcl_om reads it from a2aa62e3 on) and set into the shared `:mcl_om, :org` env, which is what mcl_om 1.8.0 reads. The four crew keys move to `:guide_card_lifecycle`, with their defaults in that app's `application/0` env. - **C7, one boot shape bundled or not.** The app always starts the service's tree; `:mcl_kanban, :bundled` only skips the app's own `mcl_om:boot`. `MclKanban.Service.start/1` is idempotent: it starts the named supervisor and answers `{:error, {:already_started, pid}}` with `{:ok, pid}`, so the race is settled by the name and not by a check-then-start. - **C8, one shared data root, one subdir per service.** The root is `MCL_DATA_DIR`, published as `:mcl_kanban, :data_root`; the subdir comes from `:mcl_kanban, :data_subdir`, whose default (empty) lives in the app module. Empty is no subdir, so the standalone release's files stay exactly where they always were. The node's identity key and health socket stay at the root, shared by every service in a bundle. - **C9, defaults into the app.** The release-only defaults moved out of `config/runtime.exs` into the app modules and app env, which is what a dependency can carry. - **The read model migrates from the app's start too**, so a release that runs no `bin/start` of ours still migrates. `bin/migrate` and `bin/start` are untouched. ## Not in this PR - A3 package 4, the singleton wrap of `CrewStandingReconciler`. `mcl_om_singleton` exists only from mcl-om `a2aa62e3` (mcl-om#8), which is in no tag: hex serves 1.8.0 and 1.9.0 waits on a Raf yes. The wrap lands as the last commit here once the pin moves to `~> 1.9`. - The reckon-db store `mode`, which stays `:single` (it must not ship before reckon-db#2). - Elixir stays 1.18. ## Proof - Full suite: 242 / 28 / 22 / 62 / 37 tests, 0 failures. `mix format --check-formatted`, `mix credo` and `mix dialyzer` clean on the same tree. - Mutants caught by name, each on a real run: `Store.dispatch` ignoring the store; `Store.id/0` falling back to the env; each of the four crew reads slid back to `:mcl_om`; `data_path/0` ignoring the subdir; `bundled?` hardcoded; `start/1` without the `already_started` clause; the migration switch ignored in either direction. - A real standalone release was built and booted: it migrated, `/health` answered `ok` with `"org":"mcl-kanban"`, and its data landed at the root with no subdir (`kanban.sqlite3`, `mcl_kanban_store/`, `identity/identity.key`) -- the backward-compatibility check.
evoq falls back to the `:evoq, :store_id` app env on any dispatch that names no
store, and that env is one value per VM. That is fine while a VM hosts one
service and wrong the moment a release hosts several: the last service to set
it would decide where every other service's commands land (mcl-martha#1, C2).

GuideCardLifecycle.Store is the one place the board's store is named: id/0 is
the single definition, in the app module (C9); dispatch/1 is the one way this
board dispatches; LiveState names the same store when it starts an aggregate.
All 16 dispatch sites go through it, and MclKanban.Service.event_store/0 takes
its id from it, so the store opened and the store written to cannot disagree.

The `:evoq, :store_id` env stays set: evoq still falls back to it for a
projection replay that carries no store of its own, and
evoq_aggregate_registry:get_or_start/2 and evoq_aggregate:start_link/2 are
deprecated for exactly this reason. No read of the board's own goes through it.

apps/mcl_kanban/test/store_test.exs puts a foreign store in that env and proves
the dispatch, the live aggregate read and id/0 all still use the board's own.
One release hosts several services, so `:mcl_om` is shared by all of them and
cannot hold any one service's own values (mcl-martha#1, C5/C6).

The org is the service's own: MclKanban.Service.org/0 is the single
definition, carried in info/0, which is where mcl_om reads it in a release
that hosts several services (mcl-om#8). mcl_om 1.8.0 ignores the info key and
reads the shared env, so config/runtime.exs sets that env from the same
definition -- the standalone release boots exactly as before.

The four crew keys move to the board's own app env: realm_name,
crew_fact_publisher and crew_unknown_limit leave the `:mcl_om` block, and
realm_key is read by both apps from one config line, because mcl_om still
hands it to macula as `realm_trust`. Their defaults live in
:guide_card_lifecycle's application env (C9) and the modules read with
fetch_env!, so a missing key is loud rather than silently defaulted.

apps/guide_card_lifecycle/test/own_settings_test.exs puts a conflicting,
well-formed value for each key in `:mcl_om` and asserts the board's own answer.
The three tests that pinned a key under `:mcl_om` move that pin with the key.
C7 -- one shape, bundled or not. MclKanban.Application always starts this
service's tree; `:mcl_kanban, :bundled` only skips the app's own mcl_om:boot,
because a release hosting several services boots them all from one list and a
second boot from inside an app would fight it. MclKanban.Service.start/1 is
idempotent: it starts the NAMED supervisor and answers
`{:error, {:already_started, pid}}` with `{:ok, pid}`, so the caller that
arrives second gets the tree already running and the race is settled by the
name rather than by a check-then-start. The boot function is a seam, so the
test hands a spy and counts calls instead of reading a log.

C8 -- one shared data root, one subdir per service. The root is MCL_DATA_DIR,
published as `:mcl_kanban, :data_root`; the subdir comes from
`:mcl_kanban, :data_subdir`, whose default (empty) lives in the app module
(C9) and not in this repo's runtime.exs, so a release hosting several services
sets one per service and nothing overwrites it on the way. Empty is no subdir,
which keeps the standalone release's files exactly where they always were.
The node's identity key and its health socket stay at the root -- shared by
every service in a bundle -- and only the store dir and kanban.sqlite3 take
the subdir.

Mutants caught by name: bundled? hardcoded false; start/1 without the
already_started clause; data_path ignoring the subdir; and the four crew reads
slid back to `:mcl_om`.
bin/start runs bin/migrate before the release boots, and a release that hosts
several services runs no bin/start of ours -- so the read model would never
see a migration (mcl-kanban#11).

ProjectBoards.Application.start/2 now calls Release.migrate/0 after the Repo
is up, guarded by `:project_boards, :migrate_on_start` (default true). It is
called from start/2 with a `:ok =' match and the seam is not wrapped in
try/rescue, so a failed migration fails the boot rather than leaving a read
model nobody migrated.

Release.migrate/0 now works in both shapes by itself: the Repo is registered
under its own module name, so a standalone `bin/migrate` starts it through
with_repo/2, and the app's own start runs the migrations against the Repo that
is already up. bin/migrate and bin/start are untouched, so the standalone
release behaves exactly as before and its second migration is a no-op.

Mutants caught by name: the switch ignored in either direction.
format: the two new test files, as mix format wants them
Some checks failed
ci / guard (pull_request) Has been skipped
ci / guard-1 (pull_request) Has been skipped
ci / elixir in . (pull_request) Has been skipped
c4 model / c4-model-1 (pull_request) Successful in 3s
c4 model / c4-model (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Failing after 2s
ci / elixir in . (container) (pull_request) Successful in 7s
ci / Dependency advisories (pull_request) Successful in 0s
ci / image (amd64) (pull_request) Has been skipped
ci / attest (pull_request) Has been skipped
53898af767
The gates and advisories containers and both Containerfile stages read
from ghcr. The macula-pub batch (macula-io/macula-realm#36) moved the
other services to the forge's public images by digest with no pull
credentials; kanban was not in it and passed only because the runner's
docker still held the ghcr image.

The Containerfile's builder and the gates job are now one image by
digest, so what ships is what was tested. The advisories job also drops
its later build of the toolchain: macula-ci-ex118@sha256:942fc83e
answers `command -v python3` with /usr/bin/python3 (3.13.5), which is
all the scan needs.

Refs macula-services/mcl-kanban#13
deps: mcl_om ~> 1.9, and the crew reconcile runs on one node (#11)
Some checks failed
ci / guard (pull_request) Has been skipped
ci / guard-1 (pull_request) Has been skipped
ci / elixir in . (pull_request) Has been skipped
c4 model / c4-model (pull_request) Has been cancelled
c4 model / c4-model-1 (pull_request) Has been cancelled
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Has been cancelled
ci / Dependency advisories (pull_request) Has been cancelled
ci / image (amd64) (pull_request) Has been cancelled
ci / attest (pull_request) Has been cancelled
ci / elixir in . (container) (pull_request) Has been cancelled
da429e9b1a
mcl_om 1.9.0 carries mcl_om_singleton and reads a service's org from its
own info/0 (mcl-om#8), so the last step the 1.8 hex pin blocked is in:
the service's supervisor lists the 60 s crew reconcile through the
singleton, so the node whose guard holds the name runs the pass and a
standby takes over when that node goes.

A netsplit runs one copy per connected partition. Each copy keeps its own
counts, so each side counts only the realm answers it received, and 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,
and reckon-db's version check settles the duplicate append. Neither copy
can end a crew the realm still answers for. A node without distribution,
the standalone release, runs it exactly as before.

Refs macula-services/mcl-kanban#11
Refs macula-services/mcl-om#8
deps: mcl_om ~> 1.9, and the reconcile stays on every node (#11)
All checks were successful
ci / elixir in . (pull_request) Has been skipped
ci / guard (pull_request) Has been skipped
ci / guard-1 (pull_request) Has been skipped
c4 model / c4-model-1 (pull_request) Successful in 3s
c4 model / c4-model (pull_request) Successful in 0s
ci / elixir in . (container) (pull_request) Successful in 11s
ci / Dependency advisories (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 6m25s
ci / image (amd64) (pull_request) Has been skipped
ci / attest (pull_request) Has been skipped
a49e787669
mcl_om 1.9.0 reads a service's org from its own info/0 (mcl-om#8), which
is what C6 needs once one release hosts several services: the shared
:mcl_om, :org env is one value per VM. The standalone release still sets
that env, which 1.9.0 falls back to only when info/0 carries no org.

The crew reconcile is NOT wrapped in mcl_om_singleton, on review (Mars,
relaying Jupiter; same finding as scribe's wrap): its pass reads
CrewAggregate.current/0 -- LiveState.of/2 on THIS node's store -- and the
discharge it may run dispatches into that same store. The store is per
node (mode :single, A3 package 2), so a singleton would reconcile one
node's roster and leave every other node's crews unreconciled. The wrap
lands with kanban's A3 package 2, the clustered store; #11 records the
netsplit answer for that day.

Refs macula-services/mcl-kanban#11
Refs macula-services/mcl-om#8
comments: the :mcl_om org env is 1.9's fallback, not what 1.8.0 reads (#11)
Some checks failed
ci / guard (pull_request) Has been skipped
ci / guard-1 (pull_request) Has been skipped
ci / elixir in . (pull_request) Has been skipped
c4 model / c4-model (pull_request) Has been cancelled
c4 model / c4-model-1 (pull_request) Has been cancelled
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Has been cancelled
ci / Dependency advisories (pull_request) Has been cancelled
ci / image (amd64) (pull_request) Has been cancelled
ci / attest (pull_request) Has been cancelled
ci / elixir in . (container) (pull_request) Has been cancelled
8bffd384fa
comments: the third 1.8.0 mention, in the org test (#11)
All checks were successful
ci / guard (pull_request) Has been skipped
ci / guard-1 (pull_request) Has been skipped
ci / elixir in . (pull_request) Has been skipped
c4 model / c4-model-1 (pull_request) Successful in 2s
c4 model / c4-model (pull_request) Successful in 0s
ci / elixir in . (container) (pull_request) Successful in 9s
ci / Dependency advisories (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 8m44s
ci / image (amd64) (pull_request) Has been skipped
ci / attest (pull_request) Has been skipped
ci / guard (push) Has been skipped
ci / guard-1 (push) Has been skipped
ci / elixir in . (push) Has been skipped
c4 model / c4-model-1 (push) Successful in 7s
c4 model / c4-model (push) Successful in 0s
ci / elixir in . (container) (push) Successful in 11s
ci / Dependency advisories (push) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (push) Successful in 6m58s
ci / image (amd64) (push) Has been skipped
ci / attest (push) Has been skipped
88efed42eb
terra manually merged commit 88efed42eb into main 2026-12-02 10:13:34 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
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!12
No description provided.