Expand description
tdln-brain — Deterministic Cognitive Layer for LogLine OS
Render a narrative frame → call an LLM provider → extract only JSON →
validate into tdln_ast::SemanticUnit.
§Why
- Prevent tool-call hallucinations
- Enforce JSON-only outputs
- Keep reasoning optional and separated
- Make failures machine-legible
§Example
use tdln_brain::{Brain, CognitiveContext, GenerationConfig};
use tdln_brain::providers::local::LocalEcho;
let brain = Brain::new(LocalEcho);
let ctx = CognitiveContext {
system_directive: "You are a deterministic planner.".into(),
..Default::default()
};
let decision = brain.reason(&ctx, &GenerationConfig::default()).await?;
println!("{:?}", decision.intent);Modules§
- parser
- Strict JSON extraction and validation.
- prompt
- Narrative rendering for cognitive context.
- providers
- LLM provider implementations.
- util
- Small utilities for token budgets and guards.
Structs§
- Brain
- The deterministic cognitive engine.
- Cognitive
Context - Cognitive context for prompt rendering.
- Decision
- A parsed decision containing reasoning and a strict intent.
- Generation
Config - Configuration for generation requests.
- Message
- A chat message with role and content.
- RawOutput
- Raw output from a neural backend.
- Semantic
Unit - Minimal AST node representing a canonical semantic intent.
- Usage
Meta - Usage metadata from a generation request.
Enums§
- Brain
Error - Errors from the cognitive layer.
Traits§
- Neural
Backend - Trait for model providers (LLM backends).