Skip to content
Design27 min readUpdated 8 Nov 2026

13. A reference realization

RG is provider-neutral. A host qualifies for a placement when it offers the capability classes of Table 16 through realizations that are qualified for the families they carry (A2). We nonetheless commit to one realization and build it first. Orleans was designed alongside one cloud and proved there while remaining portable [34]; a concrete target forces the semantics to meet real limits, and it is where the measurements of Section 20.4 will be taken. Reaktor, as released, consists of RG and RGL, the modules and tools of Section 14, and the realization described here:

  • Kotlin on every runtime;

  • Cloudflare for compute, keyed state, messaging and storage at the edge;

  • Google Cloud for long-running services and cross-cloud messaging;

  • Postgres as the transactional authority.

In our assessment it is a good default for a typical multi-runtime application, not for every one. Section 13.3 gives four further stacks: the reference stack at large scale, a Chinese cloud stack, an alternate public cloud stack and a corporate stack hosted internally.

13.1 What a host must provide#

Table 16. The capability profile of an RG host, its reference realization and alternatives. A placement is admissible only through qualified realizations (A2).
Capability class (used by) Required guarantee Reference realization Other realizations
Stateless compute place (components, Session servers) Runs Kotlin/JS or JVM code; binds resources; starts in milliseconds Workers: V8 isolates [68] Lambda, Cloud Run, Kubernetes pods
Keyed single-writer place (exclusive profile, keyed Realizes) One live instance per key; serialized turns; transactional storage co-located with the instance Durable Objects with SQLite storage [64] Orleans-style actor hosts; a store-backed actor host with fencing
Transactional store (atomic(store), row policies) ACID transactions; row-level security or equivalent; a change feed Postgres, managed by Supabase [324], reached through Hyperdrive Aurora, RDS or Cloud SQL Postgres; self-hosted Postgres
Durable channel (queues, topics) At-least-once delivery, retries, a dead-letter target; per-key order where required Cloudflare Queues [66]; Pub/Sub with ordering keys [153] SQS (FIFO), Kafka [208], NATS JetStream
Durable execution (durable Transitions, timers, human waits) Persisted step outcomes, retries, timers, external events Cloudflare Workflows [69]; Durable Object alarms Temporal [329], Step Functions
Object storage (artefacts, blobs, releases) Durable, content-addressed names R2 S3, GCS, Ceph
Long-running service place (JVM services, engines) Containers with persistent volumes k3s [190] on Compute Engine Any Kubernetes; virtual machines
Identity and secrets (Principal, Grant) Token verification at the edge with key rotation; a secret store ES256 tokens verified against JWKS; Workers secrets; Secret Manager Keycloak, Vault, cloud KMS
Observation sink (Observation) Trace ingestion with typed attributes and retention OpenTelemetry [275] into ClickHouse on k3s Any OpenTelemetry backend
Analytical store (OLAP over events, observations, features) Columnar storage; fast aggregation over append-only data; materialized views ClickHouse [63, 308] on k3s BigQuery, Druid, DuckDB
Graph store (graph queries over derived graphs) A property graph with Cypher and in-memory traversal; a change feed Memgraph [239] on k3s Neo4j, Neptune, recursive SQL
Device and browser places (Surfaces, pushed regions) ART, Kotlin/Native, a JavaScript engine, Hermes Android, iOS, browsers, Hermes engines The same

Composing missing classes#

A provider that lacks a class can still host RG if the class is built from others and the composite is qualified. A keyed single-writer place, for example, can be built from a transactional store plus epoch fencing; the handover model of Table 9 states exactly what that realization must enforce. Admission refuses a placement whose realizations are unqualified, so portability is checked rather than assumed. Where the reference providers are unavailable, a deployment changes only its Realizes and Places assertions; scopes, contracts and patches stay the same (T2). That covers an on-premises cluster, an air-gapped site, or a jurisdiction served by other providers; Section 13.3 works through such cases.

13.2 Why this stack#

Figure 2 places a whole platform on this stack, from devices to claims.

Edge isolates as the default place#

Workers run V8 isolates inside Cloudflare’s network. They start in milliseconds, are billed by use and call one another through service bindings without leaving the network [68]. This suits the common case: interactive, read-heavy, globally distributed traffic with bursty writes.

Durable Objects as the actor primitive#

A Durable Object is a single instance per identifier, with its own transactional storage [64]. That is the exclusive profile with keyed realization, supplied by the platform. Uniqueness and placement come from the provider; RG adds typed protocols, supervision, effect identity, and fencing at the external stores that check epochs.

  • Turns. Input gates defer other events only while storage operations are pending, so an await on the network lets another event in. The exclusive profile’s one-message-per-turn law is therefore realized by an explicit turn loop over the mailbox, which the qualification suite tests.

  • Idle connections. WebSocket hibernation lets a room keep idle connections without keeping the object resident.

Messaging and durable execution next to the compute#

Queues deliver at least once, with retries and dead-letter queues, but order is only best effort [66]. They therefore qualify for competing-consumer channels, not for ordered ones (Section 7). Workflows persist each step’s result, retry steps, sleep, and wait for external events with timeouts [69]. They realize durable transitions, including human gates.

Postgres as the one transactional authority#

Postgres is a capable, general-purpose transactional store, and most providers offer it, so it is easy to move. Row-level security lets grants compile to row policies, and the outbox commits in the same transaction as the effect. We use a managed provider for Postgres only, so the authority stays portable.

Google Cloud for what isolates do poorly#

Long-running JVM services and two engines run on k3s on Compute Engine; Workers reach the cluster over a private tunnel. ClickHouse holds events, observations and features for analytics: its columnar storage aggregates billions of rows, and observations joined by element identifier become queries rather than log searches. Memgraph holds graphs derived from the data, such as the follow graph, and projections of the system graph itself, for queries that are natural in Cypher: neighbourhoods, paths and communities. Both are stores in RG terms: their datasets are related to authoritative ones by Derives, and traversals compile into their query languages (Section 8). Pub/Sub carries cross-cloud fan-out with ordering keys, and offers exactly-once delivery to pull subscribers within one region [153].

Where this stack is not the best choice#

RG then places the affected components on other places; the graph does not change. The cases are:

  • heavy batch and GPU training;

  • very high write throughput to one region;

  • state that outgrows a single object;

  • fast-paced games that need unreliable datagram transport;

  • jurisdictions without these providers (Section 13.3).

13.3 Four further stacks#

The reference stack is one profile among several. Four others recur often enough to state here:

  • the reference stack at large scale;

  • a Chinese cloud stack, for deployments in mainland China;

  • an alternate public cloud stack, for organisations committed to one hyperscaler, with AWS as the example;

  • a corporate stack hosted internally, on premises or in a private cloud, sometimes without access to the internet.

Each stack chooses a realization for every capability class of Table 16, and Table 17 lists the choices. Moving a system between stacks changes four things:

  • its Places and Realizes assertions;

  • the modules that wrap provider services, such as push, sign-in, payments and model hosts;

  • the generated deployment layer;

  • the evidence of qualification.

Scopes, contracts, patches and behaviour stay the same (T2). The substantial work is qualification. A class that a stack lacks is composed from others and qualified as a composite (Section 13.1). None of the four stacks is qualified yet. The plan qualifies the reference stack first (Table 30), and each further stack is qualified by running the same suites against its providers.

Table 17. Four further stacks, by the capability classes of Table 16, with model hosts added. A class marked composed has no direct counterpart on that stack; it is built from other classes and qualified as a composite (Section 13.1). The products named are realizations to be qualified; none of the four stacks is qualified yet.
Capability class Reference stack at large scale Chinese cloud Alternate public cloud (AWS) Corporate, hosted internally
Stateless compute Workers in every region; Smart Placement near the data Function Compute, SCF or FunctionGraph; ESA Edge Routines or EdgeOne edge functions Lambda, with Node.js for Kotlin/JS and SnapStart for the JVM; Lambda@Edge pods on Kubernetes; workerd for code written for isolates [70]
Keyed single-writer place Durable Objects, with hot keys split; namespaces restricted to a jurisdiction [65] composed: an actor host on ACK, TKE or CCE, fenced by the store composed: an actor host on EKS, fenced by DynamoDB conditional writes or in Postgres composed: an actor host on Kubernetes, fenced in Postgres; Orleans or Akka where already used
Transactional store Postgres primaries per tenant or region, with read replicas; Citus for the largest tenants [78] RDS or PolarDB for PostgreSQL; TencentDB for PostgreSQL Aurora PostgreSQL; Limitless Database for sharding [14] Postgres run by CloudNativePG or Patroni
Durable channel Queues partitioned by key, each under its limit of 5,000 messages per second [67]; Pub/Sub or Kafka beyond RocketMQ (ApsaraMQ or TDMQ) with ordered messages and dead letters; Pulsar SQS, FIFO for order per group; SNS for fan-out; Kinesis or MSK for logs Kafka with Strimzi, NATS JetStream or RabbitMQ streams
Durable execution Workflows; Temporal on GKE for long, high-volume flows Temporal on Kubernetes, or CloudFlow once qualified Step Functions; Temporal on EKS Temporal [329]
Object storage R2, with Cloud Storage next to the clusters OSS, COS or OBS S3 Ceph’s object gateway or SeaweedFS
Long-running services regional GKE clusters ACK, TKE or CCE EKS or ECS OpenShift, Rancher or upstream Kubernetes
Identity and secrets as in Table 16, with keys per region sign-in by phone number, WeChat or Alipay; the provider’s KMS; SM2, SM3 and SM4 where required Cognito or an external identity provider; KMS and Secrets Manager the corporate directory over OIDC or SAML, brokered by Keycloak; Vault or OpenBao
Observation sink collectors per region with tail sampling, into sharded ClickHouse OpenTelemetry into ClickHouse, inside the country the AWS Distro for OpenTelemetry into ClickHouse on EKS OpenTelemetry into ClickHouse; Grafana
Analytical store ClickHouse shards and replicas, coordinated by ClickHouse Keeper ApsaraDB for ClickHouse or TCHouse-C; Doris or StarRocks ClickHouse Cloud or ClickHouse on EKS; Redshift ClickHouse
Graph store Memgraph with replicas; the largest derived graphs as recursive SQL TuGraph with openCypher, or NebulaGraph with nGQL Neptune with openCypher Memgraph or Neo4j
Devices and browsers as in Table 16; releases staged by cohort Android through vendors’ stores, without Google’s services; iOS; HarmonyOS NEXT; WeChat and Alipay mini-programs; H5 pages as in Table 16 managed devices; enterprise distribution
Model hosts provider APIs behind Sessions, with fallbacks domestic models on provider platforms, or open weights on GPU nodes Bedrock, or open weights on GPU instances open weights on internal GPU nodes, served with vLLM [209]

The reference stack at large scale#

Scale changes the number of authorities, not their kinds.

  • Authorities are partitioned. Stores are split by tenant or region. Each part is a consistency domain with its own primary and read replicas, and a sharding layer such as Citus [78] serves a tenant that outgrows one primary. A change that spans partitions is a saga with receipts, never a distributed transaction (Section 9). The graph authority is partitioned in the same way, and its partitions federate through RGP (Section 12.8).

  • Hot keys are split. A Durable Object serializes the turns of its key. A key with more traffic than one object can serve, such as a very large room, is split into several keys. The split is a patch to the keyed realization, and observations identify the hot keys (Section 10.7). Namespaces restricted to a jurisdiction keep objects and their storage in the European Union, in FedRAMP data centres or in the United States [65].

  • Heavy streams leave the edge queue. A Cloudflare queue accepts up to 5,000 messages per second [67]. Streams beyond that are partitioned over several queues, or moved to Pub/Sub or Kafka. Code sees the channel’s quality of service, not its realization.

  • Clusters become managed and regional. Regional GKE clusters replace k3s. ClickHouse runs as a cluster of shards and replicas coordinated by ClickHouse Keeper. Memgraph keeps replicas, and a derived graph that outgrows memory is partitioned, or its traversals are compiled to recursive SQL instead (Section 8.3).

  • Observation is sampled. Collectors in each region sample traces by their tails, keeping errors and slow paths in full and the rest in proportion. Coverage claims state the sampling (Definition 8).

  • Releases are staged. A release reaches cohorts of hosts in turn, so generations coexist for longer, and the compatibility checks for version skew (P13 in Section 16) carry more of the load.

At this scale, cost joins latency among the preferences of the placement solver (Section 6.6).

A Chinese cloud stack#

In mainland China the reference providers are unavailable or reachable only through local partners. Personal information is subject to rules on where it is stored and when it may leave the country [318, 319]. The stack therefore uses Alibaba Cloud, Tencent Cloud or Huawei Cloud. Their services cover every class of Table 16 except the keyed single-writer place, which is composed from an actor host and a store that fences by epoch. Six further differences matter.

  • A separate authority. The deployment runs its own graph authority inside the country. It elaborates the same source as the authority abroad, so the two hold equal definition digests, and they exchange contracts as signed views. Runtime facts, observations and profiles stay in the country (Section 12.8).

  • Devices. Android phones are reached through their vendors’ stores, without Google’s services, so push notifications go through the vendors’ own channels as a module realization. HarmonyOS NEXT is a further device place. Its applications are written in ArkTS, a language based on TypeScript, and they reach native code through Node-API in C, so the glue languages of Section 13.5 cover it. Kotlin reaches it through Kotlin Multiplatform frameworks such as Tencent’s Kuikly [330], not yet through an official Kotlin target. Mini-programs inside WeChat and Alipay are restricted JavaScript places. They are released through the host application’s review, so a change reaches them as a new mini-program release, not through RG’s code push.

  • Identity and payments. Sign-in by phone number, WeChat or Alipay, and payment through the latter two, are module realizations behind the same contracts.

  • Cryptography. Sectors that mandate the national algorithms SM2, SM3 and SM4 change the suites of RGP and of the stores, not the protocol (F5 in Section 12.8).

  • Models. Domestic language models, served by the providers’ platforms or as open weights on GPU nodes, realize the same Sessions as any other model host.

  • Obligations outside the graph. Regulators decide filings for sites, applications and generative services [79], and grade systems under the multi-level protection scheme [317]. The graph cannot discharge these obligations, but it supplies their evidence as claims (Section 15): the inventory of labelled data, the flows that leave the country, and where each store is placed.

An alternate public cloud stack#

An organisation committed to one hyperscaler places everything there. With AWS as the example, three differences from the reference stack matter.

  • No keyed single-writer place. AWS has no counterpart of a Durable Object. Exclusive components therefore run on an actor host on EKS, and their writes are fenced in the store, by a conditional write in DynamoDB or an epoch check in Postgres. The handover model of Table 34 is the specification such a host must meet.

  • Less at the edge. Edge functions do less there, so more components are placed in a region, and latency budgets account for the extra distance (Section 3).

  • Managed sharding of Postgres. Aurora PostgreSQL Limitless Database distributes tables over several writers behind routers [14]. Whether a transaction across its shards is one consistency domain in RG’s sense is a property for its qualification to establish, not to assume.

The other hyperscalers fit the same table. On Azure, Durable Entities and Orleans [34] provide the keyed single-writer place directly, and Service Bus sessions give order per key. Google Cloud alone covers the classes with Cloud Run, Cloud SQL or AlloyDB for PostgreSQL, Pub/Sub, Workflows and GKE, again with a composed keyed place.

A corporate stack hosted internally#

An enterprise that keeps code, data and the graph inside its own network runs every class on its own Kubernetes clusters.

  • No edge network. Stateless components run in pods, or in workerd, the open-source runtime of Workers [70], which runs the same Kotlin/JS modules; their bindings to managed services are realizations, and change with the stack. Keyed places are composed, as on AWS.

  • The control plane is the customer’s. The graph authority, RGP and the observation stores run inside the network. A vendor’s authority sees only the views that the customer exports, or nothing.

  • Identity comes from the directory. The corporate identity provider issues the principals over OIDC or SAML, and directory groups map to roles that hold grants. Approvals follow the organisation’s own separation of duties (A5).

  • Sites without the internet. An air-gapped site receives releases, models and updates of RG itself as signed artefacts carried in by hand. Their update-framework metadata [305] lets hosts verify them without reaching the signer, and the durable release channel replays them in order (Section 12.6).

  • Managed devices. Applications reach managed devices through enterprise distribution, so the distribution policy in the admission predicate (Section 9.5) is the organisation’s as well as the platform’s.

  • Models stay inside. Open-weight models are served on internal GPU nodes, for example with vLLM [209], and an external model is used only where a declared flow and a grant allow it (W11).

Several stacks at once#

Stacks combine. A product can serve most users on the reference stack and one jurisdiction on the Chinese stack. An enterprise customer can run the corporate stack and federate with the vendor’s authority. In both cases the placement solver sees the union of the host profiles, Places constraints keep each store and activation inside its stack, and the authorities federate through views (Section 12.8). Contracts are shared and checked on both sides; nothing else crosses unless a declared flow allows it.

13.4 Kotlin as the implementation#

Kotlin Multiplatform compiles the same common code to four targets [183]:

  • the JVM, for cluster services;

  • JavaScript ES modules, for Workers, Durable Objects, browsers and Hermes engines;

  • native code, for iOS;

  • Android.

With per-file module output, each Worker bundles only the code reachable from its entry point.

The compiler#

RGL uses the Kotlin compiler in three places [180, 181]:

  • Symbol processing reads declarations. It extracts contracts and their serializers (hence fingerprints), registries and FlexBuffers codecs.

  • Frontend checkers in a K2 compiler plugin report RG’s static rules as ordinary diagnostics in the IDE:

    • capture analysis for code entries;

    • Bind locality when placement is static;

    • ownership of borrowed and moved values (W9);

    • effect ceilings (W10);

    • label flow on statically known paths (W11);

    • contract compatibility (W5).

  • The plugin’s backend extension performs four transformations:

    • it lifts code entries out of closures into registered entries;

    • it stamps stable identifiers derived from declaration paths, not object identity;

    • it inserts interceptor and observation hooks only where a plan requires them;

    • it records source spans, so every element can be traced to the code that defines it.

The Compose compiler and kotlinx.serialization are the precedents [149, 184]: each delivers a programming model through a compiler plugin while the source stays ordinary Kotlin.

Coroutines#

The runtime containment forest is the coroutine job tree (Section 8.4) [105].

  • Scopes. An activation’s scope is a child of its parent activation’s scope.

  • Supervision. A one-for-one supervision facet is a supervisor job, all-for-one is an ordinary job, and escalation is an uncaught failure that propagates to the parent. Deactivation is cancellation.

  • Dispatchers are capabilities of the place:

    • the main thread on Android;

    • the event loop in a Worker;

    • the microtask queue in Hermes;

    • a bounded pool on the JVM.

  • Families.

    • A Session call is a suspending function that returns an Outcome. Its deadline is a timeout whose expiry yields UNKNOWN, never failure.

    • A signal Channel is a state flow and an event channel is a flow.

    • A mailbox is a coroutine channel whose capacity and overflow are the channel’s declared attributes.

    • A choice in a multiparty session is a select.

  • Durability. Durable work never serializes a coroutine stack: a durable component persists each step’s outcome and resumes by replaying outcomes.

Listing 14 shows the core of the mapping.

class Activation(spec: ActivationSpec, parent: CoroutineScope, place: Place) : CoroutineScope {
    override val coroutineContext: CoroutineContext =
        parent.coroutineContext + supervision(spec, parent.coroutineContext[Job]) +
            place.dispatcher + ActivationKey(spec.key, spec.epoch)
}

fun supervision(spec: ActivationSpec, parent: Job?): Job = when (spec.supervision) {
    OneForOne -> SupervisorJob(parent)
    AllForOne -> Job(parent)
}

suspend fun <R, E> SessionPort<R, E>.call(request: Request, deadline: Duration): Outcome<R, E> =
    withTimeoutOrNull(deadline) { send(request) } ?: Outcome.Unknown(request.effectId)

Listing 14.

Activations and calls on Kotlin coroutines (proposed reference implementation, abridged).

Code push#

The Kotlin/JS backend emits an ES module that hermesc compiles to bytecode; the same module runs in a Worker. A pushed region’s host imports are exactly its capability ports (Section 10.6), and its render plans may use only the surfaces its host offers (Section 8.3).

13.5 Beyond Kotlin: languages, formats and checkers#

Kotlin is the implementation language. Five other technologies have fixed parts: C++ for native components, FlexBuffers at every boundary, and TLA+, Alloy and Lean as checkers. Each acts at a definite place and in a definite layer, and each meets the graph through a typed interface rather than by convention. Three glue languages, Swift, C and TypeScript, only connect Kotlin to platforms and ecosystems. Figure 21 shows where each one acts, and Table 18 summarises what it realizes or checks.

Figure 21

Figure 21. Where each technology acts. Rows are languages, the glue languages and the encoding; columns are the places of the reference stack and, on the right, the checkers that run in CI and the IDE. A dash means the technology has no part at that place.

Table 18. Technologies beside Kotlin in the reference realization.
Technology Where it acts What it realizes or checks How it meets the graph
Swift, C, TypeScript the iOS shell, native interfaces, JavaScript hosts glue only; none of Reaktor’s semantics generated bindings and declarations
C++ phones, browsers (Wasm), servers, robots native components: codecs, inference engines, physics, control loops; a reader of graph slices FFI trunks with ownership modes; contracts generated as C++ types
FlexBuffers every boundary the encoding of rgp/1 frames, FFI payloads, plans, findings and observations read in place; sorted keys give stable bytes; a fingerprint names the schema
TLA+ CI and design review behaviour: family templates, releases, trace validation templates instantiated per region (Equation 1); results recorded as Attests evidence
Alloy IDE and CI structure: the static rules over the C-set schema; changes to the signature schema and rules as signatures and facts; counterexamples become findings
Lean 4 proof repository metatheory: preservation, determinism, compositionality definitions that mirror the schema; theorems cited by claims

Glue languages#

Swift, C and TypeScript appear only at boundaries, and none of them implements Reaktor’s semantics. Swift hosts the iOS shell and calls into Kotlin/Native. C is the binary interface between Kotlin/Native, Swift and C++. TypeScript supplies and receives declarations: karakum turns npm and Cloudflare type declarations into Kotlin bindings, and Kotlin/JS exports declarations for the React page that hosts Compose on the web and for any component a third party writes in TypeScript behind typed ports.

C++#

C++ runs where Kotlin would be too slow or where the code already exists: media codecs, inference engines, physics and robot control. A C++ component sits behind an FFI trunk. That is JNI on Android, Kotlin/Native interoperation on iOS, JSI next to a Hermes engine and WebAssembly in a browser or a Worker; on a server it is a separate process reached by a Session. Ownership modes become C++ types: 𝗆𝗈𝗏𝖾 is a unique pointer, 𝖻𝗈𝗋𝗋𝗈𝗐 a span valid for the duration of the call, and 𝗌𝗁𝖺𝗋𝖾 a shared, read-only lease. The trunk checks them at the boundary, so a borrowed camera frame cannot outlive the call that lent it (W9). Listing 15 shows the media codec of Figure 2. For hosts that have no Kotlin runtime, such as robots or game engines, a C++ reader of the kernel’s column dumps and FlexBuffers frames lets them load plans and graph slices without a JVM.

class MediaApi {
public:
    virtual Outcome<EncodedFrame, MediaError> encode(std::unique_ptr<Frame> frame,
                                                     EncodeOptions const& options) = 0;
    virtual void preview(std::span<std::byte const> frame) = 0;
    virtual ~MediaApi() = default;
};

class MediaCodec final : public MediaApi {
public:
    Outcome<EncodedFrame, MediaError> encode(std::unique_ptr<Frame> frame,
                                             EncodeOptions const& options) override;
    void preview(std::span<std::byte const> frame) override;
};

RG_COMPONENT(MediaCodec, "media-codec", RG_PROVIDES(MediaApi, "MediaApi", "v2", "c41b07d2"))

Listing 15.

A native component behind an FFI trunk; ownership modes as C++ types (proposed SDK).

FlexBuffers#

Every boundary in Figure 2 carries FlexBuffers [148]: the rgp/1 graph protocol (Section 12), FFI payloads, plans, findings and observation batches. Four properties decide the choice.

  • A receiver reads a frame in place, from a JVM byte buffer, a JavaScript array buffer or C++ memory, without parsing it into objects.

  • Frames describe themselves, so developer tools and logs can print any frame without generated code. The contract fingerprint in the frame names the schema that the receiver checks.

  • Maps keep their keys sorted, so encoding a canonical form yields stable bytes for digests and signatures.

  • Frames are compact, and vectors of integers serve as column chunks.

Listing 16 shows the patch of Listing 4 as a frame.

author    string  "agent:reviewer"
base      blob    32 bytes: digest of revision r41
contract  uint    0x5e1f02a7, fingerprint of the Patch schema
kind      uint    2 (Patch)
ops       vector
  [0]     map     { edge: blob16, op: 1 (AddIncidence), ord: 0, port: blob16, role: 3 }
  [1]     map     { elem: blob16, expect: 7 days, facet: 12, field: 2, op: 4 (SetAttribute), to: 30 days }
sig       blob    64 bytes: Ed25519 over the canonical bytes of every other key

Listing 16.

The patch of Listing 4 as an rgp/1 frame: a FlexBuffers map with sorted keys.

TLA+#

TLA+ checks behaviour. The five templates of Table 34 are hand-written today. The plan instantiates them per region from the family templates by Equation 1, so that a release ships with the model of its own protocols. TLA+ also has a second use: observations carry element identifiers and epochs, so a recorded trace can be checked against the specification. That tests whether a realization refines its family’s protocol in production, not only in the qualification suite.

Alloy#

Alloy checks structure [178]. The C-set schema of Figure 6 reads directly as Alloy signatures, and the static rules as facts. Alloy can find an instance that satisfies every rule, which shows that the rules are consistent. It can also find a counterexample to a proposed change of the signature before the change ships. Listing 17 shows the core; it is a sketch that has not yet been run.

abstract sig Element { owner: lone Element }
sig Node extends Element {}
sig Port extends Element { family: one Family, role: one Role }
sig Hyperedge extends Element { kind: one Family }
enum Family { Bind, Session, Channel, Transition }
sig Role {}
sig Incidence { edge: one Hyperedge, port: one Port, role: one Role }

fact Forest { no e: Element | e in e.^owner }
fact PortsBelongToNodes { all p: Port | p.owner in Node }
fact Nets { all p: Port | lone port.p }
fact Typed { all i: Incidence | i.port.family = i.edge.kind and i.port.role = i.role }

assert OneConnectionPerPort { all p: Port | lone (port.p).edge }
check OneConnectionPerPort for 6

Listing 17.

The core of the schema and three static rules in Alloy (sketch, not yet run).

Lean 4#

Lean proves what a bounded checker cannot: properties of graphs of every size [85]. The definitions mirror the C-set schema, and the theorems are the metatheory of Section 15: preservation of well-formedness by each patch operation (Proposition 9), determinism of traversals (Theorem 6) and compositionality (Theorem 3). Listing 18 states preservation; its proof is planned for Q3 2027 (Table 30).

structure Graph where
  Node : Type
  Port : Type
  Edge : Type
  owner : Port -> Node
  family : Edge -> Family
  role : Port -> Role
  ends : Edge -> List Port

def Graph.nets (g : Graph) : Prop :=
  forall (p : g.Port) (e f : g.Edge), List.Mem p (g.ends e) -> List.Mem p (g.ends f) -> e = f

def Graph.wellFormed (g : Graph) : Prop :=
  g.nets /\ forall (e : g.Edge) (p : g.Port), List.Mem p (g.ends e) -> allowed (g.family e) (g.role p)

structure Patch where
  pre : Graph -> Prop
  apply : Graph -> Graph

theorem preservation (op : Patch) (g : Graph) (wf : g.wellFormed) (ok : op.pre g) :
    (op.apply g).wellFormed := by
  sorry

Listing 18.

Preservation of well-formedness, stated in Lean 4 (sketch; the proof is planned).

13.6 A worked example: the chat scope#

Table 19 realizes the scope of Listing 7 and Listing 8 on the reference stack. Figure 1 placed the actor on the phone; here placement puts it in a Durable Object, next to the pool that reaches its store. The definition is unchanged, and only the Places and Realizes assertions differ. Every row is a Realizes or Places assertion produced by placement; none is written by the feature’s author. Figure 22 draws the result, and Listing 19 shows part of the Workers configuration that the deployment layer would generate for it, written out by hand.

Figure 22

Figure 22. The chat scope placed on the reference stack (Table 19). Keyed exclusive components become Durable Objects; the transactional authority is Postgres, with its outbox drained into a queue; a Workflow orders moderation before the push. Observations and ordered analytics leave for Google Cloud. Every arrow is a realization of a family in the graph, not a hand-written configuration.

{
  "name": "chat-edge",
  "main": "chat-edge.mjs",
  "durable_objects": {
    "bindings": [
      { "name": "CHAT_ROOM", "class_name": "ChatActor" },
      { "name": "PUSH_ENDPOINT", "class_name": "PushEndpoint" }
    ]
  },
  "migrations": [ { "tag": "r42", "new_sqlite_classes": ["ChatActor", "PushEndpoint"] } ],
  "queues": {
    "producers": [ { "binding": "CHAT_EFFECTS", "queue": "chat-effects" } ],
    "consumers": [ { "queue": "chat-effects", "max_retries": 5, "dead_letter_queue": "chat-effects-dlq" } ]
  },
  "workflows": [ { "binding": "MESSAGE_FLOW", "name": "message-flow", "class_name": "MessageFlow" } ],
  "hyperdrive": [ { "binding": "CHAT_DB", "id": "generated-at-deploy" } ],
  "services": [ { "binding": "MESSAGING", "service": "messaging" } ]
}

Listing 19.

The Workers configuration that the deployment layer would generate from the chat scope (excerpt, written by hand). Names, classes, queues and bindings all come from the graph.

Table 19. The chat scope of Listing 7 realized on the reference stack.
Element Realization Why it is admissible
api: Session call Phone to Worker over HTTPS with a token; Worker to Worker over a service binding Deadline and idempotency key carried; a timeout yields UNKNOWN
actor: exclusive component keyed by room One Durable Object per room; SQLite storage as the actor store; an explicit turn loop One instance per key from the platform; turns tested
timeline: signal Channel Hibernatable WebSockets from the room’s object, with sequence numbers for replay from its storage A signal needs latest-value semantics only
inbox: mailbox Channel The object’s request stream into its turn loop One consumer by construction
chat-db: transactional Store Postgres through Hyperdrive; atomic(chatDb) writes the message and an outbox row; row policies generated from grants One authority; the outbox commits with the effect
Outbox relay A Worker that drains the outbox into a queue of effects At least once with dead letters; consumers idempotent by message id
Moderation, then push A Workflow per message: moderate, guard on the verdict, push, update the room; compensation on delete Steps persisted; push only after the verdict
Notifications A Durable Object per device endpoint that records each delivery intent before calling the provider No duplicate push after a retry
Observations OpenTelemetry spans carrying element ids and the revision digest, exported to ClickHouse; analytics on a Pub/Sub topic ordered by room Joins by identity; per-room order where needed
list, chat: Surfaces Compose on Android and iOS and a web host; the list surface’s logic pushed as Hermes bytecode from R2 after admission Render plans use host surfaces only
Deployment A Workers configuration generated by the proposed deployment layer (object namespaces, queues, bindings, Hyperdrive), Google Cloud resources through its API, and Postgres migrations One source; drift is desired ⊖ observed

Four failures show the guarantees composing.

  1. A Worker crashes after the Postgres commit but before enqueueing the push. The outbox row survives and the relay sends it, so nothing is lost.

  2. The queue redelivers a message. The push step is idempotent by message id, so nothing is duplicated.

  3. A phone’s call times out. The outcome is UNKNOWN, and the client asks by idempotency key instead of resending blindly (Table 9).

  4. A room’s object is evicted mid-conversation. Its state reloads from its storage, sequence numbers let clients resume the signal channel, and a client retry carries the same effect id.

None of these four behaviours is written by the feature’s author. Listing 7 and Listing 8, about thirty lines, define the feature; moderation and push come from platform scopes that it imports. The realizations are elaborated from them, and a change to any realization is a graph patch, reviewed as one.