Skip to content

The core invariant

Every part of the kernel enforces one invariant, which governs how blocks in different cells, languages and library versions work together:

Live resources stay in owner cells.
Data crosses explicitly.
Execution crosses through kernel-controlled entry.
Rust remains the authority.

This page covers each line, the structure that holds it, and the outcomes it determines.

The invariant in one call

flowchart TB
  subgraph NUC["NUCLEUS CORE, RUST"]
    direction TB
    AUTH{{"Grant and handle authority"}}
  end
  subgraph CALLER["CALLER CELL"]
    direction TB
    CMON["Caller monitor"]
    HND[("Local handle<br/>slot, generation, rights")]
  end
  subgraph OWNER["OWNER CELL"]
    direction TB
    OMON["Owner monitor"]
    PROV["Runtime provider"]
    RES[("Live resource<br/>model, connection, iterator")]
  end
  HND -->|"names the resource"| CMON
  CMON -->|"1. typed call frame"| AUTH
  AUTH -->|"2. admitted call"| OMON
  OMON -->|"3. dispatch"| PROV
  PROV -->|"uses"| RES
  OMON -->|"4. typed outcome"| CMON

Live resource exists only in OWNER CELL. The caller holds Local handle, which names the resource and carries the caller's rights to it. Every call passes Grant and handle authority in the nucleus core before Owner monitor dispatches it, and the outcome returns as a typed value.

Live resources stay in owner cells

A resource is a live object: a loaded model, a database connection, an iterator, a native handle, a GPU allocation or a stream endpoint. It is valid only in the cell that created it, and the cell that created it is its owner.

A caller in another cell receives a local handle. The handle is an index into the caller's own handle table, with a generation, a set of rights, a lease and the owner's epoch. It carries authority only inside that table:

  • a handle always names an owner cell and an owner epoch;
  • cloning or transferring a handle never adds rights;
  • a moved handle is invalid at its source;
  • a borrowed handle is confined to its task or call scope;
  • once the owner's epoch ends, every operation on the resource is refused.

Data crosses explicitly

Between cells, data takes one of five typed forms: a value, a stream, a buffer, an artifact or a handle. A value is encoded against the interface's declared type. A stream is a sequence with an owner and a lifecycle. A buffer is a typed extent with one writer, sealed before it is shared. An artifact is content addressed by digest. A handle is a reference to a resource that stays where it is.

Pickle, CPython objects, proxy graphs and library-native objects have no encoding in the kernel ABI. A library's own types reach another cell through a sealed adapter that converts them to the interface's declared types. See Sealed adapters.

Execution crosses through kernel-controlled entry

Code in one cell reaches code in another cell only through a typed kernel capability interface call, capability.invoke, addressed by interface and export ordinal. The call is admitted against a grant the nucleus installed from sealed policy and trust inputs. A monitor may spend the rights and credit a grant delegates to it, and it can never widen them or mint new ones.

Rust remains the authority

Every component that decides authority is Rust: the nucleus core, the nucleus host and the cell monitors. CPython, CUDA, native extensions, package loaders and block adapters run only in untrusted provider processes. The nucleus core holds no guest-native type in its state, and a provider's report about its own execution is advisory: the monitor's dispatch state and its accepted-completion receipts decide the outcome.

Outcomes the invariant predicts

Situation Outcome
The owner cell restarts The owner epoch advances and every handle to its resources is stale
A block returns a value that does not match its declared type The call fails with a value_encoding_failure guest fault
A provider reports success the monitor did not accept The monitor's receipt decides, and the outcome is classified from it