| 1 | # Testing |
| 2 | |
| 3 | celld makes three promises: |
| 4 | |
| 5 | - An acknowledged write is durable. |
| 6 | - A cell has one writer at a time. |
| 7 | - Code written for Cloudflare Workers and Durable Objects operates the same on |
| 8 | celld. |
| 9 | |
| 10 | We test the API contract by differential execution against workerd, the |
| 11 | coordination protocol by model checking and deterministic simulation, and the |
| 12 | full system by fault injection on live fleets. |
| 13 | |
| 14 | ## Conformance: two runtimes, one output |
| 15 | |
| 16 | We run the same Workers and Durable Objects programs on workerd, Cloudflare's |
| 17 | production runtime, and on celld, and the outputs must match. workerd supplies |
| 18 | the reference output, so the expected behavior does not depend on celld. |
| 19 | |
| 20 | Each new API adds fixtures to the corpus. We also port the workerd Durable |
| 21 | Objects contract tests, its web-platform globals tests, and the upstream Web |
| 22 | Platform Tests. Before a release, we replay storage, SQL, alarm, stream, |
| 23 | WebSocket, and lifecycle scenarios through the full `celld` binary in each |
| 24 | deployment mode. |
| 25 | |
| 26 | ## Specification: exhaustive at small size |
| 27 | |
| 28 | The coordination protocol is specified in TLA+. Heyang Zhou wrote the |
| 29 | specifications against celld v0.1.0. His model checking found four bugs and a |
| 30 | split-brain that lost an acknowledged write. All are fixed. None had surfaced |
| 31 | in our own review or testing. |
| 32 | |
| 33 | At a small configuration, the checker visits every reachable state. The model |
| 34 | grants a linearizable object store and perfect shared clocks, so a violation |
| 35 | needs no clock skew or storage anomaly. The invariants are one writer for each |
| 36 | epoch and no lost acknowledged write. The checker also verifies that the epoch |
| 37 | in the key stops a stale owner's late writes from losing an acknowledged write. |
| 38 | |
| 39 | Each configuration pins an expected verdict, and most verdicts are failures: |
| 40 | each models a past protocol bug or a deliberately broken checker, and must |
| 41 | produce its counterexample. |
| 42 | |
| 43 | A redesign of the write-acknowledgment fence was checked before it was built. |
| 44 | The check found an eight-state counterexample against the old version: a |
| 45 | dormant cell resumes at its old epoch while its release is in flight, |
| 46 | acknowledges a write, and the following takeover restores without it. The fix |
| 47 | shipped, and the counterexample stays as a pinned failure. |
| 48 | |
| 49 | The checker also removed code. celld once sealed a cell's durable history at |
| 50 | restore. The verdicts showed that the seal only prevented the return of an |
| 51 | unacknowledged write, which celld does not promise, and that it could turn a |
| 52 | recoverable ordering error into permanent data loss. |
| 53 | |
| 54 | We update the specifications by hand with protocol changes. They do not run in |
| 55 | continuous integration. A separate record tracks what the model does not yet |
| 56 | describe, including guarantees weaker than the code's. |
| 57 | |
| 58 | ## Simulation: the protocol under adversarial schedules |
| 59 | |
| 60 | The dangerous bugs are in coordination: a crash during an ownership handoff, a |
| 61 | lease renewal that races a takeover, an alarm against a partially restored |
| 62 | cell. These windows are too narrow and too rare to wait for. |
| 63 | |
| 64 | The coordination protocol is therefore a |
| 65 | [pure decision core](https://github.com/denoland/celld/tree/main/crates/logic) |
| 66 | with no I/O. The clock, the randomness, and the object store are interfaces |
| 67 | that a simulator drives. The simulated store injects latency, compare-and-swap |
| 68 | races, and lost responses. The clocks drift, and a node can crash at each |
| 69 | await point. Scripted adversaries play the cells, such as a handler that never |
| 70 | returns or a write stream that stops halfway. V8 is not deterministic, so it |
| 71 | stays out of the simulation. |
| 72 | |
| 73 | A seeded scheduler drives each run, so a failure reproduces exactly. We check |
| 74 | safety (two writers in one epoch, a lost acknowledged write, an expired lease |
| 75 | that returns) and liveness (each armed alarm fires, ownership settles on one |
| 76 | node after a crash). A property must survive tens of thousands of seeds, and |
| 77 | the core protocols have run through millions of schedules. Deliberately broken |
| 78 | protocol variants verify that the checkers detect the faults. |
| 79 | |
| 80 | ## Live fleets: what simulation cannot see |
| 81 | |
| 82 | Simulation cannot see real S3 tail latency, real kernel and filesystem |
| 83 | behavior, or V8 under memory pressure. A permanent fleet lab runs standard VMs |
| 84 | from standard providers against a real bucket. Workloads rotate: chat rooms |
| 85 | with many WebSocket connections, working sets that shift across tens of |
| 86 | thousands of checksummed cells, deployment cutovers under load, and nodes |
| 87 | filled to the memory limit. The lab qualifies each release. We archive each |
| 88 | run's configuration, verification sweeps, node journals, kernel logs, and |
| 89 | phase timings, including failed runs. |
| 90 | |
| 91 | Faults land between verification passes. A pass fetches each cell through |
| 92 | different nodes and compares the status, the body, and the full message |
| 93 | ledger. A cell can be briefly unavailable while ownership moves, but its |
| 94 | committed state must stay complete and a live node must serve it again. |
| 95 | |
| 96 | The scenarios: |
| 97 | |
| 98 | - `SIGKILL` a node mid-write-stream and delete its local database, so recovery |
| 99 | comes only from the bucket. Every acknowledged write returns, because the |
| 100 | output gate held each response until the write was durable. |
| 101 | - Freeze an owner, write to its cells through other nodes, and unfreeze it. |
| 102 | The node sees that its lease moved and refuses to serve the old state. Each |
| 103 | write lands exactly once. |
| 104 | - Cut a node off from the bucket. It fences itself. |
| 105 | - Throttle the bucket to 429 on every request. The engine slows to the store's |
| 106 | rate and does not amplify the throttle. |
| 107 | - Stop a full host at the provider level mid-workload. Its cells move to other |
| 108 | nodes, and the returning host rejoins with no duplicate residency. |
| 109 | |
| 110 | Across every run of every scenario, the verification sweeps show zero body |
| 111 | faults, zero status faults, and zero lost messages. |
| 112 | |
| 113 | ## A few numbers we trust |
| 114 | |
| 115 | - **The epoch fence holds under contention.** Five hundred concurrent |
| 116 | claimants made 5,500 attempts on the same cells: one writer for each epoch, |
| 117 | zero violations. |
| 118 | - **A warm resident request is local.** A request to a resident cell does zero |
| 119 | bucket operations and returns in p50 ~1.1 ms and p99 ~7 ms (a fixed-host |
| 120 | measurement). Only a cold activation touches object storage. |
| 121 | - **A durable write waits for a durability proof.** A single node proves each |
| 122 | write through the bucket, so one storage round trip is the minimum. A fleet |
| 123 | of two or more nodes can instead prove a write when each follower holds it |
| 124 | on disk. A lab fleet measured about 600 ms for a bucket proof and about 25 ms |
| 125 | for a fleet proof. The bucket upload races every fleet proof, so a slow |
| 126 | follower cannot make a write slower than a bucket proof. Concurrent writes |
| 127 | to one cell share one upload. |
| 128 | - **A restore is normal work.** Placement treats the restore of an inactive |
| 129 | cell as ordinary work. The measured restore times come from the retired |
| 130 | external replicator, so this page gives no number until a fleet run measures |
| 131 | `celld-ltx`. |
| 132 | - **Ten small nodes held real scale.** Ten nodes, each with 4 vCPU and 8 GB, |
| 133 | held 10,000 resident cells and 20,000 concurrent WebSocket connections. With |
| 134 | two of the ten nodes stopped, every cell was available again on another node |
| 135 | in ~11 s at the tail (with reserve headroom). |
| 136 | |
| 137 | ## Known failure edges |
| 138 | |
| 139 | A fleet at its resident limit has no space for a lost node's cells, so losing |
| 140 | multiple nodes degrades service. We test recovery with and without reserve |
| 141 | capacity to measure this limit. |
| 142 | |
| 143 | Report a schedule that breaks a guarantee, an untested fault, or a measurement |
| 144 | that you cannot reproduce in the |
| 145 | [issue tracker](https://github.com/denoland/celld/issues). |