Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ADR 0029 — Decisions delegated by the owner

Status: accepted · 2026-10-31 (owner: “my answers decide nothing; make the changes yourself and record each rule in the documentation”).

Context

Several questions stayed open in CLAUDE.md and in the notes of earlier work (ADR 0022, 0024, 0027, 0028, the Modbus parity plan). Most of them were already answered by the code; they were only not written down as decisions. The owner delegated them on 2026-10-31. This ADR records each one in one place, with what it costs if it is wrong. User guides carry the rules that users meet.

Decisions

1. Selector parameters are joined with &

Spec 01 writes key?param=value&…; a match value uses ; inside it (is:<code>;unit:°C). Zenoh 1.10 Parameters splits on ;, so every SDK reads the raw selector string and splits on & itself (checked through a router hop). No spec change. If wrong: a client that builds selectors with Zenoh’s Parameters sends one long parameter; the responder answers invalid_message.

2. The requester sets the QoS of a request

A Zenoh reply takes the QoS of its query, so the requester chooses it: wyrm-client (and through it the gateway, the flow engine, the FFI and wyr) sends ~set and ~act/* queries with InteractiveHigh + Block + express, and ~meta/~val reads with the defaults of spec 05. A process link’s SDK does the same for its own requests. Spec 05’s QoS table describes the query; the responder does not set a reply QoS. If wrong: a third-party client with default QoS gets its command replies at Data priority behind value traffic.

3. A ptok is used once per responder

Spec 04 0.2.11 states it: each responder remembers a token’s jti until its exp and refuses it a second time (permission_denied). The memory is per process and not kept across a restart, so after a restart a token seen before can be used again until its exp. The SDK refuses a token whose exp is more than 15 minutes ahead (MAX_TOKEN_TTL_S), which bounds that window. A full cache (65 536 tokens that have not expired) refuses new tokens until one expires rather than forgetting one. Amended 2026-11-01 (spec 04 0.2.12, security review): the responder remembers a jti only after it found a grant for the request key, and one sub holds at most a quarter of the cache (16 384 tokens). Without this, any caller with a valid signature could fill the cache with tokens for keys it has no rights on and lock every writer out of a link for 15 minutes. A caller that needs more than 16 384 live tokens on one responder (about 270 per second at the default 60 s lifetime) is refused until its tokens expire. If wrong: a captured token replays once after a responder restart, within 15 minutes. TLS on every non-loopback hop makes capture the hard part.

4. The broker persists its own state with wyrm-state, not a Zenoh volume

The registry (links, grants, ACL inputs, peers, profiles pub/**, history watches, options), the gateway users, the flow definitions and their node state, broker storage and the historian are kept by their owners (WAL + postcard snapshot, or redb for storage and the historian). Zenoh’s storage manager keeps only wy/**/~val in memory (the last value for a late subscriber). The rocksdb volume is not used: it exists only as a dynamic .so, which principle 2 forbids. If wrong: nothing is lost on restart that the owner of a key does not declare again; a ~val of a link appears again on its next sample.

Every protocol link has a simulator in its crate, and the tests run against it. No link has been checked against a real device or a third-party simulator (diagslave for Modbus) yet; the guides say so in their limits. This is a gap in evidence, not a decision to skip it.

6. rustls stays pinned at =0.23.45

zenoh-link-tls 1.10.1 reads and writes one TLS session from two tasks; rustls 0.23.46 checks the shared state on every write, and the race shows as SIGBUS or dropped TLS sessions. The pin is in the root Cargo.toml with the reason. Revisit it when Zenoh is upgraded (quarterly, with the fixture suite): drop the pin when the TLS link no longer shares one session between tasks. If wrong: rustls fixes after 0.23.45 do not reach the broker until then.

7. Audit records sent during a reconnect can be lost

A link puts an audit record (sys/audit/<link>) at Background priority, without an acknowledgement. A record put while the link has no session to the router is dropped. The responder still refuses or answers the request as usual; only the record is missing. A resend needs an acknowledged audit path (a spec change); it is not done. If wrong: the audit misses commands that ran during a broker restart or a network cut.

Added 2026-11-20 (audit write path, docs/backlog.md §14). The broker’s side of the same record: what a link put and the broker received is queued (at most 1024 records, the subscriber waits when the queue is full) and written by the journal’s one writer thread with the next batch, one fsync per batch. Nobody is answered for such a record, so a kill of the broker loses the ones still in the queue (before: the ones still in the subscriber’s queue); a stop writes them all. The broker’s own records are not in this class: Control::record returns after the fsync that covers the record. docs/operations.md §1 states both.

8. RUSTSEC-2023-0071 (rsa 0.9, Marvin timing) is accepted in links/opcua

async-opcua uses rsa for the RSA security policies of OPC UA, and no fixed rsa release exists. The attack needs many timed decryptions by the server under attack; the link is a client that decrypts only the server’s replies to its own session. docs/opcua.md states it. If wrong: an attacker who can time many of the link’s decryptions on the network could recover a session key.

9. Modbus residuals stay as built

  • A ~set waits behind a running read action (read_registers, scan_units) on the same connection for at most the driver timeout (5 s) and may answer timeout (Modbus parity plan, ruling P33; docs/modbus.md).
  • ip_slave binds its port when the connection starts. If the router still holds the port during a rebuild, the connection goes Failed and retries with backoff (finding M8): no separate wait is added.
  • A slave answers exception 0x04 for a register whose bits the tree has not set yet, never a made-up 0 (rulings P24, P28).

10. A scheduler target writes only within its author’s rights

Defining or changing a target stays a config action (ADR 0022, ruling 6). The scheduler now also keeps the author’s auth grants (spec 04 0.2.10) with each target, as DQL does with a sink (ADR 0025 item 4), and refuses a target write outside them when it fires. A target stored before this change has no author grants and is refused until a user with config edits it again. If wrong: a target that worked before stops until it is edited once.

11. File stores: the low items of ADR 0027/0028 are closed

  • A connection name . or .. is refused (invalid_message).
  • A 206 reply must carry a Content-Range that starts at the asked offset; otherwise the part is refused, not used.
  • A 416 reply for an offset at or past the end of a file answers {data: [], eof: true} with the size from Content-Range: bytes */<size>.
  • upload_begin refuses a file larger than the free space of the link’s disk (minus 1 GiB), checked again at each part.
  • Spool cleanup runs on the blocking pool, not on a tokio worker.
  • An S3 multipart upload cut by Stop or Edit is aborted (AbortMultipartUpload) before the connection closes.

12. An unknown level code in a stored role grant refuses the users store

Added 2026-11-15 (typing audit). The gateway users store keeps each runtime role grant as a typed RoleGrant { key, perm: Perm }, on disk in the layout it had as (String, u8) (so SCHEMA stays 5 and older stores open unchanged). A level code that this build does not know is a decode error of the WAL record and of the snapshot: the store does not open, and the gateway, so wyrmd, does not start; the error names the key and the code. It is never read with the grant dropped, and the role never gets “no grants” either: grants match first-intersect (ADR 0031), so a dropped restricting grant before a broad one widens access, and a silently emptied role would hide the problem until a user notices. Replay already refused such a code through apply; only a snapshot loaded it. The code can come only from a newer WYRM (a downgrade) or a restore from one: go back to that version, or remove the role’s runtime grants with it, before downgrading. If wrong: a downgrade over a store that a newer version wrote with a new level stops the broker at start instead of starting with that role reduced.

13. A history selector names each parameter once

Added 2026-11-15 (typing audit, spec 01 0.2.35). The historian parses a ~val?history= selector into the typed wyrm_core::history::HistoryQuery that requesters encode, and refuses history with since, a parameter given twice, and any parameter other than history, since, agg, window, limit (invalid_parameter). Names that start with _ belong to Zenoh and are skipped, so a Zenoh option on the query never breaks a read. A selector without history or since stays the storage’s, whatever else it carries. If wrong: a third-party client that adds its own parameter to a history read gets invalid_parameter.

14. An agent task of an unknown state is kept, not loaded

Added 2026-11-16 (owner decision, typing audit of #127, commit b961157c). The agent link keeps each task’s state by its name as OrUnknown<TaskState> (links/agent/src/store.rs). A name this build does not know (a newer build wrote it) does not refuse the whole task store, as a closed set otherwise would (item 12): only that task is not loaded. It is logged, its id stays taken, and its record stays as written, byte for byte, through reloads, compaction and later writes, so the build that wrote it reads it again. A task is one operator request, not a grant: dropping it from the running set narrows nothing and widens nothing. This is the one closed set that tolerates an unknown value; every other one refuses it (docs/rust-rules.md §6). If wrong: after a downgrade, a task a newer build made is not listed until the newer build runs again.

Not decided here

  • New framework hooks that links asked for (per-point quality, poll_period with connection and device params, the sample time from the driver, ~meta from device data, a driver-owned connection leaf) are work items in docs/backlog.md, not decisions.
  • The wyrm:app world after 0.2.0 (TLS imports, a host random source) gets its own ADR.