pub struct ContextGraph { /* private fields */ }Expand description
An incrementally updated in-memory graph belonging to one caller-controlled privacy domain.
Implementations§
Source§impl ContextGraph
impl ContextGraph
Sourcepub fn check_answer(
&self,
request: &ContextRequest,
draft: &AnswerDraft,
reviews: &[ClaimReview],
policy: &AnswerPolicy,
tokenizer: &impl TokenCounter,
) -> Result<AnswerAssessment, ContextError>
pub fn check_answer( &self, request: &ContextRequest, draft: &AnswerDraft, reviews: &[ClaimReview], policy: &AnswerPolicy, tokenizer: &impl TokenCounter, ) -> Result<AnswerAssessment, ContextError>
Check a draft using independently supplied trusted reviews and current authorization.
Recompiles request and requires the exact snapshot given to the model. Every citation
must occur in that selected evidence; every claim needs a supported trusted review.
Known hard dependencies/counterclaims are traversed without dropping conflicts. Raising
or lowering confidence never bypasses a failed review. No semantic judge runs here.
The application must keep reviews, policy and authorization outside model control,
and display only the assessed claims on Release. The runtime cannot establish that a
model decomposed every factual assertion or that a supplied judge is truthful/accurate.
Source§impl ContextGraph
impl ContextGraph
Sourcepub fn new(
domain: impl Into<String>,
limits: GraphLimits,
) -> Result<Self, ContextError>
pub fn new( domain: impl Into<String>, limits: GraphLimits, ) -> Result<Self, ContextError>
Creates an empty graph. The domain must identify the application’s privacy boundary.
Sourcepub const fn revision(&self) -> u64
pub const fn revision(&self) -> u64
Current local mutation sequence. Identical upserts do not advance it.
Sourcepub fn upsert(&mut self, document: Document) -> Result<bool, ContextError>
pub fn upsert(&mut self, document: Document) -> Result<bool, ContextError>
Inserts or replaces one source and updates only its term postings. Returns whether changed.
Sourcepub fn replace_source(
&mut self,
source: &str,
documents: Vec<Document>,
) -> Result<SourceUpdate, ContextError>
pub fn replace_source( &mut self, source: &str, documents: Vec<Document>, ) -> Result<SourceUpdate, ContextError>
Atomically replaces all documents with this exact source locator, withdrawing obsolete IDs. Empty input withdraws the source. Every input must use this locator and a distinct ID; IDs owned by another source are rejected. Validation/indexing completes before live mutation. Existing edges remain, so references to withdrawn chunks continue to fail closed. This is not automatic edge migration: callers repair semantic relations explicitly.
Sourcepub fn remove(&mut self, id: &str) -> Result<bool, ContextError>
pub fn remove(&mut self, id: &str) -> Result<bool, ContextError>
Withdraws a document. Incoming hard edges remain so dependents fail closed until repaired.
Source§impl ContextGraph
impl ContextGraph
Sourcepub fn compile(
&self,
request: &ContextRequest,
tokenizer: &impl TokenCounter,
) -> Result<ContextSnapshot, ContextError>
pub fn compile( &self, request: &ContextRequest, tokenizer: &impl TokenCounter, ) -> Result<ContextSnapshot, ContextError>
Retrieves, expands, selects, cites, and seals a context snapshot using exact final counts. Every selected hard dependency and counterclaim must be authorized and fit in full.
Sourcepub fn explain(
&self,
request: &ContextRequest,
snapshot: &ContextSnapshot,
tokenizer: &impl TokenCounter,
) -> Result<SelectionExplanation, ContextError>
pub fn explain( &self, request: &ContextRequest, snapshot: &ContextSnapshot, tokenizer: &impl TokenCounter, ) -> Result<SelectionExplanation, ContextError>
Reconstruct the selector’s successful steps for an exact current snapshot/request. Stale, substituted or differently scoped snapshots fail before a trace is returned. This opt-in operation recompiles; ordinary compilation allocates no selection trace.