#4 PR 7: runtime and test parity with the Erlang twin (health socket, cookie, LiveView, supervisor, data dir) #22

Closed
mercurius wants to merge 0 commits from mercurius/4-pr7-runtime-parity into main
Member

Purpose (parity): the Phoenix twin runs and is tested like mcl-bookclub (Erlang, the leading implementation): Done-when 3 of #4, row group A of the parity check on main 6bee0640.

Refs macula-services/mcl-bookclub-phoenix#4

Supervisor ruling 2026-12-01: "A goes ahead as PR 7" (under the alignment ruling: "wherever Phoenix differs from mcl-bookclub in layout, slice names, app boundaries, supervision or test coverage, Erlang's shape wins, in idiomatic Elixir").

Row Erlang This PR
LiveView mount/click — (the admin is static there) admin_live_store_test.exs: live/2 mounts it, each task's own form is submitted with render_submit; forms get ids
Health on a Unix socket config/sys.config.src:13-15, scripts/health.sh, test :343 config/runtime.exs health_socket, Containerfile mkdir /run/mcl + HEALTHCHECK on the socket, scripts/health.sh, health_socket_test.exs (a real GET on the running node's socket)
Cookie made when absent scripts/start.sh:13-24, test :385 rel/env.sh.eex, release_cookie_test.exs
Supervisor starts/stops service_tests :107 supervisor_test.exs
Data dir default in agreement service_tests :241 data_dir_default_test.exs (every literal; a mutant in the "" branch survives a contains check)

lazy_html (test only, needed by LiveViewTest) is built from source, with lexbor's clone rewritten to macula-pub/lexbor, as macula-realm#19 does: no github.com in a clean build.

Local gates (host00): format, compile --warnings-as-errors, credo --strict, test (276 tests, 0 failures), and dialyzer all pass.

Purpose (parity): the Phoenix twin runs and is tested like mcl-bookclub (Erlang, the leading implementation): Done-when 3 of #4, row group A of the parity check on main 6bee0640. Refs macula-services/mcl-bookclub-phoenix#4 Supervisor ruling 2026-12-01: "A goes ahead as PR 7" (under the alignment ruling: "wherever Phoenix differs from mcl-bookclub in layout, slice names, app boundaries, supervision or test coverage, Erlang's shape wins, in idiomatic Elixir"). | Row | Erlang | This PR | |---|---|---| | LiveView mount/click | — (the admin is static there) | `admin_live_store_test.exs`: `live/2` mounts it, each task's own form is submitted with `render_submit`; forms get ids | | Health on a Unix socket | `config/sys.config.src:13-15`, `scripts/health.sh`, test :343 | `config/runtime.exs` `health_socket`, Containerfile mkdir `/run/mcl` + HEALTHCHECK on the socket, `scripts/health.sh`, `health_socket_test.exs` (a real GET on the running node's socket) | | Cookie made when absent | `scripts/start.sh:13-24`, test :385 | `rel/env.sh.eex`, `release_cookie_test.exs` | | Supervisor starts/stops | service_tests :107 | `supervisor_test.exs` | | Data dir default in agreement | service_tests :241 | `data_dir_default_test.exs` (every literal; a mutant in the `""` branch survives a contains check) | `lazy_html` (test only, needed by LiveViewTest) is built from source, with lexbor's clone rewritten to macula-pub/lexbor, as macula-realm#19 does: no github.com in a clean build. Local gates (host00): format, compile --warnings-as-errors, credo --strict, test (276 tests, 0 failures), and dialyzer all pass.
The store test called AdminLive.handle_event/3 by hand on a made-up socket and
fetched the page disconnected. It now mounts the console connected
(Phoenix.LiveViewTest live/2) and submits each task's form, hidden task id
included, so the template, the form names and the event are tested together.
The forms get ids (task-<id>, lookup) to be addressable.

LiveViewTest parses pages with lazy_html (test only). Like macula-realm#19 it
is built from source, and git rewrites lexbor's GitHub URL to the forge copy
macula-pub/lexbor, so a clean build touches no github.com.
mcl_om's health_socket replaces health_port (config/runtime.exs): the release
serves /health on /run/mcl/health.sock and runs no TCP health listener, so no
health port is bound on the host. A dev or test boot keeps its socket under
its data dir. The image makes /run/mcl (owned by app), its HEALTHCHECK curls
the socket, and MCL_HEALTH_PORT and EXPOSE 8454 go. scripts/health.sh is the
Erlang twin's, named for this container (0 healthy, 1 unhealthy, 2
unreachable). The architecture README and C4 boxes say the same.

Tested for real: a GET /health on the running test node's socket answers, and
ranch's address for the listener is that socket. The shipped half is read from
the files, as the twin's health_is_served_on_a_unix_socket_only_test does.
rel/env.sh.eex refused to start without MCL_COOKIE. As in the twin's
scripts/start.sh:13-24: a given MCL_COOKIE wins; unset, the cookie is
MCL_COOKIE_FILE (default /etc/mcl/secrets/erlang.cookie, the secrets volume
beside the node key), made on first start from 32 random bytes through a temp
file and mv, and kept. An empty file is replaced; no random bytes means no
start and no empty file. No shipped file carries a cookie, and a self-hoster
gets one without a step.

Tested as the twin tests it: env.sh is sourced with the release stood in for by
printing RELEASE_COOKIE.
supervisor_test: the facade supervisor is the application's top process (what
mcl_om:boot/1 starts), so the application is stopped and started again around
it: it goes down, comes back as a new process, and has no children, as the
twin's supervisor_starts_and_stops_test. The admin is the web app's one child,
the Phoenix endpoint (the twin's one child is its admin listener).

data_dir_default_test: "/tmp/mcl_bookclub" is written in the facade's
event_store/0, both division stores and config/runtime.exs. The facade's is
asked with MCL_DATA_DIR cleared; the divisions' are private, so each file's
every /tmp/mcl_bookclub literal must be the default. Every one, not just one:
a stale copy in the "" case beside a right nil case survived a
contains-the-string check (and survives the twin's).
#4 PR 7: CHANGELOG
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 3s
c4 model / c4-model (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 6m6s
6894fca975
#4 PR 7 review: no committed test temp dirs; an empty cookie file and an empty MCL_DATA_DIR are each pinned; the Host disk row names the cookie
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 3s
c4 model / c4-model (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 9m28s
9df1471191
- apps/mcl_bookclub_phoenix/tmp/ held ReleaseCookieTest's tmp_dir output (two
  generated cookies and the od stub): removed, and /apps/*/tmp/ is ignored
  (ExUnit's tmp_dir lands under the app, not the root /tmp/).
- rel/env.sh.eex's `[ -n "$MCL_COOKIE" ]` guard was pinned by no case: a file
  holding only a newline passes -s and reads back "", and an empty
  RELEASE_COOKIE falls back to the image's releases/COOKIE. A case now writes
  "\n" and expects no start, naming the file.
- data_dir_default_test asked the facade only with MCL_DATA_DIR unset, so a
  stale "" branch in service.ex survived; it is asked with "" too.
- architecture/README.md's Host disk row names the cookie under
  /etc/mcl/secrets.
Merge remote-tracking branch 'origin/main' into mercurius/4-pr7-runtime-parity
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 2s
c4 model / c4-model (pull_request) Successful in 0s
ci / guard-1 (pull_request) Successful in 6s
ci / guard (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 6m35s
ci / Release (forge, v* tag) (pull_request) Has been skipped
c4 model / c4-model-1 (push) Successful in 2s
c4 model / c4-model (push) Successful in 0s
ci / guard-1 (push) Successful in 5s
ci / guard (push) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (push) Successful in 6m38s
ci / Release (forge, v* tag) (push) Has been skipped
c6edff2d80
Member

Landed by fast-forward: main is c6edff2d80 (from a9eddab3). This repository does not allow the manually-merged style, so the PR is closed by hand.

Landed by fast-forward: main is c6edff2d80b674ae5232dada20f8cfcfc33d953e (from a9eddab3). This repository does not allow the manually-merged style, so the PR is closed by hand.
terra closed this pull request 2026-12-01 16:25:19 +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 / guard-1 (pull_request) Successful in 6s
ci / guard (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 6m35s
ci / Release (forge, v* tag) (pull_request) Has been skipped
c4 model / c4-model-1 (push) Successful in 2s
c4 model / c4-model (push) Successful in 0s
ci / guard-1 (push) Successful in 5s
ci / guard (push) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (push) Successful in 6m38s
ci / Release (forge, v* tag) (push) Has been skipped

Pull request closed

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