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`.
12
13pub mod attest;
14pub mod attribution;
15pub mod capability;
16pub mod consent;
17pub mod error_code;
18pub mod extension;
19pub mod frame;
20pub mod identity;
21pub mod query;
22pub mod record;
23pub mod record_attest;
24pub mod scope;
25pub mod token;
26pub mod usage;
27pub mod validate;
28pub mod verify;
29
30pub use attest::{
31    ALGORITHM_ED25519, AttestationVerdict, FrameAttestation, InclusionProof, InclusionStep,
32    MAX_INCLUSION_PATH_STEPS, ProvenanceAttestation, digest_string, encode_provenance_link,
33};
34#[cfg(feature = "attestation")]
35pub use attest::{
36    frame_commitment, inclusion_proof, merkle_root, provenance_chain_head, public_key_for,
37    result_set_commitments, result_set_root, root_from_proof, sign_commitment,
38    sign_frame_attestation, verify_commitment, verify_frame_attestation, verify_frame_inclusion,
39};
40pub use attribution::{AttributionReport, ContextUse};
41pub use capability::{
42    Capabilities, DataFlow, ProviderInfo, QueryCapability, embedding_fingerprints_match,
43    fingerprint_dimensions,
44};
45pub use consent::{ConsentReceipt, Grantor};
46pub use error_code::{ErrorCode, HostReaction};
47pub use extension::ExtensionValue;
48pub use frame::{
49    ContentFidelity, ContentRef, ContextFrame, FrameEmbedding, FrameKind, InlineContentRequirement,
50    Provenance, Relation, Representation, Transform, rel,
51};
52pub use identity::{FrameId, canonical_order};
53pub use query::{ContextQuery, ContextQueryResult};
54pub use record::{
55    ConstraintEffect, ContextRecord, ContractRequirement, DirectiveKind, Enforcement,
56    KnowledgeKind, LIFECYCLE_SCHEMA_VERSION, OriginClass, RESERVED_RECORD_MEMBERS,
57    RecordAttestation, RecordBody, RecordLink, RecordProvenance, RecordScope, RecordStatus,
58    RequirementResult, SharingScope, ValidationOutcome, is_reserved_record_member,
59};
60pub use record_attest::{
61    RECORD_ATTESTATION_DOMAIN, RECORD_HASH_MEMBER, RecordHashError, record_attestation_message,
62};
63#[cfg(feature = "record-hash")]
64pub use record_attest::{
65    record_hash, record_hash_is_current, record_hash_of, record_hash_preimage,
66};
67#[cfg(feature = "record-attestation")]
68pub use record_attest::{
69    sign_record, sign_record_attestation, verify_record_attestation, verify_signed_record_hash,
70};
71pub use scope::EgressScope;
72pub use token::{
73    BYTES_PER_BUDGET_TOKEN, SUGGESTED_HOST_SAFETY_FACTOR, budget_from_model_tokens, budget_tokens,
74};
75pub use usage::{ProviderUsage, ServedFrame, UsageReport};
76pub use validate::{
77    DIGEST_ALGORITHMS, format_protocol_timestamp, is_protocol_timestamp, is_well_formed_digest,
78};
79pub use verify::{FrameVerdict, Verdict, VerifyRequest, VerifyResponse};
80
81/// The stable protocol version string this crate implements (`SPEC.md` §3.1).
82pub const PROTOCOL_VERSION: &str = "contextgraph/1.0";