boundgraph-slice 0.1.0

Layer 4 of BoundGraph: the slicers that turn raw tool output into size-capped condensates.
Documentation
//! Layer 4 of BoundGraph: the slicers that make context cost linear.
//!
//! A raw tool result might be ten thousand lines. What the next step receives is
//! a few hundred tokens of structured summary — a [`Condensate`] — while the
//! original stays addressable in the content store for an auditor. That single
//! move is what turns quadratic context growth into linear growth, and it is
//! the mechanism behind Law II.
//!
//! # Why naive truncation is not an option
//!
//! Cutting the first `n` bytes off a result is cheap and almost always wrong.
//! The interesting part of a build log is at the end; the interesting part of a
//! diff is spread across hunks; the interesting part of a JSON response is its
//! shape, not its first field. Worse, a truncated result *looks* complete — it
//! invites confidently wrong conclusions, which is precisely the failure mode
//! this project exists to prevent.
//!
//! So slicing is per-kind and structure-aware. Each slicer knows what is worth
//! keeping in its own format, and every one of them reports honestly whether it
//! dropped anything.
//!
//! # The contract
//!
//! [`Slicer::condense`] is a provided method that preserves the original,
//! calls the implementation, and then checks the result against the cap. An
//! implementation cannot skip any of those, so "output never exceeds the cap"
//! is a property of the trait rather than a promise each slicer makes
//! separately. See [`slicer`] for the reasoning.
//!
//! # Status
//!
//! Feature 07, milestone M3. Built in dependency order rather than story order,
//! because US-0702 degrades to US-0703's slicer and so needs it first:
//!
//! | Story | Module |
//! |---|---|
//! | US-0701 slicer trait | [`slicer`] |
//! | US-0703 log slicer | [`log`] |
//! | US-0704 diff slicer | [`diff`] |
//! | US-0705 JSON slicer | [`json`] |
//! | US-0702 AST slicer | [`ast`] (feature `ast`) |
//!
//! [`Condensate`]: boundgraph_core::Condensate

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

pub mod diff;
pub mod json;
pub mod log;
pub mod slicer;

#[cfg(feature = "ast")]
pub mod ast;

#[cfg(feature = "ast")]
pub use ast::{AstSlicer, Language};

pub use diff::{DiffSlicer, FileDiff, FileStatus, Hunk};
pub use json::{JsonSlicer, REDACTED};
pub use log::{Level, LogLine, LogSlicer};
pub use slicer::{
    ByteCeiling, CommandOutcome, Estimate, MemoryStore, Raw, Slice, SliceError, Slicer, Store,
    StoreError, TokenCount,
};

/// Re-exported so a consumer naming a slicer does not also depend on
/// `boundgraph-core` just for its identifier.
pub use boundgraph_core::{SchemaId, SlicerId};