1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// 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.
/// generation engine, rule trait, and combinators.