Skip to main content

ContextProvenance

Struct ContextProvenance 

Source
pub struct ContextProvenance {
    pub source_uri: Option<String>,
    pub principal: Option<String>,
    pub scope: Option<String>,
    pub retention_tier: Option<String>,
    pub recorded_at_millis: Option<i64>,
    pub effective_at_millis: Option<i64>,
    pub confidence: Option<f64>,
    pub version_key: Option<String>,
    pub source_frame_id: Option<Value>,
    pub projection_state: Option<ContextProjectionState>,
    pub reason: Option<String>,
}
Expand description

Shared provenance keys for context projected by memory, resource, graph, or tool-result producers.

rig-compose continues to store provenance on ContextItem as JSON so downstream crates can attach crate-specific fields without depending on each other. This helper gives those crates a common vocabulary for the fields that matter to replay, evaluation, and omission explanations.

use rig_compose::{ContextItem, ContextProvenance, ContextSourceKind};

let provenance = ContextProvenance::new()
    .with_source_uri("memory://incident/42")
    .with_principal("alice")
    .with_scope("workspace")
    .with_confidence(0.92);

let item = ContextItem::new(ContextSourceKind::Memory, "frame-42", "prior incident")
    .with_context_provenance(provenance);

assert_eq!(
    item.context_provenance().unwrap().source_uri.as_deref(),
    Some("memory://incident/42")
);

Fields§

§source_uri: Option<String>

URI or locator for the original source record.

§principal: Option<String>

Principal, actor, tenant, or subject associated with the source record.

§scope: Option<String>

Caller-defined scope such as tenant, workspace, profile, or project.

§retention_tier: Option<String>

Retention or archive tier associated with the source record.

§recorded_at_millis: Option<i64>

Milliseconds since the Unix epoch when the source record was recorded.

§effective_at_millis: Option<i64>

Milliseconds since the Unix epoch when the source record became effective for supersession or freshness comparisons.

§confidence: Option<f64>

Source-provided confidence score, when it is distinct from ContextItem::score.

§version_key: Option<String>

Stable key used to compare competing versions of the same fact.

§source_frame_id: Option<Value>

Source frame/document id used by memory stores and eval fixtures.

Stored as JSON so existing producers can keep numeric frame ids while others use string document keys.

§projection_state: Option<ContextProjectionState>

Lifecycle state assigned before the packer makes final budget decisions.

§reason: Option<String>

Machine-readable reason for the projection state.

Implementations§

Source§

impl ContextProvenance

Source

pub fn new() -> Self

Create empty provenance ready for builder-style population.

Source

pub fn with_source_uri(self, source_uri: impl Into<String>) -> Self

Source

pub fn with_principal(self, principal: impl Into<String>) -> Self

Source

pub fn with_scope(self, scope: impl Into<String>) -> Self

Source

pub fn with_retention_tier(self, retention_tier: impl Into<String>) -> Self

Source

pub fn with_recorded_at_millis(self, recorded_at_millis: i64) -> Self

Source

pub fn with_effective_at_millis(self, effective_at_millis: i64) -> Self

Source

pub fn with_confidence(self, confidence: f64) -> Self

Source

pub fn with_version_key(self, version_key: impl Into<String>) -> Self

Source

pub fn with_source_frame_id(self, source_frame_id: impl Into<String>) -> Self

Source

pub fn with_source_frame_id_value(self, source_frame_id: Value) -> Self

Set Self::source_frame_id from an existing JSON value.

Source

pub fn with_projection_state( self, projection_state: ContextProjectionState, ) -> Self

Source

pub fn with_reason(self, reason: impl Into<String>) -> Self

Trait Implementations§

Source§

impl Clone for ContextProvenance

Source§

fn clone(&self) -> ContextProvenance

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 ContextProvenance

Source§

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

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

impl Default for ContextProvenance

Source§

fn default() -> ContextProvenance

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

impl<'de> Deserialize<'de> for ContextProvenance

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 ContextProvenance

Source§

fn eq(&self, other: &ContextProvenance) -> 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 ContextProvenance

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 ContextProvenance

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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