pub struct Kiln { /* private fields */ }Expand description
The kiln — the runtime that fires tasks and cools them to detect patterns.
Like a pottery kiln, this runtime has two distinct phases:
-
Firing: Tasks execute (
fire()), producing outputs and metrics. This is the hot phase — the work gets done. -
Cooling: After all tasks have fired, the runtime examines the completed tasks for emergent patterns. The crackle glaze forms in the cooling, not the firing.
§Example
use crackle_runtime::{CrackleTask, Kiln, ThermalProfile, TaskOutput};
struct MyTask { x: f64 }
impl CrackleTask for MyTask {
type Output = f64;
fn fire(&self) -> TaskOutput<Self::Output> {
TaskOutput::new(self.x, vec![("value".into(), self.x)])
}
}
let mut kiln = Kiln::new(ThermalProfile::default());
kiln.fire_task(MyTask { x: 1.0 });
kiln.fire_task(MyTask { x: 2.0 });
kiln.fire_task(MyTask { x: 3.0 });
let patterns = kiln.cool();Implementations§
Source§impl Kiln
impl Kiln
Sourcepub fn new(profile: ThermalProfile) -> Self
pub fn new(profile: ThermalProfile) -> Self
Create a new kiln with the given thermal profile.
Sourcepub fn default_profile() -> Self
pub fn default_profile() -> Self
Create a kiln with default thermal profile.
Sourcepub fn fire_task<T: CrackleTask>(&self, task: T) -> TaskOutput<T::Output>
pub fn fire_task<T: CrackleTask>(&self, task: T) -> TaskOutput<T::Output>
Fire a single task and record its output.
Returns the task’s output value.
§Panics
Panics if called after cool().
Sourcepub fn fire_and_record<T: CrackleTask>(
&mut self,
task: T,
) -> TaskOutput<T::Output>
pub fn fire_and_record<T: CrackleTask>( &mut self, task: T, ) -> TaskOutput<T::Output>
Fire a task and record it in the kiln for later cooling.
This stores the task’s metrics internally so patterns can be detected during the cooling phase.
Sourcepub fn fire_all<T: CrackleTask>(
&mut self,
tasks: Vec<T>,
) -> Vec<TaskOutput<T::Output>>
pub fn fire_all<T: CrackleTask>( &mut self, tasks: Vec<T>, ) -> Vec<TaskOutput<T::Output>>
Fire multiple tasks in sequence and record them all.
Sourcepub fn add_entry(
&mut self,
label: impl Into<String>,
metrics: Vec<(String, f64)>,
)
pub fn add_entry( &mut self, label: impl Into<String>, metrics: Vec<(String, f64)>, )
Add a pre-computed task entry directly (useful for testing).
Sourcepub fn task_count(&self) -> usize
pub fn task_count(&self) -> usize
The number of tasks currently in the kiln.
Sourcepub fn cool(&mut self) -> Vec<CracklePattern>
pub fn cool(&mut self) -> Vec<CracklePattern>
Cool the kiln: run pattern detection across all completed tasks.
This is where the beauty emerges. Just as a pottery kiln’s crackle glaze forms during cooling, the patterns that crackle-runtime detects are only visible after the heat of execution has passed.
Returns all detected patterns.
Sourcepub fn profile(&self) -> &ThermalProfile
pub fn profile(&self) -> &ThermalProfile
Get the thermal profile.