Skip to content

Stream and buffer authority

Cross-cell data needs a lifetime, rights and a terminal outcome that remain stable across provider and transport changes. The nucleus owns those facts for streams and sealed buffers. This page covers their authority records, state transitions, backpressure, transfer and reclamation.

Authority structure

flowchart TB
  subgraph NUC["NUCLEUS"]
    direction TB
    STR[("Stream record<br/>endpoints, credits, terminal state")]
    BUF[("Buffer generation<br/>writer, seal, attachments")]
    HND[("Local-handle lineage<br/>cell and epoch")]
    GATE{{"Rights and generation admission"}}
    STR --> GATE
    BUF --> GATE
    HND --> GATE
  end
  subgraph CELLA["OWNER CELL"]
    direction TB
    PROD["Producer or mutable writer"]
  end
  subgraph CELLB["RECEIVER CELL"]
    direction TB
    CONS["Consumer or sealed reader"]
  end
  PROD -->|"ordered item or explicit attachment"| GATE
  GATE -->|"admitted delivery"| CONS

Stream record and Buffer generation hold kernel authority. Rights and generation admission joins each operation to its local-handle lineage before an owner cell can send data or a receiver cell can consume it.

Stream authority

A stream record identifies one generation, one item type, producer and consumer endpoints, their cell epochs, the current phase, item counters and a bounded credit balance. Each endpoint receives a role-specific local handle: the producer holds write authority and the consumer holds read authority.

Items carry a monotonically increasing sequence and a digest of their encoded bytes. Production spends one credit. Consumer acknowledgement restores one credit. A producer with no available credit waits for consumption, which bounds the number of admitted items in flight. See Credit backpressure for the transport behaviour that carries this kernel decision.

The stream phases are:

Phase Meaning
open Both endpoints may use their admitted rights.
producer_half_closed The producer has finished; admitted pending items remain consumable.
consumer_half_closed The consumer has stopped accepting items.
closed The consumer has drained the stream and observed a clean terminal outcome.
faulted A provider fault or producer-cell loss ended the stream.
cancelled Kernel cancellation ended both endpoint lineages.

The exact same terminal transition is idempotent. A conflicting second close is refused. Every terminal transition revokes the complete stream-handle lineage, clears pending items and restores the accounted credit balance. Item admission therefore ends before terminal evidence can be produced.

Endpoint transfer moves one role to a new admitted cell and epoch. The source handle becomes stale before the receiver handle becomes usable. The stream record retains whether either role was transferred, and terminal evidence binds that history with the final item and credit counters.

Terminal evidence

The consumer monitor admits ordered items and the terminal delivery against its own cell identity, epoch, stream generation, item type, sequence and byte digest. The nucleus releases terminal evidence after the consumer acknowledges the terminal outcome. That evidence binds:

  • stream identity and generation;
  • final phase and reason;
  • produced and consumed item counts;
  • credit limit and restored balance;
  • producer and consumer transfer history.

The kernel writes this terminal evidence to the sequenced return lane without including a provider resource id or either local handle. The supervising data plane drains the envelope, and the control plane stores its admitted observability record. Stream items and stream handles remain inside the running kernel.

Buffer authority

A buffer record names one generation, tenant scope, exact byte length, current writer, admitted readers, live mappings and content identity. The cell's installed containment memory limit provides both the total local allocation budget and the per-buffer ceiling. Allocation is refused before bytes are exposed when either limit would be exceeded.

One generation has at most one mutable writer. Write-right transfer makes the source handle stale before the receiver handle becomes usable. Bytes arrive as ordered chunks: a chunk is admitted at the next exact offset, physically written and digest-checked, and then committed. A changed digest, overlapping offset, missing range or uncommitted chunk prevents sealing. Abort terminates the incomplete generation so partial content cannot be mistaken for a value.

The buffer phases are:

Phase Meaning
writing One writer may append admitted chunks in order.
sealed The complete content digest is fixed and only read sharing is allowed.
aborted An incomplete write has been terminated.
reclaiming No new mapping is admitted while storage is being cleared.
reclaimed Storage has been zeroed and every handle in the generation is stale.

Sealing is irreversible. A sealed generation may be shared with an authorised reader cell, while a writable generation remains private to its writer. The reader's monitor verifies its own cell identity and epoch, the buffer identity and generation, the byte length and the content digest before accepting the bytes. The reference transport copies bounded bytes between process cells; a different transport may avoid the copy only if it preserves the same authority and evidence.

Reclamation is refused while a live mapping remains. Reader death removes its mapping and invalidates its local handle. Once all mappings are gone, storage is zero-filled, the zeroing digest is recorded, the backing bytes are released and the generation becomes terminal. The kernel then retires local handle authority for that generation. Per-cell handle slots advance monotonically, so a later allocation cannot revive the old generation or its handles.

Terminal buffer evidence binds the buffer identity and generation, byte length, sealed content digest, zeroing digest, write-right transfer and number of admitted readers. The bytes and the kernel-local handles stay in the kernel. The evidence enters the sequenced return lane for operational visibility, and the application value remains with its kernel-local caller.

Continue with Handle authority for local lineage and Cell shared-memory channel for a transport backend that preserves the same authority semantics.