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
impl ContextProvenance
Sourcepub fn with_source_uri(self, source_uri: impl Into<String>) -> Self
pub fn with_source_uri(self, source_uri: impl Into<String>) -> Self
Set Self::source_uri.
Sourcepub fn with_principal(self, principal: impl Into<String>) -> Self
pub fn with_principal(self, principal: impl Into<String>) -> Self
Set Self::principal.
Sourcepub fn with_scope(self, scope: impl Into<String>) -> Self
pub fn with_scope(self, scope: impl Into<String>) -> Self
Set Self::scope.
Sourcepub fn with_retention_tier(self, retention_tier: impl Into<String>) -> Self
pub fn with_retention_tier(self, retention_tier: impl Into<String>) -> Self
Set Self::retention_tier.
Sourcepub fn with_recorded_at_millis(self, recorded_at_millis: i64) -> Self
pub fn with_recorded_at_millis(self, recorded_at_millis: i64) -> Self
Sourcepub fn with_effective_at_millis(self, effective_at_millis: i64) -> Self
pub fn with_effective_at_millis(self, effective_at_millis: i64) -> Self
Sourcepub fn with_confidence(self, confidence: f64) -> Self
pub fn with_confidence(self, confidence: f64) -> Self
Set Self::confidence.
Sourcepub fn with_version_key(self, version_key: impl Into<String>) -> Self
pub fn with_version_key(self, version_key: impl Into<String>) -> Self
Set Self::version_key.
Sourcepub fn with_source_frame_id(self, source_frame_id: impl Into<String>) -> Self
pub fn with_source_frame_id(self, source_frame_id: impl Into<String>) -> Self
Sourcepub fn with_source_frame_id_value(self, source_frame_id: Value) -> Self
pub fn with_source_frame_id_value(self, source_frame_id: Value) -> Self
Set Self::source_frame_id from an existing JSON value.
Sourcepub fn with_projection_state(
self,
projection_state: ContextProjectionState,
) -> Self
pub fn with_projection_state( self, projection_state: ContextProjectionState, ) -> Self
Sourcepub fn with_reason(self, reason: impl Into<String>) -> Self
pub fn with_reason(self, reason: impl Into<String>) -> Self
Set Self::reason.
Trait Implementations§
Source§impl Clone for ContextProvenance
impl Clone for ContextProvenance
Source§fn clone(&self) -> ContextProvenance
fn clone(&self) -> ContextProvenance
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 ContextProvenance
impl Debug for ContextProvenance
Source§impl Default for ContextProvenance
impl Default for ContextProvenance
Source§fn default() -> ContextProvenance
fn default() -> ContextProvenance
Source§impl<'de> Deserialize<'de> for ContextProvenancewhere
ContextProvenance: Default,
impl<'de> Deserialize<'de> for ContextProvenancewhere
ContextProvenance: Default,
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 ContextProvenance
impl PartialEq for ContextProvenance
Source§fn eq(&self, other: &ContextProvenance) -> bool
fn eq(&self, other: &ContextProvenance) -> bool
self and other values to be equal, and is used by ==.