boundgraph-core 0.1.0

Core primitives for the BoundGraph runtime: content-addressed digests, work orders, context, condensates, evidence, and the ledger.
Documentation
//! Core primitives for the BoundGraph runtime.
//!
//! BoundGraph governs the span between a reasoning engine proposing an action and a
//! state change committing. This crate defines the immutable values that span
//! is made of, and nothing else: no execution, no policy, no I/O.
//!
//! # The primitives
//!
//! | Symbol | Type | Role |
//! |---|---|---|
//! | `ω` | [`WorkOrder`] | A typed declaration of intended effect. A *proposal*. |
//! | `Γ` | [`Context`] | The exact admitted token window, plus what was refused. |
//! | `κ` | [`Condensate`] | A size-capped, structure-preserving summary of a result. |
//! | `ε` | [`Evidence`] | A signed verdict from a model-free checker. |
//! | `λ` | [`LedgerEntry`] | One tamper-evident record in the audit chain. |
//!
//! # Two invariants everything else rests on
//!
//! **Immutability.** Every primitive is constructed complete and never mutated.
//! There are no setters. A "change" is a new value with a new [`Digest`].
//!
//! **Content addressing.** Identity is the `blake3` digest of the canonical
//! CBOR encoding ([`Canonical`]). Equal digests mean equal values, which is
//! what lets the ledger be verified by a third party and lets the content
//! addressed store deduplicate.
//!
//! # How the Foundation Laws show up here
//!
//! The laws are enforced by the compiler and the runtime, not by this crate.
//! What this crate does is make them *representable* — and make violating them
//! awkward:
//!
//! - **Law I (Authority).** [`GrantSet::EMPTY`] is the default and there is no
//!   value meaning "unrestricted", so a step that declares nothing gets
//!   nothing. [`GrantDelta`] records requested against granted, so attenuation
//!   is auditable rather than inferred.
//! - **Law II (Context).** [`Context`] records what was *refused* as well as
//!   what was admitted, and construction fails if admissions exceed the
//!   ceiling. [`Condensate`] caps a result while keeping the original
//!   addressable.
//! - **Law III (Evidence).** [`Verdict`] has no implicit pass, and
//!   [`Evidence::covers`] means a verdict cannot be reattached to data it never
//!   saw.

#![doc(html_root_url = "https://docs.rs/boundgraph-core")]

pub mod budget;
pub mod canonical;
pub mod condensate;
pub mod context;
pub mod cost;
pub mod digest;
pub mod error;
pub mod evidence;
pub mod grant;
pub mod id;
pub mod isolation;
pub mod ledger;
pub mod work_order;

pub use budget::{Budget, Excess, MICROS_PER_USD, Unit, micros_of_usd};
pub use canonical::{Canonical, CanonicalError, from_canonical_cbor, to_canonical_cbor};
pub use condensate::{Condensate, CondensatePayload, SchemaId, SlicerId};
pub use context::{
    AdmittedItem, Context, ContextSource, EvictionReason, EvictionRecord, TokenBudget,
};
pub use cost::{AsOf, AsOfParseError, CostModel, Pricing, PricingError, TokenUsage};
pub use digest::{DIGEST_LEN, Digest, DigestParseError};
pub use error::{BoundGraphError, Result};
pub use evidence::{CheckerId, Evidence, EvidenceKind, Signature, SigningKeyId, Verdict};
pub use grant::{GrantAtom, GrantAtomParseError, GrantSet, KNOWN_DOMAINS};
pub use id::{RunId, StepId};
pub use isolation::{Confinement, Enforcement, Isolation, Tier, Worker};
pub use ledger::{CostRecord, GENESIS_PREV, GrantDelta, JournalRef, LedgerEntry};
pub use work_order::{Intent, ProposalOrigin, ToolCall, WorkOrder};