Parity PR 3b: desks implement :evoq_command_handler (#4) #14

Closed
mercurius wants to merge 0 commits from mercurius/4-pr3b-evoq-command-handler into main
Member

Purpose (feature): every phoenix desk declares evoq's :evoq_command_handler behaviour (evoq 1.31.1), as mcl-bookclub's do (macula-services/mcl-bookclub#4, PASS). 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. This is PR 3b of #4. It was stacked on PR 3 (#13), which has landed (main cad2eb39), so its base is now main.

Refs #4, reckon-db-org/evoq#3

What changes (in commit order)

  1. 0e345de, adoption.
    • 9 desks:
      • @behaviour :evoq_command_handler, with @impl on command_module/0 and handle/2; the rule is unchanged.
      • The handle_from_map/2 glue is gone.
      • dispatch/1 takes the BUILT command and is one call to :evoq_command_handler.dispatch/3, with timestamp metadata and the same store options. This closes §B's 9 "dispatch shape" rows.
      • The library validates before dispatch.
    • 4 aggregates: command_handlers/0, keyed by each command's command_type(), never the Elixir module name. execute/2 keeps its lifecycle guard, then calls :evoq_command_handler.route/3.
    • Tests: the archive, initiate and plan_party store tests build their command before dispatching.
    • Pin: host_bookclub {:evoq, "~> 1.31.1"}; no other app's pin changes.
  2. 5805cec, test/command_handlers_test.exs: :evoq_command_handler.check_handlers/1 asserts :ok for each of the 4 aggregates.
  3. c68681e, a §B row 1 one-liner: InitiateBookclubV1.from_map/1 no longer passes a stray club_name.

Behaviour notes (as in mcl-bookclub#4)

  • An unknown command type on a closed stream now gets the guard's error, not :unknown_command, because the guard runs first.
  • from_map/1 is preferred over new/1 when it is exported.

Checks (msi00, CI image @sha256:8219e637…, at this tip c68681e, evoq 1.31.1 from hex.pm)

  • deps, format, compile --warnings-as-errors, credo --strict, dialyzer: all rc 0
  • mix test: host_bookclub 169, project 7, query 11, phoenix 18, web 7; 0 failures

Mutants, each killed:

  • the wrong command_module/0: CommandHandlersTest
  • a dropped command_handlers/0 entry: 3 ProcureBookStoreTest cases
  • a removed member guard: "an unregistered member refuses every command"
  • a desk skipping the library's validate: "a rejected stream id never touches the store"
Purpose (feature): every phoenix desk declares evoq's `:evoq_command_handler` behaviour (evoq 1.31.1), as mcl-bookclub's do (macula-services/mcl-bookclub#4, PASS). 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. This is PR 3b of #4. It was stacked on PR 3 (#13), which has landed (main cad2eb39), so its base is now main. Refs #4, reckon-db-org/evoq#3 ## What changes (in commit order) 1. **0e345de, adoption.** - **9 desks:** - `@behaviour :evoq_command_handler`, with `@impl` on `command_module/0` and `handle/2`; the rule is unchanged. - The `handle_from_map/2` glue is gone. - `dispatch/1` takes the BUILT command and is one call to `:evoq_command_handler.dispatch/3`, with timestamp metadata and the same store options. This closes §B's 9 "dispatch shape" rows. - The library validates before dispatch. - **4 aggregates:** `command_handlers/0`, keyed by each command's `command_type()`, never the Elixir module name. `execute/2` keeps its lifecycle guard, then calls `:evoq_command_handler.route/3`. - **Tests:** the archive, initiate and plan_party store tests build their command before dispatching. - **Pin:** host_bookclub `{:evoq, "~> 1.31.1"}`; no other app's pin changes. 2. **5805cec, `test/command_handlers_test.exs`:** `:evoq_command_handler.check_handlers/1` asserts `:ok` for each of the 4 aggregates. 3. **c68681e, a §B row 1 one-liner:** `InitiateBookclubV1.from_map/1` no longer passes a stray `club_name`. ## Behaviour notes (as in mcl-bookclub#4) - An unknown command type on a closed stream now gets the guard's error, not `:unknown_command`, because the guard runs first. - `from_map/1` is preferred over `new/1` when it is exported. ## Checks (msi00, CI image @sha256:8219e637…, at this tip c68681e, evoq 1.31.1 from hex.pm) - deps, format, compile `--warnings-as-errors`, credo `--strict`, dialyzer: all rc 0 - mix test: host_bookclub 169, project 7, query 11, phoenix 18, web 7; 0 failures Mutants, each killed: - the wrong `command_module/0`: CommandHandlersTest - a dropped `command_handlers/0` entry: 3 ProcureBookStoreTest cases - a removed member guard: "an unregistered member refuses every command" - a desk skipping the library's validate: "a rejected stream id never touches the store"
evoq 1.31.1 holds what every desk repeated: building the typed command
from the payload, validating before dispatch, and building the
evoq command. Each maybe_ desk now names its command module and keeps
its rule in handle/2; dispatch/1 takes the built command and stamps the
timestamp metadata, as mcl-bookclub's desks do. Each aggregate keeps its
lifecycle guard in execute/2 and routes the rest through
command_handlers/0. The store cases dispatch built commands.
One case per aggregate: :evoq_command_handler.check_handlers/1 finds
each desk loadable, a command handler, and filed under its command
module's command_type/0.
initiate_bookclub_v1: from_map/1 passes no stray club_name
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 4s
c4 model / c4-model (pull_request) Successful in 0s
c68681e9e1
The command has no club_name field; new/1 ignored the key. A
copy-paste from the member and book commands.
mercurius changed target branch from mercurius/4-pr3-entry-points to main 2026-12-01 07:40:31 +00:00
host_bookclub: evoq ~> 1.31 and >= 1.31.1, every later 1.x allowed
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 4s
c4 model / c4-model (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 6m29s
c4 model / c4-model-1 (push) Successful in 5s
c4 model / c4-model (push) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (push) Successful in 7m1s
ac1fd97cb7
Member

Landed by fast-forward: main is ac1fd97cb7 (from cad2eb39), PASS r=1, CI 6191, 6192. This repository does not allow the manually-merged style, so the PR is closed by hand.

Landed by fast-forward: main is ac1fd97cb7358841d2be3bf1e6a995374557da10 (from cad2eb39), PASS r=1, CI 6191, 6192. This repository does not allow the manually-merged style, so the PR is closed by hand.
terra closed this pull request 2026-12-01 08:02:34 +00:00
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 4s
c4 model / c4-model (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 6m29s
c4 model / c4-model-1 (push) Successful in 5s
c4 model / c4-model (push) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (push) Successful in 7m1s

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!14
No description provided.