cel-brief 0.0.0

Per-turn LLM briefing layer. Assemble memory, perception, history, tools, and user message into a single budgeted, governed, receipted bundle from pluggable streams.
Documentation
//! cel-brief — Per-turn LLM briefing layer.
//!
//! See [`cellar-cel-brief.md`] for the full implementation plan. This crate is
//! the per-turn briefing layer that sits between an agent's state and the LLM:
//! every turn, sources contribute [`source::Contribution`]s to a budgeted,
//! governed [`types::Brief`].
//!
//! **Status (Phases 1 + 2 + 3 + 4):** all core types, traits, sources,
//! governance, and builder are shipped.
//!
//! **Phase 1** — core types ([`types::Brief`], [`types::BriefMessage`],
//! [`types::Role`], [`types::BriefContext`], [`types::TokenBudget`],
//! [`types::Priority`], [`types::ToolSchema`], [`types::ImageData`],
//! [`types::SourceId`]) and the [`source::Source`] trait + supporting
//! types ([`source::Contribution`], [`source::ContributionContent`],
//! [`source::SourceError`]).
//!
//! **Phase 2** — [`builder::BriefBuilder`], [`tokenizer::Tokenizer`]
//! (default [`tokenizer::CharApproxTokenizer`]; opt-in
//! [`tokenizer::TiktokenCl100k`] behind the `tiktoken` feature),
//! [`budget::PruneStrategy`] + budget enforcement, full
//! [`receipt::BriefReceipt`].
//!
//! **Phase 3** — built-in [`sources::SystemPromptSource`],
//! [`sources::UserMessageSource`], [`sources::ToolCatalogSource`],
//! [`sources::HistorySource`] + [`sources::HistoryStore`] under default
//! features; [`sources::MemorySource`] behind the `memory` feature;
//! [`sources::PerceptionSource`] + [`sources::PerceptionSnapshot`] behind
//! the `perception` feature.
//!
//! **Phase 4** — [`governance::Governance`] trait with
//! [`governance::NoOpGovernance`] default, [`governance::GovernanceVerdict`]
//! enum, and the [`receipt::RedactionRecord`] surface that
//! [`governance::GovernanceVerdict::Redacted`] returns.
//!
//! ## Quick start
//!
//! ```no_run
//! # use std::sync::Arc;
//! # use cel_brief::{BriefBuilder, BriefContext, TokenBudget};
//! # async fn example() -> Result<(), cel_brief::BriefError> {
//! let builder = BriefBuilder::new()
//!     .budget(TokenBudget::new(8000, 1024));
//!     // .source(Arc::new(MySource)) ...
//!
//! let ctx = BriefContext::new(TokenBudget::default())
//!     .with_user_message("hi");
//! let brief = builder.build(&ctx).await?;
//! println!("brief: {} messages, {} tokens",
//!     brief.messages.len(), brief.receipt.total_tokens);
//! # Ok(())
//! # }
//! ```
//!
//! [`cellar-cel-brief.md`]: file:///Users/dimitriospagkratis/.claude/plans/cellar-cel-brief.md

#![deny(missing_docs)]
#![warn(rust_2018_idioms)]

pub mod budget;
pub mod builder;
pub mod error;
pub mod governance;
pub mod receipt;
pub mod source;
pub mod sources;
pub mod tokenizer;
pub mod types;

pub use budget::{PruneStrategy, WeightedContribution};
pub use builder::BriefBuilder;
pub use error::{BriefError, Result};
pub use governance::{Governance, GovernanceError, GovernanceVerdict, NoOpGovernance};
pub use receipt::{
    BriefReceipt, DropReason, DroppedContribution, RedactionRecord, SourceStats, Timings,
};
pub use source::{Contribution, ContributionContent, Source, SourceError};
pub use sources::{
    HistoryEntry, HistorySource, HistoryStore, SystemPromptSource, ToolCatalogSource,
    UserMessageSource,
};
#[cfg(feature = "memory")]
pub use sources::{MemoryQueryStrategy, MemorySource};
#[cfg(feature = "perception")]
pub use sources::{PerceptionError, PerceptionMode, PerceptionSnapshot, PerceptionSource};
pub use tokenizer::{CharApproxTokenizer, Tokenizer};
pub use types::{
    Brief, BriefContext, BriefMessage, ImageData, Priority, Role, SourceId, TokenBudget, ToolSchema,
};

#[cfg(feature = "tiktoken")]
pub use tokenizer::TiktokenCl100k;