Skip to main content

Crate aethellib

Crate aethellib 

Source
Expand description

§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

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

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

§Stability

aethellib is currently pre-1.0. Public API naming and module layout may evolve as the crate approaches 1.0.0.

Modules§

corpus
corpus module entrypoint.
engine
generation engine, rule trait, and combinators.
prelude
Lightweight re-exports for common application-level usage.