Runtime handle lifecycle¶
A node supervises a project runtime across every assignment that targets it, and it may lose that runtime to another node at any time. It therefore keeps one record per runtime it owns, holding where the kernel is, the ownership it was granted, and the held return-lane channel, and it checks that record before every command. This page covers when the record is created, what it holds, how every command is checked against it, and how it ends.
The per-assignment handles the node uses to count and stop running work are on The runtime orchestrator.
The record's life¶
stateDiagram-v2
[*] --> recorded: accepted handshake with valid ownership
recorded --> recorded: command accepted, endpoint refreshed
recorded --> reconnecting: transport failure
reconnecting --> recorded: re-resolved, re-handshaken, resumed
reconnecting --> ended: terminal refusal or budget spent
recorded --> ended: stale_fence, non-owner, or ownership moved
ended --> [*]
A record exists only after an accepted handshake with valid ownership, and a terminal refusal ends it. Only a record's current ownership lets a command through, so a node that lost the runtime stops at the record rather than at the kernel.
What the record holds¶
The record is keyed by runtime_instance_id and held in the xratud process:
| Field | Holds |
|---|---|
route |
Namespace, service_ref, the kernel control service and port, placement |
ownership |
owner_dp_node_id, lease_id, fence_epoch and the rest of project.runtime_ownership.v1 |
endpoint |
The ready pod, address and port the node last reached |
handshake |
The last accepted handshake: kernel version and profile, image digest, trust evidence, startup |
A record is refused without an owner node, a lease id and a fence_epoch of at
least 1:
When the route names no runtime_instance_id, the node derives one from the
workspace, project, version and service. The return lane's held channel is
keyed by the same runtime instance.
Every command is checked against it¶
Before a command is sent, the ownership the command carries is compared with the record:
| Check | Refusal |
|---|---|
| A record exists for the runtime | runtime_session_not_found |
| The owner node matches | runtime_session_non_owner |
| The lease id matches | runtime_session_stale_lease |
| The fence epoch matches | runtime_session_stale_fence |
A command that passes reuses the record's handshake; a command with no record handshakes first. An accepted command refreshes the record's endpoint.
Reconnecting¶
After a transport failure, the node plans the reconnect from the record, under the same identity and fence:
contract_version kernel.grpc_client.reconnect_plan.v1
sequence re_resolve_service_endpoints
bounded_backoff_retry
rehash_select_ready_endpoint
rehandshake_with_same_identity_and_fence
resume_return_lane_from_last_ack
from_seq the last acknowledged sequence
The return lane is drained in rounds of up to 100 envelopes, with up to 8 reconnect attempts, backing off from 0.1 seconds and doubling to 30 seconds. A round ends in one of four states:
| State | Meaning |
|---|---|
drained |
The lane was read and acknowledged up to what was available |
terminal |
The lane reached its terminal envelope |
refused |
The kernel refused the node; the record ends |
exhausted |
Every attempt failed; the node tries again on a later cycle |
The cursor in the result is the furthest sequence the kernel accepted as
acknowledged, and a cursor the kernel reports ahead of its own max_seq or
past a gap is ignored. See
Readiness, handshake, and endpoint re-resolution
and Recovering the kernel link.
Ending¶
The record ends when the kernel refuses the node with stale_fence,
runtime_session_non_owner or runtime_session_not_found, or when the
control plane moves ownership. The held return-lane channel is closed with it,
so a node holds return-lane connections only to runtimes it owns.
A planned move produces an ownership transfer, project.runtime_ownership_transfer.v1:
{
"contract_version": "project.runtime_ownership_transfer.v1",
"runtime_instance_id": "rt-7f2a",
"previous_owner_dp_node_id": "dp-a",
"new_owner_dp_node_id": "dp-b",
"previous_fence_epoch": 4,
"new_fence_epoch": 5,
"transfer_reason": "owner_unavailable",
"continuity_resume_from_last_acked": true,
"old_owner_rejected_after_fence": true
}
The new owner creates its own record at its first accepted handshake under epoch 5 and resumes the return lane from the last acknowledged sequence. See Ownership handover across a break.
Records live in process memory. A restarted xratud rebuilds a record for each
runtime it owns at its first handshake, and the kernel's continuity store
supplies the position to resume from.
Related¶
- Runtime handle lifecycle across restarts for how a node finds its running kernels again and where each return lane resumes.