- Erlang 92.7%
- Python 5%
- Dockerfile 1.4%
- Shell 0.9%
| .github | ||
| apps | ||
| architecture | ||
| assets | ||
| config | ||
| deploy | ||
| scripts | ||
| security/fovea | ||
| .gitignore | ||
| .tool-versions | ||
| CHANGELOG.md | ||
| Containerfile | ||
| LICENSE | ||
| README.md | ||
| rebar.config | ||
| SECURITY.md | ||
mcl-tube
Video channels over the mesh: owners publish clips, anyone looks them up and streams them.
This exists so a channel owner can publish video from their own box and anyone on the mesh can find it and watch it, with no platform in between.
Status
Runs on macula 18 through mcl_om 1.6, and opens its own reckon-db store
(mcl_tube_store). Its advertisements name an ML-KEM key and every procedure of its own requires a sealed
caller: lookups and the watch stream are sealed end to end, and a caller that
does not seal is refused with sealed_required. Every macula SDK seals by
default.
What it does
- An owner creates a channel, uploads clips (each is scanned before it can be published), publishes, retracts and archives them, through a web UI served locally by the service.
- Anyone on the mesh looks a channel, a clip or a piece of content (a thumbnail, a logo) up, and streams a published clip, over four procedures of its own.
- The catalog is announced on four facts, so a catalogue (the portal's) can list channels and clips without asking.
Four apps, one per department:
| App | Department | What it holds |
|---|---|---|
guide_tube_lifecycle |
CMD | the channel and clip lifecycles, event sourced, and the catalog announcements |
project_tube |
PRJ | the read model, in memory, rebuilt from the store at boot |
query_tube |
QRY | the lookups and the watch stream |
mcl_tube |
service | the owner web UI and the mcl_om contract |
The contract
Procedures
Served under the org mcl-tube, so callers dial mcl-tube/<name>:
| Procedure | Kind | Answers |
|---|---|---|
mcl-tube/lookup_channel |
request/reply | a channel's current details |
mcl-tube/lookup_video_clip |
request/reply | a clip's details |
mcl-tube/lookup_content |
request/reply | a published clip's thumbnail or a channel's logo, by mcid |
mcl-tube/watch_video_clip |
stream | a published clip's bytes |
A retracted or archived clip is unservable on every path: its lookup and its
thumbnail answer not_found, a new stream is refused, and a stream already
open ends with a stream error at the next chunk. Its listing is withdrawn with
video_clip_retracted_v1, and every published clip is re-announced at least
every 5 minutes, so a catalogue can expire a listing nobody re-announced
instead of trusting one withdraw fact to arrive.
Facts
Canonical macula app facts in io.macula/mcl-tube/tube/catalog/:
| Topic | When |
|---|---|
channel_announced_v1 |
a channel was created or reconfigured, and on a heartbeat |
video_clip_published_v1 |
a clip became visible |
video_clip_retracted_v1 |
a clip was retracted or archived |
video_clip_viewed_v1 |
a clip was watched to the end, once per view |
Text fields (names, descriptions, owners, tags) are sent as CBOR text, so every stack reads them as strings; ids and mcids stay bytes. Channel and clip announcements are upserts by id, safe to receive twice. A view is announced exactly once, live, when it is recorded, because a consumer counts views by fact.
Both lists are pinned by tests (mcl_tube_service_tests,
tube_catalog_topic_tests). A change is a new name, not an edit.
Like every mcl service, it also answers the open procedures mcl_om adds:
mcl-tube/info gives its name, version and description, its org and claim
labels, node id, the macula and mcl_om versions, uptime, the health word and the
procedures it advertises; mcl-tube/get_limits gives the inbound guard's limits
and current-window stats.
Open to any mesh caller, public facts only.
Configuration
| Variable | Default | Meaning |
|---|---|---|
MCL_REALM |
required | 64-hex realm tag, sha256 of the realm name |
MCL_REALM_NAME |
required | the realm name the catalog topics carry, e.g. io.macula. The service refuses to start unless its sha256 is MCL_REALM |
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_TUBE_HTTP_PORT |
8491 |
the owner web UI |
MCL_TUBE_HTTP_IP |
127.0.0.1 |
where the owner web UI binds. It has no authentication of its own, and the container runs on host networking: the image default is loopback (reach it over an SSH tunnel, and widen only knowingly) — the dev fleet's compose overrides it to 0.0.0.0 (LAN), see macula-fleet PORTS.md |
MCL_DATA |
/bulk0/mcl-tube |
(compose) host directory for the store, the clips and the content cache |
MCL_SERVICE_NAME |
mcl-tube |
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 |
Deploy
What an operator does, in order:
- Set
MCL_REALMandMCL_REALM_NAME, and mount the data directory on a bulk drive.deploy/docker-compose.ymlalso mounts the named identity volumemcl-tube-secrets; keep it, because the next step is tied to it. - Have the realm grant this node its provider authorization. Serving an
org-namespaced procedure needs a realm-issued grant (D25) naming this node's
id, and a person admits it on the realm. Until then the realm has not
authorized this node, calls resolve to nothing, and
/healthis degraded, naming the procedures still missing an authorization underprovider_grants. A new identity is a new, unadmitted node. - Reach the owner UI over a tunnel:
ssh -L 8491:127.0.0.1:8491 <box>, then browse tohttp://localhost:8491/.
Health
/health answers whether callers can reach the service. mcl_om reports
the procedures the realm has not granted this node a provider authorization
for: degraded at once when no delegation names this node (an operator has to
grant it), after a 60 s grace window for any other refusal, so a lookup that
fails once does not flap.
Build and test
rebar3 eunit
rebar3 lint
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, OpenSSL with ML-DSA), with ffmpeg added, 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.
License
Apache-2.0. See LICENSE.