aethellib 0.8.4

Composable text generation primitives over target-specific TOML corpora with provenance tracking.
Documentation
// Copyright 2026 Arad Fadaei

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! # aethellib
//!
//! `aethellib` is a small Rust library for composable text generation over
//! target-specific TOML corpora.
//!
//! It focuses on three things:
//! - Loading typed documents into a single-target [`Corpus`]
//! - Generating text by composing reusable rules in the [`Engine`]
//! - Preserving source provenance for generated values so outputs remain traceable
//!
//! ## Core Concepts
//!
//! - [`corpus`] loads and validates documents, then builds pooled values grouped by
//!   section and field.
//! - [`engine`] executes a pipeline of rules and stores prior outputs in a
//!   [`GenerationContext`].
//! - [`prelude`] re-exports the most commonly used types for quick onboarding.
//!
//! ## Why Provenance Matters
//!
//! Generated text is more useful when you can explain where it came from.
//! `aethellib` keeps provenance on pooled and composed values so you can:
//! - Debug generation outcomes quickly
//! - Audit content sources for pipelines and toolchains
//! - Build UI/UX that can show source attribution to users
//!
//! ## Architecture
//!
//! ```text
//! TOML Sources
//!     |
//!     v
//! corpus::Corpus::from_files / CorpusBuilder
//!     |
//!     v
//! Value Pools (section + field, with provenance)
//!     |
//!     v
//! engine::Engine + composable rules
//!     |
//!     v
//! GenerationContext (named outputs + provenance)
//! ```
//!
//! ## Quick Start
//!
//! ```no_run
//! use aethellib::engine::combinators::{concat, lit, pick};
//! use aethellib::prelude::*;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     let corpus = Corpus::from_files(&["data/weapon_test_data.toml"], "weapon", None, None)?;
//!
//!     let ctx = Engine::new(&corpus, rand::rng())
//!         .with_rule(concat(
//!             "weapon_name",
//!             pick("prefix", "name".to_string(), "prefix".to_string()),
//!             concat(
//!                 "type_part",
//!                 lit(" "),
//!                 pick("type", "name".to_string(), "type".to_string()),
//!             ),
//!         ))
//!         .generate()?;
//!
//!     if let Some(value) = ctx.get_previous("weapon_name") {
//!         println!("{}", value.value);
//!     }
//!
//!     Ok(())
//! }
//! ```
//!
//! For a fuller workflow (nested rules, recall, weighted traits), see
//! `examples/main.rs` in the repository.
//!
//! ## API At A Glance
//!
//! - [`Corpus::from_files`] to load corpora from TOML sources
//! - [`Engine::new`] and [`Engine::with_rule`] to build rule pipelines
//! - [`combinators`] for prebuilt rules like `pick`, `concat`, and
//!   `weighted_choice`
//! - [`prelude`] for ergonomic imports in applications and examples
//!
//! ## Stability
//!
//! `aethellib` is currently pre-1.0. Public API naming and module layout may
//! evolve as the crate approaches `1.0.0`.
//!
//! [`Corpus`]: crate::corpus::Corpus
//! [`Engine`]: crate::engine::Engine
//! [`GenerationContext`]: crate::engine::GenerationContext
//! [`Corpus::from_files`]: crate::corpus::Corpus::from_files
//! [`Engine::new`]: crate::engine::Engine::new
//! [`Engine::with_rule`]: crate::engine::Engine::with_rule
//! [`combinators`]: crate::engine::combinators

/// corpus module entrypoint.
pub mod corpus;
/// generation engine, rule trait, and combinators.
pub mod engine;

pub mod prelude {
    //! Lightweight re-exports for common application-level usage.
    //!
    //! Import this when you want quick access to the most frequently used
    //! corpus and engine types without managing many individual paths.

    pub use crate::corpus::error::{CorpusLoaderError, CorpusLoaderErrorKind};
    pub use crate::corpus::types::{Document, DocumentMetadata, Field, Section, Target};
    pub use crate::corpus::utils::{CorpusLoaderOptions, LoadValidator};
    pub use crate::corpus::{Corpus, CorpusBuilder, PooledValue, ValuePool, ValueProvenance};

    pub use crate::engine::error::AethelError;
    pub use crate::engine::{ComposedValue, Engine, GenerationContext, InlineRule, Rule};
}