The submission relay and both promotion paths are live in production, so the runbook no longer claims that nothing has been deployed. Reframe the deployment order and pre-go-live checks as completed, and fix the verification command: strfry only returns the NIP-11 JSON with an Accept header, so the old curl | jq pipeline could never work.
12 KiB
Nostr submission relay (Chef)
Chef-side pieces of the public submission relay + image-recognition moderation
MVP (raucao/marco#97). The
canonical plan/spec lives in the Marco repo, doc/nostr/submission-relay-mvp/.
This document is the Chef runbook: what the code deploys, how it was rolled out,
and how to roll it back. The stack is deployed to production — the relay is
live at wss://submit.nostr.kosmos.org and both promotion paths are enabled.
The deployment order below is kept as a record of the rollout and for rebuilding
the service elsewhere.
What the Chef code adds
| Piece | Where | Recipe / role |
|---|---|---|
Public submission relay (strfry #2, :7778) |
one node | role[strfry_submission] → kosmos_strfry_submission::default |
Firewall for :7778 |
same node | kosmos_strfry_submission::firewall |
wss://submit.nostr.kosmos.org vhost + cert |
openresty proxy nodes | kosmos_strfry_submission::nginx (via role[openresty_proxy]) |
Approved-event sync (staging :7779 → production DB) |
production relay node | kosmos_strfry::approved_sync (via role[strfry]) |
Member bridge (:7778 → production DB, LDAP-only) |
production relay node | kosmos_strfry::member_bridge (via role[strfry]) |
| Node 24 LTS for the Node write policies | relay nodes | role-scoped kosmos_nodejs.version override |
Write policies from kosmos/akkounts extras/strfry/ are fetched at converge
time:
submission-policy.mjs— open write gates for the submission relay (Node).sync-policy.mjs— fail-closed policy forstrfry sync(Node; see below).ldap-only-policy.ts— LDAP membership gate for the member bridge (Deno; see below).
Design notes / invariants
- The submission relay is not
role[strfry].The openresty proxy builds its production_strfryupstream fromrole:strfry; a submission node must never be added to it. The new role also avoidsrole[ldap_client], because the submission relay is open to all authors and does not do LDAP. - The sync is the only non-member write path into production. It runs
strfry --config /etc/strfry-sync.conf sync <staging> --dir down, one-way, every 5 minutes.strfry sync --dir downruns the local write policy withsourceType="Sync"andsourceInfo=<remote relay URL>(src/apps/mesh/cmd_sync.cpp), sosync-policy.mjscan accept only that exact source and reject everything else.STAGING_RELAY_URLis passed to the unit and must byte-match the URL on the command line — both come from the singlenode["strfry"]["staging_relay_url"]attribute. - The sync uses the production database (
node["strfry"]["config"]["db"]) with a 100-year age floor (rejectEventsOlderThanSeconds = 3153600000) so long-delayed approvals still land. Note that0does not disable this check in strfry: strfry computesearliest = now - rejectEventsOlderThanSeconds, so0makesearliest == nowand rejects every event as "created_at too early" before the write policy runs. A large bound is the way to turn it off. - The sync config sets
nofilesexplicitly. strfry raises itsRLIMIT_NOFILEtorelay.nofilesat startup and exits if that exceeds the process hard limit. The compiled-in default (1000000) is above the systemd default here (524288), sostrfry_sync.conf.erbsetsnofiles = <production value or 524288>. Without it the sync fails to start withUnable to set NOFILES limit to 1000000. - The submission relay is reachable only from the openresty proxy nodes.
The relay trusts nginx's
X-Real-IP(realIpHeader = "x-real-ip"), so a direct connection could forge that header and defeat the policy's per-IP token bucket.kosmos_strfry_submission::firewalltherefore allow-lists the ZT IPs of therole:openresty_proxynodes instead of all of10.1.1.0/24(the per-author bucket is unaffected). Consequence: anything that talks to the relay directly over ZeroTier must be added explicitly — in particular, if the WS2 moderator is switched fromwss://submit.nostr.kosmos.orgto the ZT-directws://<relay>:7778, add the nuc's address to the allow-list (or route it through nginx). The member bridge uses loopback and is unaffected. - No
--filteron the sync. The worker only publishes approved events to the staging relay; the policy is the gate. - The member bridge is a live
strfry router, not a service. A stream group withdir = "down"subscribes tows://localhost:7778and writes member-authored events into the production LMDB; itspluginDownisldap-only-policy.ts, so membership is decided per event by LDAP and no member list is maintained. The group'sfilterbounds the REQ (and therefore the LDAP lookups) to the submission kinds.dir = "down"makes it strictly one-way: the router never watches or forwards the local DB.pluginDown's path contains no spaces, so strfry watches its mtime and hot-reloads it without a restart. It writes to the same LMDB as the relay (the same multi-process access pattern as the approved sync). - Both promotion paths are enabled from
role[strfry_submission]. Thestrfry.approved_sync.enabledandstrfry.member_bridge.enabledswitches are set as role overrides, not in the production environment, so they travel with this feature's roles. (The recipes themselves live inrole[strfry]; the relay node runs both roles.)
Attributes
| Attribute | Default | Notes |
|---|---|---|
strfry.staging_relay_url |
ws://10.1.1.183:7779 |
nuc ZeroTier IP + staging port |
strfry.approved_sync.enabled |
false |
no-op until enabled (true in role[strfry_submission]) |
strfry.member_bridge.enabled |
false |
no-op until enabled (true in role[strfry_submission]) |
strfry.member_bridge.subscribe_relay |
ws://localhost:7778 |
local submission relay |
strfry.member_bridge.plugin_cmd |
/opt/strfry/ldap-only-policy.ts |
LDAP-only pluginDown |
strfry.member_bridge.kinds |
[0, 3, 5, 360, 30360] |
router REQ kind filter |
strfry_submission.domain |
submit.nostr.kosmos.org |
|
strfry_submission.port |
7778 |
|
strfry_submission.config.db_params.mapsize |
4 GiB |
disk cap for the disposable DB |
Regression checks
site-cookbooks/kosmos_strfry/test/strfry_sync_conf_test.rb renders
strfry_sync.conf.erb with the attribute shapes approved_sync.rb passes and
fails if the sync config's rejectEventsOlderThanSeconds is missing or <= 0
(the guard for the "0 rejects every event" trap above) or if nofiles is not
set to the expected value (strfry exits at startup when its nofiles exceeds
the systemd LimitNOFILE). It needs neither a Chef server nor a converge — only
the chef gem and stdlib ERB:
ruby site-cookbooks/kosmos_strfry/test/strfry_sync_conf_test.rb
site-cookbooks/kosmos_strfry/test/member_bridge_conf_test.rb renders
member_bridge.conf.erb with the attribute shapes member_bridge.rb passes and
fails if the stream group is not one-way (dir != "down") or not gated by the
LDAP-only policy (missing/wrong pluginDown, or a plugin path containing a
space, which strfry would not hot-reload). Only stdlib ERB is needed:
ruby site-cookbooks/kosmos_strfry/test/member_bridge_conf_test.rb
Deployment order (as performed)
All of the steps below have been performed; this is the order that was used. Keep it for rebuilding the service on another host.
- HARD PRECONDITION — akkounts
livebranch. Before any converge, thelivebranch ofkosmos/akkountsmust containextras/strfry/submission-policy.mjs,extras/strfry/sync-policy.mjsandextras/strfry/ldap-only-policy.ts. Chef fetches them fromhttps://gitea.kosmos.org/kosmos/akkounts/raw/branch/live/extras/strfry/…at converge time; if any is missing, theremote_fileresource fails and the converge aborts (with a partially configured host). Verify with:curl -fsSI https://gitea.kosmos.org/kosmos/akkounts/raw/branch/live/extras/strfry/submission-policy.mjsand the same for the other two files. These files are produced by WS1, not by this repo. - DNS.
submit.nostr.kosmos.orgis a CNAME tolb.kosmos.orgat Gandi (already configured). Chef does not manage DNS; thegandi_dnsLet's Encrypt challenge cannot succeed without it. Verify it resolves before converging the proxy nodes. - Relay node. Assign
role[strfry_submission], converge. Creates the binary (or reuses it), DB, config, policy andstrfry-submission.service. The firewall allow-lists the currentrole:openresty_proxynode IPs, so the proxy nodes should already be registered as Chef nodes. - Proxy nodes. Converge
role[openresty_proxy]; this adds thesubmit.nostr.kosmos.orgsite and requests the certificate. - Enable the promotion paths. Only after the worker + staging relay (WS2)
are live:
role[strfry_submission]setsstrfry.approved_sync.enabledandstrfry.member_bridge.enabledtotrue(role overrides, not the environment). Convergerole[strfry]. This deployssync-policy.mjs, the sync config,strfry-sync.timer,ldap-only-policy.ts, the member-bridge config andstrfry-member-bridge.service. - Verify.
systemctl status strfry-submission/strfry-sync.timer/strfry-member-bridge.curl -s -H 'Accept: application/nostr+json' https://submit.nostr.kosmos.org | jq -r .name→Kosmos submission relay. (Without theAcceptheader strfry serves its HTML info page, whichjqcannot parse.)journalctl -u strfry-syncshows accepted events after an approval.journalctl -u strfry-member-bridgeshowsConnected to ws://localhost:7778and rejects non-member events (pluginDown blocked event … Only members can publish notes on this relay).- The production relay's NIP-11 and
_strfryupstream are unchanged.
Pre-go-live verification (completed)
- LMDB concurrency (verified 2026-11-17 on the nuc's
:7777mirror). Astrfry sync --dir downwas run against the same LMDB that the live relay was serving from. Result: sync exited 0 and the relay answered 13/13 subscriptions (39 events) during the sync; the relay stayed active and the event count was unchanged. This is the same access pattern the approved-sync uses on strfry-1 (same DB, separatestrfry syncprocess), so no additional lock is needed. - No rogue sync path. Confirmed before the timer was enabled: no external
negentropy/websocket path can produce
sourceType = "Sync"on the production relay; the sync policy is fail-closed on the exact staging URL.
Rollback
- Sync: set
strfry.approved_sync.enabled = falseand converge, thensystemctl disable --now strfry-sync.timer. (The recipe becomes a no-op, but it does not stop an already-running timer.) - Member bridge: set
strfry.member_bridge.enabled = falseand converge, thensystemctl disable --now strfry-member-bridge. - Submission relay / proxy: remove
kosmos_strfry_submission::nginxfromrole[openresty_proxy]androle[strfry_submission]from the node, converge, thensystemctl disable --now strfry-submission. The DB at/var/lib/strfry-submissioncan be deleted independently; the production relay and its database are untouched.
Node.js caveat (checked before converging)
The Node write policies (submission-policy.mjs, sync-policy.mjs) are Node 24
ESM scripts, so role[strfry_submission] and role[strfry] add a
role-scoped kosmos_nodejs.version override to 24.22.2. The global
default (14.21.3) is deliberately not raised. (ldap-only-policy.ts is a
Deno script and needs no Node.)
If either role is applied to a host that already runs other Node/JS services, verify they do not depend on Node 14 before converging:
- On strfry-1:
blossomuses Deno (its recipe setsDENO_DIR), not Node;substris the prebuilt Rust binary from the package registry. Neither currently installs or uses Node, so adding Node 24 is additive. Re-check ifsubstrever falls back todeno task serveror if a Node-based service is added. - Any other node that gains
role[strfry_submission]should be checked the same way.
Out of scope
- Deploying/converging, DNS changes, certificate issuance, ZeroTier changes.
- The nuc staging relay and the moderator worker (WS2; not Kosmos infra). The
member bridge is covered here (
kosmos_strfry::member_bridge). - The write policies themselves (WS1,
kosmos/akkounts).