Wave 2: mail names its own store, org and data root, and boots only when it is not bundled (mcl-martha#1) #31

Closed
opened 2026-12-02 06:53:58 +00:00 by pluto · 1 comment
Member

Purpose (feature): mcl-mail stands in one mcl-martha bundle beside the other services without fighting them. It names its own store on its read-model replay, carries its own org, takes its data root from its own app env, and leaves the mcl_om boot to the bundle when it is bundled. Its own standalone release keeps working exactly as it does today.

Raf, 2026-12-02: "Run the whole path (Recommended)"
Raf, 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
Conflict table: consolidation analysis §2.1 C2, C6, C7, C8, C9; §2.3 "mail: C2 (the replay reads evoq.store_id) and C8"; A3 package 4.

What changes here

  1. C2, the replay names its own store. mailboxes_read_model_replay:store_id/0 read application:get_env(evoq, store_id), which is one app env per VM and is set differently by every service in the bundle. It now calls mcl_mail_store:id/0, the one place this service's store id is written. The nine CMD desks already pass store_id on every dispatch and are left as they are.

  2. C6, its own org. mcl_mail_service:info/0 carries org => <<"mcl-mail">>, which mcl-om#8's boot reads in place of mcl_om.org. The {org, ...} line stays in config/sys.config.src while the pinned mcl_om release is 1.8.0, whose boot reads only that env; a test holds the two equal so they cannot drift before the pin moves.

    C6 is NOT done by this package. The pinned hex release, mcl_om 1.8.0, ignores info/0's org and reads only the mcl_om app env; only mcl_om main (a2aa62e3, service_org/1) reads the key. So the key sits inert here, the config line must NOT be dropped until the pin is ~> 1.9, and C6 completes with that pin move, not with this change.

  3. C7, the bundled switch. {bundled, true} in mcl_mail's app env makes mcl_mail_app:start/2 open the store and start the service supervisor without calling mcl_om:boot/1; the bundle's own app calls it with the list. Unset, which is every standalone release, keeps today's single call. For that to hold, mcl_mail_service:start/1 answers the running supervisor's pid when the app already started it, so the bundle's boot registers the service instead of failing already_started.

  4. C8, its data root from its own app env. event_store/0 no longer reads the MCL_DATA_DIR OS variable. The root comes from {mcl_mail, data_root}, whose laptop default is in the module and which config/sys.config.src sets to ${MCL_DATA_DIR}; the store keeps its own subdirectory mcl_mail_store under it, so /data/mcl_mail_store is unchanged.

  5. C9, the release default in the app. The {mcl_mail, data_root} entry in config/sys.config.src is the only release-level setting this change moves; the rest is already in the app module or the .app.src.

  6. A3 package 4, side effects: none to wrap. Mail publishes to and subscribes to no mesh topic (its seven procedures are CALLs), and its read model is a local ETS table rebuilt from store events. Nothing here sends or publishes per node, so a second copy of the service on another node runs no doubled side effect and no singleton is added.

Done when

  1. The replay names its store from mcl_mail_store:id/0, and a test fails if mailboxes_read_model_replay.erl reads ev oq's store_id app env again.
  2. mcl_mail_service:info/0 carries org, and a test holds it equal to the org in config/sys.config.src. The key is inert on the pinned mcl_om 1.8.0 (see item 2); the test is what keeps the two from drifting before ~> 1.9 makes it live.
  3. A test with meck shows bundled true calls no mcl_om:boot/1 and bundled false calls it once, with the store opened before either.
  4. A test sets {mcl_mail, data_root} and reads it back through event_store/0, and no os:getenv is left in the service module.
  5. mcl_mail_service:start/1 answers the running supervisor's pid when one is already up (the bundle's boot path), asserted by a test.
  6. The whole eunit suite is green on OTP 28, and a standalone release boots with MCL_DATA_DIR=/data as before.
Purpose (feature): mcl-mail stands in one mcl-martha bundle beside the other services without fighting them. It names its own store on its read-model replay, carries its own org, takes its data root from its own app env, and leaves the mcl_om boot to the bundle when it is bundled. Its own standalone release keeps working exactly as it does today. Raf, 2026-12-02: "Run the whole path (Recommended)" Raf, 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 Conflict table: consolidation analysis §2.1 C2, C6, C7, C8, C9; §2.3 "mail: C2 (the replay reads evoq.store_id) and C8"; A3 package 4. ## What changes here 1. **C2, the replay names its own store.** `mailboxes_read_model_replay:store_id/0` read `application:get_env(evoq, store_id)`, which is one app env per VM and is set differently by every service in the bundle. It now calls `mcl_mail_store:id/0`, the one place this service's store id is written. The nine CMD desks already pass `store_id` on every dispatch and are left as they are. 2. **C6, its own org.** `mcl_mail_service:info/0` carries `org => <<"mcl-mail">>`, which mcl-om#8's boot reads in place of `mcl_om.org`. The `{org, ...}` line stays in `config/sys.config.src` while the pinned mcl_om release is 1.8.0, whose boot reads only that env; a test holds the two equal so they cannot drift before the pin moves. **C6 is NOT done by this package.** The pinned hex release, mcl_om 1.8.0, ignores `info/0`'s `org` and reads only the `mcl_om` app env; only mcl_om main (a2aa62e3, `service_org/1`) reads the key. So the key sits inert here, the config line must NOT be dropped until the pin is `~> 1.9`, and C6 completes with that pin move, not with this change. 3. **C7, the bundled switch.** `{bundled, true}` in mcl_mail's app env makes `mcl_mail_app:start/2` open the store and start the service supervisor without calling `mcl_om:boot/1`; the bundle's own app calls it with the list. Unset, which is every standalone release, keeps today's single call. For that to hold, `mcl_mail_service:start/1` answers the running supervisor's pid when the app already started it, so the bundle's boot registers the service instead of failing `already_started`. 4. **C8, its data root from its own app env.** `event_store/0` no longer reads the `MCL_DATA_DIR` OS variable. The root comes from `{mcl_mail, data_root}`, whose laptop default is in the module and which `config/sys.config.src` sets to `${MCL_DATA_DIR}`; the store keeps its own subdirectory `mcl_mail_store` under it, so `/data/mcl_mail_store` is unchanged. 5. **C9, the release default in the app.** The `{mcl_mail, data_root}` entry in `config/sys.config.src` is the only release-level setting this change moves; the rest is already in the app module or the `.app.src`. 6. **A3 package 4, side effects: none to wrap.** Mail publishes to and subscribes to no mesh topic (its seven procedures are CALLs), and its read model is a local ETS table rebuilt from store events. Nothing here sends or publishes per node, so a second copy of the service on another node runs no doubled side effect and no singleton is added. ## Done when 1. The replay names its store from `mcl_mail_store:id/0`, and a test fails if `mailboxes_read_model_replay.erl` reads `ev oq`'s `store_id` app env again. 2. `mcl_mail_service:info/0` carries `org`, and a test holds it equal to the org in `config/sys.config.src`. The key is inert on the pinned mcl_om 1.8.0 (see item 2); the test is what keeps the two from drifting before `~> 1.9` makes it live. 3. A test with meck shows `bundled` true calls no `mcl_om:boot/1` and `bundled` false calls it once, with the store opened before either. 4. A test sets `{mcl_mail, data_root}` and reads it back through `event_store/0`, and no `os:getenv` is left in the service module. 5. `mcl_mail_service:start/1` answers the running supervisor's pid when one is already up (the bundle's boot path), asserted by a test. 6. The whole eunit suite is green on OTP 28, and a standalone release boots with `MCL_DATA_DIR=/data` as before.
Author
Member

Landed. PR 34 merged into main at cb5f83359f (fast-forward, read back on the origin), on top of the wave-2 change already on main at 26ef0a8.

Done-when, checked on main at cb5f833:

  1. The replay names its store from mcl_mail_store:id/0, and the test that fails if it reads evoq's store_id app env again is in place (landed at 26ef0a8).
  2. info/0 carries org => <<"mcl-mail">>. The second half of this line is superseded by the 1.9 pin: while mcl_om 1.8 was pinned, a config org had to be held equal to the key because boot read only the env. With ~> 1.9 boot reads info/0 (service_org/1), the {org, ...} line is out of config/sys.config.src, and the test is now its mirror: the_config_names_no_org_test fails if a config org returns, and the_org_mcl_om_boots_with_comes_from_info_test clears the mcl_om env and requires this service's org from mcl_om's own decision function.
  3. The bundled switch is tested (landed at 26ef0a8): bundled true calls no mcl_om:boot/1, false calls it once, the store opened before either.
  4. {mcl_mail, data_root} is read back through event_store/0, and no os:getenv is left in the service module (landed at 26ef0a8).
  5. mcl_mail_service:start/1 answers the running supervisor's pid, asserted by a test (landed at 26ef0a8).
  6. The whole eunit suite is green on OTP 28.4.3, locally 158 tests with the new one, and on the forge: PR runs 6736 (c4-model) and 6737 (lint, jobs check and the tested lock) green, and the main push runs 6757 (test, build-and-push, the tested resolve, check; guard and attest skipped by their GitHub-only guards) and 6758 (c4-model, c4-model-1) green.

The release: rebar3 as prod release assembles with mcl_om-1.9.0 and macula-18.3.0 in it. Not booted here: the shipped config is {mesh, required}, so a boot would reach the live realm's stations and file a claim, which a package check must not do. The org path that this commit changed is proven by mcl_om's service_org/1 with the env cleared, plus checked_org on the answer.

A3 package 4, for the record: mail wraps nothing in mcl_om_singleton; it publishes and subscribes to no mesh topic, and its read model is one ETS table per node that every node must fill. The split note about what a double run would do is in mcl_mail_sup, and Jupiter corrected its opening to cite mcl-graph#15's ruling that a per-node learner is not a singleton case.

Landed. PR 34 merged into `main` at cb5f83359f1f0c965a7f6f8246f3a861b61830d1 (fast-forward, read back on the origin), on top of the wave-2 change already on main at 26ef0a8. Done-when, checked on `main` at cb5f833: 1. The replay names its store from `mcl_mail_store:id/0`, and the test that fails if it reads evoq's `store_id` app env again is in place (landed at 26ef0a8). 2. `info/0` carries `org => <<"mcl-mail">>`. **The second half of this line is superseded by the 1.9 pin**: while mcl_om 1.8 was pinned, a config org had to be held equal to the key because boot read only the env. With `~> 1.9` boot reads `info/0` (`service_org/1`), the `{org, ...}` line is out of `config/sys.config.src`, and the test is now its mirror: `the_config_names_no_org_test` fails if a config org returns, and `the_org_mcl_om_boots_with_comes_from_info_test` clears the `mcl_om` env and requires this service's org from mcl_om's own decision function. 3. The bundled switch is tested (landed at 26ef0a8): `bundled` true calls no `mcl_om:boot/1`, false calls it once, the store opened before either. 4. `{mcl_mail, data_root}` is read back through `event_store/0`, and no `os:getenv` is left in the service module (landed at 26ef0a8). 5. `mcl_mail_service:start/1` answers the running supervisor's pid, asserted by a test (landed at 26ef0a8). 6. The whole eunit suite is green on OTP 28.4.3, locally 158 tests with the new one, and on the forge: PR runs 6736 (c4-model) and 6737 (lint, jobs check and the tested lock) green, and the main push runs 6757 (test, build-and-push, the tested resolve, check; guard and attest skipped by their GitHub-only guards) and 6758 (c4-model, c4-model-1) green. The release: `rebar3 as prod release` assembles with mcl_om-1.9.0 and macula-18.3.0 in it. Not booted here: the shipped config is `{mesh, required}`, so a boot would reach the live realm's stations and file a claim, which a package check must not do. The org path that this commit changed is proven by mcl_om's `service_org/1` with the env cleared, plus `checked_org` on the answer. A3 package 4, for the record: mail wraps nothing in `mcl_om_singleton`; it publishes and subscribes to no mesh topic, and its read model is one ETS table per node that every node must fill. The split note about what a double run would do is in `mcl_mail_sup`, and Jupiter corrected its opening to cite mcl-graph#15's ruling that a per-node learner is not a singleton case.
pluto closed this issue 2026-12-02 10:06:27 +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#31
No description provided.