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 0036 — Broker fault tolerance: supervised restart, endpoint lists with liveliness arbitration, warm standby by WAL replication

Status: accepted · 2026-11-05, built (options 1, 2 and 3 with stages A, B and C; amended 2026-11-08: lease arbiters, healed-split reports, history-sync cursors) (owner question: what can WYRM do for broker redundancy, what do the alternatives do, what does each option cost; owner choice: options 1 + 2 + 3 of the assessment below). Option 3 stages A and B done 2026-11-05, stage C 2026-11-06 (see “Built, stage A/B/C” under Decision). Option 2 done 2026-11-05: WYRM_ENDPOINT and wyrm_client::endpoint (wyr --connect, the FFI) take comma-separated lists; a link process opens one session per endpoint and serves a router only while wy/<site>/sys/broker is there (WYRM_BROKER_WAIT_S, default 15 s, then the next endpoint; a round of unreachable endpoints backs off 1 s ×2 up to 5 s); Dart WyrmGateway.loginAny keeps the credentials and logs in again on the next gateway; e2e link_process_walks_its_endpoints (a dead port, a plain router without the token, the broker; then the broker stops and a second broker on the dead port takes the link over). Option 1 done 2026-11-05: docs/operations.md, wyrmd stops cleanly on SIGTERM as on SIGINT, the process link hello back-off is capped at 5 s (process::HELLO_BACKOFF_MAX), e2e broker_restart_rto kills a real wyrmd with SIGKILL and prints the recovery time and the base RSS.

Context

Today a site is one wyrmd on one host. Process links know one WYRM_ENDPOINT; wyr, the FFI and the Dart packages know one endpoint or one gateway URL. All state sits in that host’s data_dir: the control plane in the WAL + snapshot of wyrm-state (ADR 0003: append-only, HMAC-chained, every append fsynced, the snapshot only a cache), and beside it secrets.bin with secrets.key, the PKI (the site CA, link.pem, gateway.key, flows.key, .requester_key), the historian’s redb files (ADR 0014), the storage redb (ADR 0017), the sealed stores of the portable Apps (scheduler, alarm, dql, uplink; ADR 0023) and the sealed runtime edits of framework drivers in data_dir/links/<id>/data (ADR 0004, driver::persist). ~val lives only in the router’s memory storage (ADR 0029, decision 4). A lost host or disk is a lost site, and a link has nowhere else to connect.

What the design already gives:

  • Restart is the recovery path. Links own and re-declare their subtree on every (re)connect; what is not re-declared does not exist (ADR 0003). Every ACL change rebuilds the router runtime (ADR 0006) and links, gateway clients and peers survive it: each rebuild is a rehearsed broker outage.
  • Links already watch the broker. A process link subscribes to the liveliness token wy/<site>/sys/broker before it starts, trusts no key while the token is gone, and repeats hello and the re-publication when it is back (process.rs, LinkConfig.republish_on).
  • Journals with a cursor exist. The historian’s change journal with next {after, max} (ADR 0026) and the alarm sinks (ADR 0034) replay from a sequence; the WAL is itself such a journal, keyed by lsn.
  • Sites are autonomous. A downstream site runs without its upstream and catches up through sinks (store-and-forward), as DSA and Sparkplug sites do.

Failure classes used below: F1 process crash, F2 host down, F3 disk lost, F4 network split between the two broker hosts (split brain), F5 network lost between a link and the broker, F6 upstream unreachable.

What the alternatives do (2026-11-05 survey):

SystemModelWhat it tells us
IOT-DSANo cluster; upstream/downstream hierarchy, dslinks reconnect, HA at the VM levelWhere WYRM is today
Sparkplug BAn edge node holds a list of MQTT servers; the Primary Host publishes STATE ONLINE/OFFLINE; the node walks the list until it finds a server where the host is online; store-and-forward meanwhileOption 2, one to one, with sys/broker as STATE
IgnitionMaster/backup pair, full state sync over its own channel, warm or cold backup, clients and drivers follow the activeOption 3; “warm” = configuration ready, devices not polled
OPC UA Part 4Non-transparent redundancy: cold/warm/hot, the client knows the ServerUriArray and fails over itself; transparent redundancy at the network levelThe cold/warm/hot vocabulary
EMQX, HiveMQ, VerneMQReal clusters: metadata in Mnesia/Mria or CRDTs, sessions sharded by consistent hashing, clients behind a load balancer, their own split-brain rulesOption 5, for cloud MQTT, not for a site broker
MosquittoNo cluster: a bridge, or active/passive with keepalived and a mirrored persistence fileOption 1 plus a VIP
NATS JetStream, Kafka, RabbitMQ quorum queuesRaft-replicated logs, 3 or 5 replicas, leader electionOption 5
Zenoh itselfA mesh of routers, a client with a list of connect/endpoints and retry, storage replication through an aligner (needs timestamping); no consensus, no leader electionOptions 2 and 4 without patching Zenoh (principle 2)

Options assessed

Effort in person-days of one engineer who knows the code base, tests included (tests dominate). Target platform: the reference board, 4-core ARM64, 2 GB. All figures are estimates.

1. Supervised restart2. Endpoint lists + liveliness arbitration3. Warm standby, WAL replication4. Mesh of two routers5. Raft cluster, 3 nodes
Effort, days2–35–840–60+10–15 on top of 390–130
Extra hardwarenonenone+1 host of the same board+1 host (the one of 3)+2 hosts
CPU/RAM of the standby00base wyrmd without links, ~1 % CPUthe whole ~val flow on the second router: a second memory storage, inter-router traffic = every sampleas 4 plus consensus on every write
Network between hosts00WAL: bytes per operation, rarely; history ≈ write rate × ~40 B per rowall of ~val, alwayslog + heartbeats
Operationsa systemd unit, a data_dir backupnothing newkey sharing, a VIP or arbitration, replication lag monitoringone more ACL subject, two gatewaysquorum, 3 hosts, runbooks
RTO5–40 s (restart 1–3 s; link back-off today up to 30 s)only with 3 or 410–30 s (detection T + router build + hello)~0 s for readers, as 3 for commands5–15 s
RPO, control plane0 (every WAL append fsynced)0≈ 0 (asynchronous: the last operation may not have arrived)as 30
RPO, history and ~valhistory rows pending a flush at SIGKILL; ~val until re-publicationthe samethe same plus replication lagthe same0 for replicated stores
CoversF1, F5, F6F5 (which router)F1, F2, F3, F6; F4 only with fencingF5 for readersF1–F4, F6

Why 4 and 5 are not taken:

  • Option 4 adds a path for readers connected to Zenoh directly and read scaling. Gateway clients, upstreams and links are covered by 2 + 3 already (same CN, same endpoint list). The price is the whole ~val flow between routers, always, and a second memory storage, which a 2 GB board feels. Deferred until a real need for reader scaling or “zero seconds for dashboards”.
  • Option 5 does not remove the hard part: links are single-active because of the devices (Modbus TCP connection limits, serial ports, OPC UA sessions), so the link failover of option 3 is needed anyway, and principle 4 (nobody reads another component’s state) would put a replicated log into every component that owns state. Its one gain is fencing without an external VIP, which option 2 provides more cheaply. Refused before 1.0.

Decision

Options 1, 2 and 3 together; 3 in three stages, each useful on its own.

Option 1 — supervised restart (now)

  • wyrmd is run under a supervisor (systemd Restart=always, or the container runtime); docs/operations.md documents the unit, the data_dir backup (the WAL and the key files are what cannot be regenerated) and the restore.
  • The process link back-off cap goes from 30 s to 5 s (process.rs): with 30 s the link’s timer, not the broker, sets the RTO. The SDK runtime keeps its own schedule.
  • An e2e test broker_restart_rto kills the active broker (SIGKILL, not a rebuild), starts it again and measures the time until every link’s liveliness token and last value are back; the number goes to docs/backlog.md beside the wyr bench figures and is measured on the reference board.
  • The historian’s pending rows are lost on a kill (flush_ms, pending cap 200 000): accepted as the RPO of history on F1; the flush interval is the knob.

Option 2 — endpoint lists and liveliness arbitration

  • WYRM_ENDPOINT takes a comma-separated list; wyrm_client::endpoint (shared by wyr, the FFI and Dart) takes a list too, and the Dart WyrmGateway.client() takes a list of gateway URLs. Zenoh’s client mode connects to the first endpoint it reaches and tries the list again when the session drops; nothing in WYRM re-implements that.
  • Arbitration by the broker’s token. A link declares its tree and answers hello only on a router where the liveliness token wy/<site>/sys/broker is present (it already waits for it). Two brokers claiming the same site at once are therefore never both served by a link: the token is one key, and Zenoh liveliness shows a link the tokens it can reach. This is Sparkplug’s STATE rule with a key WYRM already has.
  • Alone, option 2 changes nothing in a one-broker site; it is the fencing of option 3 and the reason no VIP is required.

Option 3 — warm standby by WAL replication

A second wyrmd on a second host, role standby, the same site name, with the site’s keys. It holds the control plane and the sealed stores current and runs no router, no links, no engines until it is promoted. “Warm” as in Ignition and OPC UA: configuration ready, devices not polled.

  • Role and keys (stage A). wyrmd.json5 gets standby: { of: "quic/<active>:7448", ca, enroll } on the standby and peers.standby: { allow } on the active. The standby needs the site’s own keys, or links and upstreams would not trust it after promotion: the site CA, state.key, secrets.key, gateway.key, flows.key, the requester keys and the link store keys (the last ones live in secrets.bin and come with it). They are shared once, by an operator, as a sealed bundle (wyrmd keys export --to <file> with a one-time passphrase, Argon2id + ChaCha20-Poly1305, wyrmd keys import on the standby), never over the network. The standby then enrolls on the active’s peers.enroll listener as ADR 0015 brokers do and gets a certificate with CN standby:<site>, a subject of its own in the ACL (QUIC only, read of the replication keys only, nothing else).
  • WAL replication (stage A). The active serves one queryable, wy/<site>/sys/replication/wal, answering next {after: lsn, max} with the raw WAL records from lsn + 1 (the HMAC chain comes with them: the standby verifies every record with the shared state.key, so a tampered or reordered feed is refused as a local tampered WAL is). The standby appends them to its own WAL and applies the Ops to its registry with side effects off (no router build, no process start, no audit record of its own). Replication is asynchronous; sys/replication/{lag_records, lag_ms, standby_connected} on the active and sys/standby/{status, lag_records, lag_ms, last_lsn} on the standby show it. Secrets go the same way: secrets.bin records are already ciphertext under secrets.key, so the active ships (seq, name, ciphertext) from sys/replication/secrets and the standby writes them as they are.
  • Promotion and demotion (stage A). The standby keeps a liveliness subscriber on wy/<site>/sys/broker through its QUIC session to the active. When the token is gone for standby.takeover_s (default 10 s; the session loss itself counts), it promotes itself: opens the router with the full configuration, declares sys/broker, starts embedded links and engines, and the process links, gateway clients, peers and upstreams come to it through their endpoint lists (option 2). A promoted standby writes a Promoted {from_lsn} record into the WAL and the audit journal. The former active, when it comes back, first looks for sys/broker on its standby peer; if the token is there it starts as the standby of that host (Demoted record) instead of building a router. Two brokers that cannot see each other (F4) each believe they are alone: the links decide, since they serve only one token (option 2), and the upstream refuses a second broker:<site> connection while one is up (ADR 0007 peers: one presence token per CN). Roles swap by design; there is no “primary host” fixed in configuration, only standby.of as the initial pair.
  • Built, stage A (2026-11-05; the three bullets above record the design before it, decided under ADR 0029 where it differs).
    • Configuration is symmetric. Both brokers carry peers.listen (a QUIC listener) and standby: { peer: "quic/<other>:7449", takeover_s: 10, primary }. There is no peers.standby on the active and no standby.of: either host may be the active one, and wyrmd decides at start. Both wyrmd.json5 files should otherwise be the same (links, gateway, admin_keys): a promotion opens the daemon on the followed data_dir with the standby host’s configuration.
    • No enrollment. The key bundle (wyrmd keys export <file> on the active, wyrmd keys import <file> into the standby’s empty data_dir; WYRM_KEYS_PASSPHRASE or stdin, at least 12 characters; "WYKB1" | salt | ChaCha20-Poly1305(Argon2id(passphrase, salt), cbor {name: bytes})) carries the site CA with its key, state.key, secrets.key, flows.key and the gateway’s hmac.key and gateway.key, so the standby issues itself a standby:<site> certificate from the CA (data_dir/standby/). Import refuses to overwrite any of those files. The ACL subject standby (CN standby:<site>, QUIC) exists whenever peers.listen is set: only the site’s own CA can mint that name.
    • Three WALs, by file, no apply. The active answers wy/<site>/sys/replication/wal/<store>/<after>/<max> (state = the registry, flows, users; ≤ 512 records) with {chain, last, records: [[lsn, mac, op], …]} from its segment files (wyrm_state::replicate::records_after); the standby (wyrm_state::replicate::Follower) appends each record after checking its MAC against its own chain with the shared key, and holds the store’s LOCK. It applies nothing: a promotion is Daemon::open, which replays the WAL as after any restart. The audit journal is not replicated (it stays on the host that wrote it). With state_anchor_dir the follower keeps the anchors at its head.
    • A fork is a restart from zero. When the active’s chain MAC at the standby’s LSN is not the standby’s own (a former active with records its standby never got), the follower moves the store aside as <store>.stale.<n> and follows from LSN 0. No walk back: the control-plane WALs are small.
    • Files. secrets.bin (one sealed blob, rewritten whole) and every links/<id>/token (the plaintext a link’s hello carries; its argon2 hash is in the registry) are listed by sys/replication/files [{name, sha256}] and fetched by sys/replication/file/<name> as {name, sha256, sealed}, sealed with SHA-256("wyrm-replication-files" ‖ secrets.key): the peer link is mTLS, and still no secret crosses it in clear. Link certificates are not copied: the promoted broker issues them from its copy of the CA.
    • Away means no answer. The follower polls every second (WALs; the file list every fifth poll); the active counts as away from the first poll without an answer, from a liveliness Delete of wy/<site>/sys/broker, or from a failed connect. A primary: true host takes over after takeover_s, the other after three times that (a cold start of both ends with the primary active; a lone start takes over after its own wait). An ACL rebuild of the active that waits long for its QUIC port (QUIC_PORT_WAIT, up to 30 s) can look like an absence: the primary rule below resolves it.
    • Promotion and demotion are audit records, promoted and demoted by system, not WAL records (no registry schema change). An active broker that is not primary asks the peer every 5 s whether the primary’s broker token is there and, when it is, ends its daemon and follows again; the primary never steps down. The former active, at start, follows (it counts the peer as away until the first answer, so with the peer up it never takes over).
    • No failback (amended 2026-11-07). A returning primary finds the other host active and follows it; it does not take the role back, since that would cost a second gap. The primary rule above applies only when both are active, after a split has healed. An operator moves the role back by stopping the active at a quiet moment.
    • Witnesses and fencing (amended 2026-11-07, review of the split case). Links decide by the broker token only when they are external; embedded and supervised links, the scheduler, alarm, uplink and dataflows run on every active broker, so two actives across a split would poll and write the devices twice. standby.witness (required, one or more host:port on the plant network) closes that: the standby takes over only while at least one witness accepts a TCP connection (witness_reachable, all at once, 1 s each), and an active broker that reaches no witness and has not been asked by its standby for 3 s steps down after half of takeover_s (isolated, audit demoted “cut off”), before the other side’s full takeover time ends. A fenced broker follows and takes over again on its own when a witness answers and no active does. Left open then and closed by the lease arbiters below (2026-11-08; without standby.arbiter it stays open): a split where both hosts still reach a witness but not each other (a firewall between them, a hung process, an expired standby certificate, which the follower now issues again whenever it opens a session) still gives two actives until they see each other again; an active whose witnesses are all down while its standby is down too steps down, and the site has no broker until a witness answers.
    • Lease arbiters (amended 2026-11-08, decided under ADR 0029). The case left open above (both hosts reach a witness, not each other) needs something both sides talk to that holds who has the role; a TCP port cannot. standby.arbiter (optional, ≤ 9, host:port; a warning at start without it) names lease arbiters: wyrmd arbiter serve --dir <d> --listen <addr> on a third host, its directory written by wyrmd arbiter issue --host <h> --out <d> on a broker of the pair (the site CA certificate, arbiter:<site> for h, the site name; no private key of the site). TLS over TCP with the site CA on both ends; the arbiter takes only a standby:<site> client certificate. One request per connection, u32 length + canonical CBOR: {op: hold|release, holder, ttl_ms} → {state: granted|held|recovering|released, holder?, left_ms}; holder is the host’s own random id (standby/host.id, not replicated) joined with a hash of its standby.peer (a data_dir copied from the other host still gives another name). The broker checks that the arbiter’s certificate is arbiter:<site> (the site CA signs links and lower brokers too), builds its TLS client from the current standby:<site> certificate on every round (issued again when due), and warns once when no arbiter answers; the arbiter’s certificate lasts 20 years (nothing renews it on its host). sys/arbiter_lease_s on the active shows the seconds left of its lease (0: none). The active’s renewals count from the send time of the takeover’s own grant (Arbiters::granted_at, shared with follow_with). The lease lasts half of takeover_s within 3–30 s, lives in the arbiter’s memory, and a started arbiter grants nothing for 30 s (a lease it forgot may still run). Rules: the standby takes over only when a majority grants it the lease (acquire; a minority’s grants are released at once), and waits at least 5 s with arbiters (the active’s quiet rule below must fire first); the active renews every second from the moment of the takeover, before the daemon opens; told held by a majority it cannot win, it steps down at once (demoted “another broker holds the arbiters’ lease”); without answers it keeps its lease until the send time of its last granted renewal plus the lease less 1 s (the arbiter counts from its read, later), then steps down only if its standby has not asked for 3 s (a standby that asks follows it and cannot take over). It releases the lease on a stop or step-down. One arbiter is a single point only together with the standby: both down, the active steps down; three arbiters ride that out. A hung active that resumes after its lease ran out acts for at most a second before its renewal is refused. The primary rule stays (with arbiters both can only be active for that second). Tests: arbiter_keeps_a_split_to_one_active (the standby’s peer is a dead port; no takeover while the active renews; takeover once it stops; the former active is told held and steps down), a_broker_without_its_lease_steps_down (the real wyrmd process: no takeover without the arbiter, active with it, steps down when the lease runs out though the witness answers, active again with a new arbiter), unit tests of the lease, the frames and the majority.
    • Healed split, what the loser wrote (amended 2026-11-08). A host is marked while it is active (standby/active, written at promotion). Its first follow after that moves aside, instead of removing or overwriting, the files the active does not list or lists with other contents (standby/stale/<t_ms>/files/), and exports its storage tree when it differs from the active’s first full tree (standby/stale/<t_ms>/storage.json, wyrm-storage JSON); then the mark goes. A forked WAL is moved aside as before (<dir>.stale.<n>), with or without the mark. Each set is reported to the active as sys/replication/forked/<t_ms>/<what>/<count>/<n> (kept in standby/forks until answered; any answer counts, an older active answers with an error), and the active writes one audit record standby_forked (key = the set, detail = the place on the other host) per (t_ms, what) and counts them in sys/standby_forks. Nothing is merged: an operator enters again what must stay. History rows are not moved: the loser’s rows stay in its store beside the copied ones (stage C).
    • History-sync cursors (amended 2026-11-08). The history page carries the active’s sink cursors (sinks: {name: seq}, standby-* left out; absent from an older active). The standby keeps a mark active seq → local last_seq after each copied page (≤ 4 096 per active store, in memory) and sets each sink’s local cursor to the mark at or below the active’s cursor, so after a failover a sink sends again at most the page between the mark and its cursor (the targets replace on (key, t)); a sink further behind than the oldest mark keeps its local cursor; a local sink the active no longer has is forgotten. A former active’s sinks that had not confirmed all of its own rows are not moved (standby/own_sinks, until it is active again): they send those rows, and the copied ones after them, again. One case is left: a sink created on the other host during a split, which a former active never had, is mapped past the former active’s own rows (its first mark holds them); those rows reach that sink’s target only if they had reached the other host before the split. Tests: sink_cursors_are_carried_in_local_numbers, own_sinks_are_kept_until_this_host_is_active; the moved-aside sets in standby_takes_over_and_the_old_active_demotes.
    • Rebuild hold (amended 2026-11-07). Before an ACL rebuild the active stores a hold of 60 s (Control::hold_standby), carried as hold_until (unix ms) in every registry page it serves, and, with a standby asking in the last 5 s, waits 2.5 s for it to be read; the standby moves its takeover deadline past the hold (at most 120 s ahead). The hold is released as soon as the new router is up. An active that really dies during a rebuild is taken over up to 60 s later.
    • What the active shows: sys/standby_connected (1 while the standby’s last registry query is younger than 15 s) and sys/standby_lag (registry records it had not received). The standby runs no router and shows nothing; its log says what it does.
    • Tests: standby_waits_for_a_witness, standby_holds_during_a_rebuild, cut_off_active_steps_down (the real wyrmd process: takes over, steps down when cut off, takes over again), standby_follows_the_wal, standby_takes_over_and_the_old_active_demotes (e2e), follower_*/a_forked_follower_moves_its_history_aside (wyrm-state), bundle_roundtrip_and_refusals, pages_roundtrip_and_file_names, standby_reads_replication_only. Not tested: two brokers active at once stepping down (needs two routers of one site in one process).
  • Built, stage B (2026-11-05). No journals in the stores after all: the sealed stores of the portable Apps (one file per key, ciphertext under the link’s store key, which secrets.bin carries), the framework trees (links/<id>/data/framework.tree, sealed the same way), the agent’s WAL and every installed package (packages/**, the component store included) are files, written by a temporary name and one rename, so the active lists them (sys/replication/files: name, length, mtime; scratch names and uploads/ left out) and the standby copies the ones whose listing changed, in parts of 1 MiB (file/<offset>/<len>/<name>, each part sealed with the key from secrets.key, SHA-256 of the whole file with the first part, checked before the rename), and removes what the active no longer lists. A file over 64 MiB is skipped and logged. Since ADR 0051 §1 the seed’s seed.done and seed.progress.json (top level of data_dir) are listed too, so a promoted standby never runs a finished seed again and goes on with an unfinished one. The broker storage is a redb database, which a file copy cannot take safely while it is written: wyrm_storage::Store keeps a revision counter with an epoch (set at open) and a journal of its last 20 000 changes, and the active answers storage/<epoch>/<since>/<max> with the changes after since as {epoch, rev, full, put: [[path, rec]], delete: [path]}, the whole tree when since is from another epoch, ahead, or older than the journal; the standby applies them into its own storage database, open while it follows. The sealed stores of a link are copied as the link wrote them: secrets.bin with the store keys comes along, and a promoted broker opens them as after a restart. Tests: standby_follows_stores (e2e), changes_since_pages_journal_and_falls_back_to_full (wyrm-storage), file_lists_walk_the_replicated_roots_only, storage_changes_roundtrip.
  • Built, stage C (2026-11-06). Not a history-sync target after all: the standby holds no link identity, so it reads the historian’s change journal where it reads everything else, wy/<site>/sys/replication/history/<after>/<max> (wyrm_history::Store::changes, every series, ≤ 2 000 rows or 4 MiB per answer), as {id, next, last, rows: [[seq, key, t, v, q], …]}, and writes the rows into its own historian store (data_dir/history, open while it follows; a row with the same series and time replaces the stored one, so a page read twice does no harm). The cursor lives in the standby’s store under the sink name standby-<id>, where id is the active store’s identity (meta/id in index.redb, made once at creation): after a failover the new active is another store with journal numbers of its own, so the cursor starts again for it, and the former active, now following, carries its own rows on beside the copied ones. Watch groups come with the registry (stage A), so the promoted broker records on and answers Get History from both. Tests: standby_follows_history (e2e), history_pages_roundtrip.
  • Sealed stores and driver edits (stage B, as designed). The portable runtime’s store already applies writes per job with a committed sequence; store_put/store_delete get a journal (seq, key, ciphertext) under the store key, served as sys/replication/stores/<link> with next {after, max}; the framework’s driver::persist writes join the same journal for framework links. The standby writes the ciphertext files as they are. Storage (wyrm-storage) gets a seq per change and the same next, served as sys/replication/storage.
  • History (stage C). The standby is one more history sink reader: a Target of wyrm-history-sync that writes into the standby’s own wyrm-history store (crates/wyrm-history-sync, ADR 0026), reading sys/history/sinks/standby with next {after, max}. After promotion the day files continue from what arrived; the gap is the sink lag. Until stage C ships, history is a gap after a failover, by decision.
  • What is not replicated. ~val (links refill it), gateway sessions (users log in again; tokens still verify, the key is shared), the audit journal of the former active (it stays on its disk; the standby’s own audit starts at promotion), process link output logs, a pending setup code (data_dir/gateway/setup.hash, ADR 0051 §3: it belongs to its host; each host of a pair is made with its own setup_file, and since users replicate, the other host’s setup is void once an admin exists), packages in data_dir/packages (stage B copies package files by SHA-256 through sys/replication/packages, since a link install is an Op that names them; until then an operator keeps the two package directories equal).
  • Tests. e2e on two brokers in one process space over QUIC: standby_follows_the_wal (installs, ACL change, a secret, a scheduler event; the standby’s registry equals the active’s), standby_takes_over (SIGKILL the active; links, a gateway client and an upstream are back on the standby within the measured RTO; a set works), old_active_demotes (it comes back and becomes the standby; its stale WAL tail after the fork point is refused and archived as wal.stale.<lsn>), split_brain_links_serve_one_token, standby_refuses_a_tampered_feed.

Consequences

  • Two hosts hold the site’s keys. Adding a standby is a trust decision of the same weight as adding a downstream CA was (ADR 0007): whoever holds the standby’s data_dir is the site. The bundle never crosses the network in WYRM’s own protocol; the operator carries it.
  • RPO is not zero and is not meant to be. Asynchronous replication can lose the operation an administrator was making at the moment of the crash; they will see it. Synchronous replication (waiting for the standby’s acknowledgement on every Op) would make the active depend on the standby, one more way to fail. Refused.
  • Exactly one active, always. Everything that owns state (admin, flow engine, storage, scheduler, alarm, dql, uplink, every link) runs on the active only; a standby is idle. This follows principle 3 (the broker owns only itself) and principle 4 (nobody reads another’s state directly: the standby reads journals through get, not files).
  • Links stay single-active. No link polls a device from two hosts at once; a warm standby cannot be a hot one for devices. OPC UA “hot” is out of reach by the devices’ nature, not by design.
  • A failover costs seconds, not zero. takeover_s plus a router build plus every link’s hello and re-publication. On F4 the links serve whichever broker they reach; two reachable brokers with two tokens are an operator error visible in sys/standby/status and in the audit, not a data corruption: each link serves one.
  • Base RAM of wyrmd without links on the board is not measured yet. Option 1’s test measures it beside the RTO; it decides whether one 2 GB board can be the standby of a site and a working node for something else.
  • docs/backlog.md (section 13) records what is done of each option and stage and what is left; option 4 stays an item with its estimate.

Alternatives

  • A VIP (keepalived, VRRP) in front of two brokers. Needs a shared L2 segment and a privileged daemon, which edge boards and cloud networks often cannot give; still needs the state replication of option 3. Kept as an operator’s choice on top of option 2, never required.
  • Replicating data_dir at the block or file level (DRBD, rsync). Copies redb files mid-write, carries the WAL anyway, and gives no replication lag figure the broker can show. Refused in favour of the journals the components already have.
  • Zenoh storage replication for ~val. The aligner needs timestamping and a storage on both sides; the owners refill ~val on reconnect anyway. Not needed.
  • A standby that also runs the links read-only (“hot”) to shorten the RTO. Devices refuse second connections or answer both, and every driver would need a dry mode. Refused; the RTO is spent in hello and re-publication, which a hot link would not skip.
  • Options 4 and 5, above.