Skip to main content

ContextGraph

Struct ContextGraph 

Source
pub struct ContextGraph { /* private fields */ }
Expand description

An incrementally updated in-memory graph belonging to one caller-controlled privacy domain.

Implementations§

Source§

impl ContextGraph

Source

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

Source

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.

Source

pub fn len(&self) -> usize

Number of live source documents.

Source

pub fn is_empty(&self) -> bool

Whether the graph has no live documents.

Source

pub const fn revision(&self) -> u64

Current local mutation sequence. Identical upserts do not advance it.

Source

pub fn upsert(&mut self, document: Document) -> Result<bool, ContextError>

Inserts or replaces one source and updates only its term postings. Returns whether changed.

Source

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.

Source

pub fn remove(&mut self, id: &str) -> Result<bool, ContextError>

Withdraws a document. Incoming hard edges remain so dependents fail closed until repaired.

Adds a typed edge. Both endpoints must exist. Contradiction links are symmetric and atomic.

Explicitly removes an edge, including both directions of a contradiction.

Source§

impl ContextGraph

Source

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.

Source

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.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.