| 1 | # What celld guarantees |
| 2 | |
| 3 | celld makes two promises about your data. Exactly one node serves a cell |
| 4 | at a time, so two machines never write the same database. And celld does |
| 5 | not answer a write until that write survives a failure, so nothing you |
| 6 | were told succeeded is lost. |
| 7 | |
| 8 | This page explains how celld keeps both promises. Fencing prevents a |
| 9 | slow, paused, or disconnected node's writes from damaging the current |
| 10 | owner's data after it loses a cell. |
| 11 | Each ownership epoch has a separate storage prefix, so a stale node's |
| 12 | writes cannot overwrite the current owner's data. |
| 13 | Both guarantees require a bucket with working conditional writes and |
| 14 | ranged reads, and a supervisor that restarts the process. |
| 15 | |
| 16 | ## What the bucket must provide |
| 17 | |
| 18 | celld needs four properties from the object store: |
| 19 | |
| 20 | - A conditional create: the write must fail when the object exists. |
| 21 | - A conditional overwrite: the write must fail when the object changed |
| 22 | after the read. |
| 23 | - Read-after-write consistency: a read after a successful write must |
| 24 | return that write. |
| 25 | - Ranged reads: a read must return the requested byte range and the bytes |
| 26 | from that range. |
| 27 | |
| 28 | Epoch GC (`CELLD_LTX_RETENTION_SECS`) needs a fifth property: |
| 29 | |
| 30 | - List-after-write consistency: a listing after a successful write must |
| 31 | include the written object. |
| 32 | |
| 33 | Amazon S3, Cloudflare R2, Google Cloud Storage, and Azure Blob Storage |
| 34 | provide it. A Tigris Global or Dual-region bucket provides it only in the |
| 35 | region of the write. An operator must not enable epoch GC on such a |
| 36 | bucket when the nodes of a fleet are in more than one region. |
| 37 | |
| 38 | The qualified stores are Amazon S3, Cloudflare R2, Tigris, Google Cloud |
| 39 | Storage, and Azure Blob Storage. celld's release tests run against R2, |
| 40 | and the S3 path uses the same client and the same headers. |
| 41 | |
| 42 | Backblaze B2, Hetzner Object Storage, and DigitalOcean Spaces do not |
| 43 | implement the required conditional writes. celld is not correct on such |
| 44 | a store: two nodes can then own one cell. A store can also accept the |
| 45 | conditional headers and ignore the condition, and that store fails late |
| 46 | and silently, so run the storage test below. |
| 47 | |
| 48 | MinIO (the community edition) implements the conditional writes and |
| 49 | passes the storage test, but celld has not qualified it for production. |
| 50 | One release is broken: RELEASE.2025-09-06T17-38-46Z answers the |
| 51 | conditional create of an absent object with `NoSuchKey`, so the first |
| 52 | deploy fails (denoland/celld#162). Use RELEASE.2025-09-07T16-13-09Z or |
| 53 | later. |
| 54 | |
| 55 | The request dialect differs per provider. An S3-compatible bucket gets |
| 56 | the `If-None-Match: *` and `If-Match` headers, and the condition |
| 57 | compares the etag. A `gs://` bucket selects the Cloud Storage XML API |
| 58 | with the `x-goog-if-generation-match` precondition and OAuth |
| 59 | credentials, because Cloud Storage does not apply `If-Match` to a PUT. |
| 60 | An `az://` bucket (the NAME is the container) uses the same `If-` |
| 61 | headers, which Put Blob applies. The adapter treats `AlreadyExists` and |
| 62 | `Precondition` (HTTP 412 on Azure) as clean conditional-write |
| 63 | rejections and keeps every other error ambiguous, because an ambiguous |
| 64 | write can have changed the object. |
| 65 | |
| 66 | Azure was qualified on 2026-08-18 under an account key, a VM managed |
| 67 | identity, and an AKS workload identity, single-node. A managed identity |
| 68 | on Azure App Service or Azure Container Apps does not work; see |
| 69 | [limitations](limitations.md). |
| 70 | |
| 71 | ## The storage test |
| 72 | |
| 73 | No store publishes these properties, so celld asks the store directly. |
| 74 | The command `celld diagnose` sends four conditional writes to your |
| 75 | bucket and reports the result: |
| 76 | |
| 77 | ``` |
| 78 | ok bucket conditional write (create, reject-create, update, reject-stale) |
| 79 | ``` |
| 80 | |
| 81 | Two of the four writes must fail. A store that accepts either one |
| 82 | cannot fence a cell, so celld names the store as the fault and the |
| 83 | command exits with an error. Each node also runs these writes before it |
| 84 | serves. The node then requests part of a second object and verifies the |
| 85 | returned range and bytes. |
| 86 | |
| 87 | The startup test uses new objects for each attempt. It makes at most |
| 88 | three attempts when an operation fails without a clear cause. The node |
| 89 | starts with a warning after all three attempts fail because a temporary |
| 90 | outage can end after startup. The node stops immediately when a required |
| 91 | conditional write or ranged read is unsupported. It also stops when the |
| 92 | store ignores a condition or returns a wrong range or wrong bytes. A node |
| 93 | cannot disable this startup test. Use `celld diagnose --read-only` with a |
| 94 | credential that cannot write. |
| 95 | |
| 96 | The diagnose test writes and deletes one small object under `probe/`. |
| 97 | The startup test uses a second object for the ranged read. A process |
| 98 | that stops mid-test can leave an object behind; it is small, and celld |
| 99 | never reads it. |
| 100 | |
| 101 | celld reserves `probe/`, `cells/`, `nodes/`, `node-cells/`, `fleet/`, |
| 102 | `deploy/`, `deploy-blobs/`, `log/`, `wake/`, and `telemetry/`. celld deletes |
| 103 | objects under some of these prefixes, so an application must not write under |
| 104 | any of them. |
| 105 | |
| 106 | celld requires ranged reads for stored cell data. The startup test stops |
| 107 | a node when the store ignores the `Range` header or returns incorrect |
| 108 | bytes. |
| 109 | |
| 110 | ## The supervisor |
| 111 | |
| 112 | You must run celld under a supervisor that restarts the process, such |
| 113 | as systemd, Docker with a restart policy, or Kubernetes. A node fences |
| 114 | itself when it loses its lease (the mechanism is below), and a fenced |
| 115 | process exits; without a restart, the fleet loses that capacity until |
| 116 | an operator intervenes. |
| 117 | |
| 118 | The supervisor must restart without an attempt limit, and it must wait |
| 119 | at least one lease lifetime between attempts. A node that cannot |
| 120 | acquire a lease at startup retries and does not exit, so a repeated |
| 121 | fence needs a node that acquires a lease and then loses it, and the |
| 122 | wait keeps that cycle slow enough to observe. |
| 123 | |
| 124 | ## The mechanism |
| 125 | |
| 126 | The short version: the ownership records use conditional writes, so two |
| 127 | nodes cannot acquire one cell. The replicated data carries its fencing |
| 128 | epoch in the object key, so a node that lost ownership writes only into |
| 129 | a superseded prefix. And before celld acknowledges a write, it proves |
| 130 | the write durable and confirms that it still owns the cell. |
| 131 | |
| 132 | ### The ownership record |
| 133 | |
| 134 | Each cell has one ownership record in the bucket. The record names the |
| 135 | owner node's session and carries a fencing epoch. A node acquires a |
| 136 | cell with a conditional create when no record exists, or a compare-and-swap |
| 137 | on an existing record. The bucket accepts only one competing write, so two |
| 138 | nodes cannot acquire the same cell. |
| 139 | |
| 140 | Every activation advances the epoch, a takeover and a local wake alike. |
| 141 | Each owner therefore replicates under a fresh epoch, and an epoch never |
| 142 | has two writers. |
| 143 | |
| 144 | ### The epoch prefix |
| 145 | |
| 146 | The replicator copies each cell's SQLite data to the bucket under |
| 147 | `cells/<cell>/ltx/e<epoch>/`, with plain unconditional PUTs. The epoch |
| 148 | in the key is the fence: a node that lost ownership can keep writing, |
| 149 | but its writes land in a superseded prefix, and a restore selects the |
| 150 | current lineage. (The tiering path can first combine segments from many |
| 151 | cells into a node bundle, and it drains each segment into its per-cell |
| 152 | prefix later.) |
| 153 | |
| 154 | The compactor reads retained bundles when a cell's segments leave the |
| 155 | in-memory index. A failed compaction retries after 30 seconds, and repeated |
| 156 | failures increase the delay to a maximum of 300 seconds. The bundle collector |
| 157 | advances through retained objects and deletes a bundle only when the per-cell |
| 158 | prefixes cover every segment in that bundle. |
| 159 | |
| 160 | The prefix protects the new owner's data from stale writes. The next |
| 161 | two sections protect the durability promise. |
| 162 | |
| 163 | ### The acknowledgement rule (RPO=0) |
| 164 | |
| 165 | A gate holds each write response until a durability proof covers the |
| 166 | write. A read-only response waits in the same way when the object has |
| 167 | committed a write that no proof covers yet. An error answer waits under |
| 168 | the same rule, because the message of a handler that throws can carry a |
| 169 | value that the handler read. An R2 mutation waits for the source object's write |
| 170 | proof. Therefore, the mutation cannot change the application bucket before the |
| 171 | source write is durable. A raw TCP connection, write, TLS upgrade, or shutdown |
| 172 | waits for the same proof. A response body that streams gets the same rule for |
| 173 | each chunk, so a chunk that an object produces after the response head waits |
| 174 | for a proof of the writes it can reveal. A client therefore cannot act on a |
| 175 | value that a crash can still lose. After a |
| 176 | bucket proof, celld reads the ownership record once and acknowledges |
| 177 | only if the record still names this node at this epoch. A partitioned |
| 178 | node can commit locally and replicate into its superseded prefix, but |
| 179 | the ownership read then shows the new owner, so celld does not |
| 180 | acknowledge the write. The check reads the record instead of comparing a |
| 181 | clock, so a paused process or a skewed clock cannot pass it. |
| 182 | |
| 183 | A fleet proof does not require this read. The owner sends each write to |
| 184 | one or two other nodes, which hold a copy of its recent writes; those |
| 185 | nodes are its followers, and the set of them is the ensemble. Every |
| 186 | follower must fsync the write, and a takeover seals the prior node-log |
| 187 | session before it restores, so the stale owner cannot complete another |
| 188 | fleet proof. |
| 189 | |
| 190 | An unfinished SQL write cursor can return rows before SQLite commits the |
| 191 | write. Outside an explicit transaction, the application must consume those |
| 192 | rows before output or `storage.sync()`, so the gate can cover the commit. |
| 193 | celld rejects that output while the write cursor remains unfinished. |
| 194 | |
| 195 | ### The ensemble needs two nodes |
| 196 | |
| 197 | A node picks its followers from the other nodes in the fleet, so it never |
| 198 | counts itself. One follower is enough, therefore a fleet needs two |
| 199 | running celld nodes before any node can complete a fleet proof. |
| 200 | `CELLD_DURABILITY=fleet` is the default, so a fleet of one node requests the |
| 201 | fleet posture and does not get it. |
| 202 | |
| 203 | A node recruits up to two followers, so a fleet of three or more nodes holds |
| 204 | three copies of an acknowledged write. The ensemble keeps acknowledging while |
| 205 | one follower remains, therefore a fleet does not fall back to the bucket each |
| 206 | time it loses a follower. |
| 207 | |
| 208 | A node without an ensemble stays correct. It acknowledges each write on a |
| 209 | bucket proof instead, so celld still does not acknowledge a write before a |
| 210 | durability proof covers it. The cost is latency: the write waits for the object |
| 211 | store, and an object store round trip is much slower than a follower fsync. |
| 212 | |
| 213 | ### The takeover recovery gate |
| 214 | |
| 215 | The default fleet mode can acknowledge a write once the node-log |
| 216 | ensemble stores it; the bucket upload can complete later. Each process |
| 217 | session therefore creates a conditional node-log record before its |
| 218 | first fleet-durable acknowledgement. |
| 219 | |
| 220 | A cold activation checks the prior owner's log records before it reads |
| 221 | the bucket. An absent record proves that the session never acknowledged |
| 222 | past the bucket, and a sealed record proves that recovery completed. An |
| 223 | open or recovering record makes the activation run recovery: it fences |
| 224 | the record with a compare-and-swap, seals the reachable followers, |
| 225 | uploads their retained segments and bundles into the per-cell prefixes, |
| 226 | and then marks the record sealed. The activation cannot restore until |
| 227 | this sequence completes. |
| 228 | |
| 229 | A cell can stop while its node session stays open. If acknowledged writes |
| 230 | remain outside its per-cell prefix, its next activation gathers that tail. |
| 231 | The log epoch becomes active before its first fleet proof. An active epoch |
| 232 | requires at least one current follower to return its complete retained range. |
| 233 | A fleet acknowledgement requires every ensemble member to store the write, |
| 234 | so one complete follower tail can provide the recovery evidence. If no |
| 235 | follower proves completeness, the activation fails and keeps the recovery |
| 236 | requirement. An inactive epoch has issued no fleet proof, so its bucket |
| 237 | bundles can provide the recovery data. When a stopped cell has a recorded |
| 238 | recovery requirement, the node keeps the log epoch until a bucket proof |
| 239 | covers its acknowledged data. A staged upload can complete after the cell |
| 240 | stops, so its bucket proof permits an ensemble change without another |
| 241 | activation. The next activation still folds any tail outside the per-cell |
| 242 | prefix. |
| 243 | |
| 244 | A follower restart retains evidence of a damaged batch or a gap before a |
| 245 | later batch. The follower cannot certify the affected range until valid data |
| 246 | covers the gap. A directory read error fails the request and permits a retry. |
| 247 | The error does not become permanent evidence of a gap. A follower's HTTP |
| 248 | error does not prove that its data is absent, even when its lease has expired. |
| 249 | When no follower can return a complete tail, persistent response errors |
| 250 | can block recovery and startup. This check cannot detect a deleted final |
| 251 | batch if no later batch or persisted end records its range. |
| 252 | |
| 253 | A torn batch can contain an unacknowledged write. Recovery cannot distinguish |
| 254 | that case from damage after an acknowledgement. Therefore, the existing loss |
| 255 | record can report an uncertified range even when no acknowledged write is |
| 256 | missing. |
| 257 | |
| 258 | The `/peer/log/tail` endpoint selects its response through the request's |
| 259 | `tail_format` field. A missing field or the value `1` selects the older |
| 260 | entries-only format, `CLT1`. The value `2` selects the ranged format, `CLT2`, |
| 261 | and another value fails the request. An older caller gets an HTTP error |
| 262 | when the follower cannot certify a known fragment, so an incomplete tail |
| 263 | cannot become a successful entries-only response. |
| 264 | |
| 265 | New nodes request the ranged format and decode both response formats. An |
| 266 | entries-only response provides no range evidence, so recovery treats that |
| 267 | response as inconclusive. It proves neither completeness nor data loss. |
| 268 | A recovery that requires a follower witness waits until a current member |
| 269 | returns the necessary range evidence. Therefore, response compatibility does |
| 270 | not guarantee uninterrupted recovery or startup during a mixed-version update. |
| 271 | Old nodes retain their existing recovery checks. |
| 272 | |
| 273 | A restarting node serves authenticated follower seal and tail requests before |
| 274 | it completes its own predecessor recovery. Therefore, nodes that restart |
| 275 | together can recover acknowledged writes from their surviving follower disks. |
| 276 | The node accepts application requests and new follower appends only after |
| 277 | startup completes. |
| 278 | |
| 279 | A large dead node can hold this recovery open for minutes. The recovery |
| 280 | reads the retained bundles in windows of at most 512 MiB. It uploads the |
| 281 | rows of one window and releases them before it reads the next window, so |
| 282 | the memory of the recovery does not grow with the size of the session. A |
| 283 | cell that has rows in several windows receives one object for each window. |
| 284 | A recovery attempt that fails or times out does not fail the waiting |
| 285 | requests. |
| 286 | The cell waits, and it retries the activation with a backoff |
| 287 | (`CELLD_RECOVERY_RETRY_MS`, default 1000). The requests fail with a |
| 288 | resolve error only after the retry budget is spent |
| 289 | (`CELLD_RECOVERY_RETRIES`, default 240). |
| 290 | |
| 291 | ### Epoch-chain restore |
| 292 | |
| 293 | A restore composes the epoch prefixes that contain LTX data into one |
| 294 | chain. It starts at the newest prefix and walks down. An epoch that |
| 295 | opened with a whole-database snapshot starts the chain at transaction |
| 296 | one. An epoch that paged in continues its predecessor: its prefix holds a |
| 297 | marker object at the successor of the cut it paged from, and then its own |
| 298 | deltas, so the chain links the predecessor up to that cut and the epoch |
| 299 | from the cut onward. A link must end exactly at its successor's cut, so an |
| 300 | epoch that does not continue the chain is not part of it. celld no longer |
| 301 | writes an epoch seal object, and a legacy `e<epoch>.seal.json` object does |
| 302 | not limit the chain. |
| 303 | |
| 304 | ### Epoch GC |
| 305 | |
| 306 | When `CELLD_LTX_RETENTION_SECS` has a positive value on a fleet node, the |
| 307 | owner of a cell deletes the epoch prefixes that no restore reads. The |
| 308 | owner builds the restore chain over every epoch prefix of the cell, |
| 309 | including its own. It continues only |
| 310 | when the newest epoch of the chain is its own epoch. Then its own first |
| 311 | object is in the listing, so a node that takes the cell over later also |
| 312 | lists that object and restores from a base at the same epoch or higher. |
| 313 | A paged cell also waits until its local file is complete, because until |
| 314 | then it reads pages from the objects of the chain that it restored. Next, |
| 315 | the owner reads the ownership record and continues only when the record |
| 316 | names this node at this epoch. It writes `retired.json` with the |
| 317 | base, and then it deletes the prefixes below the base. It keeps its own |
| 318 | epoch, the epoch before it, and each epoch younger than the configured |
| 319 | time. |
| 320 | |
| 321 | The order of these steps protects the data. If the owner reads the |
| 322 | ownership record before its own first object is in the listing, a fenced |
| 323 | owner can delete the base of the node that took the cell over. A |
| 324 | conditional write to the ownership record does not add protection, |
| 325 | because the cell can move between any check and the delete. The late |
| 326 | delete is safe because an epoch below the base never becomes part of a |
| 327 | chain again. This argument needs list-after-write consistency. |
| 328 | |
| 329 | A fenced node can append an unacknowledged tail to an older prefix. When |
| 330 | a successor opened with a whole-database snapshot, a later restore reads |
| 331 | the full chain and can expose that tail. This does not violate the |
| 332 | contract, because a failed or absent acknowledgement does not prove that |
| 333 | the write is absent, and a node-log recovery or a bundle drain can add an |
| 334 | acknowledged tail after an earlier restore. When a successor paged in, the |
| 335 | chain clips the older prefix at the successor's cut. This is safe because |
| 336 | the takeover recovery gate seals the prior node-log session before the |
| 337 | successor restores, so no write past the cut can be acknowledged. |
| 338 | |
| 339 | A paged cell's restore reads no chain up front. The cell opens over a |
| 340 | sparse local file, and each page the cell touches is read from the |
| 341 | objects on first use. The node then fills the rest of the file in the |
| 342 | background, and a filled cell reads only its local file. A chain smaller |
| 343 | than `CELLD_LTX_PAGED_MIN_MB` is downloaded whole, as before. |
| 344 | |
| 345 | ### Self-fencing |
| 346 | |
| 347 | Each node holds a lease in the bucket. The lease carries an expiry, and |
| 348 | the node renews it after one third of the lifetime (`CELLD_TTL_MS`, |
| 349 | default 10000 ms). A renewal that does not reach the bucket does not |
| 350 | fence the node, because the node retries while the published expiry has |
| 351 | not passed. |
| 352 | |
| 353 | A node that cannot reach the bucket cannot renew and cannot replicate, |
| 354 | so it must not own cells. When its published expiry passes, it fences |
| 355 | itself: it stops each active cell, and it fails every request that it |
| 356 | has not completed. A node also fences at once when its lease record is |
| 357 | gone, or no longer matches the record that the node published, because |
| 358 | the node can no longer prove that it holds the authority. |
| 359 | |
| 360 | The fence writes nothing to the bucket. Each peer already reads the |
| 361 | lease as dead or replaced, so a peer can acquire the cells through the |
| 362 | ownership records. And a request is safe even before the fence runs, |
| 363 | because celld compares the current time against the published expiry |
| 364 | each time it routes a request. |
| 365 | |
| 366 | An ingress checks a cached remote route against its observed lease deadline |
| 367 | for each new request. At the deadline, the ingress reads ownership again, |
| 368 | even if the previous owner keeps its connections open without a response. |
| 369 | Recovery still needs the bucket and the required durable data. |
| 370 | A draining ingress can resolve and forward to a live remote owner. It |
| 371 | refuses new ownership of an unowned cell or a cell with an expired owner. |
| 372 | |
| 373 | A request already sent to the previous owner can remain incomplete. The |
| 374 | ingress does not replay that request, because the handler can have committed |
| 375 | a write before it stopped. The caller can cancel the request. |
| 376 | |
| 377 | A fenced node logs a line that starts with `SELF-FENCE:` and stops with |
| 378 | the exit code 3. celld reports other internal failures with the same |
| 379 | prefix and code, so the line names the cause. An expired lease uses the |
| 380 | `node_lease_watchdog_fence` event. A missing record uses the |
| 381 | `node_lease_record_missing_fence` event, and a record that no longer |
| 382 | matches the node uses the `node_lease_record_mismatch_fence` event. The |
| 383 | mismatch event does not name an author, because the node cannot prove |
| 384 | which writer wrote that record. The fenced state is terminal: |
| 385 | only a restart returns the node to the fleet, through the same |
| 386 | cold-activation path that a peer failure uses. |
| 387 | |
| 388 | The fence line names the lease state, and it cannot name the store |
| 389 | request that produced that state. A removed record, a replaced record |
| 390 | and a failed read are three different operator problems, so celld can |
| 391 | report each lease request on its own. Set |
| 392 | `RUST_LOG=celld=info,store=debug` to turn this on. The node then logs a |
| 393 | `node_lease_read` event and a `node_lease_write` event for each request |
| 394 | against its own lease record. Each event carries an `outcome` field: |
| 395 | `found`, `missing`, `applied`, `rejected` or `error`. An `error` |
| 396 | outcome carries the store failure in an `error` field, and a `found` |
| 397 | outcome carries the `generation` field of the record that came back. |
| 398 | The target is off at every other filter, so a node in production pays |
| 399 | nothing for it. |
| 400 | |
| 401 | The failure of a node is a normal input, not a recovery procedure; the |
| 402 | [testing page](testing.md) shows the kill tests that exercise this |
| 403 | path. |
| 404 | |
| 405 | ## Alarm discovery and the wake format |
| 406 | |
| 407 | SQLite stores the alarm deadline, consumption, retry state, and installation |
| 408 | identity. An alarm hint only causes celld to read SQLite. The hint does not |
| 409 | authorize an alarm handler to run. |
| 410 | |
| 411 | Each committed alarm installation has a separate object under `wake/entries/`. |
| 412 | The ownership epoch and a persistent SQLite sequence identify the installation. |
| 413 | An alarm response waits for its publication PUT and the existing output proof. |
| 414 | Updates within the same minute also require a new publication PUT. |
| 415 | |
| 416 | Cleanup uses conditional writes to publish a retirement record under |
| 417 | `wake/retired/`. The record requires a durability proof, a current owner, |
| 418 | and a confirmed replacement publication when an alarm remains armed. |
| 419 | Cleanup deletes only older identities or a proven consumed identity. |
| 420 | An old DELETE therefore cannot delete a later installation. |
| 421 | This protocol requires no conditional DELETE operation from the bucket. |
| 422 | After the proof, celld attempts to delete known obsolete publications directly. |
| 423 | These deletions do not block an alarm response. |
| 424 | |
| 425 | Each cleanup pass lists at most 128 objects and processes at most eight cells |
| 426 | concurrently. The next pass continues the listing, and the final page restarts |
| 427 | the scan. A failed DELETE or a late PUT can require another complete scan. |
| 428 | The default interval is 60 seconds. `CELLD_WAKER_TICK_MS` changes this interval |
| 429 | and the due-scan interval. A large inventory can require many intervals, and |
| 430 | an additional node can repeat the same reads and deletes. |
| 431 | The collector requests a SQLite refresh for a remaining installation only when |
| 432 | its minute is due. Future installations stay dormant until that minute. |
| 433 | The timer still controls delivery, so the refresh cannot run the handler early. |
| 434 | |
| 435 | The `wake/format.json` object selects format 2. The `wake/waker.json` object |
| 436 | holds the advisory lease for the fleet's waker role. A new node or deployment |
| 437 | initializes an empty fleet or upgrades a stopped v0.4.1 fleet automatically. |
| 438 | An unsupported format prevents startup. Existing application objects outside |
| 439 | the reserved namespaces do not prevent initialization. |
| 440 | The previous `wake-format.json`, `wake-v2/`, and `wake-retired-v2/` names |
| 441 | also identify unsupported engine data and prevent fresh initialization. |
| 442 | |
| 443 | ### Start a fleet with this format |
| 444 | |
| 445 | An empty fleet initializes this format automatically. An upgrade from v0.4.1 |
| 446 | uses the same bucket and preserves the existing node data directories. |
| 447 | The upgrade requires a stopped fleet. Mixed versions cannot share a serving |
| 448 | fleet because v0.4.1 cannot read the new alarm discovery entries. |
| 449 | |
| 450 | 1. Stop application traffic and deployment writers. Stop every old node and |
| 451 | its supervisor, then wait for every node lease to expire. |
| 452 | 2. Back up the stopped fleet's bucket and node data. Keep the node names, |
| 453 | peer addresses, and data directories for the restart. A follower disk can |
| 454 | contain acknowledged writes that the bucket does not yet contain. |
| 455 | 3. Prevent the old binaries from restarting or writing to the bucket. |
| 456 | Revoke their credentials or remove their access through the deployment |
| 457 | system. The format marker cannot stop an old binary from writing. |
| 458 | 4. Start the new binary on every node with the same configuration, data, and |
| 459 | addresses. Wait for the fleet to become healthy before resuming traffic. |
| 460 | |
| 461 | Startup upgrades the format automatically. The nodes can start together and |
| 462 | complete the same migration. A live node lease prevents the migration, so |
| 463 | stop every old writer and wait for its lease to expire before the restart. |
| 464 | The operator must prevent old writers from returning after the upgrade. |
| 465 | |
| 466 | The migration inventories stored cells and creates a discovery seed for each |
| 467 | cell. It preserves the databases, node logs, ownership records, deployments, |
| 468 | and application objects. Existing legacy wake entries remain unused. |
| 469 | The inventory uses pages of at most 128 entries and includes cells whose |
| 470 | old alarm discovery entry is missing. |
| 471 | |
| 472 | A discovery seed makes recovery read the cell's SQLite alarm state. Recovery |
| 473 | creates the installation identity without changing the deadline or retry |
| 474 | state. A seed does not authorize an alarm handler to run. The normal |
| 475 | retirement proof removes the seed after durable recovery and replacement |
| 476 | discovery, so an interrupted migration cannot silently discard an alarm. |
| 477 | Recovery can load cells with future alarms while it processes these seeds. |
| 478 | |
| 479 | If a node stops during the migration, another starting node resumes it. |
| 480 | The nodes cannot serve until the complete inventory succeeds. Later starts |
| 481 | use the completed format without another migration. Alarms can run late |
| 482 | during the outage. |
| 483 | |
| 484 | Do not roll back by starting an old binary against the upgraded fleet. |
| 485 | Restore the complete stopped-fleet backup for a rollback. That restoration |
| 486 | loses writes made after the backup, so preserve those writes separately. |
| 487 | |
| 488 | Normal restarts and ownership transfers within this format preserve the |
| 489 | alarm history. Each restored writer takes a new ownership epoch and keeps |
| 490 | the stored sequence and consumed state, so an old mutation cannot target |
| 491 | a later installation. |