Desks implement evoq_command_handler (evoq 1.31.1) #4

Manually merged
terra merged 4 commits from mercurius/4-evoq-command-handler into main 2026-12-01 07:37:15 +00:00
Member

Purpose (alignment): every mcl-bookclub desk declares evoq's evoq_command_handler behaviour, so the rule, the wiring and the dispatch read the same in every slice and a miswired desk fails a test instead of its first command.

Refs reckon-db-org/evoq#3, macula-services/mcl-bookclub-phoenix#4 (step 4 of that package).

What changes

  • rebar.config: {evoq, ">= 1.31.1 and < 2.0.0"}. 1.31.1 is the first release on hex.pm that carries the behaviour. The repo's existing constraint style is kept.
  • The 9 maybe_* desks:
    • -behaviour(evoq_command_handler), with command_module/0.
    • handle/2 is unchanged.
    • The handle_from_map/2 and handled/2 glue is gone, because evoq_command_handler:execute/3 builds the typed command.
    • dispatch/1 is one call to evoq_command_handler:dispatch/3. It still validates before dispatch: the library runs validate/1 and returns its refusal without reaching the router. It still stamps the timestamp metadata and keeps the same store options.
  • The 4 aggregates gain command_handlers/0, keyed by each command module's command_type/0. execute/2 keeps the lifecycle guard, then calls evoq_command_handler:route/3.
  • test/command_handlers_tests.erl: evoq_command_handler:check_handlers/1, one test per aggregate.
  • CHANGELOG, Unreleased.

Behaviour notes

  • A command type an aggregate does not know, sent to an archived, unregistered, retired or finished stream, now gets the lifecycle guard's error instead of unknown_command. The guard runs first, as in the evoq#3 design.
  • The typed command is now built with from_map/1, because evoq prefers it when the command module exports it. All 9 from_map/1 only pass their fields to new/1, so behaviour is unchanged.

Proof (msi00, CI image macula-ci-otp@sha256:dd2ba6eb…, OTP 28.4.3)

  • Tip b745505, evoq 1.31.1 from hex.pm ({vsn,"1.31.1"} in _build): rebar3 lint rc 0, rebar3 eunit rc 0 (all 125 tests passed), rebar3 dialyzer rc 0.
  • Mutants, each killed:
    • maybe_plan_party:command_module/0 returns the wrong module: killed by command_handlers_tests.
    • The retire_book_v1 entry is dropped from book_aggregate:command_handlers/0: killed by 3 procure_book_tests cases.
    • The unregistered guard is removed from member_aggregate: killed by register_member_tests:an_unregistered_member_refuses_every_command.
  • CI: forge Actions are off on this repo (CI not ported yet), so there is no forge run.
Purpose (alignment): every mcl-bookclub desk declares evoq's `evoq_command_handler` behaviour, so the rule, the wiring and the dispatch read the same in every slice and a miswired desk fails a test instead of its first command. Refs reckon-db-org/evoq#3, macula-services/mcl-bookclub-phoenix#4 (step 4 of that package). ## What changes - `rebar.config`: `{evoq, ">= 1.31.1 and < 2.0.0"}`. 1.31.1 is the first release on hex.pm that carries the behaviour. The repo's existing constraint style is kept. - The 9 `maybe_*` desks: - `-behaviour(evoq_command_handler)`, with `command_module/0`. - `handle/2` is unchanged. - The `handle_from_map/2` and `handled/2` glue is gone, because `evoq_command_handler:execute/3` builds the typed command. - `dispatch/1` is one call to `evoq_command_handler:dispatch/3`. It still validates before dispatch: the library runs `validate/1` and returns its refusal without reaching the router. It still stamps the timestamp metadata and keeps the same store options. - The 4 aggregates gain `command_handlers/0`, keyed by each command module's `command_type/0`. `execute/2` keeps the lifecycle guard, then calls `evoq_command_handler:route/3`. - `test/command_handlers_tests.erl`: `evoq_command_handler:check_handlers/1`, one test per aggregate. - CHANGELOG, Unreleased. ## Behaviour notes - A command type an aggregate does not know, sent to an archived, unregistered, retired or finished stream, now gets the lifecycle guard's error instead of `unknown_command`. The guard runs first, as in the evoq#3 design. - The typed command is now built with `from_map/1`, because evoq prefers it when the command module exports it. All 9 `from_map/1` only pass their fields to `new/1`, so behaviour is unchanged. ## Proof (msi00, CI image `macula-ci-otp@sha256:dd2ba6eb…`, OTP 28.4.3) - Tip b745505, evoq 1.31.1 from hex.pm (`{vsn,"1.31.1"}` in `_build`): `rebar3 lint` rc 0, `rebar3 eunit` rc 0 (all 125 tests passed), `rebar3 dialyzer` rc 0. - Mutants, each killed: - `maybe_plan_party:command_module/0` returns the wrong module: killed by `command_handlers_tests`. - The `retire_book_v1` entry is dropped from `book_aggregate:command_handlers/0`: killed by 3 `procure_book_tests` cases. - The unregistered guard is removed from `member_aggregate`: killed by `register_member_tests:an_unregistered_member_refuses_every_command`. - CI: forge Actions are off on this repo (CI not ported yet), so there is no forge run.
The nine maybe_ desks declare the evoq_command_handler behaviour and name
their command module; handle_from_map/2 goes, and dispatch/1 is one call to
evoq_command_handler:dispatch/3 with the same timestamp metadata and store
options. The four aggregates keep their lifecycle guard and route the rest.
evoq's floor moves to 1.31.1, where the behaviour lands.
One check_handlers/1 assertion per aggregate.
terra manually merged commit 5ae794c8c8 into main 2026-12-01 07:37:15 +00:00
Sign in to join this conversation.
No reviewers
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-bookclub!4
No description provided.