Expand description
causa-kernel — ContextBlock conversation kernel. No dependency on a host application, a UI shell, or another agent framework.
The kernel holds ordered material and atomic identity-preserving edits, plus third-party model, preparation, tool and cancellation contracts. It performs no I/O, execution policy or conversation management. Reference execution lives in causa-runtime; concrete transports live in edge crates.
Structs§
- Artifact
Hint - Provenance a caller attaches to bytes handed to
ArtifactStore::persist, so the store can label what it receives. - Artifact
Ref - Pointer to a tool output persisted out-of-band (e.g. a spilled oversized observation), kept on the result instead of the full content.
- BlockId
- UUID identity of one fact block, independent of its current position.
- Block
Meta - Envelope provenance. Fields are serde-additive so older records without them still deserialize.
- Call
Control - Cooperative control for a logical model invocation, preparation or tool work.
- Cancellation
Token - The cancellation primitive behind the control planes, re-exported so the port is self-contained for external drivers. A token which can be used to signal a cancellation request to one or more tasks.
- Context
- Ordered material with atomic, identity-preserving edits.
- Context
Block - A typed fact. Three axes: identity, content, envelope provenance.
- Context
Edit - An exclusive, uncommitted edit builder for a context.
- Context
Frame - The ordered material selected for one model request.
- Edit
Failure - An edit failure together with every submitted block of edit material.
- Generation
Options - Sampling knobs a caller may pin for the invocation.
Nonemeans “unspecified”: renderers omit the knob and the provider default applies. - Invocation
Id - Identity of one model invocation: which turn, and which round inside it.
- Media
Ref - A media fact: a cheap, durable reference. Bytes never enter facts — they appear only in resolved render payloads (provider side).
- Model
Invoke Error - A model-invocation failure: a
ModelInvokeErrorKindplus human-readable detail (provider text included where available). - Model
Output - The gateway result envelope. Pure response conversion consumes neither this value nor its usage and reasoning; execution consumers retain them.
- Model
Ref - Opaque model identifier, rendered verbatim into the provider request’s
modelfield. The kernel never parses it; resolution is the gateway’s job. - Model
Request - Everything one logical invocation needs. All fields stay unchanged across internal retries; the gateway owns any attempt numbering and retry policy.
- Model
Response - The model door’s fact shape: what the model said (text) and asked (tool calls). Named for the participant, not for any wire role.
- Model
Usage - Provider-reported token accounting for one model response.
- Prepare
Error - Failure to prepare a request’s material.
- Processor
Context - Context made available to tool batch processors.
- Reasoning
Payload - Structured reasoning content: the model’s thinking text plus the optional provider signature some APIs attach so it can be replayed on later turns. Recorded as-is by callers; the kernel does not interpret or persist it.
- Replacement
- One replacement expressed in coordinates of the original block sequence.
- RoundId
- Ordinal of a model round within a turn (0-based).
- Round
Info - Configuration visible while preparing this invocation’s material.
- Text
Payload - A single string of text. Serializes transparently as the inner string.
- Tool
Batch - One tool batch with a completed prefix and pending suffix.
- Tool
Call Context - Identity of one tool dispatch, handed to
Tool::execute. - Tool
Call Draft - A tool call as the model proposed it, before the caller assigns its declaration
BlockId. Exactly what the gateway parsed off the wire. - Tool
Call Entry - A declaration plus its optional completed result.
- Tool
Call Id - Borrowed content key for comparing tool calls within a caller-selected
scope. Instance pairing always uses the declaration’s
BlockId. - Tool
Call Payload - A model-issued tool call. Its containing block ID is the declaration identity; provider-issued identifiers ride on BlockMeta::provider_call_id.
- Tool
Definition - The model-facing description of one callable tool; renderers map it onto the protocol’s tool entries (name, description, parameter schema).
- Tool
Output - What a tool returned, as recorded by the tool door.
- Tool
Output Meta - Optional observability sidecar on a tool output; never part of pairing.
- Tool
Result Payload - The result fact for one tool call: its declaration identity, terminal status, output, media, and ordered notes. Pairing is kernel-enforced.
- Tool
Surface - The tool definitions offered to the model for one invocation; renderers
turn this into the protocol’s
toolsarray. - TurnId
- Identity of an execution, independent of its context material.
Enums§
- Artifact
Kind - What an artifact holds.
- Batch
Error - Invalid batch construction, completion, or partition state.
- Block
Content - The content shape of a block. Three shapes: one message’s ordered parts (any role), a tool call, a tool result.
- Cache
Directive - Prompt-cache instruction carried on a
ModelRequest. The Anthropic translation face renders explicitcache_controlbreakpoints at the stable-prefix anchors; OpenAI-family providers cache server-side and accept the directive as a documented no-op. - Content
Part - One content atom inside a
BlockContent::Partsblock: ordered, identity-free, sharing the block’s envelope. New modalities arrive as new variants (additive); media bytes stay out of facts forever. - Control
Error - Why a control check failed.
- Edit
Error - Why an atomic context edit could not be committed.
- Model
Block Error - Why a model response cannot be converted into blocks.
- Model
Invoke Error Kind - Classification of a logical model invocation failure.
- Model
Stop Reason - Why the model stopped producing output for this round, as reported by the gateway. The kernel validates only the EndTurn/ToolUse structural pairing; interpreting terminal reasons is driver policy.
- Processor
Error - Failure to finish a processing phase. Per-call rejection is a result,
and should be recorded on the batch while returning
Ok(()). - Source
Error - Listing failure — the catalog as a whole is unusable right now.
- Store
Error - Error surface of the
ArtifactStoreport. - Stream
Delta - One incremental observation from a streaming provider.
- Tool
Execution Error - Single-call failure inside a source. The executor’s tool adapter
(
ToolBridgeincausa_runtime) turns every variant into a structured tool result the model reads; the status mapping lives there, not here. - Tool
Result Error - Why tool results cannot be appended to the supplied material scope.
- Tool
Result Status - Terminal status of one tool invocation, recorded verbatim as a fact; mapping from execution errors is the driver’s job, not the kernel’s.
- Truncation
- Whether tool output content was shortened to fit the token limit.
Traits§
- Artifact
Store - Persistence port for tool artifacts — where oversized tool outputs are
spilled and read back. Callers persist raw bytes plus an
ArtifactHintand receive anArtifactRefto embed in the result; concrete stores are host concerns. - Context
Preparer - Prepares an independent request frame with exclusive access to context.
- Dynamic
Tool Source - One external tool catalog. Implementors own their connection, their
naming (see the
mcp_{server_id}_{tool}namespace convention incausa-extension), and their change notifications. - Model
Gateway - The model-invocation port: concrete gateways (provider adapters) live
outside the kernel and translate
ModelRequests onto their transport, honoring the invocation’s control plane. - Tool
- The tool port: one callable tool the model can invoke. Implementations live outside the kernel; the driver’s executor dispatches them. A tool returns only its recorded result. Handling unknown outcomes and retaining output belong to the execution consumer, not tool declarations.
- Tool
Batch Processor - A pre- or post-processing phase over one exclusively borrowed tool batch.
Functions§
- completed_
model_ stream - Wrap an already-complete output as a single-
Donestream — the degenerate form the defaultstreamimplementation and tests use. - validate_
tool_ result_ append - Validates this result append without mutating or consuming its inputs.
Type Aliases§
- Model
Stream - Bounded stream of provider deltas. Cancellation is observable through
the same
CallControltheinvokepath uses — drivers racenext()against the cancellation token, never poll.