causa-kernel 0.1.4

Causa kernel — primitive facts (ContextBlock) and behavior contracts (ports)
Documentation
//! 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.
//! [`GenerationOptions`] describes requested generation settings; hosts own
//! model capability selection and persisted definitions.
//!
//! # Stable serialized forms
//!
//! A host stores context, so the serialized form of [`Context`] and of every
//! type it contains is the stable set: [`ContextBlock`], [`BlockId`],
//! [`BlockMeta`], [`WireMeta`], [`BlockContent`], [`Role`], [`ContentPart`],
//! [`TextPayload`], [`MediaRef`], [`SealedPart`], [`ToolCallPayload`],
//! [`ToolResultPayload`], [`ToolResultStatus`], [`ToolOutput`],
//! [`ToolOutputMeta`], [`Truncation`], [`ArtifactRef`], [`ArtifactKind`],
//! [`ToolChange`] and [`ToolDefinition`].
//! From `0.1.0` a breaking change to one of these forms needs a minor
//! version. Adding an optional field is not a break: a reader ignores a field
//! it does not know, and a field missing from an older record reads as unset.
//!
//! Every other serializable type (model output, request options,
//! identifiers, error kinds) can be written to logs but carries no such
//! promise. A host that stores one owns its migration.

#![deny(unsafe_code)]
#![deny(missing_docs)]

mod context;
mod ports;

// --- context: the external rule interface ------------------------------------
pub use context::block::{
    BlockContent, BlockMeta, ContentPart, ContextBlock, MediaRef, Role, SealedPart, TextPayload,
    ToolCallPayload, WireMeta,
};
pub use context::ids::{BlockId, InvocationId, RoundId, TurnId};
pub use context::material::{
    Context, ContextEdit, ContextFrame, EditError, EditFailure, Replacement, ToolResultError,
    validate_tool_result_append,
};
pub use context::model::{
    ModelBlockError, ModelItem, ModelItemContent, ModelResponse, ModelStopReason, ToolCallDraft,
};
pub use context::tool_data::{
    ArtifactKind, ArtifactRef, ToolCallId, ToolOutput, ToolOutputMeta, ToolResultPayload,
    ToolResultStatus, Truncation,
};
pub use context::tools::{ToolChange, ToolDefinition, current_tools};

// --- ports: behavior seams for external implementors ------------------------
pub use ports::batch::{
    BatchError, ProcessorContext, ProcessorData, ProcessorError, RejectedToolResult, ToolBatch,
    ToolBatchProcessor, ToolCallEntry,
};
pub use ports::control::{CallControl, ControlError};
pub use ports::gateway::{
    CacheDirective, GenerationOptions, ModelGateway, ModelInvokeError, ModelInvokeErrorKind,
    ModelOutput, ModelRef, ModelRequest, ModelStream, ModelUsage, ReasoningPayload, StreamDelta,
    completed_model_stream,
};
pub use ports::prepare::{ContextPreparer, PrepareError, RoundInfo};
pub use ports::source::{DynamicToolSource, SourceError, ToolExecutionError};
pub use ports::tool::{
    ArtifactHint, ArtifactStore, StoreError, Tool, ToolCallContext, ToolDescription, ToolHints,
    ToolSurface,
};
/// The cancellation primitive behind the control planes, re-exported so the
/// port is self-contained for external drivers.
pub use tokio_util::sync::CancellationToken;