pub struct Evidence { /* private fields */ }Expand description
Immutable observation recorded by discovery or execution code.
§Lineage
An evidence record is EvidenceOrigin::Direct by default. A producer that
computes a record from exact source records attaches lineage with
Self::derived_from. Lineage is runtime truth held in the live
knowledge store: the origin is deliberately excluded from the serialized
wire, so the serialized form of every record — direct or derived — is
byte-identical to the historical contract. Durable lineage export is a
future versioned surface, not this record’s wire.
§Examples
use termivar_core::{
ConfidenceScore, EntityId, Evidence, EvidenceKind, EvidenceSource,
EvidenceValue, KnowledgePredicate,
};
let evidence = Evidence::new(
EntityId::new("endpoint:https://example.test")?,
EvidenceKind::Http,
KnowledgePredicate::new("http.header", "server")?,
EvidenceValue::Text("nginx".into()),
EvidenceSource::new("discovery.headers", "server-header")?,
ConfidenceScore::from_percent(85)?,
);
assert_eq!(evidence.reliability().basis_points(), 8_500);Implementations§
Source§impl Evidence
impl Evidence
Sourcepub fn new(
subject: EntityId,
kind: EvidenceKind,
predicate: KnowledgePredicate,
value: EvidenceValue,
source: EvidenceSource,
reliability: ConfidenceScore,
) -> Self
pub fn new( subject: EntityId, kind: EvidenceKind, predicate: KnowledgePredicate, value: EvidenceValue, source: EvidenceSource, reliability: ConfidenceScore, ) -> Self
Records evidence with an explicit source reliability and a generated ID.
Sourcepub fn with_id(
id: EvidenceId,
subject: EntityId,
kind: EvidenceKind,
predicate: KnowledgePredicate,
value: EvidenceValue,
source: EvidenceSource,
reliability: ConfidenceScore,
) -> Self
pub fn with_id( id: EvidenceId, subject: EntityId, kind: EvidenceKind, predicate: KnowledgePredicate, value: EvidenceValue, source: EvidenceSource, reliability: ConfidenceScore, ) -> Self
Records evidence with a host-assigned stable identity.
Reusing the ID for different evidence remains an identity conflict in
the knowledge store. Producers that also need a stable observation
timestamp should use Self::with_id_at.
Sourcepub fn with_id_at(
id: EvidenceId,
subject: EntityId,
kind: EvidenceKind,
predicate: KnowledgePredicate,
value: EvidenceValue,
source: EvidenceSource,
reliability: ConfidenceScore,
observed_at_ms: u64,
) -> Self
pub fn with_id_at( id: EvidenceId, subject: EntityId, kind: EvidenceKind, predicate: KnowledgePredicate, value: EvidenceValue, source: EvidenceSource, reliability: ConfidenceScore, observed_at_ms: u64, ) -> Self
Records evidence with host-assigned identity and observation time.
Supplying both fields allows a deterministic producer to recreate an exactly equal evidence record for idempotent insertion.
Sourcepub fn derived_from(self, derivation: EvidenceDerivation) -> Self
pub fn derived_from(self, derivation: EvidenceDerivation) -> Self
Marks this record as derived from exact parent evidence record(s).
Structural validity of the lineage is enforced when the
EvidenceDerivation is constructed; contextual validity (parent
existence, subject agreement, self-reference, and cycles) is enforced
atomically by the knowledge store on insertion.
Sourcepub fn id(&self) -> &EvidenceId
pub fn id(&self) -> &EvidenceId
Returns the evidence identifier.
Sourcepub fn kind(&self) -> &EvidenceKind
pub fn kind(&self) -> &EvidenceKind
Returns the broad evidence category.
Sourcepub fn predicate(&self) -> &KnowledgePredicate
pub fn predicate(&self) -> &KnowledgePredicate
Returns the namespaced predicate.
Sourcepub fn value(&self) -> &EvidenceValue
pub fn value(&self) -> &EvidenceValue
Returns the typed observation value.
Sourcepub fn source(&self) -> &EvidenceSource
pub fn source(&self) -> &EvidenceSource
Returns the observation provenance.
Sourcepub fn reliability(&self) -> ConfidenceScore
pub fn reliability(&self) -> ConfidenceScore
Returns the source reliability score.
Sourcepub fn observed_at_ms(&self) -> u64
pub fn observed_at_ms(&self) -> u64
Returns the observation timestamp in Unix milliseconds.
For a derived record this is the derivation instant, not an independent re-observation of the underlying subject.
Sourcepub fn origin(&self) -> &EvidenceOrigin
pub fn origin(&self) -> &EvidenceOrigin
Returns whether this record is direct or derived, with exact lineage.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Evidence
impl<'de> Deserialize<'de> for Evidence
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>,
impl Eq for Evidence
impl StructuralPartialEq for Evidence
Auto Trait Implementations§
impl Freeze for Evidence
impl RefUnwindSafe for Evidence
impl Send for Evidence
impl Sync for Evidence
impl Unpin for Evidence
impl UnsafeUnpin for Evidence
impl UnwindSafe for Evidence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.