1.2 Design review: the control plane
The control plane is the part of the system that keeps working after any one process dies. It contains durable workflows, workers, queues, an agent runtime, and the usage gateway that feeds them. Their failure semantics decide whether a retry preserves what the user intended or repeats a side effect, which is why the control plane deserves its own review rather than a paragraph in the whole-system one. In a control plane the review question is always the same: what is persisted before each external effect, and what does replay do after a crash at any point?
Concepts from other sections (16)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- Control plane: the API server, etcd, scheduler, and controller manager, which store desired state and decide what should run where; worker nodes carry out those decisions. Read more: Chapter 10: Kubernetes Workloads and Deployment
- Idempotency: the property that applying an operation more than once has the same effect as applying it once. Read more: Chapter 3: RPC and Protocols
- At-least-once delivery: committing after the work, so a crash between work and commit causes a redelivered duplicate but never a loss. Read more: 5.3 Coordination and technology choice
- Dead letter: an activity whose retries are exhausted, parked in the DLQ with
ActivityDeadLettereduntil an operator redrives it. Read more: 7.5 Activities - fsync: a system call that forces written data (or a directory’s entries) to durable storage. Read more: 6.7 Safetensors for every dtype, atomic checkpoints, and the token stream in AI Engineering
- Visibility timeout: the lease length ; a leased task is invisible to other pollers until it expires. Read more: 7.3 The task queue
- Task token: the opaque token encoding queue, task id, lease token, run id, , and , which a completion must present. Read more: 7.4 The task protocol and workers
- Design review: a reader who did not write the document checking it against a rubric and returning comments and a decision. Read more: 1.1 Design review: the tracer and the serving platform
- Review note: an unresolved checklist item recorded with an owner, a next step, and a done condition. Read more: 38.1 Professional responsibility and disclosure in AI Engineering
- usage ledger: the durable per-request record of tenant, key, model, status, tokens, and latency. Read more: 25.5 The usage ledger and admin API in AI Engineering
- StatefulSet: a workload controller that gives each Pod a stable name and its own persistent claim, with ordered rollout. Read more: 10.7 Durable and worker images and charts
- write-ahead logging (WAL): a journal mode in which commits append pages to a log, so readers and the single writer do not block each other. Read more: 1.11 SQL and SQLite: schema, transactions, WAL mode, indexes, aggregates in Programming and Algorithms
- SIGKILL: an uncatchable signal that ends a process between two instructions, leaving only what is on disk. Read more: 12.3 The durable server is SIGKILLed in a loop during a corpus build
- Torn tail: an incomplete record at the end of the last segment, left by a crash mid-append; it is truncated at recovery. Read more: 7.1 The append-only event log
- Poison task: a task that fails the same way on every attempt, so retries cannot fix it. Read more: 12.4 A poison task lands in the dead-letter queue
- Version marker: a
MarkerRecordedevent that records which code path a run took at a change, read byGetVersion. Read more: 7.6 Deterministic replay
This section applies the eight-line rubric from Design review: the tracer and the serving platform to that question. It assumes you know the durable engine and its workflows from Durable Orchestration and Workers in Systems Engineering, and the journal from Durable agent runs in the same book. You will trace two paths through the system by hand, a corpus build activity and an agent write that needs approval, and then read a model review, docs/reviews/control-plane.md, written out in full below: every rubric line answered with evidence from the solution code, every “no” turned into a note with an owner and a next step, and a decision at the end.
Try answering each rubric line from the two traces before reading the model’s answer. The lines you cannot answer from the traces are usually the ones the review ends up marking “no”.
Learning objectives
- Review contracts, data ownership, idempotency, tenant boundaries, load shedding, observability, and recovery as one system.
- For each transition in a durable workflow, say what is on disk before anything outside the process acts on it.
- Explain how leases, fencing tokens, and idempotency keys turn at-least-once delivery into an effect that looks exactly once.
- Explain why an agent write with an unknown outcome is escalated to a human rather than retried or skipped.
- Tie every rubric answer to evidence and turn every missing answer into an owned note.
What a control-plane review looks for
Section titled “What a control-plane review looks for”A control-plane review looks at contracts, data ownership, idempotency, tenant boundaries, load shedding, observability, and recovery together, because in this part of the system they fail together. Two distinctions organize the work. The first is between durable state and process memory: anything that lives only in a process is gone after a crash, so every claim about recovery must point at something on disk. The second is ownership: for every transition, someone (a component, a person) owns it, and the review identifies who.
From there the principles follow in order. Durability is decided per transition: for each arrow in a trace, ask whether the fact is on disk before anything outside the process acts on it. At-least-once delivery is the given and idempotency is the design: leases expire and tasks are redelivered, so every activity’s effect must be keyed, by <workflow id>/<activity id> for activities and by the run id plus step for agent runs. Late actors must be fenced: a worker that was presumed dead can come back, and its completion has to be made harmless. Unknown outcomes are escalated, not guessed: an agent write whose result was not recorded becomes indeterminate, and a poison activity becomes a dead letter, and both page a human with a runbook. Finally, a review that finds nothing is a weak review; the rubric lines that lack evidence become notes with owners.
Tracing two paths by hand
Section titled “Tracing two paths by hand”The two traces below exercise most of the control plane between them: the log, the queue, leases, idempotency, sagas, signals, and the journal. Each step names what is durable when it happens.
A CorpusBuild activity, stage shard
Section titled “A CorpusBuild activity, stage shard”- The workflow (
corpus_build.go) registers its compensation (corpus.cleanup) and schedules activitycorpus.stagewith activity idshard. The command is appended to the workflow’s history in the segmented log, which fsyncs before acknowledging (log.go,formats/wal.md). - The task is enqueued; every queue transition is logged before it takes effect (
queue.go). A worker long-polls and receives a lease: a visibility timeout and a fencing token carried inside the opaque task token (tasks.go). - The worker runs
{corpus} run --stage shardas a child process (subprocess.go,spec/subprocess-activity.md) withTL_IDEMPOTENCY_KEY=<workflow id>/shard, the same on every attempt. It tails the child’s progress file and turns checkpoints into heartbeats (heartbeat timeout 2 minutes, start-to-close 2 hours, 5 attempts). - The child writes shards under
corpus/<dataset>/<version>/and exits: 0 (done), 65 (bad input, never retried), 75 (temporary, retried), 130 (cancelled after SIGTERM). The exit code becomes the activity’s result or failure, and the completion is logged.
Now ask “crash here?” at each step. If the worker dies at step 3 or 4, the lease expires and the task is delivered again; the rerun sees the same idempotency key and its work directory, and resumes rather than duplicating. If the server is SIGKILLed, it truncates the torn last record on restart, rebuilds queues from the log, and redelivers the leases that were live. A late completion from the old worker carries an old fencing token and is refused. The effect is at least once; the idempotency key is what makes it look exactly once.
This is not a hypothetical. The drill The durable server is SIGKILLed in a loop during a corpus build measured it: five kills, 14 tasks delivered twice and 3 three times, no acknowledged event lost, and the shards hold every row once (2026-10-09-durable-kill9.md).
An AgentRun write tool that needs approval
Section titled “An AgentRun write tool that needs approval”The second trace follows the durable agent (run.go, journal.go).
Runappendsrun.startedwith the input messages. Each model call and tool call is a step:step.startedis recorded before it runs andstep.completedwith its result before the result is used; every append is fsynced.- The gate classifies the tool as a write that needs approval; the loop stops with an approval error, and
Runreturnsawaiting_approvalwith the pending markers. Nothing external has happened. - A human sends the
approvesignal with the marker; it is appended as asignalrecord. - The next
Runreplays every completed step from the journal (no model call, no tool call again), sees the approval, and runs the write.
Again ask what a crash does. A crash between step.started and step.completed of a read re-runs the read. For a write the outcome is unknown, so the run stops as indeterminate until a human sends reconcile: the journal never guesses whether a write happened. Running the same run id with different input is refused (ErrInputMismatch).
The task
Section titled “The task”The task is to write docs/reviews/control-plane.md as the design review of the control plane. Answer each of the eight rubric lines (defined in Design documents and design reviews) with evidence from the completed system. Each “no” becomes a review note with an owner and a next step, and the review ends with a decision.
The model review
Section titled “The model review”The review opens with its scope:
Review: the control plane (
docs/reviews/control-plane.md). Scope: the durable server (log, queue, workflows, activities, timers, signals), the workers and subprocess activities, the platform workflows (CorpusBuild, TrainRun, EvalSuite, ModelRelease), durable agent runs, and the gateway’s usage ledger and policy as they feed the control plane.
It then answers the rubric, one row per line, each “yes” backed by a file or a measured number:
| Rubric line | Answer | Evidence or note |
|---|---|---|
| problem, users, constraints first | yes | workflows that outlive any process: a corpus build or a training run takes minutes to hours and must survive worker and server crashes. Users: the operator ({ctl} wf describe, wf dlq list), the release approver, agent runs. Constraint: a single kind node, the durable server as one StatefulSet pod on a WAL volume claim |
| two options, same criteria, numbers | yes | single-node log versus the optional three-replica Raft log (raft.go): the single node loses availability (not data) while its pod restarts; Raft tolerates one of three replicas down (a majority of 2) at the cost of two more pods and a network round trip before each commit. Single node chosen for one kind node; Raft replicates exactly the WAL record bytes, so switching is a deployment change |
| what the choice gives up | yes | availability during a restart: the SIGKILL drill measured a build taking 6 min 10 s instead of 2 min 30 s under five kills, with nothing lost |
| every interface names its contract | yes | proto/tl/durable/v1, formats/wal.md, spec/subprocess-activity.md, proto/tl/raft, formats/corpus-config.schema.json, formats/usage.v1.sql, formats/policy.v1.schema.json |
| failure modes, detection, degradation | yes | table below |
| capacity and latency budgets, arithmetic | no | note N1 |
| rollout and rollback, migrations | no | note N2 |
| open questions with an owner | yes | notes N1 to N3 |
Failure modes
Section titled “Failure modes”The failure table falls out of the traces: each row is a “crash here?” question with its detection and its recovery.
| Failure | Detection | Degradation and recovery |
|---|---|---|
| durable server SIGKILLed | DurableRedeliveriesSpike (runbook) | torn tail truncated on restart; live leases redelivered after their visibility timeout; reruns keyed by idempotency key |
| a worker dies mid-activity | heartbeat timeout (2 min for corpus stages) | the lease expires and the task is redelivered; a late completion is refused by its fencing token |
| a poison task fails every attempt | DurableDeadLetters after 5 attempts (runbook) | the waiting workflow is stuck until the cause is fixed and the task redriven (poison-task postmortem) |
| a cancelled or failed corpus build | the workflow’s result | the saga runs corpus.cleanup: no partial shards or token files remain; fetched raw documents stay as a shared cache |
| a subprocess ignores SIGTERM | exit code after the 30 s grace | SIGKILL; the attempt fails and is retried |
the WAL fills its wal_max_bytes quota | appends fail with RESOURCE_EXHAUSTED | new work is refused rather than the disk filled; existing history stays readable |
| an agent write with an unknown outcome | the run’s status indeterminate | stops until a human reconcile signal; never re-executed blindly |
The two “no” lines, and one assumption the review could not settle, become notes with owners:
- N1, capacity (owner: durable control plane, before the next stage of the build). The design states no budget for WAL growth or redelivery cost. Next step: from the SIGKILL drill’s numbers (17 extra deliveries over five kills) and the segment size (64 MiB per segment), write the WAL bytes per CorpusBuild and per TrainRun, and set
wal_max_bytesfrom that with headroom, so the quota is a known number of builds rather than a guess. - N2, rollout (owner: durable control plane). Workflow code is replayed against recorded history, and a change to a workflow’s sequence of commands makes replay of a run started under the old code fail with a nondeterminism error (
replay.go). The mechanism to avoid it exists,workflow.GetVersion(workflow.go), which records a version marker for new runs and returns the old version when replaying old ones, but no document states the rule for using it. Next step: write that every change to a workflow’s command sequence goes behindGetVersion, and say how a worker rollout treats runs in flight. - N3, assumption to test (owner: agent runtime). An approval signal names a marker, but the review found no stated expiry for approvals. Next step: decide whether an approval is valid forever or only for the run attempt that asked, and test it in the next drill.
The decision
Section titled “The decision”Approve with changes. N1 and N2 must be closed (a WAL budget and a workflow-versioning rule) before the control plane is called production ready; N3 is an accepted risk until the agent runtime’s next review.
Why this review
Section titled “Why this review”Evidence beats assertion: every “yes” names a file or a measured number, and a “yes” without one is a “no” waiting to happen. Two traces cover most of the rubric, because following a CorpusBuild and an approved agent write exercises the log, the queue, leases, idempotency, sagas, signals, and the journal, and the failure table falls out of asking “crash here?” at every step. And the “no”s are honest. Capacity and rollout are where control planes usually fail in production, through unbounded logs and replay-breaking deploys, and they are exactly the lines the solution’s documents do not yet answer. Writing them as owned notes is the useful output of the review.
What can go wrong
Section titled “What can go wrong”The ways a control-plane review fails mirror the principles it is meant to check. If version selection or a document claim is left implicit, a reader or client cannot determine which contract or evidence applies; the model review avoids this because every rubric answer names its contract file or measured number. If the failure path is skipped, the successful example works but malformed input or a rollback breaks the system; here each trace is followed by its replay-after-a-crash analysis, and the failure table lists detection and recovery for every row.
Warning: A review that omits a named owner and recovery condition cannot guide an operator when conditions change. Every “no” in the model is a note with an owner and a next step, and the decision names what closes it.
Where this leads
Section titled “Where this leads”This review rests on two earlier pieces: the rubric and the shape of a review from Design review: the tracer and the serving platform, and the log whose fsync-before-ack every durability claim depends on, from The append-only event log. The agent trace comes from Durable agent runs. Next, Design review: the whole system applies the same rubric to everything at once.
Key terms
Section titled “Key terms”- Lease: a time-limited claim on a task, made of a visibility timeout and a fencing token.
- Fencing token: a number that grows with every delivery of a task; only the current lease’s token may heartbeat or complete.
- Idempotency key: an identifier stable across attempts (
<workflow id>/<activity id>) that lets an effect detect and skip or resume a duplicate. - Saga: a sequence of steps with recorded compensating actions that undo earlier steps on cancel or failure.
- Indeterminate: the status of an agent run whose write was started but whose outcome was not recorded; it waits for a human
reconcile.
Summary
Section titled “Summary”- Tie each claim to the exact evidence that supports it: a contract file, a line of the solution, a postmortem’s numbers.
- In a control plane the review question is always what is persisted before each external effect, and what replay does after a crash at any point.
- At-least-once delivery is the given; idempotency keys and fencing tokens make the effect look exactly once.
- Unknown outcomes are escalated to a human, never guessed.
- State the owner, success condition, and recovery action before declaring the work complete, and record unresolved assumptions so the next review can test them.
Review questions
Section titled “Review questions”- Why does an activity need an idempotency key if the durable server already records its completion?
Answer
The completion is recorded only after the effect. A worker can finish the effect and die before reporting it, or report it with an expired lease; the task is then delivered again and the effect runs a second time. The key, stable across attempts, lets the effect detect and skip or resume the duplicate. - What does the fencing token protect against that the visibility timeout does not?
Answer
The timeout decides when a task is given to someone else; it cannot stop the first worker from coming back. The token grows with every delivery, and only the current lease's token may heartbeat or complete, so a late completion from the earlier lease is refused instead of overwriting the new attempt's result. - Why does the durable agent stop as
indeterminatefor a write but simply re-run a read?Answer
A read has no external effect, so running it again is safe. A write whose `step.started` was recorded but whose `step.completed` was not may or may not have happened; re-running it could double the effect, and skipping it could lose it. Only a human (or a system that can check the outside world) can decide, so the run waits for `reconcile`. - Why is “a cancelled build leaves no partial shards” achieved with a saga and not a transaction?
Answer
The effects are files written by separate processes over minutes; there is no transaction spanning them. A saga records a compensating action (`corpus.cleanup`) before the first step whose outputs it must undo, and runs it on cancel or failure.