Skip to main content

BriefBuilder

Struct BriefBuilder 

Source
pub struct BriefBuilder { /* private fields */ }
Expand description

Assembles a Brief from registered Sources.

See the module-level docs for usage. The default tokenizer is CharApproxTokenizer (≈ 4 chars per token); the default governance is NoOpGovernance; the default strategy is PruneStrategy::default (== PruneStrategy::ImportanceFirst).

Implementations§

Source§

impl BriefBuilder

Source

pub fn new() -> Self

Construct a fresh builder with no sources, the default CharApproxTokenizer, NoOpGovernance, the default TokenBudget (8000 total / 1024 reserved), and PruneStrategy::ImportanceFirst.

Source

pub fn source(self, source: Arc<dyn Source>) -> Self

Register a Source. Duplicate SourceIds are rejected at BriefBuilder::build time, not here.

Source

pub fn governance(self, governance: Arc<dyn Governance>) -> Self

Swap the Governance hook. Defaults to NoOpGovernance.

Source

pub fn tokenizer(self, tokenizer: Arc<dyn Tokenizer>) -> Self

Swap the Tokenizer. Defaults to CharApproxTokenizer.

Source

pub fn budget(self, budget: TokenBudget) -> Self

Set the TokenBudget used for pruning.

Source

pub fn strategy(self, strategy: PruneStrategy) -> Self

Source

pub fn sources(&self) -> &[Arc<dyn Source>]

Borrowed view of the configured sources. Useful for tests.

Source

pub fn current_budget(&self) -> &TokenBudget

The configured budget.

Source

pub async fn build(&self, ctx: &BriefContext) -> Result<Brief>

Assemble the Brief for ctx.

Steps:

  1. Reject duplicate SourceIds.
  2. Fan out to every source in parallel via join_all. Per-source errors surface in step 4 — fan-out itself never fails.
  3. Tokenize each surviving Contribution using the active Tokenizer (source-provided estimated_tokens is treated as a hint only).
  4. Apply budget pruning via apply_budget.
  5. Assemble draft Brief (system concatenation, message order preserved within priority, tools collected).
  6. Run Governance::review. Allow / Redacted advance; Rejected surfaces as BriefError::Rejected.
  7. Build the BriefReceipt with per-source stats, drops, and timings.

On any fatal source error (anything other than SourceError::Skipped), build returns BriefError::Source. Skipped sources are silently treated as zero contributions.

Trait Implementations§

Source§

impl Debug for BriefBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BriefBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.