Skip to main content

Contribution

Struct Contribution 

Source
pub struct Contribution {
    pub content: ContributionContent,
    pub estimated_tokens: usize,
    pub importance: f32,
    pub redactable: bool,
    pub tags: Vec<String>,
}
Expand description

One item produced by Source::contribute.

The builder treats estimated_tokens as a hint (always re-tokenized ground-truth on the builder side), but uses importance and the source’s Priority to drive budget pruning. redactable lets governance (Phase 4) selectively rewrite content rather than dropping it.

Fields§

§content: ContributionContent

What this contribution carries.

§estimated_tokens: usize

Source-estimated token cost. Treated as a hint — the builder re-tokenizes for ground truth before pruning.

§importance: f32

Importance in [0.0, 1.0]. Higher importance survives pruning. Out-of-range values are clamped on admission.

§redactable: bool

If true, governance may rewrite the content rather than dropping it. If false, governance can only allow or reject.

§tags: Vec<String>

Free-form tags (e.g. "summary", "recent") used by governance and debugging.

Originally sketched as Vec<&'static str>, widened to Vec<String> so Contribution can satisfy serde::Deserialize — required so all brief types round-trip through serde. Static callers pay one allocation per tag; receipt-side consumers gain round-trippability.

Implementations§

Source§

impl Contribution

Source

pub fn system(text: impl Into<String>, estimated_tokens: usize) -> Self

Build a ContributionContent::System contribution with sensible defaults (Critical-importance text, not redactable, no tags).

Source

pub fn text( role: Role, content: impl Into<String>, estimated_tokens: usize, ) -> Self

Build a ContributionContent::Text contribution.

Source

pub fn tool(schema: ToolSchema, estimated_tokens: usize) -> Self

Build a ContributionContent::Tool contribution.

Source

pub fn with_importance(self, importance: f32) -> Self

Set the importance, clamped to [0.0, 1.0].

Source

pub fn with_redactable(self, redactable: bool) -> Self

Mark the contribution as redactable (or not) by governance.

Source

pub fn with_tag(self, tag: impl Into<String>) -> Self

Append a free-form tag.

Trait Implementations§

Source§

impl Clone for Contribution

Source§

fn clone(&self) -> Contribution

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Contribution

Source§

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

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

impl<'de> Deserialize<'de> for Contribution

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Contribution

Source§

fn eq(&self, other: &Contribution) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Contribution

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Contribution

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.