Skip to main content

ContextQueryResult

Struct ContextQueryResult 

Source
pub struct ContextQueryResult {
    pub frames: Vec<ContextFrame>,
    pub truncated: bool,
    pub dropped_estimate: Option<u32>,
    pub frame_attestations: Vec<FrameAttestation>,
    pub result_attestation: Option<ProvenanceAttestation>,
}
Expand description

The response to a context/query call.

§Where an attestation rides

frame_attestations and result_attestation are the wire home of SPEC.md §6.5’s evidence (§6.5.5, F11–F13). They sit on the result rather than on the frames envelope because an attestation is a property of the answer, exactly like truncated: the envelope carries only what the transport needs (type, the correlation id), and an in-process provider that returns a ContextQueryResult with no envelope at all must still be able to sign what it serves.

Both are optional and both are omitted when empty, so an unsigned answer is byte-identical to one from a provider written before this existed.

Fields§

§frames: Vec<ContextFrame>§truncated: bool

True if the provider had more candidates than fit the budget.

§dropped_estimate: Option<u32>§frame_attestations: Vec<FrameAttestation>

Detached per-frame evidence, one entry per attested frame (SPEC.md §6.5.5). Never a parallel array: each entry names the FrameId it covers in full.

§result_attestation: Option<ProvenanceAttestation>

One signature over the whole answer: a detached attestation whose signed_commitment is the §6.5.3 Merkle root over the commitments of exactly the frames in frames, in canonical order.

Implementations§

Source§

impl ContextQueryResult

Source

pub fn unattested( frames: Vec<ContextFrame>, truncated: bool, dropped_estimate: Option<u32>, ) -> Self

An answer carrying no detached evidence — what every provider that does not sign returns.

It exists so that adding frame_attestations and result_attestation to this struct is not a rewrite for a caller that never signs anything. A struct literal naming the first three fields stopped compiling when those two landed; this constructor, and ..Default::default() on a literal, are the two ways to keep such a caller to a one-line change.

Source

pub fn total_token_cost(&self) -> u64

Sum of token_cost across returned frames — must never exceed the query’s max_tokens for a conforming provider (checked in contextgraph-conformance, phase 3; this is the cheap client-side sanity check any host can run today).

Source

pub fn respects_budget(&self, max_tokens: u32) -> bool

Source

pub fn respects_frame_limit(&self, max_frames: u32) -> bool

Whether the provider honored the query’s max_frames cap (SPEC.md §B4).

max_frames was part of the query contract from the beginning and was audited by nothing: a provider returning ten thousand one-token frames against max_frames: 8 passed every check. Frame count is a real cost — each frame carries a title, a citation label, and rendering chrome the token budget does not capture.

Source

pub fn frames_with_dishonest_cost(&self) -> Vec<&str>

Frames whose declared token_cost does not match the canonical count for their content (SPEC.md §B3).

Returns ids so a host’s audit report can name the offending frames rather than only the provider.

Source

pub fn canonical_token_cost(&self) -> u64

The sum of the canonical costs of the returned frames — what the provider’s frames actually cost, as opposed to what it claimed.

Source

pub fn is_attested(&self) -> bool

Whether this answer carries any detached evidence at all (SPEC.md §6.5.5).

Source

pub fn attestation_for(&self, frame: &FrameId) -> Option<&FrameAttestation>

The attestation entry covering one frame identity, if the provider sent one.

Matching is on the whole (provider_id, frame_id, content_digest) triple, never on the frame id alone: two frames sharing an id but not a digest are different bytes, and handing the first one’s evidence to the second is the substitution the identity binding exists to prevent (SPEC.md §6.5.2).

Source

pub fn orphaned_attestations(&self, provider_id: &str) -> Vec<&FrameId>

Attestation entries naming a frame this result does not carry (SPEC.md §6.5.5, F11).

An entry with no frame beside it is evidence for something the host was never shown. It is not merely useless: a host that counted entries rather than matching them would report an answer as more thoroughly attested than it is. Returned as identities so a report can name them.

Trait Implementations§

Source§

impl Clone for ContextQueryResult

Source§

fn clone(&self) -> ContextQueryResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContextQueryResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ContextQueryResult

Source§

fn default() -> ContextQueryResult

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ContextQueryResult

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ContextQueryResult

Source§

fn eq(&self, other: &ContextQueryResult) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ContextQueryResult

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ContextQueryResult

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.