Parity PR 4: emitters, facts and CMD supervision into host_bookclub (#4) #15

Closed
mercurius wants to merge 0 commits from mercurius/4-pr4-emitters into main
Member

Purpose (feature): the mesh emitters, the facts module and the CMD supervision live in host_bookclub, as in mcl-bookclub (DECIDED 2026-12-01 "move them into host_bookclub...mcl-bookclub-phoenix should be as much aligned with mcl-bookclub as possible!"), and each emitter has a test that it publishes. This is PR 4 of #4, the "moved" rows of the alignment plan (comment c6881) and the emitter part of gap table H.4. The subscriber tests and the flake fix follow in PR 4b, stacked on this one.

Refs #4

What changes (in commit order)

  1. 3ab510c, the move.
    • Emitters and facts:
      • emit_member_registered_v1_to_mesh, emit_book_procured_v1_to_mesh and emit_book_retired_v1_to_mesh each get their own slice folder in host_bookclub, as in E.
      • MclBookclubPhoenix.Facts becomes HostBookclub.MclBookclubFacts (E mcl_bookclub_facts.erl), with the same topics, fields and wire rules, and @specs added.
      • The emitters' interested_in/0 reads XxxV1.event_type(), not a literal.
    • Supervision:
      • HostBookclub.Supervisor is its own module, like host_bookclub_sup.erl:16-46. It starts the policy and the 3 emitters, with E's restart limits of 5 in 10 s.
      • The facade's supervisor loses the emitters. Its admin is the Phoenix endpoint (PR 5).
    • Deps: host_bookclub takes mcl_om ~> 1.4 and macula ~> 16.0. The facade keeps macula for its capability handler.
    • The boundary test gets E's exemptions:
      • esqlite is nowhere in CMD.
      • macula and mcl_om appear only in the emit_*_to_mesh desks and the facts module.
      • A third test pins the exemption to exactly those four files, so it cannot quietly widen.
    • Moved test: facts_contract_test becomes mcl_bookclub_facts_test in host_bookclub.
    • Docs: README, architecture/README.md, c4_diagrams.py and the regenerated c4-components.svg, in the same commit, which is the repo's rule.
  2. 3d1bd83, tests.
    • emit_member_registered_v1_to_mesh_test: each of the 3 emitters publishes its fact after a real store dispatch. meck stands in for :macula and :mcl_om ([:passthrough, :no_link], as E and the repo's event_store_test do), so nothing leaves the VM. Both emitter tests check skip-on-replay and the event type each one listens for.
    • supervisor_test: the policy and the 3 emitters are the children.

Closes gap rows: §C emit_member_registered, emit_book_procured, emit_book_retired, facts, CMD supervision, facade supervisor (emitters out); §F emitters.

Notes for review

  • Start order: the emitters now start with host_bookclub, before the facade's mcl_om:boot/1, as in E. init/1 is trivial. A publish before the mesh is up returns {:error, _} from :mcl_om.mesh_handles/0, and evoq's retry owns redelivery. Their replay policy is :skip.
  • Starting macula in tests: host_bookclub's test runs now start the macula and mcl_om apps. macula_root starts local workers and empty supervisors only; dialing is mcl_om:boot/1, which only the facade calls.
  • Live subscribers in tests: at this tip the test env still starts the policy and the emitters, as main does today. PR 4b turns them off in the test env (start_subscribers), which is the flake fix.

Checks (msi00, CI image, at this tip 3d1bd83)

  • deps, format --check-formatted, compile --warnings-as-errors, credo --strict, dialyzer: all rc 0
  • mix test: host 182, prj 7, qry 11, fac 11, web 7; 0 failures. The 7 facts tests moved from fac to host.

Mutants killed:

  • An emitter publishes on another topic, or the facts module drops club_name: killed by "a registered member is published as a fact".
  • An emitter is dropped from the supervisor: killed by the supervisor test.
  • A policy file's comment names macula: killed by the boundary test.
Purpose (feature): the mesh emitters, the facts module and the CMD supervision live in host_bookclub, as in mcl-bookclub (DECIDED 2026-12-01 "move them into host_bookclub...mcl-bookclub-phoenix should be as much aligned with mcl-bookclub as possible!"), and each emitter has a test that it publishes. This is PR 4 of #4, the "moved" rows of the alignment plan (comment c6881) and the emitter part of gap table H.4. The subscriber tests and the flake fix follow in PR 4b, stacked on this one. Refs #4 ## What changes (in commit order) 1. **3ab510c, the move.** - **Emitters and facts:** - `emit_member_registered_v1_to_mesh`, `emit_book_procured_v1_to_mesh` and `emit_book_retired_v1_to_mesh` each get their own slice folder in host_bookclub, as in E. - `MclBookclubPhoenix.Facts` becomes `HostBookclub.MclBookclubFacts` (E `mcl_bookclub_facts.erl`), with the same topics, fields and wire rules, and `@spec`s added. - The emitters' `interested_in/0` reads `XxxV1.event_type()`, not a literal. - **Supervision:** - `HostBookclub.Supervisor` is its own module, like `host_bookclub_sup.erl:16-46`. It starts the policy and the 3 emitters, with E's restart limits of 5 in 10 s. - The facade's supervisor loses the emitters. Its admin is the Phoenix endpoint (PR 5). - **Deps:** host_bookclub takes `mcl_om ~> 1.4` and `macula ~> 16.0`. The facade keeps `macula` for its capability handler. - **The boundary test gets E's exemptions:** - `esqlite` is nowhere in CMD. - `macula` and `mcl_om` appear only in the `emit_*_to_mesh` desks and the facts module. - A third test pins the exemption to exactly those four files, so it cannot quietly widen. - **Moved test:** `facts_contract_test` becomes `mcl_bookclub_facts_test` in host_bookclub. - **Docs:** README, `architecture/README.md`, `c4_diagrams.py` and the regenerated `c4-components.svg`, in the same commit, which is the repo's rule. 2. **3d1bd83, tests.** - `emit_member_registered_v1_to_mesh_test`: each of the 3 emitters publishes its fact after a real store dispatch. meck stands in for `:macula` and `:mcl_om` (`[:passthrough, :no_link]`, as E and the repo's `event_store_test` do), so nothing leaves the VM. Both emitter tests check skip-on-replay and the event type each one listens for. - `supervisor_test`: the policy and the 3 emitters are the children. Closes gap rows: §C emit_member_registered, emit_book_procured, emit_book_retired, facts, CMD supervision, facade supervisor (emitters out); §F emitters. ## Notes for review - **Start order:** the emitters now start with host_bookclub, before the facade's `mcl_om:boot/1`, as in E. `init/1` is trivial. A publish before the mesh is up returns `{:error, _}` from `:mcl_om.mesh_handles/0`, and evoq's retry owns redelivery. Their replay policy is `:skip`. - **Starting macula in tests:** host_bookclub's test runs now start the `macula` and `mcl_om` apps. `macula_root` starts local workers and empty supervisors only; dialing is `mcl_om:boot/1`, which only the facade calls. - **Live subscribers in tests:** at this tip the test env still starts the policy and the emitters, as main does today. PR 4b turns them off in the test env (`start_subscribers`), which is the flake fix. ## Checks (msi00, CI image, at this tip 3d1bd83) - deps, `format --check-formatted`, compile `--warnings-as-errors`, credo `--strict`, dialyzer: all rc 0 - mix test: host 182, prj 7, qry 11, fac 11, web 7; 0 failures. The 7 facts tests moved from fac to host. Mutants killed: - An emitter publishes on another topic, or the facts module drops `club_name`: killed by "a registered member is published as a fact". - An emitter is dropped from the supervisor: killed by the supervisor test. - A policy file's comment names macula: killed by the boundary test.
As in mcl-bookclub: the three emit_*_to_mesh desks, each in its own
slice folder, and HostBookclub.MclBookclubFacts (was the facade's
MclBookclubPhoenix.Facts) live in the CMD division. HostBookclub.Supervisor
starts the policy and the three emitters, like host_bookclub_sup; the
facade's supervisor keeps no children. Same topics, fields and wire
rules; the emitters now read their event type from the event module.

host_bookclub takes mcl_om and macula. The division-boundary test gets
the Erlang twin's exemption: only the emitter desks and the facts
module may name the mesh SDK.
Test that each emitter publishes its fact, and the CMD supervision
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 2s
c4 model / c4-model (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 9m20s
c4 model / c4-model-1 (push) Successful in 3s
c4 model / c4-model (push) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (push) Successful in 13m1s
3d1bd83a3e
Against a real store and its evoq subscription, with meck standing in
for :mcl_om.mesh_handles/0 and :macula.publish/4, as the Erlang twin's
emit_member_registered_v1_to_mesh_tests does. The supervisor test pins
the four children HostBookclub.Supervisor starts.
Member

Landed by fast-forward: main is 3d1bd83a3e (from ac1fd97c), PASS r=1, CI 6215, 6216. This repository does not allow the manually-merged style, so the PR is closed by hand.

Landed by fast-forward: main is 3d1bd83a3e9f81267f8ffb239f71d176fa09ded3 (from ac1fd97c), PASS r=1, CI 6215, 6216. This repository does not allow the manually-merged style, so the PR is closed by hand.
terra closed this pull request 2026-12-01 09:14:01 +00:00
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 2s
c4 model / c4-model (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 9m20s
c4 model / c4-model-1 (push) Successful in 3s
c4 model / c4-model (push) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (push) Successful in 13m1s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 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-bookclub-phoenix!15
No description provided.