Skip to main content

contextgraph_types/
lib.rs

1//! `contextgraph-types` — the Context Graph Protocol (CGP) wire types.
2//!
3//! This crate is the industry-facing artifact: **MIT licensed, zero
4//! dependencies beyond `serde`**, publishable to crates.io on its own so a
5//! third party can implement a CGP host or provider without pulling in any
6//! other code. The normative shape these types bind to is [`SPEC.md`] at the
7//! repository root; every doc comment below cites a section of it.
8//!
9//! [`SPEC.md`]: https://github.com/macanderson/context-graph-protocol/blob/main/SPEC.md
10//!
11//! Protocol version: `contextgraph/1.0-draft`.
12
13pub mod attribution;
14pub mod capability;
15pub mod consent;
16pub mod error_code;
17pub mod frame;
18pub mod identity;
19pub mod query;
20pub mod record;
21pub mod scope;
22pub mod token;
23pub mod usage;
24pub mod validate;
25pub mod verify;
26
27pub use attribution::{AttributionReport, ContextUse};
28pub use capability::{
29    Capabilities, DataFlow, ProviderInfo, QueryCapability, embedding_fingerprints_match,
30    fingerprint_dimensions,
31};
32pub use consent::{ConsentReceipt, Grantor};
33pub use error_code::{ErrorCode, HostReaction};
34pub use frame::{
35    ContentFidelity, ContentRef, ContextFrame, FrameEmbedding, FrameKind, InlineContentRequirement,
36    Provenance, Relation, Representation, Transform, rel,
37};
38pub use identity::{FrameId, canonical_order};
39pub use query::{ContextQuery, ContextQueryResult};
40pub use record::{
41    ConstraintEffect, ContextRecord, ContractRequirement, DirectiveKind, Enforcement,
42    KnowledgeKind, LIFECYCLE_SCHEMA_VERSION, OriginClass, RecordAttestation, RecordBody,
43    RecordLink, RecordProvenance, RecordScope, RecordStatus, RequirementResult, SharingScope,
44    ValidationOutcome,
45};
46pub use scope::EgressScope;
47pub use token::{
48    BYTES_PER_BUDGET_TOKEN, SUGGESTED_HOST_SAFETY_FACTOR, budget_from_model_tokens, budget_tokens,
49};
50pub use usage::{ProviderUsage, ServedFrame, UsageReport};
51pub use validate::{
52    DIGEST_ALGORITHMS, format_protocol_timestamp, is_protocol_timestamp, is_well_formed_digest,
53};
54pub use verify::{FrameVerdict, Verdict, VerifyRequest, VerifyResponse};
55
56/// The protocol version string this crate implements. Frozen to `contextgraph/1.0`
57/// only at the public v1.0 release (`SPEC.md` §Version strings).
58pub const PROTOCOL_VERSION: &str = "contextgraph/1.0-draft";