The runtime orchestrator¶
A node that starts work in a kernel needs to know what it has started, stop it when the assignment ends, and slow its intake before it takes on more than it can run. The runtime orchestrator is the node's record of that work. It holds one runtime handle per active assignment, bounded by the node's worker slots, updates each handle from the kernel's lifecycle evidence, and computes the backpressure signal the node reports every cycle. This page covers the handle, its lifecycle, the backpressure signal, drain, and the metrics.
What the orchestrator holds¶
flowchart TB
subgraph XD["XRATUD PROCESS MEMORY"]
direction TB
subgraph ORC["RUNTIME ORCHESTRATOR, at most max_worker_slots handles"]
direction LR
H1[("Handle<br/>assignment A")]
H2[("Handle<br/>assignment B")]
end
BP{{"Backpressure signal<br/>xratud.kernel_ipc_backpressure.v1"}}
ORC --> BP
end
RUN["Run route<br/>start at dispatch"]
FIN["Finalize<br/>stop"]
K["Kernel lifecycle evidence"]
HB["Heartbeat<br/>ipc_backpressure"]
RUN -->|"start_runtime"| ORC
FIN -->|"stop_runtime"| ORC
K -->|"lifecycle_state, health_status"| ORC
BP --> HB
Handles live in the xratud process and last as long as it does. A kernel's
own state is kept by the kernel; the handle is the node's view of it, used to
stop the runtime at finalize and to bound how many run at once. See
Lease acquisition, dedupe, and finalize.
The runtime handle¶
A start requires assignment_id, run_id and node_id. A second start for
the same assignment returns the existing handle, and a start beyond
max_worker_slots active handles is refused:
A new handle holds:
| Field | Holds |
|---|---|
runtime_id |
A new random identifier |
assignment_id, run_id, node_id, attempt, workspace_uuid |
From the assignment |
trace_id, session_id |
From the assignment, or run_id when absent |
interface_id, export_ordinal, entrypoint, engine, io_profile |
What the runtime invokes |
policy_digest |
The policy snapshot digest |
status, lifecycle_state, health_status |
running, accepted, warming at start |
started_at_epoch |
When it was started |
Kernel lifecycle evidence¶
Each lifecycle record the kernel returns is validated as kernel lifecycle
evidence and applied to the handle named by its correlation.assignment_id:
lifecycle_stateandhealth_statusare copied onto the handle.statusbecomesrunningwhilelifecycle_stateisaccepted,startedorprogress, andterminalfor any other state.- The record is appended to the handle's history, which keeps the last 128.
A record for an assignment with no active handle is counted as rejected with
reason runtime_not_active, and a record that fails validation is refused.
Both show in the metrics.
The backpressure signal¶
Every cycle, the orchestrator compares its active handles with
max_worker_slots and the local queue with its high watermark:
| Condition | reason |
signal |
|---|---|---|
| Every slot holds a handle, and work is queued | runtime_capacity |
drain |
| Every slot holds a handle, and the queue is empty | runtime_capacity |
throttle |
| The queue is at its high watermark or flagged | queue_pressure |
throttle |
| Within 2 seconds after either condition cleared | cooldown |
throttle |
| Otherwise | open |
open |
The signal is reported as xratud.kernel_ipc_backpressure.v1 under
ipc_backpressure in the heartbeat's metadata, with the active count, the
maximum, both pressure ratios, the queue depth and watermark, and
cooldown_until_epoch. The 2-second cooldown keeps a node that dips just below
its limits from reopening and closing on alternate cycles.
Drain¶
On shutdown the orchestrator stops every active handle, under the shutdown's reason, and reports:
{"contract_version": "xratud.runtime_drain.v1", "reason": "<shutdown reason>", "stopped": 3, "active_count": 0}
The drain appears in the cycle summary as runtime_drain. See
Shutdown and drain.
Metrics¶
The cycle summary carries the orchestrator's counters as runtime_metrics:
active_count, max_active
started_total, stopped_total, failed_total
lifecycle_evidence_applied_total, lifecycle_evidence_rejected_total
last_backpressure_reason, overload_cooldown_seconds, overload_until_epoch
failed_total counts starts refused for a missing field or full capacity. A
rising lifecycle_evidence_rejected_total means kernel records are arriving
for assignments the node has already finalized, or in a shape that fails
validation.