No description
  • Erlang 82.1%
  • Python 11.3%
  • Shell 3.7%
  • Dockerfile 2.9%
Find a file
2026-11-24 01:11:59 +01:00
.github c4_model: the claims hold, and the gate is the current one 2026-10-24 01:40:50 +02:00
apps/mcl_news The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:21:02 +01:00
architecture fix: the C4 carriers move too, and the floor test's comments agree (mcl-om#42 R1) 2026-10-30 17:35:53 +01:00
assets fix: the C4 carriers move too, and the floor test's comments agree (mcl-om#42 R1) 2026-10-30 17:35:53 +01:00
config The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:21:02 +01:00
deploy The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:21:02 +01:00
scripts The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:21:02 +01:00
.gitignore scaffold: rebar3 new mcl_service from mcl_om 3f76daf 2026-09-24 01:03:15 +02:00
.tool-versions scaffold: rebar3 new mcl_service from mcl_om 3f76daf 2026-09-24 01:03:15 +02:00
CHANGELOG.md fix: the C4 carriers move too, and the floor test's comments agree (mcl-om#42 R1) 2026-10-30 17:35:53 +01:00
Containerfile The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:21:02 +01:00
LICENSE scaffold: rebar3 new mcl_service from mcl_om 3f76daf 2026-09-24 01:03:15 +02:00
README.md README: drop the GitHub Sponsors badge 2026-11-23 22:20:29 +00:00
rebar.config 0.3.0: macula 18 and mcl_om 1.6 (mcl-om#42) 2026-10-30 17:01:58 +01:00
SECURITY.md SECURITY.md: response times, attachment and identity rules, drills (macula-io/macula#174) 2026-10-31 02:59:28 +01:00

mcl-news

CI License ghcr.io BEAM Buy Me a Coffee

Macula

Sovereign news sensor: polls public RSS/Atom sources and reports each new item as a mesh fact


Built on macula 18 and mcl_om 1.6.

What it does

A sensor. Every five minutes it fetches each configured RSS/Atom source over HTTPS (certificates checked against the system CA store, plain OTP inets and ssl, no third-party news API), parses it, and reports every item it has not reported before as one fact:

<realm>/mcl-news/news/wire/news_item_reported_v1

The defaults are European public broadcasters: France 24, VRT NWS and DW.

Each fact carries the item (item_id, source, title, summary, url, image_url, lang, topics, published_at), a deterministic enrichment (topic_class, emoji, reporting_country, reporting_country_name, subject_country, subject_country_name, source_type), fetched_at, and body, a readable headline line for consumers that reason over text. Every string is tagged text; times are milliseconds. image_url links the publisher's own picture (from the feed, or og:image on the article page) and is empty when there is none.

One topic. Category, country and source type are payload fields to filter on. The service this one replaces also published every item to one sub-topic per axis value, so each mind of a society could subscribe to a slice; no consumer of that exists, and values belong in the payload, not in topic names. It can come back when a consumer needs it.

Who reported it is the publisher macula verified on delivery, this sensor's own node identity. The payload carries no sender label.

A source's first fetch seeds, it does not flood: only its newest item is reported and the rest of its backlog is marked seen, whether that fetch is at boot or when a source that was down comes back. An item counts as reported only once its publish succeeded, so a dark mesh delays reports and loses none. Item ids already reported are remembered in a bounded in-memory window (4000 by default), rebuilt on restart.

It asks the realm for no extra authority. /health is green while the sensor runs; a source that is down, or a dark mesh, is not a health failure.

Running it

rebar3 compile
rebar3 eunit
rebar3 lint
rebar3 dialyzer

scripts/health.sh                      # against a running node

The image builds in the team's macula-ci-otp image and runs on macula-pq-runtime, both pinned by dated tag and digest (the same pair every mcl service uses); the service tests hold the pins.

podman build -t mcl-news -f Containerfile .

Configuration

Variable Default Meaning
MCL_REALM required 64-hex realm tag, the sha256 of the realm's name. No default: a service that guesses its realm announces itself where nobody can attribute it.
MCL_REALM_KEY required The realm's public signing key, hex encoded: the trust anchor, not an identifier. Every org-namespaced advertisement is verified against it, so without it nothing resolves, the boot claim never reaches the realm, and the service stays green while unreachable. Public material, not a secret.
MACULA_STATION_SEEDS required Station hosts to dial, host[:port], comma-separated. No default: naming a realm costs nothing, dialling a production station from every dev clone does.
MACULA_STATION_NODE_IDS required The matching 64-hex station node ids, comma-separated, index-paired with the seeds. The dial is pinned (D5): mcl_om refuses to boot a pool with an unpinned seed.
MCL_REALM_NAME required The realm's name, as the fact topic carries it. At start, sha256 of it must equal MCL_REALM or the node refuses to start.
MCL_NEWS_FEEDS built-in list Sources, `name
MCL_NEWS_POLL_MS 300000 How often every source is polled.
MCL_NEWS_SEED_COUNT 1 Items per source reported on the first poll.
MCL_NEWS_MAX_SEEN 4000 Item ids remembered, so old news is not reported again.
MCL_SERVICE_NAME mcl-news The service label on the claim the realm's operator sees at boot. Falls back to the service's own name.
MCL_BOX empty The host label on that claim: which box is asking. Set by whatever deploys the service.
MCL_HEALTH_PORT 8498 Health endpoint, assigned in macula-fleet PORTS.md. Host networking makes a collision a silent bind failure, so take a new one from there rather than picking one.
MCL_NODE_NAME mcl_news Erlang node name.
MCL_NODE_HOST 127.0.0.1 Erlang node host.
MCL_COOKIE unset Erlang cookie. Unset, the image makes a random one on first start in the secrets volume (/etc/mcl/secrets/erlang.cookie, 0600) and keeps it. Distribution and epmd listen on 127.0.0.1 only. A remote shell: docker exec -it mcl-news /app/start.sh remote_console.

deploy/docker-compose.yml runs it, and carries what the service knows about itself. If you deploy through something else, let that carry placement: which host, which station, which realm, which secret store. Keeping the two apart is what stops a config table in a README and the real environment drifting.

Deployment

The image has two channels. A v* tag publishes its own version and then, once attest has signed and attested that digest, points :latest at it, which no box follows: macula-fleet instead pins a <version>@sha256:<digest> from its own release workflow, canary first. For mcl-news the pin lives in a reviewed macula-fleet commit: edge/gitops/release-targets:88 names edge/scripts/docker-compose.mcl-news.yml as the canary file, and its line 39 carries 0.2.0@sha256:<digest>. A push to main publishes :main and :<sha>, the tip for trying, and nothing follows those, so a merge deploys nothing. The semver tags stay published, so a host can be pinned back to a known one to roll back. A push that changes only documentation builds no image (scripts/is_image_push.sh).

The service's org is this repository's name, fixed in config/sys.config.src, and it is the org segment of the fact topic. mcl-news has no procedure of its own; mcl-om adds mcl-news/info and mcl-news/get_limits, both open, and capabilities/0 is the list.

Two things CI cannot do for you, both of which have bitten:

  1. The registry package may be created private, and the pull then fails on the host with a bare unauthorized that names nothing. Check it after the first build. On ghcr the org.opencontainers.image.source label in the Containerfile is what links the package to the repository.
  2. The host needs MCL_REALM, MCL_REALM_NAME, MCL_REALM_KEY and the addresses of the stations it dials supplied from somewhere they are not committed.

The service contract

Six callbacks in mcl_news_service, all required, all resolved by name by mcl_om at startup on a live node. The -behaviour(mcl_om_service) attribute turns a missing one into a compile error rather than an undef where nobody is watching, and the eunit suite guards the attribute itself.

Adding a store later

This service has no reckon-db store, which is the right answer for most. The reckon-db applications run either way; what a store adds is a data directory, an open handle, and something written.

The cheapest way to get one is to scaffold again with store=1, which generates the callbacks, the config and the guards together.

⚠ By hand it is three things and not one, and the missing third crash-loops the node. Export store_id/0 and data_dir/0; add the evoq adapter block to config/sys.config.src, without which boot raises {not_configured, event_store_adapter} before any service code runs; and mount a volume in the compose file. A sibling service put two of three fleet nodes into a boot loop by doing the first and not the second.

Architecture

The C4 model — system context, containers and components — is in architecture/README.md, with the diagram sources in architecture/c4_diagrams.py and the rendered SVGs in assets/.

Licence

Apache-2.0.