AXON Architecture Overview
AXON is built on a three-phase pipeline that transforms cognitive intent into executable AI programs:Architecture Principles
1. Separation of Concerns
- Phase 1 (Compiler): Language-agnostic semantic understanding
- Phase 2 (Backends): Model-specific prompt generation
- Phase 3 (Runtime): Execution orchestration and validation
2. Cognitive-First Design
Every component speaks the language of intelligence:- No mechanical abstractions: No
forloops, noifstatements - Semantic nodes only:
ReasonChain,ProbeDirective,WeaveNode - Epistemic type system:
FactualClaimvsOpinion, not justString
3. Model Agnosticism
The IR (Intermediate Representation) has zero dependencies on any LLM provider:The Three Phases
Phase 1: Compiler (axon/compiler/)
Transforms source text into a validated Intermediate Representation:- Lexer (
lexer.py) — Tokenizes source into a stream of tokens - Parser (
parser.py) — Builds a cognitive AST (Abstract Syntax Tree) - Type Checker (
type_checker.py) — Validates epistemic type constraints - IR Generator (
ir_generator.py) — Lowers AST to model-agnostic IR
IRProgram with resolved flows, personas, anchors, and types.
Phase 2: Backends (axon/backends/)
Compiles IR into provider-specific prompt structures:AnthropicBackend— Claude-optimized prompts with extended thinkingGeminiBackend— Google Gemini with system_instruction formattingOpenAIBackend— (Stub) GPT-4 Chat Completions formatOllamaBackend— (Stub) Local model adaptations
CompiledProgram with system prompts, user prompts, and tool declarations.
Phase 3: Runtime (axon/runtime/)
Orchestrates execution with validation, retry, and tracing:Executor— Main orchestrator coordinating all componentsSemanticValidator— Enforces epistemic type contractsRetryEngine— Adaptive retry with failure context injectionTracer— Records every semantic decision for observabilityMemoryBackend— Persistent semantic storage layer
ExecutionResult with step outputs, validation results, and full trace.
Data Flow
Key Design Patterns
Visitor Pattern (Compiler)
Both the Parser and IR Generator use explicit visitor registries:Protocol-Based Abstraction (Runtime)
TheModelClient protocol decouples execution from LLM APIs:
Continuation-Passing Style (Validation)
Anchor checking and validation use CPS for composable error handling:Component Communication
Compiler → Backend
Backend → Runtime
Runtime → Tracing
File Organization
Next Steps
Compiler Deep Dive
Explore the lexer and parser implementation
Backend Architecture
Learn how prompts are generated
Runtime Execution
Understand the execution pipeline
