Skip to content

Kernel lifecycle bridge

The node decides when a run's runtime can be stopped and how many runtimes it can hold, and only the kernel knows when a run has actually started, finished or failed. The kernel lifecycle bridge carries that knowledge across. For each kernel event a run produces, it validates the event, forwards it as an event record, and applies the kernel's lifecycle evidence to the run's runtime handle. This page covers the event types it reads, the lifecycle evidence contract, how a handle's state follows it, and the counts and logs it reports.

From kernel events to handle state

flowchart TB
  subgraph KE["KERNEL EVENTS FOR ONE RUN"]
    direction LR
    RE["kernel.runtime_evidence"]
    SL["kernel.stream.lifecycle"]
    PT["policy.trust.pre_invoke,<br/>policy.trust.post_invoke"]
    LE["lifecycle_evidence<br/>kernel.lifecycle_evidence.v1"]
  end
  subgraph NODE["NODE"]
    direction TB
    VAL{{"Validate each against<br/>its contract"}}
    H[("Runtime handle<br/>lifecycle_state, health_status")]
    EV["Event records"]
    VAL --> EV
    VAL --> H
  end
  CP["Control plane<br/>events channel"]
  RE --> VAL
  SL --> VAL
  PT --> VAL
  LE --> VAL
  EV --> CP

Each kernel event is validated before it is forwarded, so a malformed event is logged on the node and kept off the control plane's event channel. Lifecycle evidence is the one kind that also changes node state: it moves the run's runtime handle, and the node counts handles against its capacity and stops them at finalize. See The runtime orchestrator.

The lifecycle evidence

kernel.lifecycle_evidence.v1, carried in an event's payload as lifecycle_evidence or as the payload itself:

Field Values
lifecycle_state accepted, started, progress, completed, failed, cancelled, timeout, drained
health_status warming, healthy, degraded, draining, drained
reason, emitted_at Present
correlation workspace_uuid, assignment_id, run_id, node_id, attempt (0 or more), trace_id, session_id
source event_type, and event_seq of at least 1
runtime resolver_mode, runtime_behavior, resolution_stage, each one of the resolver runtime's values or unknown

The handle is running while lifecycle_state is accepted, started or progress, and terminal for the other five. The runtime block reports how the run's dependencies were resolved; see The resolver runtime.

What is emitted

For each event the bridge reads:

Kernel event When valid When invalid
kernel.runtime_evidence Forwarded as an event record Log: kernel runtime evidence rejected by dataplane contract validation
kernel.stream.lifecycle Forwarded as an event record Log: kernel stream lifecycle evidence rejected by dataplane contract validation
policy.trust.pre_invoke Forwarded as an event record Log: kernel pre-invoke policy trust evidence rejected by dataplane contract validation
policy.trust.post_invoke Forwarded as an event record Log: kernel post-invoke policy trust evidence rejected by dataplane contract validation
Lifecycle evidence Applied to the handle, and a kernel.lifecycle.evidence event emitted Log: kernel lifecycle evidence rejected by runtime manager

The kernel.lifecycle.evidence event records the applied state:

{
  "contract_version": "kernel.lifecycle_evidence.v1",
  "lifecycle_state": "completed",
  "health_status": "healthy",
  "reason": "run_completed",
  "source_event_type": "kernel.stream.lifecycle",
  "source_event_seq": 42,
  "runtime_id": "5d0c9e1f..."
}

Lifecycle evidence for an assignment whose handle the node has already released is counted as rejected without a log. The other event types are described on Kernel evidence projection.

The counts

A run reports what the bridge did with its events as lifecycle_evidence in its progress report and in its completion log:

consumed                             lifecycle evidence applied to the handle
rejected                             lifecycle evidence refused or for a released handle
projected_runtime_evidence           kernel.runtime_evidence forwarded
projected_stream_lifecycle           kernel.stream.lifecycle forwarded
projected_policy_trust_pre_invoke    policy.trust.pre_invoke forwarded
projected_policy_trust_post_invoke   policy.trust.post_invoke forwarded
projection_rejected                  events refused by their contract

A run with projection_rejected above 0 has kernel events that stayed on the node; the node's logs name each one and the validation error. A rejected count with no matching log means the kernel reported lifecycle for a run the node had already finalized.