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
131
132
133
134
135
136
137
138
// 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 with typed expressions and compiled plans
//! - 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`] validates and executes typed generation plans 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::PlanBuilder + RuleExpr
//! |
//! v
//! validate + compile
//! |
//! v
//! GenerationContext (named outputs + provenance)
//! ```
//!
//! ## Quick Start
//!
//! ```no_run
//! use aethellib::engine::combinators;
//! 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 key = RuleKey::new("weapon_name")?;
//! let prefix = PoolRef::new("name", "prefix")?;
//! let kind = PoolRef::new("type", "type")?;
//!
//! let compiled = PlanBuilder::new(&corpus)
//! .rule(
//! &key,
//! combinators::join([
//! combinators::pick(prefix, None, ""),
//! combinators::lit(" "),
//! combinators::pick(kind, None, "")
//! ]),
//! )
//! .validate()?
//! .compile()?;
//!
//! let mut rng = rand::rng();
//! let ctx = compiled.generate(&mut rng)?;
//!
//! println!("{}", ctx.require(&key)?.value);
//!
//! Ok(())
//! }
//! ```
//!
//! For a fuller workflow (chance, recall, custom expressions), see
//! `examples/main.rs` in the repository.
//!
//! ## API At A Glance
//!
//! - [`Corpus::from_files`] to load corpora from TOML sources
//! - [`PlanBuilder::new`] and [`PlanBuilder::rule`] to build typed plans
//! - [`combinators`] for typed expression helpers like `pick`, `join`, and
//! `weighted`
//! - [`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
//! [`PlanBuilder::new`]: crate::engine::PlanBuilder::new
//! [`PlanBuilder::rule`]: crate::engine::PlanBuilder::rule
//! [`GenerationContext`]: crate::engine::GenerationContext
//! [`Corpus::from_files`]: crate::corpus::Corpus::from_files
//! [`combinators`]: crate::engine::combinators
/// corpus module entrypoint.
/// generation engine for typed planning and compiled execution.