Skip to content
Design6 min readUpdated 27 Oct 2026

3. Preliminaries

The design draws on four bodies of theory and two bodies of engineering practice. This section fixes the notions the paper uses, in the form it uses them, and says where each is used. Appendix E gives a longer primer with worked examples, and Appendix D a reading plan.

3.1 Graphs, hypergraphs and networks#

A directed graph has vertices, edges, and source and target maps from edges to vertices. A hypergraph lets one edge join any number of vertices [30]. Any hypergraph can be drawn as a bipartite incidence graph, with vertices and hyperedges as two sorts of node and one edge per incidence. Kernels store a hypergraph this way, and graph algorithms run on it.

  • In a port graph, vertices own named ports and edges attach to ports, so a connection says not only which components meet but at which interface.

  • Network science adds measures over large graphs [26, 265]: degree, centrality, communities and percolation. Multilayer networks keep several edge types over one vertex set [197].

  • A RG is a port hypergraph whose incidences carry a role and a position, plus a forest of containment (Section 5). Its incidence graph is where network measures apply: centrality estimates blast radius, and communities propose regions.

Figure 3 draws one session in the three forms.

Figure 3

Figure 3. One session among a client, a server and an auditor, drawn three ways. Each incidence of (c) carries a role and a position, so nothing that (a) states is lost (Appendix E.1).

3.2 Categories, presheaves and rewriting#

A category has objects and composable arrows; a functor maps one category to another, preserving composition [137, 221].

  • C-sets. For a small category 𝒞, a functor X:𝒞→𝖲𝖾𝗍 is a C-set, also called a copresheaf. Each object of 𝒞 becomes a set (a table) and each arrow a function (a column of foreign keys). Graphs are the C-sets over the category with two objects E and V and two arrows s,t:E→V. Morphisms of C-sets are natural transformations, and 𝖲𝖾𝗍𝒞 computes limits and colimits table by table [280].

  • Typing. A graph typed over a type graph T is a morphism into T. The category of such graphs is again one of presheaves, 𝖲𝖾𝗍∫T.

  • Gluing. A pushout glues two objects along a common part.

  • Rewriting. A double-pushout (DPO) rule L←K→R deletes the image of L\K and glues in R along K [102]. With an injective match, it applies exactly when nothing that remains would be left dangling. In an adhesive category, pushouts along monomorphisms behave like unions of sets [210]. There, rewriting has the Church–Rosser, parallelism and concurrency theorems that Section 9 uses.

  • Open systems. A cospan J→G←K is a system G with input boundary J and output boundary K, and cospans compose by pushout. Hypergraph categories are the algebra of such wiring [136]: free ones correspond exactly to cospans of hypergraphs with discrete interfaces [35]. A functor into spans of transition systems then assigns behaviour compositionally [193] (Section 7).

3.3 Order, fixpoints and incremental computation#

  • Lattices. A lattice is a partial order with binary joins and meets [82]. On a complete lattice, every monotone map has a least fixpoint (Knaster–Tarski). On a lattice of finite height it is reached by iterating from the bottom element. Chaotic iteration reaches the same fixpoint in any fair order [75]: this is why a traversal’s result does not depend on schedule or partition (Theorem 6).

  • Semirings. A semiring (S,⊕,⊗) generalizes path problems [250]: Boolean for reachability, min-plus for the shortest route, max-plus for the worst-case latency of an acyclic call chain, max-min for capacity.

  • Datalog evaluates recursive rules to their least fixpoint, with negation allowed only between strata [4]. Lattice-valued Datalog generalizes it [232]. Program analyses are the classic use [266].

  • Incremental computation. A Z-set is a multiset with integer multiplicities, so an insertion is +1 and a deletion −1. DBSP maintains a query over Z-sets under deltas; for linear operators the cost is proportional to the change [46].

  • Coordination. The CALM theorem says a problem has a consistent, coordination-free distributed implementation exactly when it is monotone [16, 167].

  • Galois connections. A Galois connection between two orders relates a requirement to the offers that meet it; Section 6.6 uses one.

3.4 Specification, refinement and model checking#

A system is a state machine: an initial condition and a next-state relation. A behaviour is an infinite sequence of states. TLA+ writes a specification as 𝐼𝑛𝑖𝑡∧□[𝑁𝑒𝑥𝑡]v∧𝐹𝑎𝑖𝑟𝑛𝑒𝑠𝑠 [214].

  • Safety and liveness. A safety property says that nothing bad ever happens; a liveness property, that something good eventually does [12].

  • Refinement. One specification refines another if each of its behaviours, mapped through a refinement mapping, is a behaviour of the other [1]. Composition is conjunction [2].

  • Model checking explores every reachable state of a bounded instance [24]. Breadth-first exploration returns shortest counterexamples, and the bounded models of Table 9 work this way.

  • Other methods. Alloy checks first-order structural constraints within bounds [178]. Proof assistants such as Lean prove properties for all sizes [85].

Appendix C.1 gives a complete TLA+ module for the Session call family.

3.5 Machines: memory, layout and cost#

Each level of the memory hierarchy is larger and at least an order of magnitude slower than the one above it: registers, caches, main memory, solid-state storage. The network lies beyond them [100, 168]. Data moves between caches and memory in lines of typically 64 bytes, so cost is dominated by how many lines a computation touches.

  • What hardware rewards. Sequential access lets hardware prefetch. Following pointers defeats it.

  • Layout. Storing each field in its own array (structure of arrays) rather than objects with all fields (array of structures) puts the data a loop needs in consecutive lines.

  • Sparse structure. Compressed sparse row (CSR) stores sparse incidence the same way [194].

  • Handles. Generational handles replace pointers that may dangle.

This is data-oriented design [5, 130], and it is how the kernel stores the graph (Section 11). On the JVM and in JavaScript engines the same layout also avoids allocation and garbage-collection pressure, through primitive and typed arrays.

Across a multi-runtime system the same arithmetic holds at a larger scale [86]. Each step below typically costs one or more orders of magnitude more than the one before it:

  • an in-process call (nanoseconds);

  • a call across a native boundary;

  • a call between processes;

  • a remote call within a region (around a millisecond);

  • a call across continents (tens to hundreds of milliseconds).

Placement and batching therefore dominate end-to-end cost. This is why RG lets location be abstracted but never latency (Section 6).

3.6 Distributed-systems reality#

Components fail independently, and messages may be delayed, lost, duplicated or reordered [48, 230].

  • Impossibility. In an asynchronous system, no deterministic protocol reaches consensus if even one process may crash [134]. Under a network partition, a service must choose between consistency and availability [144].

  • Timeouts. A timeout cannot tell a slow peer from a dead one, so a call that timed out has an unknown effect.

  • Exactly once. Delivery can be at most once or at least once. “Exactly once” is at-least-once delivery plus deduplication by a stable effect identity, an idempotency key, at the place where the effect commits [166].

  • Leases and fencing. A lease holder may pause past its expiry. Only the authority that stores the data can reject a stale holder, by comparing a monotonically increasing epoch, or fencing token [155, 199].

  • Consensus. Paxos and Raft build replicated authorities that issue such epochs [213, 272].

  • Cross-service changes. Independent services rarely share ACID transactions [166]. A change that spans them commits an outbox record with the local effect, or runs as a saga with compensations [140].

  • Coordination-free convergence. State that only grows by joins converges without coordination: CRDTs [310].

  • Time. Logical clocks order events consistently with causality, and consistent snapshots capture a global state [56, 211].

Figure 4 draws the case that leases alone get wrong. Section 7 and Section 9 and Section 13 build each of these into families, outcomes and activation.

Figure 4

Figure 4. Fencing. A lease holder pauses past its expiry, wakes and writes with a stale epoch. Only the store that holds the data can refuse that write, by comparing epochs. Without the check both writes are accepted, which is the ownership-handover counterexample of Table 9.