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: ContributionContentWhat this contribution carries.
estimated_tokens: usizeSource-estimated token cost. Treated as a hint — the builder re-tokenizes for ground truth before pruning.
importance: f32Importance in [0.0, 1.0]. Higher importance survives pruning.
Out-of-range values are clamped on admission.
redactable: boolIf true, governance may rewrite the content rather than dropping
it. If false, governance can only allow or reject.
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
impl Contribution
Sourcepub fn system(text: impl Into<String>, estimated_tokens: usize) -> Self
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).
Sourcepub fn text(
role: Role,
content: impl Into<String>,
estimated_tokens: usize,
) -> Self
pub fn text( role: Role, content: impl Into<String>, estimated_tokens: usize, ) -> Self
Build a ContributionContent::Text contribution.
Sourcepub fn tool(schema: ToolSchema, estimated_tokens: usize) -> Self
pub fn tool(schema: ToolSchema, estimated_tokens: usize) -> Self
Build a ContributionContent::Tool contribution.
Sourcepub fn with_importance(self, importance: f32) -> Self
pub fn with_importance(self, importance: f32) -> Self
Set the importance, clamped to [0.0, 1.0].
Sourcepub fn with_redactable(self, redactable: bool) -> Self
pub fn with_redactable(self, redactable: bool) -> Self
Mark the contribution as redactable (or not) by governance.
Trait Implementations§
Source§impl Clone for Contribution
impl Clone for Contribution
Source§fn clone(&self) -> Contribution
fn clone(&self) -> Contribution
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Contribution
impl Debug for Contribution
Source§impl<'de> Deserialize<'de> for Contribution
impl<'de> Deserialize<'de> for Contribution
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Contribution
impl PartialEq for Contribution
Source§fn eq(&self, other: &Contribution) -> bool
fn eq(&self, other: &Contribution) -> bool
self and other values to be equal, and is used by ==.