pub struct SemanticAttributionTracker {
pub records: HashMap<u64, AttributionRecord>,
pub output_index: HashMap<u64, Vec<u64>>,
pub session_index: HashMap<u64, Vec<u64>>,
/* private fields */
}Expand description
Tracks attribution chains between outputs and their source documents / embeddings / inference results, enabling explainability and audit.
Fields§
§records: HashMap<u64, AttributionRecord>Primary store: record_id → record.
output_index: HashMap<u64, Vec<u64>>Secondary index: output_id → list of record_ids.
session_index: HashMap<u64, Vec<u64>>Secondary index: session_id → list of record_ids.
Implementations§
Source§impl SemanticAttributionTracker
impl SemanticAttributionTracker
Sourcepub fn record(
&mut self,
output_id: u64,
sources: Vec<AttributionSource>,
tick: u64,
session_id: Option<u64>,
) -> u64
pub fn record( &mut self, output_id: u64, sources: Vec<AttributionSource>, tick: u64, session_id: Option<u64>, ) -> u64
Records an attribution event and returns the new record_id.
Sourcepub fn records_for_output(&self, output_id: u64) -> Vec<&AttributionRecord>
pub fn records_for_output(&self, output_id: u64) -> Vec<&AttributionRecord>
Returns all records attributed to output_id, sorted by record_id ascending.
Sourcepub fn records_for_session(&self, session_id: u64) -> Vec<&AttributionRecord>
pub fn records_for_session(&self, session_id: u64) -> Vec<&AttributionRecord>
Returns all records belonging to session_id, sorted by tick ascending then
record_id ascending.
Sourcepub fn top_documents(&self, n: usize) -> Vec<u64>
pub fn top_documents(&self, n: usize) -> Vec<u64>
Returns the n document ids most frequently appearing as
AttributionSource::Document across all records.
Ties are broken by doc_id ascending. The result is truncated to n entries.
Sourcepub fn remove_record(&mut self, record_id: u64) -> bool
pub fn remove_record(&mut self, record_id: u64) -> bool
Removes a record and cleans up all secondary indices.
Returns true if the record existed.
Sourcepub fn stats(&self) -> AttributionStats
pub fn stats(&self) -> AttributionStats
Computes aggregate statistics over all held records.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SemanticAttributionTracker
impl RefUnwindSafe for SemanticAttributionTracker
impl Send for SemanticAttributionTracker
impl Sync for SemanticAttributionTracker
impl Unpin for SemanticAttributionTracker
impl UnsafeUnpin for SemanticAttributionTracker
impl UnwindSafe for SemanticAttributionTracker
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.