One graph model and a concurrent engine
The work graph holds the promises of a project as commitments: one actor owes an outcome to another, under a grant, by a deadline, and an acceptance query decides whether it was met. A change is admitted only when it breaks no commitment. This page describes the store such a graph would run on. It follows a revision of the design drafted by Gemini 4 Carbon on 12 November 2026 from the design of 11 November, as corrected by a review the same day. The paper now prints two implementations of it, read from the files their tests compile: the concurrent graph in C++23, whose 40 checks pass under the address, undefined-behaviour and thread sanitizers, and the whole engine in Kotlin, whose 59 tests pass. Neither runs inside Reaktor yet, and neither has been timed.
Overview#
The revision makes two moves.
- One graph model. The coordination graph and the typed model of the subject live in one graph with one kind of identity, one kind of patch and one rule of admission. A commitment's region names the same elements that checks and Atlas read, so there is no second store to keep in step.
- One concurrent engine. The store keeps immutable snapshots, records what every query read, and admits a change in two phases: the expensive checks run in parallel without locks, and only a short final step is serialised. Heartbeats never touch the stored graph.
Why one model#
Two stores, one for promises and one for the subject, would each need identities, patches, read-set tracking, watches and admission, and a change that touches both, such as an agent that edits code and reports progress on its commitment in the same step, would need a transaction across them.
A graph of objects with pointers and locks fails in a different way when many agents write at once. A lock per node deadlocks when one patch touches several elements in a different order from another patch. A compare-and-swap per edge cannot evaluate an acceptance query that reads several predicates, because the query needs them all from one consistent state.
The unified model#
The model is a typed port hypergraph: nodes, ports, hyperedges and incidences, where an incidence joins a hyperedge to one of its endpoints. Every node, port and hyperedge is also an entity, and an incidence may end at any entity.
| Part | Kinds | Families | Present |
|---|---|---|---|
| Coordination core | Actor, proposition, record, resource | Commits, attests, decides, grants, contributes, uses | In every project, at the level of intent |
| Structure of the subject | The kinds of the subject's typed model | Its connections and structural assertions | When the subject is held as a typed model in the store: code, building components, a data pipeline or a curriculum |
Every assertion also carries a modality: intended, realised, observed or claimed. The revision adds four things to the earlier design.
- Assertions about assertions. The work graph needs edges that point at edges. A reservation of a resource attaches to the commitment it serves. A commitment and a decision each cite the grant that authorises them. A decision can supersede an earlier decision. Letting an incidence end at a hyperedge allows all of these directly. The category of such graphs is still a presheaf topos, so rewriting by double pushout keeps its guarantees: independent patches commute, and a change of vocabulary migrates the data in a defined way.
- Shared capacity in escrow. Budgets, hours, build slots and devices are resources, and a reservation of one is a uses assertion. Admission reads a resource through a threshold predicate, "at least k units of r are free over the interval I", and checks that the free capacity at the head revision still covers the reservation. Two reservations that both fit never conflict, although both change the same counter.
- Levels for each discipline. Each vocabulary brings its own order of levels with intent at the top. A building might use intent, spatial, system, element and site. Manna's curriculum might use intent, domain, resource and chapter. Plain files need only intent and subject. Software has its own chain from intent down to the machines it runs on.
- Guards as standing commitments. A guard that an actor wants to keep holding becomes a commitment of that actor to itself, of kind maintain, with no exclusive region and no deadline, whose acceptance query is the guard. Rules that protect the software and promises between people and agents then pass through the same admission.
Admission#
The work graph admits a proposed change at the head revision only when five clauses hold. Admission against commitments defines them in full.
| Clause | It holds when |
|---|---|
| A1 Validity | The change applies cleanly and the result passes the subject's checks |
| A2 Freshness | Nothing admitted since the change's base revision wrote anything the change read |
| A3 Authority and escrow | The actor's grant is live and covers what the change writes, and every reservation fits the free capacity and the grant's budget |
| A4 Write lease | Where the change writes into an active commitment's declared region, the actor is its debtor or a delegate, or holds the creditor's permission |
| A5 Semantic guard | No acceptance query that held before the change fails after it, unless the change amends or releases that commitment |
When an acceptance query is too expensive to run before the commit, the commitment's timeout policy decides. Under fail-closed, the default for structural, regulated and financial commitments, the change waits for asynchronous verification. Under optimistic-at-risk, the change is admitted, the commitment is marked at risk, and both parties are told.
The concurrent engine#
The engine combines five techniques.
- Snapshots of immutable chunks. Each sort is stored as parallel columns cut into immutable chunks of 4,096 rows. A snapshot is a set of chunk tables and a revision number. A reader pins a snapshot by writing the current epoch into its own slot and loading the snapshot's root, with no lock and no retry, and reads it for as long as it needs. A change copies the chunk tables and only the chunks it touches. A replaced snapshot is freed once every reader has announced a later epoch, a scheme called epoch-based reclamation. On the JVM and in Kotlin/Native the garbage collector does this work, and a plain atomic reference is enough.
- Read sets recorded by the store. Every query and check reads through a tracked reader, which sets one bit for every predicate it reads, so the read set is complete by construction. A set of 100,000 predicates fits in 12.5 KB. The store also keeps, for every predicate, the revision that last wrote it. Checking freshness visits only the set bits and compares each predicate's last write with the change's base revision, so its cost follows what the change read, and the store needs no log of earlier writes.
- A region index and an escrow ledger. For every predicate, the index names the commitment that holds its exclusive lease, so clause A4 is one lookup, and lists the commitments whose acceptance queries read it, so clause A5 re-runs only the queries that a change could have broken. The index is chunked like the columns, so a change copies only the parts it touches. Resource capacities live in a ledger that admission checks against the free amount, which avoids the aborts that a version check on one shared counter would cause, and the gate records every reservation it admits.
- Admission in two phases. In the first phase a worker pins the snapshot, builds a candidate that shares every unchanged chunk, and runs the checks of A1 and the affected queries of A5 in parallel, adding what they read to the read set. In the second phase, under a short lock, the gate checks that nothing in the read set was written after the base revision (A2), checks grants and the free capacity of each resource (A3) and leases (A4), applies the change to the head with its last-write revisions, reservations and at-risk marks, publishes the next revision and sends its writes to the watches. The Kotlin engine runs the same checks without a lock: it publishes with one compare-and-set on the head and, when another change was published first, checks again against the new head.
- A liveness wheel beside the graph. A heartbeat updates one atomic slot for its commitment and writes nothing to the graph. A ticker scans the slots and proposes a change only when a heartbeat lapses, a creditor's review window ends or a deadline passes. While a creditor is reviewing, the debtor's clock is paused.
Bounds#
The revision states these bounds for a store with |Π| active predicates and a change that reads |Rd| of them and writes |Wr|. The times it quotes, such as a commit gate measured in microseconds, are targets: neither implementation has been timed.
| Operation | Synchronisation | Cost | How |
|---|---|---|---|
| Pin a snapshot | Wait-free: one load, one store, one load | Constant, no allocation | Announce the epoch in the reader's own slot, then load the snapshot root |
| Read an entity and its incidences | No locks | Its degree, plus one bit per predicate | Chunk index by shift, bit set in the tracked reader |
| Run A1 and the affected A5 queries | Parallel, no locks | The size of the queries the change touches | Candidate snapshot over shared chunks |
| Commit gate | Short lock | |Π|/64 + |Rd| + |Wr| | Last-write revision of each predicate read, lease and escrow lookups, copies of the touched chunks |
| Wake watchers | Fan-out, no locks | |Wr| × subscribers | Writes routed through an index of watches |
| Renew a heartbeat | One atomic store | Constant, no graph write | Slot in the liveness wheel |
What it gives the agentic plane#
Several of the plane's present limits are limits of the store the plans use today.
- Agents that write at once. Plans today refuse an operation on an item that someone else changed after the writer's revision, for that item only. The code has no such check: agents that share a checkout can overwrite each other's edits, and agents in separate worktrees find a clash only when they land. With recorded read sets, a change is refused exactly when something it read, whether an item, a declaration or a file, was written after its base revision.
- Refusals that say whom to ask. A refusal names the failed clause, the predicate, the commitment and its holder, so an agent that is blocked can message the holder or escalate to the creditor instead of retrying.
- Heartbeats that cost nothing. Agents renew their work every few minutes. In the wheel a renewal is one atomic store, so the graph records only the events that matter: a lapse, an expired review or a missed deadline.
- Waiting without polling. A watch wakes a waiting agent when a predicate it waits on changes, and at no other time.
- Quota and machines as resources. Subscription quota, build slots and test phones are shared capacities, and escrow lets work reserve them before it starts.
Review of the revision#
The model is sound and the engine's five techniques are the right ones. A review on 12 November 2026 found six faults in the revision's reference code. The paper's source was corrected the same day, and both implementations avoid all six.
- The reference code did not compile. The column header used
std::sortandstd::uniquewithout including<algorithm>, and Apple's C++ library rejectsstd::atomic<std::shared_ptr<const Snapshot>>, which it does not implement. The headers now include what they use, and the store pins snapshots with its own epochs. - Pinning a snapshot was not wait-free. Where a standard library does provide an atomic shared pointer, it guards it with an internal lock. The corrected store uses epoch-based reclamation: a pin is one load, one store and one load, and a replaced snapshot is freed only after every reader has moved past it.
- Two sizes were wrong. An incidence row as declared took 24 bytes because of alignment, where the revision said 12. Its fields now run from largest to smallest, and it takes 16. A set of 100,000 bits takes 12.5 KB, where the revision said 15.6 KB.
- The commit step left out its own writes. It checked escrow capacity but never recorded the reservation, so two changes admitted one after the other could both take the last unit, and it dropped the at-risk marks it computed. It now records the reservations, summed for each resource, and the marks.
- A change cost more than the rows it wrote. Copying a snapshot copied its whole region index, so every change cost time in proportion to the number of predicates. The index is now chunked like the columns.
- The log of writes grew forever. The commit step walked a log of every earlier change on each commit. The store now keeps the revision that last wrote each predicate, and the freshness check reads those.
Two implementations#
The paper prints two implementations of this design in its appendices. Each listing is read from the file that its tests compile, so the code on the page is the code that passed.
- The concurrent graph in C++23. Appendix D implements the store alone in five headers and about 870 lines: nodes, ports and hyperedges in persistent columns, read sets, the region index and the escrow ledger, snapshots pinned with epochs, the two-phase gate and the liveness wheel. It leaves meaning to its host, which supplies four functions: how to evaluate a proposition, whether a grant covers a change, whether an actor may write inside another commitment's lease, and whom to wake. Its 40 checks include four writers adding edges to one hub while two readers check every snapshot, and they pass under AddressSanitizer, UndefinedBehaviorSanitizer and ThreadSanitizer.
- The whole engine in Kotlin. Appendix E implements everything the paper specifies in eleven files and about 1,330 lines: the unified model, the five admission clauses with their witnesses, the ten verbs, liveness and the reactor, the status queries, modes and markets, the federation host log and shadow migration. It favours clarity over speed, and the garbage collector reclaims old snapshots. Its 59 tests follow the paper's scenarios, among them the clash in the ceiling void, fifty agents reserving from one budget on fifty threads, and the late slab whose twelve blocked trades surface as one item.
Writing the store closed three gaps that the revision left open, and the paper's description of the engine now includes them.
- Each entity has a predicate for the list of what attaches to it. A change that read the list is refused when another change adds to it, while two changes that only add edges to the same hub both pass.
- A change is refused at the gate when a commitment began guarding what it writes after the change was checked, because that guard never ran against the change.
- An entity cannot be retired while anything still attaches to it, and a reused slot carries a new generation, so a handle to a retired entity never reaches the entity that replaced it.
Writing the tests found three faults in the rules, and the Kotlin engine closes them.
- Any member of a decision could withdraw another member's vote. Only the member who cast a vote, or an agent acting for that member, can now supersede it.
- An actor could earn capability through grants it had issued itself. Trust now never flows through the actor being judged.
- A migration dropped the keys that make a retried change idempotent, so a retry after a migration could apply twice. A migration now keeps the keys and the history.
The split settles the engine's language. The engine's meaning lives in Kotlin, the language of Reaktor and Hangar, so it can run inside Hangar's process first. The concurrent graph lives in C++23, where memory layout and atomics are under control, and can be mounted beneath the Kotlin engine once timings show the need.
One question stays open: the size of a predicate decides how well admission works. If one predicate covers a whole file, unrelated edits to that file refuse each other. If every declaration is a predicate, read sets and the region index grow. The revision does not say how predicates map onto Atlas's identities, and step W2 of the build order measures exactly this, as false refusals and missed conflicts.
Where it fits the build order#
Reaktor work graph builds the work graph in six steps, W0 to W5. W0 and W1 add deadlines, heartbeats and commitments to the plans Hangar keeps today and need no new store. The engine matters from W2 on, when admission checks commitments with read sets. The lowest-risk path is to run the Kotlin engine's admission and liveness behind the plan store's existing operations, measure false refusals and missed conflicts on real runs, choose the size of a predicate from those measurements, and mount the C++ store beneath the engine when timings show the need.
Sources#
- The work graph paper: Work graph, in particular commitments, admission, liveness and subject spaces with structure.
- The revision of 12 November 2026, with the review's corrections: one graph model and concurrent engine in the paper.
- The two implementations with their tests: the C++23 concurrent graph and
the Kotlin engine. Their source is in
papers/work-graph/code/at the workspace root. - Techniques: multiversion concurrency control (Bernstein and Goodman, 1983); persistent data structures (Driscoll, Sarnak, Sleator and Tarjan, 1989); compressed purely functional graph snapshots (Dhulipala, Blelloch and Shun, 2019); incremental computation over Z-sets (Budiu and others, 2023); serialisable snapshot isolation (Fekete and others, 2005); epoch-based reclamation (Fraser, 2004); validation against each record's last write, as in Silo (Tu, Zheng, Kohler, Liskov and Madden, 2013); hashed timing wheels (Varghese and Lauck, 1997); adhesive categories (Lack and Sobociński, 2005); functorial data migration (Spivak, 2012); data-oriented design (Fabian, 2018).