ADR 0006 — ACL changes rebuild the router runtime
Status: accepted · 2026-10-20
Context
wyrm-admin generates the Zenoh access_control section from the link registry (and, since iteration 4, from the peers section, ADR 0007). Zenoh 1.10.1 has no public live reload of it: TablesLock::update_config is pub(crate) and only Zenoh’s own tests call it.
Decision
- Rebuild on ACL change. Install/remove of a process or external link and quarantine
approvecallControl::schedule_reload, which waits 300 ms (so the current reply leaves first) and sends a signal on the reload channel.Daemon::run_untilstops the currentBrokerand starts a new one with a freshly generated ACL. Embedded installs/removes do not rebuild: embedded links have no ACL rule. - What survives a rebuild is owned by the
Daemon: the adminControl(registry, audit, CA, link secrets, supervisor with its child processes), theFlowHost(flow store, flow signing key) and theGateway(user store, signing key, sessions, WebSocket tickets). What is rebuilt is theBroker: router runtime, storage/REST plugins, one in-process session, the admin responder with its watchers, embedded links, the flow engine and the gateway’s HTTP/WS server. - Order. Start: build the runtime, open the in-process session, attach admin + embedded links + process supervision, spawn the flow engine, then
runtime.start()opens the listeners (so the first remote query finds their queryables and tokens), then the gateway server. Stop: gateway server, flow engine, admin (watchers, embedded links, responder), thensession.close()beforeruntime.close(). - Process links are not restarted.
Attached::stopleaves processes running; on the next attachSupervisor::startis a no-op for a live process. The processes reconnect by themselves and re-publish~meta/~valwhen thewy/<site>/sys/brokerliveliness token returns (LinkConfig::republish_on). - Coalescing is partial. After the old broker has stopped,
run_untildrains the reload signals already queued (e.g. several installs in a row) and rebuilds once. A signal that arrives after the drain causes one more rebuild. - ACL shape. Default deny.
- Each remote link gets, by certificate CN and only over
tls: everything onwy/<site>/downstream/<id>/**,query/replyon its ownsys/links/<id>/~act/hello, ingressputonsys/audit/<id>, and liveliness onsys/broker(broker-watch). - Loopback (
tcp,unixsock-stream) inprodand operator CNs (overtls) are requesters only: they ask (query, subscribe, liveliness) and receive (put, delete, reply, liveliness token) onwy/<site>/**and onwy/<d>/**of every downstream site, but cannot put, serve queries or declare tokens outside**/@adv/sub/**(advanced subscriber bookkeeping;@adv/pubbelongs to the owning link only). - In
dev, loopback has full rights onwy/<site>/**. - Peer brokers get the rules of ADR 0007.
- In-process sessions (admin, embedded links, flow engine, gateway, plugins) bypass the ACL.
- Each remote link gets, by certificate CN and only over
- Local process links use loopback mTLS with their own CN, not UDS + uid as the wiki describes, because the Zenoh ACL has no uid subject. UDS stays for later.
- Removed ids are retired. Without a CRL a removed link’s certificate stays valid until it expires, so its id is never installed again and its CN is not quarantined again (
Registry::retired). Exception, 2026-10-22 (owner decision, DSA Deauthorize):sys/quarantine/~act/deauthorize {link}puts a runtime external link back into quarantine instead (Op::Deauthorize,Registry::held): its token, secrets and ACL rules go, and so does every gateway grant that widens a role on exactly its branch (restrictive ones stay; Remove does the same), the CN keeps no rights, and only a manual Authorize admits it again —allow_all_linksskips held CNs. Remove still retires. - Authorize (DSA form, 2026-10-22):
sys/quarantine/~act/authorize {dsid, group, name, driver, params};dsidis an enum of the quarantined CNs, re-declared on every change (as are the link list of Deauthorize and the role list ofgroup).nameis the link’s display name (the id stays the CN, which the ACL matches).groupgives that gateway rolewriteonwy/{site}/downstream/<id>/**(as Update Permissions, audited). Eachquarantine/<cn>node keeps its ownapprovewith the same form. Test:authorize_and_deauthorize. - Quarantine. An unknown CA-signed CN is seen through
link_events_listener()→auth_identifier(). Default deny already blocks it (stricter than the wiki’s “may putsys/quarantine/<cn>”).approveinstalls it as an external link and triggers a rebuild. Only sessions on thetlslink listener count (it trusts our CA alone; a peer site’s CA on QUIC can sign any CN). - Admission options (2026-10-22, DSA
allowAllLinks/quarantine), persisted in the registry (Op::SetOption, SCHEMA 5), set asconfigvaluessys/allow_all_links(default off) andsys/enable_quarantine(default on), audited (set_option). Withallow_all_linksan admissible CN (admissible: not a known, rejected or retired id, an operator, a peer broker or a downstream site name) is installed as an external link on first sight (auditauto_install), then the runtime rebuilds; the link token goes only tolinks/<id>/tokenon the broker, and the operator copies it to the device as afterapprove. With both off, unknown CNs are ignored. Setting an option does not rebuild by itself. The broker logs a warning at start whileallow_all_linksis on. - Link grants (2026-10-22, ADR 0013): a link’s policy also holds
grant-<id>-{query,watch,sub,back}for the paths it was granted (acl::grant_rules), so a requester link reaches other branches by its CN. A grant change rebuilds the runtime like any other ACL change. sys/acl_denied(wassys/metrics/broker/acl_denied_totaluntil 2026-10-22) = sum ofzenoh_{rx,tx}_network_message_dropped_payload_bytes_count{reason="access-control"}read from@/<zid>/router/metrics(gzip). It needs the Zenohstatsfeature and a read-only admin space; remote sessions cannot read@/**under the ACL.
Consequences
- A rebuild drops all Zenoh sessions for about 1 s. The memory
~valstorage starts empty and the owners refill it. - A rebuild also closes every user WebSocket. Gateway sessions and unspent tickets survive (they live in
Gateway), so clients reconnect without a new login. The Dart client does it itself (2026-10-24):WyrmGateway.client()gives aReconnectingClient, which opens a new socket with a fresh ticket, opens itslistandsubscribestreams again (aliststarts over withrefreshed), lets reads wait and go again, and fails asetorinvokecut by the close (it may have run); the explorer shows “Reconnecting…” meanwhile. - ACL changes are rare (lifecycle operations), so the cost is acceptable for one site.
- On a clean shutdown
Control::shutdownstops the supervised children; they are not adopted by PID on the next start. The wiki wants process links to survive a broker restart (systemdKillMode=process); that needs PID adoption and is not done yet. - Revisit when Zenoh exposes a public live ACL reload.
Open
Failed rebuild orphans process links— fixed:run_untilcallsControl::shutdownalso whenBroker::start/stopfails.- Coalescing relies on a fixed 300 ms delay plus one drain; there is no debounce window.
- PID adoption of process links (see Consequences).
Alternatives
- Patch Zenoh to expose
TablesLock::update_config. Rejected: principle 1 (Zenoh is never patched or forked). - Permissive ACL plus authorization only in the responder SDK. Rejected: the SDK checks
ptokon~set/~act, but cannot stop a session from publishing into another link’s~valor declaring its liveliness token. - A second router per link class. Rejected: more processes and hops for a rare event.