Skip to content
Design10 min readUpdated 27 Oct 2026

8. Traversals: one computational primitive

8.1 Definition#

Definition 8 (Traversal). A traversal is a tuple θ=(σ,V,μ,⊕,υ,β). Here σ is a selector (the element kinds and the directed role pairs (k,r→r′) to follow, including containment); V is a value domain; μk,r→r′:V→V are message functions; ⊕ is an associative, commutative aggregation; υk:V×V→V are update functions, one per node kind k; and β is a budget. On a graph G, θ denotes the least solution of x(v)=υ𝑘𝑖𝑛𝑑(v)(x0(v),⨁(u,k,r→r′)∈σ(v)μk,r→r′(x(u))), where σ(v) enumerates the selected incidences arriving at v, when that least solution exists. Theorem 6 gives sufficient conditions for lattices; a path problem needs a closed semiring, so counting paths needs an acyclic graph or a bound. A traversal returns a value assignment (a query), a patch (a rewrite) or a patch to the runtime or deployment layer (a plan). It always also returns findings and a coverage claim: the revision, the layers and scopes visited, the elements the budget excluded, and the opaque boundaries it could not see.

What the current runtime calls a visitor is the pair (μ,υ) of a traversal. The traversal adds what those visitors left implicit: the selector, the algebra, the schedule and the budget. Equation (2) is one step of a graph network [29, 145], generalised from vertices and edges to typed incidences with roles. A Transformer layer is the special case of a complete graph with a learned, attention-weighted aggregation [344, 346]. The analogy is deliberate. One parallel primitive replaced the bespoke recurrent and convolutional architectures; here one typed primitive replaces the bespoke algorithms that the current runtime hand-wrote inside classes: wiring, shape extraction, deep-link search, telemetry installation and rendering. Because the representation is a set of incidence tables (Section 11), learned analyses can later read the same tensors.

Figure 12

Figure 12. One step of a traversal (Equation 2). Along each selected incidence, a message function chosen by family and role pair transforms the neighbour’s value. Messages are aggregated by an associative, commutative ⊕ and combined with the node’s own value by an update chosen by its kind. Iterating to the least fixpoint gives the result, in any order (Theorem 6).

8.2 Algebraic classes#

The traversals of interest compute in four classes, each with its own guarantees. Rewrites and plans come from any class: they are traversals whose result is a patch.

  1. Folds over the containment forest. These are attribute grammars [205]. Inherited attributes flow down: the injection environment, theme, authority context and layout constraints. Synthesized attributes flow up: sizes, effect footprints, exported ports, readiness and digests. They are incrementally re-evaluable after an edit, the classic technique of language-based editors [297].

  2. Path problems over a semiring (S,⊕,⊗,0‾,1‾) [194, 250]. Boolean for reachability (unreachable routes, effect reachability, taint [298]); min-plus for the shortest route; max-plus for the worst-case latency of an acyclic call chain; max-min for capacity; counting for path multiplicities in acyclic graphs; and provenance polynomials [156] to explain why a finding holds.

  3. Fixpoints over lattices, i.e. Datalog with lattice values [4, 232]. These cover dependency resolution with ambiguity detection, capability eligibility, effect ceilings, contract inference and compatibility closures.

  4. Solvers: placement (integer programming), partitioning into regions [192] and layout. These are not monotone and are not least solutions of (2). A traversal of the first three classes builds the constraint system, an external solver solves it and returns a certificate, and traversals of the first three classes validate the result before admission.

Theorem 6 (Determinism and cost). Let V be a lattice of finite height h, ⊕=⊔, and let every μ and υ be monotone. Then (2) has a least solution. Every fair chaotic iteration from ⊥ reaches it, whatever the order, parallelism or partition of the graph. A worklist schedule performs at most h⋅|X| updates and O(h⋅|I|) message evaluations.

This is the asynchronous-iteration theorem for monotone systems [75, 195] applied to (2). The proof is in Appendix A. It rules out a class of defects that hand-written visitors can have: breadth-first and depth-first visitors that disagree, wiring that depends on hash order, and results that change between runs.

Proposition 7 (Incremental maintenance). Represent a revision as a Z-set (a signed multiset) of elements and incidences, and a patch as a Z-set Δ. If a traversal is expressed in DBSP’s operators (linear operators, bilinear joins, distinct and fixpoint), then its incremental form θΔ, a stateful operator that keeps the integrals of its inputs, satisfies θ(G+Δ)=θ(G)+θGΔ(Δ). For linear operators the cost is proportional to |Δ| [46].

Reaktor’s design documents require that an incremental update equal a fresh analysis of the same input [293]. With Proposition 7 this is a theorem about the compiled traversal rather than a test of each implementation. Findings, injection plans, route tables and closures become views maintained under patches, as in differential dataflow [236] and build systems [251].

Proposition 8 (Coordination-freedom). In the model of relational transducer networks, a traversal over a graph partitioned across machines can be evaluated without coordination if and only if it is monotone in the graph [16, 167]. Non-monotone traversals (“no provider exists”, “this route is unreachable”, “no grant permits this effect”) are evaluated as stratified programs over a consistent cut [56].

The kernel labels each traversal monotone or stratified. It refuses to report a non-monotone result over an inconsistent cut, reporting unknown instead. This is the formal form of the rule that a missing observation is not evidence of absence.

8.3 Instances#

Table 8 lists the platform services that are traversals in RG. Each was a subsystem, a class or a manual procedure in the current runtime.

Table 8. Platform services as traversals.
Service Selector Class Output
Dependency injection Bind consumer→provider; containment (inherited environment) lattice (c) Bind patch; findings: missing, ambiguous, cross-place
Navigation, deep links Transition on Routes; route containment Boolean/min-plus (b), fold (a) route table; deep-link plan; unreachable-route findings
Rendering and layout containment of Surfaces and slots fold (a) render plan realised by Compose or React hosts
Lifecycle runtime containment; Bind order fold (a) activation and deactivation plan (providers first)
Capability and placement capability ports; Places lattice (c), solver (d) eligible places; placement with certificate
Effects, authority and flow Session, Channel, Access from entry points; Grant; labels Boolean (b), lattice (c) effect footprint per entry; ungranted effects; illegal flows
Code-push closure required-together relations (Section 9.5) lattice (c) smallest compatible release region
Impact and tests reverse reachability over connections and Access Boolean (b) affected scopes, invalidated evidence, tests to run
Telemetry Session, Channel in a scope fold (a), returning a patch patch adding interceptor and observer roles
Data invalidation References, Access, Derives Boolean (b) caches and views to invalidate
Lints any structural predicate (a)–(c) findings with witnesses and coverage
Data graphs References over graph-family datasets (b), (c), compiled to the store paths, cycles, cascades and visibility, with coverage

Routes and their transitions form a statechart [163]: route containment gives hierarchy, a container whose tabs keep separate back stacks gives orthogonal regions with history, and a modal return is a Transition in return mode carrying a typed result (Figure 13). Resolving a deep link is a path problem: find the shortest path of transitions, under their guards, from the current configuration to the target’s chain of ancestors. Back stacks are runtime state over this structure. Because they are validated walks of the transition graph, a deep link can no longer produce a stack that no sequence of user actions could produce, which the current runtime does not check.

Rendering#

A Surface owns a region of the interface, not every painted shape: text, layout and drawing inside it stay ordinary Compose or React code. Containers are surfaces with named slots, and screens are surfaces mounted at routes. Rendering is a fold over the active configuration. It passes constraints and theme down and receives sizes and readiness back, and its result is a render plan of keyed mounts that a Compose or React host reconciles. A surface binds to its component’s ports, observing Channel signals and sending to mailboxes or sessions, so state and operations stay in the graph while presentation stays in the renderer. Because the fold is generic over slots, an arbitrary design is a different arrangement of surfaces and slots, not a copy of a framework container. When a surface’s logic runs in a pushed region (Section 9.5), the render plan crosses the trunk as data: a keyed tree of mounts, typed by the surface contracts the host offers. The host’s widget catalogue is a set of capability contracts. A pushed region can therefore use only the surfaces its host provides, and admission checks this, as in Redwood [52].

Traversals over data#

Rows never enter the graph, but much data is itself a graph: follow relations, dependencies, prerequisites, bills of materials. A traversal over a dataset of the graph family is compiled into the store’s own query language and runs where the data lives: recursive SQL for Postgres, Cypher [139] for a graph store such as Memgraph [239], SQL with window and array functions for an analytical store such as ClickHouse, or Datalog. Its algebraic class is unchanged. Theorem 6 therefore still holds, and Proposition 7 holds wherever the store offers a change feed. The kernel plans the query and the store executes it, so path finding, cycle detection, deletion cascades and visibility are each written once, not once per client and store. Listing 2 and Listing 3 show one traversal and its compiled form.

val blockedBy = traversal<Set<TaskId>>("tasks.blocked-by") {
    over(db["tasks"], along = Task::dependsOn)
    start { it.status == Open }
    lattice(SetUnion)
    compileTo(Postgres)
}

Listing 2.

A traversal over a dataset (proposed API) and the query it compiles to.

WITH RECURSIVE reach(task_id, dep_id) AS (
    SELECT t.id, d.depends_on
    FROM tasks t JOIN task_deps d ON d.task_id = t.id
    WHERE t.status = 'open'
  UNION
    SELECT r.task_id, d.depends_on
    FROM reach r JOIN task_deps d ON d.task_id = r.dep_id
)
SELECT task_id, array_agg(dep_id) AS blocked_by, bool_or(dep_id = task_id) AS cyclic
FROM reach GROUP BY task_id;

Listing 3.

The recursive query that Listing 2 compiles to, written out by hand; UNION deduplicates, so the recursion terminates on cycles and reports them.

Dependency injection and other containers#

Resolution is the lattice traversal of Table 8. It searches the scope chain for compatible providers, reports a missing or ambiguous provider as a finding with a witness, and never depends on construction order. Foreign containers such as Koin, Hilt or Spring are adapters: an opaque Scope whose beans are Bind providers, imported with provenance. Interoperating with a framework therefore no longer requires the kernel to depend on it.

Figure 13

Figure 13. Navigation as a statechart over Routes and Transitions. Containment gives hierarchy; a container with three tabs gives orthogonal regions, each with a history state (H) that restores its back stack; a modal returns a typed result. A deep link is resolved as a shortest valid path, so every stack it produces is reachable by user actions.

8.4 Pure traversals, effectful executors#

Traversals are pure. Effects belong to executors, which apply plans under explicit authority. This preserves the design rule that visitors are pure, bounded interpretations [293] and that rewrites return patches, and still lets everything that the current runtime hard-coded become graph-derived:

  • Structured concurrency. The lifecycle executor applies activation plans. Each Activation gets a coroutine scope that is a child of its parent activation’s scope, so the runtime containment forest is the job tree [105]. Cancellation propagates down the forest, and failure propagates up according to the scope’s supervision facet [20]. The dispatcher is a capability port offered by the place: the main thread on Android, the event loop in a browser, the microtask queue in Hermes. This replaces the current runtime’s scopes fixed inside classes (a SupervisorJob and a default dispatcher per graph, with GlobalScope escapes) by scopes derived from the graph.

  • Reconciliation. A reconciler is a traversal that computes 𝑑𝑒𝑠𝑖𝑟𝑒𝑑⊖𝑜𝑏𝑠𝑒𝑟𝑣𝑒𝑑, keyed by stable identity, plus an executor that applies the difference idempotently. For a surface subtree this is React’s keyed reconciliation; for places and resources it is a Kubernetes controller [47]. Both are level-triggered, and both read the same graph.

  • Instrumentation. An installed observer is a plan in the observation layer, attached to a revision and removed with it, never an untracked side effect.

The four categories of the design documents (read-only analysis, rewrite proposal, installed instrumentation and runtime execution) are thus queries, patches, observation plans and executors.