ADR 0018 — Requests from upstream sites
Status: accepted · 2026-10-24 (owner decision, backlog item 1: a downstream accepts write from above on downstream/dataflows always; config on sys only when that downstream allows it explicitly). Reverses the “read-only upstream” of ADR 0007. Amended 2026-10-31 (owner decision): allow_config opens config on the whole site, links included, as the group of a DSA upstream connection.
Context
An upstream broker shows its downstream sites in its tree (ADR 0007, 0015), but nobody there can set a value or run an action on them: the downstream’s ACL drops every ~set/~act query from broker:<upstream>, the downstream’s links trust only their own site’s keys, and the upstream’s gateway refuses non-read operations on downstream sites.
A DSA broker lets requests through: the downstream names a permission Group on each upstream connection (sys/upstream/<name>/group), and a request from above is checked twice, by the upstream against its user’s permissions and by the downstream against that group. WYRM keeps both checks with the means it has: the router ACL, ptok signatures and the LimitedKey caps of ADR 0004/0013.
Decision
- What a downstream accepts from each upstream (one flag per upstream entry, as DSA’s group, fixed to the owner’s two levels):
- always
writeonwy/<d>/downstream/**,wy/<d>/dataflows/**andwy/<d>/storage/**(the broker storage of ADR 0017 is device-like data; DSA’s group covers/datatoo); configonwy/<d>/sys/**, andconfiginstead ofwriteondownstream,dataflowsandstorage(link actions such as Export, Edit, Stop, Restart; amended 2026-10-31), only withallow_configon that upstream:wyrmd.json5peers.upstream[].allow_config, orsys/upstream/<u>/allow_config(writable atconfig) for one added at runtime. A change rebuilds the broker (the ACL changes).
- always
- Router ACL on the downstream. For the own site and the sites it relays: ingress
queryand egressreplyon…/{downstream,dataflows,storage}/**/~setand…/**/~act/*for every upstream (upstream-write-in/-out); the same on…/sys/**only for an upstream withallow_config(upstream-<u>-config-in/-out, subjectupstream-<u>), with adenyon…/sys/links/*/~act/hello(it checks a link token, not aptok, and answers with the link’s secrets: only the link’s own session asks it;denywins in a Zenoh policy, and no other policy of a peer session allows it). A relayed site’ssysneedsallow_configat every hop (edge for central, plant for edge), as DSA checks the group at each broker. - Keys: the upstream publishes them, the downstream follows them. A token for a key of site
dcarriessite = dand is signed at the upstream (its gateway, or an operator’s admin key). The upstream’s admin answerswy/<u>/sys/signing_keys={write: {<site>: [key…]}, config: {…}}from a queryable on that one key (the router’s~valstorage and the admin’ssys/**queryable do not cross brokers): forwrite, its own admin keys and gateway key and every key it learned from its own upstreams (so plant, below edge, trusts central’s keys too); forconfig, its own keys and theconfigkeys of the upstreams it allowsconfig, so a key reachesconfigbelow only if every hop on the way allows it. Never a flow key: flows do not reach other sites (owner decision 8).- The downstream’s admin asks each upstream for it every 10 s over the peer link (ACL:
signers-<u>-out/-inhere,signers-<d>-in/-outthere, exactly that key, the queryable’s declaration included). It is checked (at most 16 sites, 8 keys each, 32-byte keys) and stored in the registry (Registry::signers,config_signers, SCHEMA 18). Only a real change rebuilds the broker, so a reconnect does not loop; the first connection to an upstream rebuilds once. Keys of an upstream that is gone are not trusted. - Every key is trusted as a
LimitedKey, never as an admin key:writekeys by links underwy/<d>/downstream, the flow engine underwy/<d>/dataflows, the storage underwy/<d>/storage;configkeys atconfigby all four (the admin underwy/<d>/sys, links, flow engine and storage under their sections), only from an upstream withallow_config. Process links get them inhelloafter the rebuild. The token’s own grants andmaxstill apply: the effective right is the smaller of the user’s grant at the upstream and the downstream’s cap.
- The downstream’s admin asks each upstream for it every 10 s over the peer link (ACL:
- Gateway on the upstream.
setandinvokeon a downstream site are allowed (WebSocket andPOST /api/invoke). The user’s grants are checked as for the own site (wy/<d>/xaswy/<u>/x, as reads already were), and the token is minted for sitedwith the own-site grants rewritten towy/<d>/…(wy/**grants stay) and the subjectuser:<name>@<u>, so the downstream’s audit names where the user came from. Grants are therefore a policy for every site below: an operator on the upstream writes every downstream site’s devices, as far as each downstream allows. - Clocks. Tokens live 5 minutes (
PTOK_TTL) and are checked against the downstream’s clock: sites must keep their clocks within a few minutes (NTP).
Consequences
- A downstream that trusts an upstream for
writetrusts every site above it (the keys come through its upstream); refusing that means not connecting to that upstream. - Requests from above are audited on the downstream like local ones (
sys/audit/<link>, subjectuser:<name>@<site>) and share the per-caller rate limits. - An operator at the upstream with an admin key reaches a downstream with a token for that site (
SigningTokens::new(key, "<d>"));wyrkeeps the own site by default. - Rotating a key at the upstream reaches the downstream within about 10 s, with one rebuild.
- A
sysaction from an upstream withoutallow_configis dropped by the ACL: the caller waits for its timeout instead of gettingpermission_denied. - A
configaction on a link from an upstream withoutallow_configreaches the link (the ACL lets every~actondownstreamthrough) and getspermission_denied, without detail (spec 04).
Alternatives
- Keys in the enrollment answer (ADR 0015):
wyrmd.json5upstreams never enroll, and a rotated key would need a new enrollment. - Keys typed into
sys/upstream: manual, and a chain would need central’s keys typed at plant. - The downstream re-signs requests from its upstream: Zenoh routes queries end to end; the downstream sees no hop where it could.