Skip to content

Rebuilding node state after restart

A starting xratud process has an empty registry, no sessions and no spools. It has the volume, and it reads the volume in a fixed order, because every position it loads afterwards is checked against the identity it loads first.

This page covers that order: what each step reads, what it produces, and what a failure at that step leaves the node able to do.

The order

flowchart TB
  subgraph VOL["NODE VOLUME, /var/lib/xratu"]
    direction TB
    IDS[("identity/xratud.identity.json")]
    CURF[("cursor/ watch cursor file")]
  end
  CFG(["Node configuration"])
  subgraph PROC["NEW XRATUD PROCESS"]
    direction TB
    BIND{{"Cursor identity binding"}}
    RH{{"Return handler registry"}}
    REG[("Runtime state registry")]
    WCO["Watch cursor owner"]
    PRB["Probe server"]
  end
  CP["Control plane"]
  IDS -->|"1. dataplane_uuid,<br/>cp_identity_revision"| BIND
  BIND -->|"2. binding tokens"| WCO
  RH -->|"3. must be ready"| REG
  CFG -->|"4. defaults"| REG
  CURF -->|"5. position, or a<br/>corruption condition"| WCO
  WCO -->|"mirrors the position"| REG
  REG -->|"6. bootstrap_pending"| PRB
  REG -->|"7. register"| CP
  WCO -->|"7. watch from the position"| CP

The numbers on the edges are the start order. Cursor identity binding is derived from identity/xratud.identity.json before cursor/ watch cursor file is read, so the position is checked against the identity it was written under. Return handler registry is the one gate that stops the start, and the edges marked 7 are the first cycle, where the node reconciles with Control plane.

Step Reads Produces
1 identity/xratud.identity.json The node's dataplane_uuid and cp_identity_revision
2 Step 1, then configuration The two tokens the cursor record is bound to
3 The return handler registry A readiness verdict that must hold
4 Node configuration The registry at its declared defaults
5 cursor/xratud_watch_cursor_*.json The live position, or a corruption condition
6 Steps 4 and 5 Probes reporting bootstrap_pending
7 The lease state file, then the control plane Recovered leases, registration, assignments

The identity binding comes first

The binding tokens are taken from the enrollment identity state, falling back to the configured dataplane_uuid and to the literal cp_identity_revision_unavailable when the identity state supplies no control-plane identity revision.

A position recorded under cp_identity_revision_unavailable is bound to that literal, so once the node does know its real control-plane identity revision, the same file loads as a binding mismatch, the node holds a corruption condition, and the control plane answers the next watch with a resync. The position is restored from the control plane in one cycle, which is how any position the node cannot prove is restored.

A failed return handler registry stops the start

Step 3 is the one step that refuses to continue. When the kernel return handlers are not ready, the process raises before it reaches the registry or the cursor, so a node takes assignments only once it has a return path. Every other step has a defined degraded outcome.

What the first cycle restores

lease recovery       claims held by this worker id are expired, due leases are swept
registration         the node registers and the registry records it
watch                the position is taken to what the control plane holds
sessions             deployment reconciliation hands back live project runtimes
return lanes         a drain per runtime instance resumes from its return cursor

Lease recovery runs once per process, and its result is recorded in the registry under lease_recovery. See Lease dedupe and finalize.

The session table and the return cursors are process state, so the node rediscovers its runtimes through reconciliation and resumes each return lane from the position it then holds. See Runtime handle lifecycle across restarts.

State that comes back from its source

Held by the process Recovered from
Staged status envelopes The control plane's assignment ledger
Spooled telemetry The record's own source
Kernel return positions The kernel's continuity store
Local assignment claims The control plane's lease, which lapses and is dispatched again
Execution dedupe records The control plane, which dispatches the assignment again

An assignment that completed and whose terminal status never reached the control plane is dispatched again, and the dedupe record that would have recognised it went with the process. The work is carried out a second time. Where that work is a build or a publication, the content-addressed artifact makes the repetition a no-op at the registry. See Idempotency and replay-safe reprocessing.