No description
  • Erlang 61.7%
  • Python 23.4%
  • Dockerfile 9.2%
  • Shell 5.7%
Find a file
2026-11-24 01:11:27 +01:00
.github ci: call the C4 gate that reads the front page 2026-10-23 21:08:12 +02:00
apps/mcl_embedder The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:14:22 +01:00
architecture c4_model: an embedder model that grants per procedure and names its open pair 2026-10-23 04:31:55 +02:00
assets c4_model: an embedder model that grants per procedure and names its open pair 2026-10-23 04:31:55 +02:00
config The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:14:22 +01:00
deploy The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:14:22 +01:00
scripts The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:14:22 +01:00
.gitignore scaffold: rebar3 new mcl_service 2026-09-23 14:47:25 +02:00
.tool-versions build: mcl_om 0.27 and the team image pair; the claim names the service and its box 2026-09-24 02:41:44 +02:00
CHANGELOG.md deps: declare macula, at 16 2026-10-22 03:01:03 +02:00
Containerfile The Erlang cookie stays on the box; distribution and epmd on loopback (PR 1 squashed) 2026-11-23 21:14:22 +01:00
LICENSE scaffold: rebar3 new mcl_service 2026-09-23 14:47:25 +02:00
README.md README: drop the GitHub Sponsors badge, add the Buy Me a Coffee badge 2026-11-23 22:20:10 +00:00
rebar.config docs: the floor statements say 16, and the tests hold it 2026-10-22 03:35:13 +02:00
SECURITY.md SECURITY.md: response times, attachment and identity rules, drills (macula-io/macula#174) 2026-10-31 02:59:16 +01:00

mcl-embedder

CI License ghcr.io BEAM Buy Me a Coffee

Macula

Multilingual sentence embeddings as a mesh procedure, for callers that cannot run the ONNX model themselves.


This exists so every service on the mesh can embed text, even on a box that cannot run the model, by calling the one box that can.

Status

Built and tested locally, not yet deployed. Builds on macula 16 through mcl_om 1.4 (wire 1.0, the wire the fleet has spoken since 19 Oct), on mcl_embed (fastembed over ONNX, multilingual-e5-small, 384 dimensions).

The procedure

mcl-embedder/embed, request and reply:

Request Reply
#{text => Text} #{vector => [float()]}
#{text => Text, kind => <<"query">>} the same, with the model's query prefix applied
#{text => Text, kind => <<"passage">>} the same, with the model's passage prefix applied
#{texts => [Text]} #{vectors => [[float()]]}

kind is how a caller does asymmetric retrieval without knowing the model's convention: embed what you store as passage and what you search with as query. Anything else, or none, embeds the text as it is. Text may be sent as a binary or as CBOR text; a request with no text is refused with bad_request.

The name and the request are pinned by tests (mcl_embedder_service_tests, serve_embed_tests). A change is a new name, not an edit.

Requirements

⚠ An AVX2 host. The ONNX Runtime SIGILLs on a CPU without AVX2, taking the node down with it. Run one embedder on an AVX2 box and let everything else call it over the mesh.

The image is Debian (glibc), not the Alpine every other mcl service uses: the ONNX Runtime fastembed links is prebuilt against glibc. The model is baked into the image at build time, so a container never downloads it.

mcl-embedder/embed is the service's own procedure, and the only one; mcl_om adds mcl-embedder/info and mcl-embedder/get_limits to every service, both open; capabilities/0 is the list. info answers with the service's name, version and description, its org and claim labels, node id, the macula and mcl_om versions, uptime, the health word and the capabilities it advertises; get_limits answers with the inbound limits. Public facts only.

Configuration

Variable Default Meaning
MCL_REALM required 64-hex realm tag
MCL_REALM_KEY required the realm's public signing key, hex
MACULA_STATION_SEEDS required station hosts, host[:port], comma-separated
MACULA_STATION_NODE_IDS required the matching 64-hex station node ids
MCL_HEALTH_PORT 8480 health endpoint
MCL_SERVICE_NAME mcl-embedder label on the boot claim the realm's operator sees on the Providers desk
MCL_BOX unset label naming the host, also on the boot claim; set it where you deploy
MCL_EMBED_MODEL_DIR /models where the baked model is (set in the image)

Deploy

  1. Run it on an AVX2 host, with deploy/docker-compose.yml, which mounts the named identity volume mcl-embedder-secrets.
  2. Have the realm grant this node its provider authorizations (D25), a grant per org procedure, mcl-embedder/embed among them. Until then its own procedure is not advertised, a call to it resolves to nothing, and /health (mcl_om's own check) is degraded, naming mcl-embedder/embed under provider_grants. A new identity is a new, unadmitted node, so keep the volume.

Health

/health reports whether callers can reach its own procedure: a missing provider grant is degraded. The model loads on the first call and is not probed.

Build and test

rebar3 eunit      # runs mcl_embed's deterministic stub, not the model
rebar3 lint

A Rust toolchain is needed: mcl_embed builds its NIF from source. The image builds the real model (CARGO_FEATURES=real-embed). OTP 28.4.3, pinned in .tool-versions, the Containerfile and CI, and a test fails when they disagree with the VM running it. The image builds in the team's ghcr.io/macula-io/macula-ci-otp and runs on ghcr.io/macula-io/macula-pq-runtime (Debian trixie, glibc, which the ONNX Runtime needs), both pinned by dated tag and digest; CI runs in the same build image.

Architecture

The C4 model is in architecture/README.md, with its diagrams drawn by architecture/c4_diagrams.py into assets/. Change the script, run it (python3 architecture/c4_diagrams.py), and look at the result before committing.

mcl-embedder system context

License

Apache-2.0. See LICENSE.