Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Core Concepts

naaf is built around four core traits, all driven by a shared Runtime. These traits form the building blocks of every workflow.

The Four Traits

TraitPurposeKey Method
TaskProduces an artefact from inputrun(&self, runtime, input)
CheckValidates a subject, returns findingscheck(&self, runtime, subject)
MaterialiserTransforms output (often with side effects)materialise(&self, runtime, input)
RepairPlannerProduces the next input from failed attemptsrepair(&self, runtime, attempts)

Each trait is async, takes a runtime reference for capabilities, and returns a strongly typed result. No stringly-typed dictionaries — your Rust types flow through the entire pipeline.

Relationship Between Traits

Input → Task → Output → Materialiser → Subject → Check → Findings
                    ↑                              ↓
                    ←←←←←← RepairPlanner ←←←←←←←←←←←←

The core loop works as follows:

  1. A Task produces an Output
  2. A Materialiser optionally transforms the output into a Subject
  3. A Check validates the subject and returns Findings
  4. If findings are non-empty, a RepairPlanner can produce a new input for retry

Runtime

The Runtime provides shared capabilities to all traits:

#![allow(unused)]
fn main() {
use naaf_core::Runtime;

let runtime = Runtime::new();
}

You can extend the runtime with capabilities:

#![allow(unused)]
fn main() {
use naaf_llm::LlmClient;
use naaf_qdrant::QdrantClient;

// Extend with LLM and vector database capabilities
let runtime = Runtime::new()
    .with_llm(LlmClient::new())
    .with_vector_db(QdrantClient::new(url, api_key));
}

Guide to This Section

  • Task — Produces output from input
  • Check — Validates output, returns findings
  • Materialiser — Transforms output between stages
  • RepairPlanner — Plans retry input from failures
  • Step — Combines Task, Check, Materialiser, and RepairPlanner