Skip to content

Runtime handle lifecycle across restarts

A project runtime keeps running when the xratud process that started it ends, and the node's handle on it ends with the process. The handle is a process-local record of a session: the route to the kernel, the ownership it was granted and the handshake it completed. A restarted node has none of them, and it reaches the same running kernels again through reconciliation.

This page covers what is lost with the process, how the node finds its runtimes again, and where each return lane resumes from.

The handle's contents and the checks every command passes are on Runtime handle lifecycle.

What the process holds

flowchart TB
  subgraph PROC["XRATUD PROCESS"]
    direction TB
    SESS[("Session table<br/>keyed by runtime_instance_id")]
    CURS[("Return cursors<br/>last acked sequence per runtime")]
    LANE["Return lane worker<br/>one thread per session"]
  end
  subgraph POD["PROJECT RUNTIME POD"]
    direction TB
    KERN["Project kernel"]
    STORE[("Continuity store")]
  end
  SESS -->|"route, ownership, endpoint"| LANE
  CURS -->|"resume position"| LANE
  LANE <-->|"held stream"| KERN
  KERN --> STORE

Session table and Return cursors are both process state, and Return lane worker is a thread per session. Project kernel and its Continuity store are in a separate pod with a separate lifecycle, so a node restart leaves them running and holding evidence.

What a restart leaves

Held by the process After a restart
The session table Empty
The return cursor per runtime instance Empty, since the file sits in the process working area
The return lane threads Gone, and the kernel sees the stream close
The ownership grant and fence epoch Re-supplied by the control plane with the assignment
The kernel and its evidence Running, with every envelope the node had not acknowledged

Finding the runtimes again

Deployment reconciliation hands it the runtimes it is responsible for, with the ownership and the route from the control plane, and each one is recorded as a session again. A session requires a complete ownership grant: an owner node identifier, a lease identifier and a fence epoch of at least one, so a session cannot be recorded from a partial answer.

For each recorded session the node re-resolves the kernel endpoint from the Kubernetes Service and EndpointSlice, re-handshakes, and starts a return lane worker. See Readiness handshake and endpoint re-resolution and Deployment reconciliation.

Where the return lane resumes

The node sends the position it holds as the lane's opening sequence. After a restart it holds nothing, so it opens at zero and the kernel replays from the start of what its continuity store still holds.

That replay is absorbed at the receiving end. Each envelope is spooled under an outbox identifier built from the runtime instance, the sequence and the digest, and the control plane's batch report counts accepted and duplicate reports separately, so a re-delivered envelope is recognised at the far end. The node treats accepted and duplicate alike as delivered.

Reconnect Opening sequence
Within one process, after a dropped stream The last acknowledged sequence
After a process restart Zero, replaying what the kernel still holds
After ownership moved to another node The new owner's position, from its own cursor

The position still only advances on the kernel's reported maximum, so a replay from zero advances through the same checks as any other drain. See Cumulative acks.

Ownership decides who may resume at all

A reconnect is refused where the node is no longer the owner. The session checks name the condition: a missing session, a non-owner caller, a stale lease or a superseded fence epoch. A refusal stops the reconnect, so a fenced session is never re-established and one runtime keeps one owner.

When ownership is transferred the plan raises the fence epoch by one, refuses the previous owner afterwards, and the new owner resumes from its last acknowledged position. See Ownership handover across a break.