wave 2: mcl-stations as a bundle member — org from info/0, a bundled switch, and no double boot #16

Closed
opened 2026-12-02 06:56:08 +00:00 by hygiea · 4 comments
Member

Purpose (feature): mcl-stations can be hosted inside the one clustered mcl-martha release beside the other services — it reads its own org from its own service module instead of another app's env, and it does not boot mcl_om a second time when the bundle already did — while its own standalone release keeps working exactly as it does today.

Raf DECIDED 2026-12-02 "Run the whole path (Recommended)", and 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."

Refs martha-ai/mcl-martha#1, macula-services/mcl-om#8.

This is the wave-2 per-service package for this repository (BRIEF 2026-12-02_wave2_common.md, analysis ANALYSIS_2026-12-01_mcl-martha-consolidation.md §2.3 "Every service" and A1/A3).

Done when

Each line below is one item of the common list, checked against THIS repository.

  1. store_id passed explicitly on every dispatch (C2) — not applicable here, and here is why. The service is storeless: rebar.config takes no evoq dependency ("No event store: the service exports no store_id/0"), mcl_stations_service exports none of the store callbacks, and the read model is an ETS table owned by station_store (CHANGELOG 0.7.0). There is no dispatch and no store to name. Nothing changes for this item.
  2. Its own org from its own service module (C6). mcl_stations_service:info/0 carries org => <<"mcl-stations">>, which is the key mcl_om:service_org/1 reads first (mcl-om#8), so in the bundle the service advertises under its own org rather than whatever the one shared mcl_om.org env says. The service keeps its own keys nowhere else: it has no crew keys and no other per-service setting that today comes from another app's env. Done when: a test asserts the org key's presence and that it equals info/0's name.
  3. No second mcl_om:boot when bundled (C7), in the one shape Mars ruled for the wave (mail#31's). mcl_stations_app:start/2 ALWAYS starts this service's supervisor, in both shapes, and the application's own process is that supervisor; {mcl_stations, [{bundled, true}]} in app env skips one thing only, this application's own mcl_om:boot(mcl_stations_service). Bundled, the hosting release's one mcl_om:boot([...]) list calls mcl_stations_service:start/1, which is now idempotent and answers {ok, Pid} with the running supervisor instead of {error, {already_started, _}}. Absent or false (the standalone release, and every existing deployment), this application boots exactly as today. Done when: tests prove both shapes without booting mcl_om — bundled starts the supervisor and does not call the boot, standalone starts it and calls the boot with mcl_stations_service, and start/1 answers with the running supervisor on a second call.
  4. Data subdir from app env under one shared root (C8) — not applicable, same reason as 1. The service writes nothing to disk: 0.7.0 removed MCL_DATA_DIR and the on-disk store, and the model refills from the DHT snapshot at every boot.
  5. Release-only defaults move into the app (C9). The org literal moves out of config/sys.config.src's mcl_om block and into info/0, so a dependency carries it. What stays in sys.config.src is not this service's: identity_key_path, health_socket, realm, realm_key and the macula crypto profile are mcl_om's settings, set once by the bundle (C5). The mcl_om.org env line stays for the 1.8.0 window, where mcl_om still reads only the env, with a comment naming that.
  6. A3 package 4 — the ingest_node_records singleton wrap: NOT DONE, by Mars's ruling (option a, 2026-12-02), because this service's code shows the wrap would break serving. What a double run does was recorded above and is harmless — but the harm here is the other direction, in the singleton itself:
    • list_stations answers from this node's own read model: station_read_model:fold/2 (station_read_model.erl:117) folds station_store's ETS table, which is protected and written only by its owner process (station_store.erl:57).
    • ingest_node_records is the only writer of that table, from the DHT snapshot and its subscriptions.
    • mcl_om_singleton runs the work on one node. Every other node would then keep an EMPTY table while still advertising Org/list_stations, so a caller routed there gets an empty directory — and its health is permanently {degraded, not_subscribed_to_records}, because ingest_node_records:subscribed/0 and links_up/0 catch noproc and answer false, which mcl_stations_service:health_of/3 reports under that name.
      So, unlike the other services' side effects, this one is per node by design. The reasoning lives in mcl_stations_sup's module doc so the next reader does not "fix" it back.
  7. Backward compatible. The standalone release keeps working unchanged: same boot path, same configuration, green on the mcl_om 1.8.0 pin it builds against today. Done when: rebar3 eunit is green, and the whole suite that runs today still runs.

Out of scope

  • The reckon-db store mode (A3 package 2): waits for reckon-db#2, a separate package.
  • mcl-martha release work and the LAN realm (package 7).
Purpose (feature): mcl-stations can be hosted inside the one clustered mcl-martha release beside the other services — it reads its own org from its own service module instead of another app's env, and it does not boot mcl_om a second time when the bundle already did — while its own standalone release keeps working exactly as it does today. Raf DECIDED 2026-12-02 "Run the whole path (Recommended)", and 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." Refs martha-ai/mcl-martha#1, macula-services/mcl-om#8. This is the wave-2 per-service package for this repository (BRIEF 2026-12-02_wave2_common.md, analysis `ANALYSIS_2026-12-01_mcl-martha-consolidation.md` §2.3 "Every service" and A1/A3). ## Done when Each line below is one item of the common list, checked against THIS repository. 1. **`store_id` passed explicitly on every dispatch (C2) — not applicable here, and here is why.** The service is storeless: `rebar.config` takes no evoq dependency ("No event store: the service exports no store_id/0"), `mcl_stations_service` exports none of the store callbacks, and the read model is an ETS table owned by `station_store` (CHANGELOG 0.7.0). There is no dispatch and no store to name. Nothing changes for this item. 2. **Its own org from its own service module (C6).** `mcl_stations_service:info/0` carries `org => <<"mcl-stations">>`, which is the key `mcl_om:service_org/1` reads first (mcl-om#8), so in the bundle the service advertises under its own org rather than whatever the one shared `mcl_om.org` env says. The service keeps its own keys nowhere else: it has no crew keys and no other per-service setting that today comes from another app's env. **Done when:** a test asserts the `org` key's presence and that it equals `info/0`'s `name`. 3. **No second `mcl_om:boot` when bundled (C7), in the one shape Mars ruled for the wave (mail#31's).** `mcl_stations_app:start/2` ALWAYS starts this service's supervisor, in both shapes, and the application's own process is that supervisor; `{mcl_stations, [{bundled, true}]}` in app env skips one thing only, this application's own `mcl_om:boot(mcl_stations_service)`. Bundled, the hosting release's one `mcl_om:boot([...])` list calls `mcl_stations_service:start/1`, which is now idempotent and answers `{ok, Pid}` with the running supervisor instead of `{error, {already_started, _}}`. Absent or false (the standalone release, and every existing deployment), this application boots exactly as today. **Done when:** tests prove both shapes without booting mcl_om — bundled starts the supervisor and does not call the boot, standalone starts it and calls the boot with `mcl_stations_service`, and `start/1` answers with the running supervisor on a second call. 4. **Data subdir from app env under one shared root (C8) — not applicable, same reason as 1.** The service writes nothing to disk: 0.7.0 removed `MCL_DATA_DIR` and the on-disk store, and the model refills from the DHT snapshot at every boot. 5. **Release-only defaults move into the app (C9).** The org literal moves out of `config/sys.config.src`'s `mcl_om` block and into `info/0`, so a dependency carries it. What stays in `sys.config.src` is not this service's: `identity_key_path`, `health_socket`, `realm`, `realm_key` and the macula crypto profile are mcl_om's settings, set once by the bundle (C5). The `mcl_om.org` env line stays for the 1.8.0 window, where mcl_om still reads only the env, with a comment naming that. 6. **A3 package 4 — the `ingest_node_records` singleton wrap: NOT DONE, by Mars's ruling (option a, 2026-12-02), because this service's code shows the wrap would break serving.** What a double run does was recorded above and is harmless — but the harm here is the other direction, in the singleton itself: - `list_stations` answers from this node's own read model: `station_read_model:fold/2` (`station_read_model.erl:117`) folds `station_store`'s ETS table, which is `protected` and written only by its owner process (`station_store.erl:57`). - `ingest_node_records` is the only writer of that table, from the DHT snapshot and its subscriptions. - `mcl_om_singleton` runs the work on one node. Every other node would then keep an EMPTY table while still advertising `Org/list_stations`, so a caller routed there gets an empty directory — and its health is permanently `{degraded, not_subscribed_to_records}`, because `ingest_node_records:subscribed/0` and `links_up/0` catch `noproc` and answer `false`, which `mcl_stations_service:health_of/3` reports under that name. So, unlike the other services' side effects, this one is per node by design. The reasoning lives in `mcl_stations_sup`'s module doc so the next reader does not "fix" it back. 7. **Backward compatible.** The standalone release keeps working unchanged: same boot path, same configuration, green on the mcl_om 1.8.0 pin it builds against today. **Done when:** `rebar3 eunit` is green, and the whole suite that runs today still runs. ## Out of scope - The reckon-db store `mode` (A3 package 2): waits for reckon-db#2, a separate package. - mcl-martha release work and the LAN realm (package 7).
Author
Member

Sequencing (Mars, 2026-12-02), and where the work stands.

This branch (PR 17) carries C7 only — the bundled switch: mcl_stations_app:start/2 reads {mcl_stations, [{bundled, true}]}, starts nothing when set, and calls mcl_om:boot(mcl_stations_service) exactly as before when absent. Three mutants each turn the matching test red.

Held for the last commit, because all four need mcl_om 1.9 and hex tops out at 1.8.0:

  • org in info/0 (C6);
  • the mcl_om.org literal leaving config/sys.config.src (C9);
  • dependency_floors_tests' mcl_om floor moved to 1.9.0, with the pin at ~> 1.9 and rebar.lock regenerated;
  • the ingest_node_records singleton wrap (A3 package 4).

Meanwhile the env literal stays where it is, which is what keeps the standalone release booting with an org on 1.8: 1.8 reads the org only from mcl_om's env, and info/0's key is inert there.

Sequencing (Mars, 2026-12-02), and where the work stands. This branch (PR 17) carries **C7 only** — the bundled switch: `mcl_stations_app:start/2` reads `{mcl_stations, [{bundled, true}]}`, starts nothing when set, and calls `mcl_om:boot(mcl_stations_service)` exactly as before when absent. Three mutants each turn the matching test red. Held for the last commit, because all four need mcl_om 1.9 and hex tops out at 1.8.0: - `org` in `info/0` (C6); - the `mcl_om.org` literal leaving `config/sys.config.src` (C9); - `dependency_floors_tests`' mcl_om floor moved to 1.9.0, with the pin at `~> 1.9` and `rebar.lock` regenerated; - the `ingest_node_records` singleton wrap (A3 package 4). Meanwhile the env literal stays where it is, which is what keeps the standalone release booting **with an org** on 1.8: 1.8 reads the org only from `mcl_om`'s env, and `info/0`'s key is inert there.
Author
Member

Correction to the last commit's contents, found while holding: rebar.lock is not part of it. The file is gitignored in this repository (.gitignore:2), and the tested resolve is filed by CI, not committed — so there is nothing for the branch to regenerate or carry. The last commit is: org in info/0 (C6); the mcl_om.org literal leaving config/sys.config.src (C9); the pin to ~> 1.9 with dependency_floors_tests' floor moved to 1.9.0; and the ingest_node_records singleton wrap.

Also checked while holding: mcl-om main (a8e35a1) leaves mcl_om_singleton's API as the wrap expects — child_spec/2, whereis/1 — and mcl-om#13 was CI only (publish-hex on the forge), so the v1.9.0 tag Venus is cutting carries the helper this package needs.

Correction to the last commit's contents, found while holding: **`rebar.lock` is not part of it.** The file is gitignored in this repository (`.gitignore:2`), and the tested resolve is filed by CI, not committed — so there is nothing for the branch to regenerate or carry. The last commit is: `org` in `info/0` (C6); the `mcl_om.org` literal leaving `config/sys.config.src` (C9); the pin to `~> 1.9` with `dependency_floors_tests`' floor moved to 1.9.0; and the `ingest_node_records` singleton wrap. Also checked while holding: mcl-om main (`a8e35a1`) leaves `mcl_om_singleton`'s API as the wrap expects — `child_spec/2`, `whereis/1` — and mcl-om#13 was CI only (publish-hex on the forge), so the v1.9.0 tag Venus is cutting carries the helper this package needs.
Author
Member

Ruling recorded: (a) — ingest_node_records is NOT wrapped in mcl_om_singleton (Mars, 2026-12-02, after the finding below came from this package's code).

The common list's package 4 assumes a side effect that is merely doubled. This one is the opposite: it is the per-node feeder of the read model that list_stations and health answer from, so making it one copy across a cluster is what breaks it.

  • list_stations answers from this node's read model: station_read_model:fold/2 (station_read_model.erl:117) folds station_store's ETS table, protected, written only by its owner process (station_store.erl:57).
  • ingest_node_records is the only writer of that table (DHT snapshot plus subscriptions).
  • A mcl_om_singleton runs the work on the holder only. Every other node would keep an empty table while still advertising Org/list_stations, so callers routed there get an empty directory, and health there would be permanently {degraded, not_subscribed_to_records}: subscribed/0 and links_up/0 catch noproc and answer false, and mcl_stations_service:health_of/3 reports exactly that.

The reasoning is now in mcl_stations_sup's module doc, beside the feeder, so a later reader does not "fix" it back; and the double run the common list asked about stays recorded as harmless.

Ruling recorded: **(a) — `ingest_node_records` is NOT wrapped in `mcl_om_singleton`** (Mars, 2026-12-02, after the finding below came from this package's code). The common list's package 4 assumes a side effect that is merely doubled. This one is the opposite: it is the per-node feeder of the read model that `list_stations` and health answer from, so making it one copy across a cluster is what breaks it. - `list_stations` answers from this node's read model: `station_read_model:fold/2` (`station_read_model.erl:117`) folds `station_store`'s ETS table, `protected`, written only by its owner process (`station_store.erl:57`). - `ingest_node_records` is the only writer of that table (DHT snapshot plus subscriptions). - A `mcl_om_singleton` runs the work on the holder only. Every other node would keep an empty table while still advertising `Org/list_stations`, so callers routed there get an empty directory, and health there would be permanently `{degraded, not_subscribed_to_records}`: `subscribed/0` and `links_up/0` catch `noproc` and answer `false`, and `mcl_stations_service:health_of/3` reports exactly that. The reasoning is now in `mcl_stations_sup`'s module doc, beside the feeder, so a later reader does not "fix" it back; and the double run the common list asked about stays recorded as harmless.
Author
Member

Landed and closed: the package's three commits are on main as 520a811 (12b164d the C7 switch in the one ruled shape, 23a8d56 the org from info/0 with the 1.9 pin, 520a811 the comment corrections), and the main push run is fully green — 6781 test.yml and 6780 c4-model, with job 27683 (the signer filing) finishing green after its runner picked it up.

Every item of the common list is either done or recorded as not applicable/not done with its evidence:

  • C7 — the bundled switch in mail#31's shape, plus the idempotent start/1.
  • C6 — org in info/0; C9 — the shared mcl_om.org literal gone, kept out by a test.
  • The pin is ~> 1.9 with the floor test at 1.9.0.
  • A3 package 4 — deliberately not done: ingest_node_records stays per node, with the code references and the health path recorded above and in mcl_stations_sup.
  • C2 and C8 — not applicable to this service (storeless).

Standalone release unchanged: the same boot path, the same configuration, as prod release assembles.

Landed and closed: the package's three commits are on `main` as `520a811` (`12b164d` the C7 switch in the one ruled shape, `23a8d56` the org from info/0 with the 1.9 pin, `520a811` the comment corrections), and the main push run is fully green — `6781` test.yml and `6780` c4-model, with job `27683` (the signer filing) finishing green after its runner picked it up. Every item of the common list is either done or recorded as not applicable/not done with its evidence: - C7 — the bundled switch in mail#31's shape, plus the idempotent `start/1`. - C6 — `org` in `info/0`; C9 — the shared `mcl_om.org` literal gone, kept out by a test. - The pin is `~> 1.9` with the floor test at 1.9.0. - A3 package 4 — deliberately not done: `ingest_node_records` stays per node, with the code references and the health path recorded above and in `mcl_stations_sup`. - C2 and C8 — not applicable to this service (storeless). Standalone release unchanged: the same boot path, the same configuration, `as prod release` assembles.
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-stations#16
No description provided.