pub trait ContextProvider: Send + Sync {
// Required methods
fn id(&self) -> &str;
fn info(&self) -> &ProviderInfo;
fn capabilities(&self) -> &Capabilities;
fn query<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 ContextQuery,
) -> Pin<Box<dyn Future<Output = Result<ContextQueryResult, HostError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn verify<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 VerifyRequest,
) -> Pin<Box<dyn Future<Output = Result<VerifyResponse, HostError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), HostError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
A registered Context Graph Protocol provider, queryable behind one handle regardless of
transport. info()/capabilities() return values cached at handshake
time, so they are cheap synchronous getters even for out-of-process
providers.
Required Methods§
Sourcefn id(&self) -> &str
fn id(&self) -> &str
The provider’s host-facing id — its routing key and its consent key
(SPEC.md §4 and §10).
Sourcefn info(&self) -> &ProviderInfo
fn info(&self) -> &ProviderInfo
Identity + declared data-flow direction, surfaced at consent time (SPEC.md §3, ).
Sourcefn capabilities(&self) -> &Capabilities
fn capabilities(&self) -> &Capabilities
Capabilities negotiated at the handshake (SPEC.md §3): which frame
kinds this provider serves, whether it echoes a correlation id, does
graph, names an embedding space, answers context/verify, which frame
representations it can return, and whether it answers context/resolve.
That is the whole of Capabilities — seven fields. This comment used
to describe upsert, subscriptions and filters, which
ADR 0004
removed because nothing implemented them. The sentence outlived them and
was copied into docs/implementing-a-provider.md, so a provider author
read it as the contract (#151).
Sourcefn query<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 ContextQuery,
) -> Pin<Box<dyn Future<Output = Result<ContextQueryResult, HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 ContextQuery,
) -> Pin<Box<dyn Future<Output = Result<ContextQueryResult, HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Answer a context query with budgeted, provenance-carrying frames
(SPEC.md §5). The host — not the provider — enforces the budget and consent;
a provider that over-runs its budget is caught by the host, not
trusted (crate::host).
§Signing
A provider that signs what it serves populates
frame_attestations and
result_attestation on the
result it returns (SPEC.md §6.5.5). There is no second method and no
second channel: the evidence is part of the answer, so an in-process
provider and a transport-backed one carry it identically, and a host
can never be handed signatures that disagree with the frames they cover
(ADR 0014).
This trait previously offered a defaulted query_attested returning an
AttestedQueryResult, from the months when the frames envelope had
nowhere to put an attestation. It does now, so both are gone.
The host checks whatever arrives against its
TrustStore and records the outcome in the
composition audit. Whatever it finds, the frames are served either
way (SPEC.md F9).
Provided Methods§
Sourcefn verify<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 VerifyRequest,
) -> Pin<Box<dyn Future<Output = Result<VerifyResponse, HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn verify<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 VerifyRequest,
) -> Pin<Box<dyn Future<Output = Result<VerifyResponse, HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Revalidate frames the host already holds, without any frame body
travelling (docs/context-reuse.md §4 context/verify).
Defaults to answering Verdict::Unknown
for every requested identity, so an existing provider implements
nothing and is simply treated as unable to vouch for its frames — the
host then re-queries them. A provider that overrides this MUST also
advertise Capabilities::verify,
since the host only asks providers that declare support.
Sourcefn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), HostError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Shut the provider down cleanly (SPEC.md §3 lifecycle). In-process providers
default to a no-op; transport-backed providers send shutdown and
reap their child. Overridable.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".