store: the station read model moves from barrel_docdb to an ETS table #2

Closed
hygiea wants to merge 0 commits from hygiea/1-stations-ets into main
Member

Purpose (work): mcl-stations stops using RocksDB — its directory is served from one ETS table, and the service writes nothing to disk — so the RocksDB images can be deleted once every service is ported (macula-io/macula-ci-images#19, design §2).

DECIDED 2026-11-23 (Raf): "we don't use rocksDB anymore", then "Port them off, then delete (Recommended)".

What changes

  • station_store (new) owns one ETS set keyed by the signer's key id, and does EVERY write. A station's node_record and station_endpoint arrive independently and land in one row, so each write is a read-modify-write; one process doing it is what keeps one record type's fields from erasing the other's. The table is protected with read_concurrency, so station_read_model:fold/2 reads it directly, no call.
  • station_read_model keeps the pure projections (project_node_record/2, project_station_endpoint/2), the serving helpers and to_wire/1; its three writes are calls into the store, and open/1 and db/0 are gone.
  • A sweep drops a row once NEITHER of its records is live, on the same is_live/2 the readers use. Before, a lapsed row was only skipped at serve time and kept forever. sweep_now/0 lets a suite drive one.
  • No migration: the model is a cache of what the DHT holds, refilled from the snapshot at every boot, so the table lives and dies with its owner. MCL_DATA_DIR and data_dir/0 go; start/1 opens nothing, and the supervisor starts the store before the feeder.
  • barrel_docdb, the rocksdb overrides block in rebar.config and rocksdb_link_tests are removed. The images become the plain pair on the forge's own registry, by digest: macula-ci-otp builds, macula-pq-runtime runs; lint's job container is the builder with the org's read-only pull account (CI_IMAGE_PULL_USER / CI_IMAGE_PULL_TOKEN, the martha#63 form).
  • Docs: README, architecture/README.md and both C4 diagrams (regenerated from architecture/c4_diagrams.py, rendered and checked) lose barrel/rocksdb and gain station_store. Version 0.7.0, per the file's own convention: the CHANGELOG heading, the app.src vsn and info/0 move together, as commit 82bd80d did for 0.6.0.

Tests: the fixture starts and stops station_store instead of a temp dir; the two barrel-specific cases become the sweep's two verdicts (drops a row with both records lapsed, keeps one with either live); the service suite asserts the store-then-feeder child order and that a feeder restart costs no row, and its image-pin case moves to the plain pair. The corrupt-record case in list_stations_tests drives served/3 directly: nothing that writes the table can lay down a record that does not verify, and the guard stays for depth.

Proof on this tip (e4f31868, OTP 28.4.3 locally): rebar3 compile, rebar3 eunit (128 tests, all passed), rebar3 lint, rebar3 xref and rebar3 dialyzer all exit 0.

Not in this change, on the owner after it lands: drop /bulk0/mcl-stations:/data from beam03's compose and delete /bulk0/mcl-stations (50 GB, nothing to keep) once the new version is healthy. That is Raf's pin signature, through the Supervisor's menu.

Refs #1
Refs macula-io/macula-ci-images#19

The forge port (af56f92)

The whole CI moves to the forge (macula-io/martha#601, ci-images#19 step 1a), on macula-realm's landed pattern:

  • lint.yml and build-push.yml become one test.yml (guard, check, hand-lock, lock-arrives, advisories); plain-shell checkout, no marketplace action, timeout-minutes on every job that runs steps.
  • The shared gates are the ci-images-*.yml stand-ins in this directory (byte-identical to macula-realm's copies at the shas their headers name): a cross-repository call on the forge needs a public repository on the other side.
  • No registry push and no signing any more. The release image is the signer's, off CI, built from the resolve the tests ran on: hand-lock files <commit>.<sha256>.rebar.lock on the tested-locks release on a push to main, lock-arrives proves the hand-off on every PR. Until P6 gives this service a signer, this repository publishes no image and a box keeps the digest it already runs.
  • attest is gone: GitHub OIDC keyless has no forge equivalent, and realm left it GitHub-only.
  • The two guards whose subject changed are replaced, not dropped: the tested-resolve hand-off is pinned, and any ghcr.io, docker/* action, push: true or uses: actions/ in the files we author fails the suite (mutation-checked).

Proof: in the forge's own image on msi00 (macula-ci-otp@sha256:3e202cf7...), rebar3 lint && xref && eunit && dialyzer exit 0 with 129 tests passed -- exactly what test.yml's check job runs.

Before the first push to main: the tested-locks pre-release must exist on this repository (a lander creates it once, as macula-realm#3 did), or hand-lock goes red on main.

Purpose (work): mcl-stations stops using RocksDB — its directory is served from one ETS table, and the service writes nothing to disk — so the RocksDB images can be deleted once every service is ported (macula-io/macula-ci-images#19, design §2). DECIDED 2026-11-23 (Raf): "we don't use rocksDB anymore", then "Port them off, then delete (Recommended)". **What changes** - `station_store` (new) owns one ETS `set` keyed by the signer's key id, and does EVERY write. A station's `node_record` and `station_endpoint` arrive independently and land in one row, so each write is a read-modify-write; one process doing it is what keeps one record type's fields from erasing the other's. The table is `protected` with `read_concurrency`, so `station_read_model:fold/2` reads it directly, no call. - `station_read_model` keeps the pure projections (`project_node_record/2`, `project_station_endpoint/2`), the serving helpers and `to_wire/1`; its three writes are calls into the store, and `open/1` and `db/0` are gone. - A sweep drops a row once NEITHER of its records is live, on the same `is_live/2` the readers use. Before, a lapsed row was only skipped at serve time and kept forever. `sweep_now/0` lets a suite drive one. - **No migration**: the model is a cache of what the DHT holds, refilled from the snapshot at every boot, so the table lives and dies with its owner. `MCL_DATA_DIR` and `data_dir/0` go; `start/1` opens nothing, and the supervisor starts the store before the feeder. - `barrel_docdb`, the rocksdb `overrides` block in `rebar.config` and `rocksdb_link_tests` are removed. The images become the plain pair on the forge's own registry, by digest: `macula-ci-otp` builds, `macula-pq-runtime` runs; lint's job container is the builder with the org's read-only pull account (`CI_IMAGE_PULL_USER` / `CI_IMAGE_PULL_TOKEN`, the martha#63 form). - Docs: README, architecture/README.md and both C4 diagrams (regenerated from `architecture/c4_diagrams.py`, rendered and checked) lose barrel/rocksdb and gain `station_store`. Version 0.7.0, per the file's own convention: the CHANGELOG heading, the app.src vsn and `info/0` move together, as commit 82bd80d did for 0.6.0. **Tests**: the fixture starts and stops `station_store` instead of a temp dir; the two barrel-specific cases become the sweep's two verdicts (drops a row with both records lapsed, keeps one with either live); the service suite asserts the store-then-feeder child order and that a feeder restart costs no row, and its image-pin case moves to the plain pair. The corrupt-record case in `list_stations_tests` drives `served/3` directly: nothing that writes the table can lay down a record that does not verify, and the guard stays for depth. **Proof on this tip** (e4f31868, OTP 28.4.3 locally): `rebar3 compile`, `rebar3 eunit` (128 tests, all passed), `rebar3 lint`, `rebar3 xref` and `rebar3 dialyzer` all exit 0. **Not in this change, on the owner after it lands**: drop `/bulk0/mcl-stations:/data` from beam03's compose and delete `/bulk0/mcl-stations` (50 GB, nothing to keep) once the new version is healthy. That is Raf's pin signature, through the Supervisor's menu. Refs #1 Refs macula-io/macula-ci-images#19 ## The forge port (af56f92) The whole CI moves to the forge (macula-io/martha#601, ci-images#19 step 1a), on macula-realm's landed pattern: - `lint.yml` and `build-push.yml` become one `test.yml` (guard, check, hand-lock, lock-arrives, advisories); plain-shell checkout, no marketplace action, timeout-minutes on every job that runs steps. - The shared gates are the `ci-images-*.yml` stand-ins in this directory (byte-identical to macula-realm's copies at the shas their headers name): a cross-repository call on the forge needs a public repository on the other side. - **No registry push and no signing any more.** The release image is the signer's, off CI, built from the resolve the tests ran on: `hand-lock` files `<commit>.<sha256>.rebar.lock` on the `tested-locks` release on a push to main, `lock-arrives` proves the hand-off on every PR. Until P6 gives this service a signer, this repository publishes no image and a box keeps the digest it already runs. - `attest` is gone: GitHub OIDC keyless has no forge equivalent, and realm left it GitHub-only. - The two guards whose subject changed are replaced, not dropped: the tested-resolve hand-off is pinned, and any `ghcr.io`, `docker/*` action, `push: true` or `uses: actions/` in the files we author fails the suite (mutation-checked). Proof: in the forge's own image on msi00 (`macula-ci-otp@sha256:3e202cf7...`), `rebar3 lint && xref && eunit && dialyzer` exit 0 with 129 tests passed -- exactly what `test.yml`'s check job runs. **Before the first push to main:** the `tested-locks` pre-release must exist on this repository (a lander creates it once, as macula-realm#3 did), or `hand-lock` goes red on main.
mcl-stations no longer uses RocksDB (macula-io/macula-ci-images#19, design
§2). The read model is now one ETS `set`, keyed by the signer's key id, owned
by a new `station_store` process; `station_read_model` keeps the pure
projections and the serving helpers, and its three writes became calls into
the store. The shape of a row is unchanged, so `list_stations` serves exactly
what it served before.

Why an owner process rather than a bare table: a station's `node_record` and
`station_endpoint` arrive independently and land in one row, so every write
is a read-modify-write (read the row, clear the fields that type owns, write
the projection back). Two writers interleaving that would each write a row
read from before the other's, and one type's fields would vanish. The store
does every write in its own process, and the projection stays pure and
testable. The table is `protected` with `read_concurrency`, so readers --
`fold/2`, which every reply walks -- go straight to it with no call.

A sweep now drops a row once NEITHER of its records is live, on the same
`is_live/2` the readers use. Before, a lapsed row was only skipped at serve
time and kept forever, which is what made the on-disk model grow without
bound. `sweep_now/0` is exported so a suite drives a sweep instead of
sleeping for the interval.

No migration, because there is nothing to migrate: the model is a cache of
what the DHT holds, refilled from the snapshot at every boot. That is also why
the table lives and dies with its owner, `station_store` starts BEFORE the
feeder in the supervisor, and the service's `start/1` no longer opens
anything. `MCL_DATA_DIR` and `data_dir/0` are gone; the service writes
nothing to disk.

Removed with the store: the `barrel_docdb` dependency, the rocksdb
`overrides` block in rebar.config, and `rocksdb_link_tests`. The images become
the plain pair on the forge's own registry, pinned by digest --
`macula-ci-otp` builds, `macula-pq-runtime` runs, and lint's job container is
the builder with the org's read-only pull account (CI_IMAGE_PULL_USER /
CI_IMAGE_PULL_TOKEN). The container comment on why there is no volume says
what is now true: nothing is written at all.

Tests: the fixture starts and stops `station_store` instead of a temp dir;
the two barrel-specific cases are replaced by the sweep's two verdicts (drops
a row with both records lapsed, keeps one with either live); the service suite
asserts the store-then-feeder child order and that a feeder restart costs no
row, and its image-pin case moves to the plain pair. The corrupt-record case
in list_stations now drives `served/3` directly: nothing that writes the table
can lay down a record that does not verify, and the guard stays for depth.
Version 0.7.0, per the file's convention (the CHANGELOG heading, the app.src
vsn and info/0 move together).

Proof, on this tree: `rebar3 compile`, `rebar3 eunit` (128 tests, all
passed), `rebar3 lint`, `rebar3 xref` and `rebar3 dialyzer` all exit 0;
both regenerated C4 diagrams render with no barrel or rocksdb box, and
`rsvg-convert` shows the components diagram with station_store under
station_read_model.

Refs macula-io/macula-ci-images#19.
The supervisor was one_for_one. A store crash takes the ETS table with it, so
the feeder would keep running, subscribed, against an empty table: the
directory would refill only as stations re-broadcast, a refresh apart (≤225 s
by the record TTL), and list_stations would answer a short directory in the
meantime. rest_for_one with the store first restarts the children started
after the crashed one -- the feeder -- which snapshots again at once.

An ingest crash still leaves the store alone: it is the only child after the
feeder, so nothing restarts but the feeder, and its rows survive (the case
commit e4f31868 added).

Jupiter's note on the e4f31868 review; one change plus a test, as agreed.

Proof, on this tree: rebar3 eunit 129/129 (the new case, with the store
killed by name, fails on one_for_one and passes here -- checked by flipping
the strategy back and watching it error), lint, xref and dialyzer all exit 0;
architecture/README.md and the components diagram say rest_for_one.
The third and last piece of the forge port for this repository
(macula-io/martha#601, macula-io/macula-ci-images#19 step 1a), following
macula-realm's landed pattern at b86a5cc.

WHY IT COULD NOT STAY AS IT WAS. Every job ran on ubuntu-latest, in a ghcr
image, through marketplace actions, and called reusable workflows in the
PRIVATE macula-ci-images. On the forge each of those fails for its own reason:
a JavaScript action needs `node` in the job image and macula-ci-otp has none
(proven on macula-station run 50: `exec: "node": executable file not found in
$PATH` at the first checkout); ghcr refuses this organisation; and a
cross-repository call needs a PUBLIC repository on the other side.

WHAT CHANGES.

- `lint.yml` and `build-push.yml` become one `test.yml`, with jobs guard,
  check, hand-lock, lock-arrives and advisories -- realm's shape, so a job's
  outputs reach the next job without a workflow_call hop, which Forgejo has no
  reason to support and realm avoids.
- The checkout is plain shell, the form ci-images' own workflows use: the token
  reaches git through the environment, never a URL or a command line, and the
  checkout is refused if it is not the commit the run names.
- The shared gates are stand-ins in this directory (`ci-images-*.yml`),
  byte-identical copies of ci-images' files at the shas their headers name, as
  realm carries them. They go when macula-ci-images is reachable to forge
  callers again.
- NO REGISTRY PUSH AND NO SIGNING. The release image is the signer's, off CI,
  built from the resolve the tests ran on (macula-realm#3): `check` prints the
  rebar.lock it tested and its sha256, `hand-lock` files the bytes on the
  `tested-locks` pre-release as `<commit>.<sha256>.rebar.lock`, and
  `lock-arrives` proves on every pull request that the hand-off arrives whole.
  Until P6 gives this service a signer, this repository publishes no image and
  a box keeps the digest it already runs.
- Every job that runs steps carries timeout-minutes. A `uses:` job cannot (the
  key is not in GitHub's set for a reusable-workflow call), and the file it
  calls carries its own.
- scripts/is_image_push.sh goes with the image job that used it; the README's
  deployment section and the compose file stop naming ghcr and name the forge
  registry, with the digest pin a deployment uses.

The service tests move with it: the pins now read test.yml, and the two guards
whose subject changed are replaced rather than dropped. `the tested resolve is
filed for the signer` pins the hand-off (the name carries the digest, the POST
files it, lock-arrives compares), and `no registry push and no marketplace
action` fails if either authored file ever names ghcr.io, a docker/* action,
`push: true` or `uses: actions/`. The attest pin goes: there is no GitHub OIDC
on the forge, and realm's choice is to leave attest GitHub-only.

Proof, in the forge's own CI image on msi00 (never on host00, per the CPU
ruling): `git.macula.io/macula-io/macula-ci-otp@sha256:3e202cf7...` runs
`rebar3 lint && rebar3 xref && rebar3 eunit && rebar3 dialyzer` to exit 0 with
129 tests passed, which is exactly what test.yml's check job runs. The absence
test was mutation-checked: planting `ghcr.io` in test.yml turns it red.

Refs macula-services/mcl-stations#1, macula-io/macula-ci-images#19.
image: build the release from the tested rebar.lock, not a fresh resolve
Some checks failed
Test / erlang in . (pull_request) Has been skipped
c4 model / c4-model-1 (pull_request) Failing after 3s
c4 model / c4-model (pull_request) Failing after 0s
Test / erlang in . (container) (pull_request) Failing after 0s
Test / Dependency advisories (pull_request) Failing after 0s
Test / guard-1 (pull_request) Successful in 5s
Test / guard (pull_request) Successful in 0s
Test / rebar3 lint, xref, eunit, dialyzer (OTP 28.4.3) (pull_request) Successful in 3m9s
Test / File the tested resolve for the signer (pull_request) Has been skipped
Test / The tested lock arrives whole (pull_request) Successful in 1s
c4 model / c4-model-1 (push) Failing after 2s
c4 model / c4-model (push) Failing after 0s
Test / guard-1 (push) Successful in 3s
Test / guard (push) Successful in 0s
Test / erlang in . (container) (push) Failing after 9s
Test / erlang in . (push) Has been skipped
Test / Dependency advisories (push) Failing after 0s
Test / rebar3 lint, xref, eunit, dialyzer (OTP 28.4.3) (push) Successful in 3m32s
Test / File the tested resolve for the signer (push) Successful in 3s
Test / The tested lock arrives whole (push) Has been skipped
8e5c050ae0
The signer hands this build the lock the suite tested, and cmp after get-deps
refuses a lock rebar3 would silently rewrite. A signer-lock stage exports that
lock from the builder for the signer's own check, and the check job names its
read-only permissions. Uranus r=3 R1, N1, N2.
Member

Landed on main by Terra: main 82bd80d..8e5c050a (fast-forward to this PR head). Main push run test.yml 2243: check, guard and the hand-lock job green; named reds only (macula-ci-images#11, #12). Closed by the dispatcher because manual-merge marking is off on this repo (405).

Landed on main by Terra: main 82bd80d..8e5c050a (fast-forward to this PR head). Main push run test.yml 2243: check, guard and the hand-lock job green; named reds only (macula-ci-images#11, #12). Closed by the dispatcher because manual-merge marking is off on this repo (405).
mars closed this pull request 2026-11-23 04:02:48 +00:00
Some checks failed
Test / erlang in . (pull_request) Has been skipped
c4 model / c4-model-1 (pull_request) Failing after 3s
c4 model / c4-model (pull_request) Failing after 0s
Test / erlang in . (container) (pull_request) Failing after 0s
Test / Dependency advisories (pull_request) Failing after 0s
Test / guard-1 (pull_request) Successful in 5s
Test / guard (pull_request) Successful in 0s
Test / rebar3 lint, xref, eunit, dialyzer (OTP 28.4.3) (pull_request) Successful in 3m9s
Test / File the tested resolve for the signer (pull_request) Has been skipped
Test / The tested lock arrives whole (pull_request) Successful in 1s
c4 model / c4-model-1 (push) Failing after 2s
c4 model / c4-model (push) Failing after 0s
Test / guard-1 (push) Successful in 3s
Test / guard (push) Successful in 0s
Test / erlang in . (container) (push) Failing after 9s
Test / erlang in . (push) Has been skipped
Test / Dependency advisories (push) Failing after 0s
Test / rebar3 lint, xref, eunit, dialyzer (OTP 28.4.3) (push) Successful in 3m32s
Test / File the tested resolve for the signer (push) Successful in 3s
Test / The tested lock arrives whole (push) Has been skipped

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