Reeve Docs

Docs / Architecture

Multi-replica cluster

Reeve runs active-active. Every backend replica serves requests, runs every plugin instance and answers for every installed type. One PostgreSQL database decides ownership, liveness and held slots. One Redis carries hints and short-lived coordination that is safe to lose. A single replica is a fleet of one and runs the same code paths.

The shared rules are in constraints. Operator procedures (scaling out, removing a replica, skips, floors) are in running multiple replicas.

            clients (web app, companion)
                      |
          balancer / ingress (no affinity)
          /           |            \
    replica r1    replica r2    replica r3     each: every plugin, every hub, an applier
          \           |            /
   PostgreSQL: members and leases, owned units, held slots, change log,
               status sections, command rows, boot state, roll turns
   Redis:      hint bus, member-ask transport, window claims, SignalR backplane,
               sessions and sign-in flow stores, rate-limit counters

The cluster library

Every replica, a single one included, is a member of the cluster library (Reeve.Cluster) and holds its lease on the database clock. Reeve builds on these primitives:

Primitive Store What Reeve uses it for
Members and leases (reeve_cluster.member) PostgreSQL The roster, liveness, the wait set of a configuration write
Owned units (reeve_cluster.owned, one fencing token per tenure) PostgreSQL Work that runs on exactly one serving replica
Held slots (reeve_cluster.slot) PostgreSQL Per-key mutexes and concurrency limits
Change log and generations PostgreSQL Configuration state rebuilt on every replica
Status registry (reeve_cluster.member_status) PostgreSQL Each replica's status report
Claims Redis At-most-once windows
Member ask and keyed ask Redis Requests between replicas

The reeve_cluster schema belongs to the library. Reeve reads it for diagnosis and through the library's API, and writes it only through the library. The one direct read is the start-up window check (rolling upgrades).

Coordination:Clustered (unset means off) turns on only the coordination a fleet needs beside the library: the Matter bridge's live-state relay, the plugin roll's census, observation replication's default and a few defaults that follow. Owned work, held mutexes, fire de-duplication, the host-build check, requests between replicas and configuration writes run through the library at every replica count.

PostgreSQL decides, Redis hints

Every ownership and liveness decision goes through PostgreSQL. A partition then collapses to one question: can this replica reach the database? Releasing ownership decentrally is safe. Claiming it decentrally is not, because divergent membership views produce two owners or none.

Redis is mandatory on every deployment (constraint) but holds nothing whose loss breaks correctness. Each Redis use states what happens when Redis does not answer. See the arbitration rule.

State kept in Redis has no in-memory twin

The second-factor, passkey, step-up and OIDC hand-off stores, repair-flow sessions and widget previews live in Redis at every replica count. There is no in-memory implementation in production and no backend switch. Nothing pins a follow-up request to the replica that served the first one, so a per-replica store would break the flow. While Redis is down these flows fail closed, as sessions do. A new store for cross-request state is written against Redis or PostgreSQL (no correctness-critical state in one replica's memory).

Replica identity

A replica is a replica id: REPLICA_ID or Workflow:Engine:ReplicaId, required on every process (constraint). A process is the replica id plus a process id drawn once at process start, so a restarted pod that reuses its replica id is a different process.

The plugin roll's census and stage, the module-swap acknowledgement, the occurrence log and a member ask's expected process all key on the process id. A peer's process id comes from its reeve status section. The library's epoch is not used, because it changes at every join, including an in-process fence and rejoin. A running peer without a fresh reeve section makes the roll's census incomplete, and the roll waits.

The roster is the library's

Every roster reader goes through the library's members: the status page, replica removal, the plugin roll's census, the host-build check, observation shares, requests between replicas, the recovery restart, the replica logs and the redescribe walk. Reeve keeps no membership table or heartbeat of its own. A crashed replica stops counting as running when its lease runs out (Cluster:LeaseTtl).

A replica is running while its member row reads joining or active with a valid lease, or fenced. A draining row, an expired lease and an id with no row are not running. The library never deletes a member row, so "has a row" is not "running".

A fenced replica's process lives and is readmitted, so its flows wait rather than being adopted. A replica that exits while fenced keeps its fenced row and reads as running until the same id joins again. Its flows wait, its removal is refused and it holds alert clears. This case (a pod replaced, or a StatefulSet scaled down, during a fence) is refused, not handled. The operator deletes the row (running multiple replicas).

Applied-snapshot agreement stops counting a fenced row 5 minutes after its lease ended, read on the database clock. After Cluster:LeaseTtl (30 s by default) a fenced replica's status writes are refused, so its report can only block an activation, never agree with one. A replica that returns under the same id gets a new epoch and installs the active version like any replica that joins after an activation.

Exclusive work

The cluster library places work that must run on one replica. Reeve elects no coordinator and keeps no assignment map (constraint). Placement is best effort and correctness is hard: churn can cause a brief gap or a duplicated attempt, never double execution, because a holder checks its tenure before an effect outside the cluster. The tenure contract tabulates when each holder learns it lost its tenure and how far it can overlap a successor.

Every unit kind is placed, non-convergent and registered on every replica

Every unit kind goes through AddReeveUnit, AddReeveTenureUnit or AddReeveJob. It uses the placer, is not convergent and is registered on every replica, because the placer places only kinds its own replica registered. A unit with an effect outside the cluster calls EnsureOwner() immediately before it. A unit whose feature is off is still placed and does nothing.

The unit host retries a start that threw, with a backoff growing from 1 s to 30 s. A single node starts its unit kinds one placement pass after it serves. The kinds a replica holds are in its reeve status section and on the Cluster tab. The list is advisory, because a kind can show on two replicas for a moment while it moves.

Singleton work placed this way includes the repository syncs, the trigger host, the OAuth token refresh, the Matter bridge link, the workflow journal reconcile, the helper time tick, the baby monitor evaluator, the workload presence, orphan and observation sweeps, the system-plugin bootstrap and the demo content runs.

Each single-runner job is a unit kind of its own

Every job that needs a single runner (alert maintenance and delivery, command cleanup, device-model retention, discovery cleanup, resource-index sync, object-storage migration, the device-history orphan sweep and similar) is its own unit kind, run only while its replica owns the kind. One kind per job lets the placer spread jobs over the fleet and hand each over on its own.

A job checks its tenure before each effect outside the cluster. A job that finishes is not rerun in that tenure. One that throws is rerun after a backoff. A job whose first pass must not wait for its interval runs one at the start of its tenure (the workflow journal reconcile does).

A per-key mutex is a held slot with a limit of one

ClusterMutex is a held slot with a limit of one: a 30 s time to live renewed every 10 s, and a final Lost token. A drain does not end it. It stays held until its holder releases it. The plugin connection leases, the MQTT availability leader, the workflow run lock, the workloads engine's leadership and the plugin operation locks are mutexes.

No mutex is granted before the replica serves or while it is fenced, at any replica count. A crashed holder's key is free after 30 s (constraint).

Plugin operations hold mutexes; the boot steps keep a session lock

The plugin install, update-start, sync, retention and broadcaster-apply locks are ClusterMutex keys. These operations check the mutex's Lost token between steps and stop at the next one, so a draining or fenced replica stops installing while a peer takes over.

  • A sync walk saves once, so an abandoned one leaves nothing and the next trigger redoes it.
  • An install that stops before its record commits answers 409 install_in_progress. After the record commits, it runs its tail.
  • A sync that fails after losing its lock records no error, because a peer may hold the key.
  • Instance create and delete take the update-start mutex for one commit and carry no Lost check.

The database initialiser and the demo seed run before the replica serves, when every cluster primitive refuses an acquire. They take BootLock, a PostgreSQL session lock on its own connection, bounded at 60 attempts 2 s apart with an unguarded fallback (constraint). Without the fallback a slow first boot would become a crash loop.

Each at-most-once use names its store and its outage policy

Use Primitive When the store does not answer
Fire de-duplication, trigger cooldowns, the baby monitor's sound and test-alert claims Redis claim, Grant policy (WindowClaim) Admits: each replica that sees the event runs it, and a cooldown admits
Workflow run slots (Parallel, Queued), camera viewer and event-media slots PostgreSQL held slot Admits
OIDC refresh lease PostgreSQL held slot, limit one Refuses
Per-key mutexes PostgreSQL held slot, limit one Refuses

Fire de-duplication and cooldowns are best effort, so they are not worth a database write per event or silent automations while Redis is down. A slot is held by a run or a socket on one replica, so it must end at that replica's fence, which only the database's member rows can tell.

The windows are the stated exception to at-most-once. While Redis does not answer, reeve_cluster_redis_policy_uses_total counts each admission, and a Redis failover that loses a key can admit one event twice. A use that must fail closed is not a Redis claim. Only a serving replica wins a claim or takes a slot.

WindowClaim is first-claimant-wins and nothing releases it. HolderWindowClaim lets the first claimant hold the key for the window: later claims by the same process admit and renew, others are refused until a window passes with no holder claim, and a restarted process is a different holder. The cooldown gate is a cluster-wide minimum interval between fires. It admits on a non-positive window and on any backend failure, and refuses while the replica is not serving.

A single node behaves the same: it claims each keyed fire in Redis, takes a PostgreSQL slot for each Parallel or Queued run, and drops a fire queued while it is not serving. The host's claim is the only de-duplication.

A tenure is checked before an effect outside the cluster

The OAuth token refresh shows the pattern and its one exception. The oauth-token-refresh unit calls EnsureOwner() immediately before each refresh request. From the send on, the request, the read of the answer and the save of the rotated token run to the end even if the stop begins meanwhile, because the identity provider consumes the old refresh token at the send. A pause longer than the member lease between the check and the send can still send one stale request.

The hint bus

IClusterBus is one Redis pub/sub bus for every cross-replica hint. A broker fault never fails a caller. Publishes are best effort, and each channel has a database-authoritative backstop.

Hint Backstop
Workload command nudge and completion The caller's database poll of the command row
Workload reconcile request The leader's periodic drift pass
Workload settings changed The settings cache's short time to live and its reload on reconnect
Hub credential revoked Periodic authoritative credential revalidation
Device ingest view changed The view's absolute time to live
Gateway presence events The shared presence store
Session frame nudge (reauth) The next sweep
Device-history sweep requested, observation appended The owner's or reader's own timer

Channel names (including workload_module_swap_ack) are wire names. They are append-only and never renamed outside a full-stop release (frozen names), or a mixed-build fleet silently drops every hint. Each message carries the sender's replica id and a schema version. A receiver skips its own origin and tolerates payload changes, which the overlap rule keeps additive.

Adapter commands use durable rows plus lossy hints

An adapter's session terminates on exactly one replica. A command for a session held by a peer is written as a durable command row and the owner is nudged on the bus. The owner delivers it on its own socket and the caller waits on the row.

The row moves Pending, Delivered, then one terminal state. The first terminal write wins, and a late response completes the row only if it has not already timed out. Payload and response are encrypted at rest. A non-owner never answers NoSession, because the bus is lossy and that would strand a caller whose session landed on a peer. The workloads side is in workloads.

A forwarded button press is a bus message with a holder-side dedup

A Matter button press ingested on a replica that does not hold the bridge link goes to the holder on its own channel, matter_bridge_button_press. The holder keeps the last 10 s of fire keys and admits a press once. A press is at-most-once on this transport and is dropped after 3 s.

Configuration writes

A configuration write appends to the cluster library's change log in the transaction that commits it. Every replica's applier reads the log, rebuilds the state of each changed aggregate type from one database snapshot with one reconciler per type, and publishes it as a new generation. A request reads the generation it pinned at admission (constraint).

The request that made the write is answered only once every serving replica has applied it (constraint). The wait set is the replicas holding a lease on the database clock. A replica that lost its lease or fenced is not waited for, and a starting replica catches up before it serves.

Outcome Answer
A wait that runs out 202 write_unconfirmed
A commit a fenced replica refuses 503 write_refused

A write waits for the slowest serving replica. A crashed replica holds it at most AckTimeout (51 s). A stalled one fences after ReconcileTimeout plus ApplyStallLimit (45 s). The web application and the companion show a notice and re-read on both answers. Some components converge after the answer (plugin instance starts, trigger arms, the Matter exposure gate, the egress allowlist), and the dispatch checks refuse a stale component meanwhile.

Aggregate types with special rules

Resource indexes. The indexes type captures only the configuration columns of integration.resource_indexes. The sync job writes the state columns (ETag, sync times, error, publisher key) on the same row. An update that touches only uncaptured columns appends no entry, so a sync pass never wakes the applier. A write to api/resource-indexes calls EnsureWritable() first. A manual sync does not. The boot seed reads the rows through EF, because it runs before the first generation exists.

OIDC settings. The oidc type holds the enabled flags and the providers with their decrypted client secrets, the deployment client secret already laid over the provider it is bound to. Sign-in, callback, session refresh and the administrator's identity link read it through IOidcSettingsReader.

  • On a serving replica the reader answers the generation the request pinned, so a login sees every provider edit whose write was answered.
  • On a replica that does not serve, or when the pin is not the generation the replica holds, it reads the settings store with the same overlay and redaction. Sign-in paths are allowed on such a replica.
  • The reconciler registers each decrypted secret for log redaction and drops the cached metadata document of a provider whose issuer or metadata address changed. It writes nothing.
  • The binding of the deployment secret to the sole provider is recorded by a boot step on every replica and by every save of the OIDC settings. It appends no entry.
  • UpdateOidcAsync calls EnsureWritable() after its permission check.

A client secret that cannot be decrypted is null in the record until the next write to the OIDC settings or a restart. Restoring the data-protection key ring alone does not bring it back on a serving replica.

Trusted signing keys. They are not part of a generation. Every verification and the plugin loader's revoked-key rule read integration.trusted_signing_keys on every call, so a trust or revoke reaches every replica on its next read, and a replica that has not started serving can still verify an artifact it restores at boot. When the deployment declares Managed:TrustedKeys, the list is answered from the validated configuration snapshot instead and writes to it are refused.

The trusted-keys-revalidation job revalidates the installed signatures on one replica when the hash of the effective lists differs from the one it last revalidated (runtime setting plugins / trusted_keys_revalidated). A key write through the API wakes it, locally and through the hint channel trusted_keys_revalidation_requested. A lost hint costs at most one 30 s check. A pass that keeps failing on the same list is retried after a delay doubling from 30 s to 15 minutes.

Managed home. When the deployment manages the home (Managed:Home), the home reconciler reads no rows and the record comes from the managed snapshot on every replica. A changed TimeZoneId reaches the next device-access check on each replica as soon as it reloads the file, with no change entry.

Saves are captured where they commit

ReeveDbContext, ObjectStorageGateDbContext and WorkflowDbContext carry the cluster capture, added after their DI interceptors (constraint), so the entries land in the transaction that commits. The workloads context has no capture. The host registers the cluster library and the capture mapping itself, not through AddInfrastructure. A context built without them throws, so a hand-built test container that builds a primary context calls AddClusterCapture.

When you add a mapped entity:

  • An entity type maps to one aggregate type. DeviceSource exposes its owning device's id as a mapped property so the capture key can read it. Plugin type ids are lower-cased in capture keys.
  • Home maps to access, so the home and location write services and the onboarding completion append the home entry themselves, in the transaction of the save (IConfigChangeWriter).

A write the capture cannot see appends its entry itself:

  • The write that begins a transaction appends last and commits (ConfigWrite).
  • A write that joins an open transaction hands its entry to the committer that adopted the transaction (ConfigWrite.Defer, ConfigWrite.Adopt). A transaction whose committer has not adopted it is refused, because appending inside it would hold the cluster-wide change-log lock for the rest of its work.
  • The workflow editor appends one workflow entry before its commit (IWorkflowWriteLog), because promote and rollback are bulk updates the capture cannot see. A publish or rollback reaches peers at the applier's poll, not by wake-up.

Raw writes that change nothing a reconciler reads append nothing: runtime settings, the OIDC deployment binding, the rewrite of sensitive plugin configuration into its encrypted form, a stored-secret replacement, a plugin's own settings writes and plugin-reported device columns.

Requests between replicas

IReplicaRequestRelay is the port every caller uses for a request to another replica. It runs over the library's member ask (constraint).

Call Addresses Used for
SendAsync A process Flow submits, the flow end hook
SendToReplicaAsync A replica id, no process check Replica logs, the recovery restart, the redescribe walk, a plugin's holder call
ListLivePeersAsync The running peers Peer lookups

A request for a unit kind's holder (the Matter link's verbs and its holder question) goes over the library's keyed ask to the matter-bridge-link unit instead.

Sealed. Every request and answer is a format byte followed by JSON sealed with ASP.NET Data Protection (purpose Reeve.ReplicaRequestRelay, one sub-purpose per direction) on the key ring the replicas share. The library keeps both directions in Redis in plain text, and a flow submit carries raw form answers and the user id. A handler's exception and a request that does not open answer failed with no text, logged on the serving replica. A replica whose key ring differs from its peers' can neither serve their requests nor read their answers.

Outcomes. A process-addressed send asks only a target the roster reads as running. The target answers gone when another process of that replica id took the request. gone is the only outcome that lets a flow be adopted elsewhere. Roster faults, busy or fenced targets and unanswered asks never yield it.

A request that never ran (nobody took it, the target was stopping or had no handler, the roster was unreadable) is safe to retry. A roster that cannot be read in time throws, which differs from "not running". A replica that crashed inside its lease reads as running until the lease expires, so a request to it waits its whole budget. A forwarded flow submit is withdrawn when not taken within 5 s and answers 503 FLOW_OWNER_BUSY. A stopping process takes no new request, and peers read it as running until its drain writes draining.

No request is a durable command. The host registers no handler for the library's durable commands. Opening a Matter pairing window, rotating its code and removing a fabric need their answer now, and a replay after the fact is wrong. Redescribe stays a durable job of its own, and workload commands stay durable in the workloads library.

Flow submits are forwarded to the owning process

A plugin config, options, action or repair flow is owned by the process that started it, because a plugin may keep the flow's work in memory. A submit arriving elsewhere is forwarded through the relay and runs on the owner. A forwarded submit is never forwarded again, and when the owner is gone the receiver adopts the flow.

  • A submit made with a personal access token carries the token's id. The owner runs it as that token, resolved again from the database, so the scope applies there too. A token revoked or expired meanwhile answers 401.
  • The forwarding wait is the owner's submit timeout plus a margin, so the owner's answer to a timed-out plugin arrives first.
  • A fenced replica runs no flow step until readmitted. A draining one starts no work that could outlive the plugin host. A retry reaches a peer.
  • When a peer adopts a flow while a step runs, the step's write is refused and the client retries on the code alone.
  • Relay handlers stay registered until the process exits, so requests already taken finish while stopping.
  • Flow finish payloads can contain secrets, so the result is populated only on the action branch.

The web application and the companion retry a busy owner for 249 s, which covers the longest stop and the lease of a replica killed before it wrote draining.

Plugin calls go to the connection-lease holder

A plugin keeps a long-lived connection on the replica that holds its connection lease, a held slot keyed plugin-conn:<type>:<instance>:<resource>. A command or resync that reaches the instance on another replica is passed on by the plugin through IPluginConnectionOwnership, and the host carries it:

  1. When this replica holds a valid lease on the key, the call runs here.
  2. Otherwise the slot holder read names the replica whose slot on the key is valid by the database clock. More than one holder, like none, is no holder.
  3. The call goes to that replica as the member request kind plugin.holder-call, sealed like every relay request.
  4. The holder answers unreadable for a payload it does not know and runs nothing. It runs the call only when it runs that instance of that type and holds a valid lease on the key. The call is marked as forwarded, so a call that reaches the facility again on that flow is refused. Otherwise it answers not-holder. A plugin failure answers failed:<reason code> with no message text.

A call that did not run (no holder, a failed lookup, not taken, not-holder, unreadable) throws PluginHolderUnavailableException. An unanswered call, an answer this build cannot read or a relay failure throws PluginHolderCallUnconfirmedException, a TimeoutException, because the holder may have run it. Nothing waits for a new holder.

The answer budget is Workloads:Gateway:CommandTimeoutSeconds, capped at Cluster:ActionTimeBudget minus the relay's 2 s ask share. The take budget is at most 5 s of that. An action budget below 3 s is refused at start.

Redescribe walks the running peers

A manual redescribe asks its local plugin instance first, then each running peer in turn over the member ask. Only the plugin knows which connection lease serves a device, so the host has no lease key to read a holder for. A peer that crashed inside its lease still reads as running, and the ask to it waits DeviceModel:RedescribeCallTimeout (120 s) plus 2 s before the walk moves on. The job stays durable in the device-model job store. Its lease is at least that timeout and is renewed while the job runs.

A recovery restart names its replica, and that replica confirms it

While the roster holds a running replica other than this one, a recovery restart that names no target is refused with 400 and stops nothing. When the roster holds only this replica, or none, an unnamed restart stops this replica, fenced or joining included. Without session affinity the replica serving a request is whichever pod the balancer picked, so an implicit target would be a guess.

A named peer is asked over the member ask. It checks that the id is its own, resets its failure count, schedules its stop and answers before the API returns 202, in any phase.

Outcome Status
Accepted 202
Peer is not running 404
Roster unreadable within 2 s, or the peer does not take the request 503
Peer does not answer 504
Peer fails 502

Some outcomes are ambiguous: "no running replica has that id" can look identical to a reply lost just after the target took the request and restarted. The status endpoint reports a peer's safe mode from that peer's status report, so a stopped peer's safe mode can show for the report's 45 s time to live.

Fencing

A replica fences itself when it cannot keep the acknowledgement's promise by its own account: its lease cannot be renewed, its applier has stalled past ReconcileTimeout plus ApplyStallLimit, an attempt is stuck, a fatal fault occurred, or the database has moved to a new timeline. It never fences by comparison with its peers, because lag measured relative to peers cascades: one pod restarting past a failed entry would make every peer look behind.

A fenced replica:

  • refuses requests outside the reachable-when-fenced set with 503 replica_fenced. That set is sign-in, me, health, metrics, version, client-config, system status, replica logs, the recovery endpoints, plugin list, toggle and restart, and the cluster status and skips;
  • aborts the connections it tracks and stops its unit kinds and mutexes;
  • rejoins with a full load.

A single-replica home fenced by a long pause is an outage of the whole interface until it rejoins. A type whose full load keeps failing keeps the replica out of service. A skip opens the way when no replica has acknowledged the entry. Otherwise only a release that fixes the reconciler does. Safe mode runs the reconcilers too, so it is no way out.

Eligibility after a fence

Actors that act for the fleet but hold no tenure (background plugin dispatch, peer calls, discovery providers, flow steps, device-model job claims, trigger fires) read the singleton ReplicaEligibility. The fence sink turns it off at fence step 4 and ReplicaReadmissionHostedService turns it on again (constraint). Readmission reads the local phase, never the readiness status, and requires that no fence was counted since the Serving read.

Safe mode

Safe mode starts the host without plugins so an operator can recover from a plugin that breaks boot. It is engaged by the --safe-mode flag, or automatically after Bootstrap:AutoEngageThreshold consecutive failed boots of this replica.

  • Immutable for the process. It is set once in Program.Main. There is no runtime toggle, because anyone reaching an admin endpoint could then disable OIDC mid-flight. A restart is the only way out.
  • Per-replica boot streak. Each replica keeps its own streak in bootstrap.replica_boot_state, keyed by replica id and written before the host exists, so a healthy replica cannot mask a crash-looping sibling. A hosted service registered last resets the streak once every hosted service has started. Only a failure the database records counts (constraint).
  • Refusals are not failures. A start-up window refusal is recorded as a reason (prefix [window] ) and a time, never as a count, so the orchestrator's restarts never engage safe mode.
  • The fleet row is observational. The singleton bootstrap.boot_state row is for operator and recovery-UI visibility and never drives the automatic decision.
  • It cannot cure the database. Safe mode only withholds plugins. It does not help with an unmigrated or missing database, a failing configuration load or a build outside the window.

A safe-mode replica leaves rotation and is fenced on the host side

While a replica runs in safe mode, /health/ready answers 503 (the safe-mode check) and /health/live stays 200. A middleware answers every request whose endpoint is not marked AllowWhenFenced with 503 replica_not_serving and Retry-After: 1, whether or not Coordination:Clustered is set. What stays open is what a fenced member serves, which includes the Cluster tab. OIDC answers 503 and advertises no providers, so the login screen shows the local form recovery needs. With DisableLocalLogin set, only accounts holding the Administrator role may sign in locally there (authentication).

The replica stays Serving in the cluster library. It answers member asks (the restart relay), reports its status, applies the log and runs the database-only unit kinds. The placer gives it no kind that skips in safe mode or needs a running plugin, and it does not take the workloads-engine mutex. A replica that boots in safe mode resets its failure count at ApplicationStarted, so the restart a startup probe causes does not count as a failed boot.

On a single replica under Kubernetes the Service then has no endpoint. The exits are in troubleshooting.

Replica status and alerting

Each replica's status report is its reeve section of the library's status registry. It is written to PostgreSQL every Cluster:StatusReportInterval (refused above 22.5 s) and includes the unit kinds the replica holds and its process id. A replica the status page expects is Silent while its section is absent, unreadable or older than 45 s. A replica fenced for longer than LeaseTtl reads Silent, and so does one that exited while fenced, until the same id joins again.

GET /api/admin/cluster/status answers the library's whole read to home.manage only, on a fenced replica too. Using PostgreSQL rather than Redis keeps the status page and alerts working while Redis is down.

The alert reconciler runs every 30 s on the owner of replica-status-alert. It raises on known-present conditions and clears only on positive evidence of absence. An unknown condition or an unreported replica clears nothing, and an expected replica without a fresh report holds every clear until it reports or leaves the window. A refused replica is silent, so its refusal is read from its own boot-state row. The alert row keeps the original raise time. A stored recovery override is announced and dropped once, by the owner of the alert reconciler.

Start-up and shutdown

Start-up order.

  1. Before it reads boot state, the backend retries an unreachable Postgres for Database:StartupWaitSeconds (90 s).
  2. Each boot step takes a Postgres session advisory lock for that step only (below).
  3. The start-up window check runs before any migration.
  4. The host starts, and its hosted services start one at a time.

Two bounds.

  • The start-up watchdog (Bootstrap:MaxStartupSeconds) gives the backend's own start a running-time budget. It expires once and ends the process with code 75 as a counted boot failure. Its clock stops while the Redis start-up wait and the cluster library's join run, so waiting for a dependency is not a failed boot (constraint).
  • Hosting:StartupTimeoutSeconds (300 s, range 30 to 3600) is the host's own start timeout. It bounds the cluster library's join and first full load, which retry without limit before the server listens, and every hosted service after them. Past it the process exits 75 and the orchestrator restarts it. It matches the chart's startup probe. A start that legitimately needs longer is a crash loop until the operator raises the setting and the probe.

Migrations run before the host starts and are outside both bounds.

Database outages at boot. A failure the database cannot take, because it is unreachable or not migrated yet, is logged as not counted and the process exits 75. A Postgres outage longer than the wait is therefore a restart loop that never reaches safe mode, and a failure before the boot-state table exists on a first install is not counted either.

Shutdown order. Hosted services stop in reverse registration order. The member-ask dispatcher stops first and keeps a quarter of the shutdown timeout to finish the requests it took. Then the library's drain starts. It waits out the requests running at its start (up to ProxyReadTimeout) and ends by writing draining, so requests a replica took finish before peers can adopt its work.

The chart sizes Hosting:ShutdownTimeoutSeconds (199 s, after a 5 s preStop sleep) and the termination grace period (214 s) for both drains: the library's StopBudget + ProxyReadTimeout + 2 × RenewTimeout (131 s) plus 5/16 of the timeout. Compose sets 204 s and 214 s. A values file that sets the shutdown below that does not render. A request that stays open without a bound ends on host stop (constraint).

Timings

The cluster timings are the same on every replica and sized for a Raspberry Pi 4 on an SD card, whose multi-second I/O stalls must not fence it. The library has no per-replica option, so a mixed fleet takes the slowest node's numbers. Changing them is a full-stop release (overlap rule).

Option Value What it bounds
Cluster:LeaseTtl 30 s Member lease; a crashed replica's hold on writes and roster
PlacementInterval, StopBudget, FencedTransactionTimeout 2 s, 5 s, 5 s With LeaseTtl, a unit's failover after a crash: 41 s
RenewInterval, RenewTimeout 3 s, 3 s Lease renewal
ClusterMutex:TimeToLive, ClusterMutex:RenewInterval 30 s, 10 s A crashed or draining holder's key; three renewals per time to live ride out a missed one
Cluster:ReconcileTimeout 15 s One reconciler attempt, a full load included
ApplyStallLimit, AckTimeout (derived) 30 s, 51 s Fence after a stall (45 s with ReconcileTimeout); the longest a write waits
Cluster:ActionTimeBudget 55 s The longest a writing handler is declared to take
Cluster:ProxyReadTimeout 120 s The shortest read timeout of any proxy in front of a replica
Hosting:ShutdownTimeoutSeconds, grace period 199 s, 214 s (chart); 204 s, 214 s (Compose) Both drains: 194 s in all with the chart's value, 195 s with Compose's

ProxyReadTimeout must exceed ReadIndexTimeout plus ActionTimeBudget plus AckTimeout, which the library checks at start. A 60 s proxy read timeout would leave a 13 s ActionTimeBudget, too short for a plugin install with an inline pull, a bundle import or a blueprint install. A 10 s ReconcileTimeout fences a Pi on an ordinary stall.

Load balancing without affinity

Nothing pins a client to a replica (constraint).

Real-time hub. State pushes, availability and device events reach clients over one hub authenticated by the session cookie the REST API uses, never a bearer token. Clients open the WebSocket without the SignalR /negotiate call, so a connection is one request any replica can take. The server offers the WebSocket transport only. A route that drops WebSocket upgrades gets no realtime, and nothing falls back to long polling or server-sent events.

  • Every connection joins its user's group (user_{userId}). Each push goes to the groups of the users who may see the device, read from the access state at broadcast time. The Redis backplane carries it to whichever replica holds the socket.
  • A replica that is not serving sends nothing, rather than push from a state that may miss a revocation.
  • Alert pushes carry only the id and go to the view-permission group (or to the users who may see the subject). Fleet safe-mode state goes only to home.manage holders.
  • A client that left its group to mute the stream leaves it again after each reconnect, and anything pushed while the socket was down is re-read by the clients (clients, SignalR reference).

Any replica answers for an installed type. Whether a plugin type is installed is read from its installation record, not from the serving replica's registry. A replica asked to create an instance of an installed type it has not loaded yet applies the install itself and answers once the type registers. After Plugins:TypeCatchUpTimeout it answers 503. Starting, resuming and submitting a flow resolve the type the same way and answer 503 PLUGIN_TYPE_NOT_LOADED, leaving the flow as it was. Every replica runs every enabled instance. Creates, deletes, enables and disables reach each replica through the plugin_instance generation. See plugins.

Balancer resend rules. The chart's ingress and the Compose balancer resend a request to another replica after a connection error or a 503, up to three tries, for idempotent methods only, and never after a read timeout (constraint). A refusal at admission means nothing ran. A request that timed out may have committed.

The balancer matches the status alone, so it may resend a PUT or DELETE answered 503 write_refused. What those handlers do outside configuration must be idempotent. The web application and the companion retry an admission refusal once after Retry-After and never retry write_refused. The Compose balancer counts only connect errors and timeouts, so it does not take a replica out of rotation for a 503.

The frontend re-resolves the backend. The frontend image proxies /api/ and /hubs/ to an upstream whose one server, REEVE_BACKEND_UPSTREAM, is re-resolved through every nameserver in the container's /etc/resolv.conf (valid=5s). A name in proxy_pass is otherwise resolved once at start, so a backend recreated on another address would answer 502 until the frontend restarts (constraint). Unless the nameserver answers the short name, REEVE_BACKEND_UPSTREAM must be fully qualified. The chart sets it from clusterDomain. An operator's own default.conf is served untouched and resolves once at start.

Plugin roll

A plugin update reloads one replica at a time, so a reconnecting adapter refused by the reloading replica connects to another one.

Turns are leases on the database clock. The roll's leader sends one replica at a time its turn. The replica claims the turn itself in one row per plugin type, cluster.plugin_roll_turns, written by single autocommitted statements that use now(), so every age, expiry and fence bound is on the database clock. The holder renews the lease while the turn runs, up to a turn budget, checks the claim immediately before raising each registration fence (constraint) and releases the row with the turn's outcome.

No replica may fence before the row's expiry plus the gateway's longest fence hold, and a turn cannot outlive its lease (enforced by options validation). The peers go first, ordered by replica id, and the leader takes its own turn last.

A native plugin's workflow blocks are swapped in each replica's own turn, after its instance reloads, when their shapes are unchanged. During a roll, and after a fallback on some replicas, replicas hold different block code. A block id only the new version exports exists only on replicas that swapped or restarted.

The walk keeps no position. Each call of the stage recomputes from the row, the census and the states the replicas report, so a new leader, a new turn or a retry starts empty. The walk answers done only after it has asked the fleet for fresh reports and a fleet of at least FleetSize live replicas has answered at the new version. After every live replica runs the target, superseded artifacts in the shared store are pruned once. The stage's id and placement are a cross-build key (constraint).

Module swap coordination. The leader commits the target version on the grant and on the installation record of the source repository, idempotently. It reloads nothing and never rolls back. Replicas publish what they run for every targetable type on workload_module_swap_ack and hand the same publish to their own coordinator, because the bus never delivers a replica its own publish. A blank version is the leader's re-announce nudge, not an acknowledgement. Reports of replicas the census has not listed for two intervals are forgotten, and a census fault skips the tick, so an unknown fleet never makes a peer look gone. After a reconnect a replica re-announces its own state and nudges the fleet to re-announce theirs.

Halts, Retry and Give up. A turn that fails, a turn that does not finish, and a fault at the new version reported from anywhere in the fleet each halt the walk in the row. A fault is keyed [replica, incarnation, subject, version], the subject being instance:{id}, registration:{type} or safe-mode. A halt that gains a key is a new halt, so a Retry never acknowledges a fault its operator was not shown.

A halt survives a restart, a crash and a leader failover. It ends only by an operator's action:

  • Retry acknowledges the faults it listed and continues.
  • Give up ends the update RollbackFailed with nothing undone.

Both act only on an update the library reads as open at the plugin roll, and never inside the fence bound of an unreleased turn. A row left unreleased after a failed turn is read as a halt. The pin is committed, so each replica still loads the new version at its next boot, and a restart neither clears a halt nor works around it. Auto safe mode counts as a fault at the new version. Manual safe mode stays outside the walk. Deleting the instance under update, or the repository its module loads from, is refused. The operator side is in upgrading.

Safety gates. A plugin update does not start while live replicas run different host builds. The gate reports versions and replica counts. A clustered host refuses a plugin update (fleet_size_unset, 409) unless Workloads:PluginRoll:FleetSize is set, because the walk target comes from configuration alone. With FleetSize 1 a turn may fence the only replica serving.

A fixed fleet size, no autoscaling. The Helm chart renders no HorizontalPodAutoscaler. A count an autoscaler moves gives the roll no value to wait for: below the target the walk stalls, above it a replica joins mid-roll. Backend replicas and FleetSize follow replicaCount. Frontend replicas follow it unless frontend.replicaCount is set.

Rolling upgrades

A release inside the running build's window is installed by a rolling update, replica by replica. A full-stop release and a jump from below the window are installed by a full stop (constraint).

The window. Every build carries ReeveRollFrom, the oldest host version it may serve beside. Its window is every build at or above it by SemVer precedence. A build that sets none has the exact window (an identical informational version). Every change is measured against the whole window (overlap rule), and a window spans at most two adjacent releases of the cluster library (constraint).

Build identity. The build string is the full informational version, so two builds with different metadata are two builds. IHostBuildConsensus compares this replica's build string with the Version of every member that holds a valid lease and reads joining or active, at every replica count. A read fault, or this replica missing from the read, is a split. The install gate, the auto-update wait, the workload update, the roll stage and the status version box hold their work while the fleet runs more than one build. ReeveRollFrom is read from the Reeve.Api assembly and only the host checks it.

The start-up window check. Before it migrates anything, a replica reads reeve_cluster.member itself, counts every unexpired lease on the database clock in any state except its own replica id, and compares the versions with its window. It then migrates the cluster library, raises the library's version floor to ReeveRollFrom and migrates the host's chain. The migration job and a replica that migrates nothing run the same steps.

A refusal exits with code 76 and writes its reason into the replica's boot-state row. It is not a boot failure. Two builds that both pass before either has joined, and an old replica that rejoins after its lease expired, are not caught by the exact window. The ReeveRollFrom floor closes both. Rolling back after a gate has raised the floor is a full stop.

The host roll harness. Run by hand, it builds the candidate image from the commit under test with REEVE_ROLL_FROM set for the pair, pulls the old release image, and rolls a three-replica stack from one to the other under checks. A window with nothing released inside it starts no stack and exits 0. See end-to-end testing.

Advisory locks

A boot step (the database initializer, the demo seed) takes a Postgres session advisory lock on its own unpooled connection, held for that step only (constraint). Closing the connection frees the lock, while a pooled connector would return to the pool still holding it. The advisory key of a lock name is derived with a stable scheme shared by every build in the window, so builds exclude each other during a rolling upgrade. The step retries a bounded number of times and then runs unguarded with a warning. It never waits without bound. The lock needs a database session that belongs to its client, so a pooler in front of PostgreSQL runs in session mode.

Transaction-scoped advisory keys serialise short critical sections across replicas: creating the first data-protection key, helper dependency-graph writes, workflow creation across the demo seeder and configuration import, and every writer of the workload-gateway URLs. Advisory locks go through the shared package (constraint).

  • Running multiple replicas: scaling out, removing a replica, skips, floors.
  • Upgrading: rolling and full-stop upgrades, plugin-roll halts.
  • Workloads: sidecar sessions, the gateway and workload commands.
  • Data: the database, migrations and boot.
  • Plugins: install, activation and the type registry.
  • Clients: reconnect behaviour of the web application and the companion.