Two repositories, two version lines. This repo (
axon-lang, AGPL-3.0-or-later, public) ships the language + runtime + compiler + 7 LLM backends + Cognitive I/O + WebSocket session types — currently v2.3.0. The commercial control plane (axon-enterprise, EULA, private) layers multi-tenant identity / RBAC / SSO / metering / audit / vertical compliance on top of this language via a pinned Cargo dependency — currently v3.0.7. The version numbers diverge by design (enterprise iterates on the SaaS surface independently of the language). If you don't run a commercial Axon deployment, this repo is all you need; the badge above is the only version that matters for you.
What is AXON?
AXON is a compiled language that targets LLMs instead of CPUs. It has a
formal EBNF grammar, a lexer, parser, AST, intermediate representation, seven
native Rust LLM backends (Anthropic, OpenAI, Gemini, Kimi, GLM, Ollama,
OpenRouter), and a 100% Rust + C23 native runtime with semantic type checking, an
algebraic-effects execution engine, real-time SSE / NDJSON / WebSocket
session-typed streaming, retry + circuit-breaker resilience, and execution
tracing. The FIPS-routable cryptographic + tokenisation kernels live in
axon-csys as standalone C23 (no opaque C bindings — every
kernel is a _Generic-dispatched, [[nodiscard]]-annotated, sanitizer-clean
C23 source file with a Rust wrapper).
Beyond cognition, AXON ships Cognitive I/O — a λ-calculus-based infrastructure layer where resources, control loops, observability, security kernels, and UI components carry their regulatory class (HIPAA / PCI_DSS / GDPR / SOX / SOC 2 / ISO 27001 / FIPS / CC EAL 4+) as a compile-time type. Programs that fail coverage are rejected before they run. No other programming language does this.
v2.3.0 (Fase 41) adds the first session-typed real-time dialogue primitive in
any production language: declare a session (the bidirectional protocol),
bind it to a socket (the WebSocket transport with credit-refined
backpressure), and the compiler proves the two endpoints are duals
(Caires–Pfenning linear-logic Curry–Howard); the runtime enforces every step,
seals the residual cursor on disconnect for typed reconnection, and projects
to W3C Server-Sent Events when the protocol is single-polarity. See
docs/paper_websocket_cognitive_primitive.md.
It is not a Python library, a LangChain wrapper, a YAML DSL, or a Terraform
replacement. It is a new kind of calculus — see
docs/paper_lambda_lineal_epistemico.md
for the formal semantics (Cálculo Lambda Lineal Epistémico).
Cognitive I/O — Build Infrastructure with Compile-Time Compliance
The big differential added in v1.0 — ten new top-level declarations that turn AXON into the only language where "does this app leak PHI?" is a type error, not a post-mortem finding.
| Primitive | What it is | Formal backing |
|---|---|---|
resource | Infrastructure token (DB, cache, bucket, GPU) with linear / affine / persistent lifetime | Linear Logic (Girard 1987) |
fabric | Topological substrate (VPC, cluster, namespace) | Separation Logic (O'Hearn–Reynolds) |
manifest | Declarative "belief" about desired infrastructure shape, with κ (regulatory class) annotations | Epistemic Logic (Fagin–Halpern) |
observe | Quorum-gated snapshot of real state, producing a ΛD envelope ⟨c, τ, ρ, δ⟩ | Decision D4: partition ≡ void, never doubt |
reconcile | Active-Inference control loop: observe → drift → shield → act | Free Energy Principle (Friston) |
lease | τ-decaying affine capability; post-expiry use is a CT-2 Anchor Breach | Hybrid affine + revocation (D2) |
ensemble | Byzantine quorum aggregator over N observations with common-knowledge fusion | Fagin–Halpern Cφ |
topology + session | Typed directed graph over declared entities with Honda–Vasconcelos duality + deadlock detection | π-calculus binary sessions |
socket (v2.3.0) | Session-typed WebSocket transport with credit-refined backpressure, typed reconnection via cognitive_states, SSE-as-fragment projection | Caires–Pfenning Curry–Howard + Rast credit-refined types (paper_websocket_cognitive_primitive.md) |
immune + reflex + heal | KL-divergence anomaly sensor + O(1) signed-trace motor response + Linear-Logic one-shot patch FSM | Cognitive Immune System (paper_immune_v2.md) |
component + view | Declarative UI with the same compile-time κ coverage rule — regulated types need a covering shield or the compiler rejects | Regulatory Type Theory (Fase 9) |
Hard differentiators vs. Terraform / Pulumi / Kubernetes manifests
- Compile-time compliance.
shield<HIPAA>/type PatientRecord compliance [HIPAA, GDPR]are types. A.axonprogram that sends PHI to an unshielded endpoint failsaxon check— same exit code as a syntax error. - Blame Calculus (Findler–Felleisen). Every error is classified as CT-1 (axon/runtime bug), CT-2 (program author: anchor breach, expired lease), or CT-3 (infrastructure: partition, missing credential, provider quota). No silent downgrades.
- Audit-ready artefacts.
axon dossier+axon sbom+axon audit --framework {soc2,iso27001,fips,cc,all}+axon evidence-packageproduce byte-identical, deterministic JSON/ZIP — the SHA-256 of every output is a contract against your release. - 100% Rust + C23 runtime, no interpreter. The whole stack — lexer, parser, type-checker, IR, the algebraic-effects execution engine, the HTTP server, the seven LLM backends, the streaming wire, the session-typed WebSocket driver — is a single native Rust binary; the FIPS-routable cryptographic + tokeniser kernels live in
axon-csysas standalone C23 (nounsafeglue:_Generic-dispatched headers,[[nodiscard]]everywhere, sanitizer-clean, valgrind-clean). Download a prebuilt orcargo build --release. No GC, no interpreter, no runtime dependency. - Cognitive immune system.
immune + reflex + healis a first-class language primitive, not a plug-in. Signed HMAC traces per firing, three compliance modes (audit_only/human_in_loop/adversarial), Linear-Logic patch FSM preventing double-application. - Post-Quantum-ready ESK. HMAC-SHA256 baseline + Ed25519 + ML-DSA-65 (NIST FIPS 204 Dilithium) + Hybrid signer (NIST SP 800-208 transition posture). Feature-gated; no silent classical fallbacks.
- Persistence is a typed cognitive primitive. A database in AXON is an
axonstore, not an ORM bolt-on: retrieved rows are born epistemicallyUntrustedand aconfidence_flooris enforced at read and write; every mutation appends to an HMAC-Merkle audit chain;retrieveis a bounded, back-pressuredStream<Row>; and store access is capability-typed and checked at compile time. No other language treats stored data this way. - Real-time dialogue is a typed cognitive primitive (v2.3.0). A WebSocket in AXON is a
socketover a declaredsession, not a JSON envelope over bytes: the compiler proves the two endpoints are duals (Caires–Pfenning intuitionistic linear logic,S̄ ≡ S⊥), so the connection is deadlock-free and protocol-conformant by construction; credit-refined backpressure (backpressure: credit(k)) is decidable in Presburger arithmetic at compile time; a mid-protocol disconnect seals the residual session-type cursor + credit window into an AAD-boundcognitive_statessnapshot, and the typed?resume=resume restores it under tenant + flow_id binding; a single-polarity protocol'ssocketALSO speaks W3C Server-Sent Events byte-compat with Fase 33's existing SSE pipeline (S_SSE = Π_↓(S_WS)).
External audit readiness
The audit engine ships 108 mapped controls across the four major external frameworks:
- SOC 2 Type II — 31 TSC controls (CC + C + PI + P)
- ISO/IEC 27001:2022 — 41 Annex A controls
- FIPS 140-3 (CMVP) — 14 CAVP/FSM entries
- Common Criteria EAL 4+ — 22 SFRs + SARs
Each framework has an operational runbook (docs/compliance/runbook_*.md) and a CI workflow (.github/workflows/audit_evidence.yml) that emits the evidence ZIP on every release.
Try it in 30 seconds
pip install axon-lang # or: download the Rust binary from Releases
echo 'type PatientRecord compliance [HIPAA, GDPR] { ssn: String }
shield PHIShield { scan: [pii_leak] on_breach: halt severity: critical
compliance: [HIPAA, GDPR] }
axonendpoint Api { method: POST path: "/p" body: PatientRecord
execute: F output: PatientRecord shield: PHIShield
compliance: [HIPAA, GDPR] }
flow F(r: PatientRecord) -> PatientRecord {
step R { ask: "summarize" output: PatientRecord } }' > app.axon
axon check app.axon # compile-time compliance verification
axon dossier app.axon # regulatory posture JSON
axon audit app.axon --framework all # per-framework gap analysis
Remove the shield line and axon check fails with "endpoint 'Api' sends regulated type '{HIPAA, GDPR}' without a covering shield — ESK Fase 6.1 coverage rule". That failure is a type error, not a lint warning.
Reference programs
examples/healthcare_reference.axon— HIPAA + GDPR + GxP + SOC 2examples/banking_reference.axon— PCI_DSS + SOX + SOC 2examples/government_reference.axon— FISMA + NIST 800-53 + SOC 2examples/ui/healthcare_console.axon— UI built on top of the healthcare backend with compile-time κ-redacted rendersexamples/tool_dispatch.axon— flow-leveluse <Tool> on "${param}"native tool dispatch with request-parameter binding (§Fase 54)
Academic references
docs/paper_lambda_lineal_epistemico.md— λ-L-E calculus: Theorem 5.1 Stochastic Degenerative Soundnessdocs/paper_immune_v2.md— Cognitive Immune System with red-teaming metrics (F1 ≥ 0.80 per class)docs/paper_esk.md— Regulatory Type Theory for Cognitive Systems (Theorems 10.1–10.5)
Production Status
AXON v2.3.0 is production-ready. The full stack is cross-validated, 100% Rust + C23:
- ✅ 65+ cognitive + Cognitive-I/O primitives wired to the native runtime
- ✅ 285 HTTP routes tested end-to-end
- ✅ Seven native Rust LLM backends (Anthropic, OpenAI, Gemini, Kimi, GLM, Ollama, OpenRouter) with full async streaming
- ✅ Real-time streaming wire — SSE + NDJSON, type-driven transport inference, per-chunk algebraic-effect dispatch
- ✅ Session-typed WebSocket dialogue (v2.3.0) — declared
session+socket, statically-checked duality (Caires–Pfenning), credit-refined backpressure (Presburger discharge), typed reconnection via AAD-boundcognitive_statessnapshots, SSE-as-fragment unification - ✅ Multiparty projection (v2.3.0) —
GlobalType+project_all(Honda–Yoshida–Carbone safe-realizability gate) for n-agent skill/tool topologies - ✅
axonendpointas a first-class HTTP REST primitive — typed routes, body + output schema validation,Idempotency-Key, auth scopes - ✅
axonstorecognitive data plane — epistemically typed rows, HMAC-Merkle audit chains,Stream<Row>, capability-typed access - ✅ Compile-time regulatory compliance for HIPAA / PCI_DSS / GDPR / SOX / SOC 2 / ISO 27001 / FIPS / CC EAL 4+
- ✅ Cognitive immune system (anomaly detection + reflex + heal) paper-faithful
- ✅ Post-Quantum signatures: HMAC-SHA256 baseline + Ed25519 + ML-DSA-65 + Hybrid (NIST SP 800-208)
- ✅
axon-csysC23 kernels — FIPS-routable SHA-256 / HMAC-SHA256 / SIMD G.711 / BPE tokeniser / FSM dispatch (computed gotos) / buffer pool (207× faster than Vec<u8>) — standalone C23 with sanitizer-clean + valgrind-clean CI lanes - ✅ PostgreSQL persistence with migrations and health checks
- ✅ Structured observability (JSON logging + request tracing)
- ✅ LLM call resilience (retry + circuit breaker + fallback)
- ✅ 2,245 axon-lang + 535 axon-frontend + 13 axon-csys = 2,793 Rust tests; cross-stack zero-regression discipline. Python side is now a thin PyPI wrapper that downloads + invokes the native Rust binary (the language interpreter is 100% Rust/C23 — the Python suite was retired in Fase 40's Pure Silicon pivot).
- ✅ Zero "por ahora", zero "lo mínimo" — production-complete
Designed for cognitive AI applications that require formal semantics, reliability, epistemic rigor, and provable regulatory coverage.
persona LegalExpert {
domain: ["contract law", "IP", "corporate"]
tone: precise
confidence_threshold: 0.85
refuse_if: [speculation, unverifiable_claim]
}
anchor NoHallucination {
require: source_citation
confidence_floor: 0.75
unknown_response: "Insufficient information"
}
⚠️
enforceis the behavioral carrier in anchors. It is the ONLY anchor field injected as a direct behavioral directive to the LLM.require/rejectare post-generation validation constraints.descriptionis metadata-only — it does NOT reach the model. Useenforcefor text that must shape the model's behavior.
flow AnalyzeContract(doc: Document) -> StructuredReport {
step Extract {
probe doc for [parties, obligations, dates, penalties]
output: EntityMap
}
step Assess {
reason {
chain_of_thought: enabled
given: Extract.output
ask: "Are there ambiguous or risky clauses?"
depth: 3
}
output: RiskAnalysis
}
step Check {
validate Assess.output against: ContractSchema
if confidence < 0.8 -> refine(max_attempts: 2)
output: ValidatedAnalysis
}
step Report {
weave [Extract.output, Check.output]
format: StructuredReport
include: [summary, risks, recommendations]
}
}
Native Rust + C23 Runtime
AXON v2.3.0 ships a production-hardened 100% Rust + C23 native runtime server with 285+ HTTP routes, 65+ primitives wired to runtime, an algebraic-effects execution engine, a real-time SSE / NDJSON / session-typed WebSocket streaming wire, a full ℰMCP (Epistemic Model Context Protocol) implementation, PostgreSQL persistence, structured observability via tracing, LLM call resilience (retry + circuit breaker + fallback chains across seven native backends), and a complete native CLI (check, compile, run, serve, parse, dossier, sbom, audit, evidence-package, and more).
The Rust + C23 stack is the canonical implementation of the language. Fase 40 (Pure Silicon, v2.0.0) retired the Python interpreter — the original pip install axon-lang package is now a thin wrapper that downloads + invokes the native Rust binary. The FIPS-routable cryptographic + tokeniser kernels live in axon-csys as standalone C23 (no unsafe glue: _Generic-dispatched headers, [[nodiscard]] everywhere, sanitizer-clean + valgrind-clean CI lanes).
Production Foundation (Phase K):
- Observability: JSON structured logging with request tracing, daily log rotation, configurable levels
- Resilience: Exponential backoff retry, per-provider circuit breakers, configurable fallback chains across 7 LLM backends
- Persistence: Full PostgreSQL integration with embedded migrations, JSONB storage, in-memory fallback for development
Quickstart
# Build the native runtime
cd axon-rs
cargo build --release
# Start the server with default in-memory storage
cargo run --release -- --port 3000
# Or with PostgreSQL persistence + structured logging
DATABASE_URL="postgresql://user:pass@localhost/axon" \
cargo run --release -- \
--port 3000 \
--log-format json \
--log-file ./logs \
--database-url "$DATABASE_URL"
# Deploy a flow
curl -X POST http://localhost:3000/v1/deploy \
-H "Content-Type: application/json" \
-d '{"source": "flow analyze { step reason { prompt: \"Analyze the input\" } }", "backend": "stub"}'
# Execute
curl -X POST http://localhost:3000/v1/execute/analyze
# MCP endpoint (JSON-RPC 2.0)
curl -X POST http://localhost:3000/v1/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
Phase K — Production Hardening (v1.0.0 foundation)
AXON v1.0.0 launched with three production-critical systems that remain the foundation of every subsequent minor release:
1. Observability (K1)
- Structured logging via
tracingcrate with JSON output - Request tracing with UUID correlation (x-request-id header)
- Daily log rotation with configurable directory
- Configurable levels via
AXON_LOGenv or--log-levelCLI - Instrumentation on all LLM calls: backend, model, latency_ms, tokens_in/out
2. Resilience (K2)
- Exponential backoff retry (500ms base, 2.0x multiplier, 30s max, jitter)
- Per-provider circuit breaker (5 failures → Open, 30s cooldown → HalfOpen, 2 successes → Closed)
- Retry-After header respecting for rate limit hints
- Fallback chains (e.g., anthropic → openrouter → ollama)
- Error classification (retryable vs. terminal)
- Covers all 7 LLM backends: Anthropic, OpenAI, Gemini, Kimi, GLM, OpenRouter, Ollama
3. Persistence (K3-K4)
- PostgreSQL backend with full ACID semantics
- 12 domain tables (traces, sessions, daemons, audit_log, axon_stores, dataspaces, hibernations, event_history, execution_cache, cost_tracking, schedules, backend_registry)
- 15 performance indexes for query optimization
- Embedded migrations (zero external DB setup for development)
- UPSERT semantics for idempotent writes
- JSONB storage for nested structures
- In-memory fallback when
DATABASE_URLunset (perfect for development & CI/CD)
Write-through pattern ensures all state mutations (flows, sessions, daemons, hibernations) persist to PostgreSQL while maintaining fast in-process reads.
Architectural Decisions
Storage Pattern: StorageDispatcher Enum
- Uses concrete dispatch via
StorageDispatcherenum instead ofdyn Trait - Enables zero-cost abstraction:
PostgresBackendorInMemoryBackendat compile time - No runtime trait object overhead, full optimization from compiler
Async/Await Safety
- All storage operations are async, but never held across await points
- Mutex locks are released before database I/O
- Prevents deadlocks and enables high concurrency
Graceful Fallback
- Database connection failures don't crash the server
- Automatic fallback to
InMemoryBackend(with logging) - State persists in-memory for the process lifetime
- Clients experience no service interruption
Runtime Surface
| Surface | Count |
|---|---|
| HTTP API routes | 285 |
| Language primitives | 65+ (cognitive + Cognitive I/O) |
| LLM backends | 7 (anthropic, openai, gemini, kimi, glm, openrouter, ollama) — native async, all streaming |
| MCP tool types | 8 (flow, dataspace, axonstore, shield, corpus, compute, mandate, forge) |
| MCP resource types | 10 (traces, metrics, backends, flows, dataspaces, axonstores, shields, corpora, mandates, forges) |
| MCP workflow prompts | 5 (research, decide, secure_transfer, reflect, analyze_image) |
axon-lang (axon-rs) lib tests | 2,245 |
axon-frontend lib tests | 535 (incl. §41.a-c algebra + §41.h multiparty) |
axon-csys lib tests | 13 (Rust wrapper; C23 kernels exercised by cargo test + sanitizers/valgrind in CI) |
| Rust workspace total | 2,793 — zero regressions |
| Python wrapper tests | 16 (the thin PyPI wrapper that downloads + invokes the native binary; the interpreter was retired in Fase 40) |
| SQL tables | 12 (traces, sessions, daemons, audit_log, axon_stores, dataspaces, hibernations, event_history, execution_cache, cost_tracking, schedules, backend_registry) |
| Performance indexes | 15 |
ΛD (Lambda Data) — Epistemic Guarantees
Every AXON operation carries a formal epistemic envelope ψ = ⟨T, V, E=⟨c, τ, ρ, δ⟩⟩:
- Theorem 5.1: Only raw data may carry certainty c=1.0; all derived operations cap at c≤0.99
- Epistemic Lattice: ⊥ ⊑ doubt ⊑ speculate ⊑ believe ⊑ know
- Blame Calculus: CT-2 (caller) / CT-3 (server) / Network attribution on every error
- CSP §5.3: MCP tools carry constraint satisfaction schemas
TypeScript SDK
import { AxonClient } from "@axon/mcp-client";
const client = new AxonClient({ baseUrl: "http://localhost:3000" });
await client.initialize();
// Discover and call tools
const tools = await client.listTools();
const result = await client.callTool("axon_compute_evaluate", { expression: "pi * 2" });
const envelope = AxonClient.extractEnvelope(result);
console.log(envelope?.certainty); // 0.99 (transcendental → derived)
// Read resources
const backends = await client.readResource("axon://backends");
// Get workflow prompts
const prompt = await client.getPrompt("workflow:research", { question: "How does attention work?" });
Full language specification: docs/axon_language_specification.md
Paradigm Shifts
AXON's compiler-level paradigm shifts elevate the language from prompt compilation to a Cognitive Operating System.
I. Formal Model — Epistemic Constraint Calculus
Each program P in AXON operates over a typed epistemic lattice (T, ≤) where
the compiler enforces semantic constraints at compile time. The paradigm shifts
extend this with three new formal mechanisms:
Epistemic Scoping Function. Given an epistemic mode
m ∈ {know, believe, speculate, doubt}, the compiler applies a constraint
function C(m) that maps to a tuple of LLM parameters and auto-injected
anchors:
C : Mode → (τ, p, A)
where
τ ∈ [0,1] — temperature override
p ∈ [0,1] — nucleus sampling (top_p)
A ⊆ Anchors — auto-injected constraint set
C(know) = (0.1, 0.3, {RequiresCitation, NoHallucination})
C(believe) = (0.3, 0.5, {NoHallucination})
C(speculate) = (0.9, 0.95, ∅)
C(doubt) = (0.2, 0.4, {RequiresCitation, SyllogismChecker})
This is calculated at compile time — the IR carries the resolved constraint set, so the executor applies them as zero-cost runtime overrides.
Parallel DAG Scheduling. A par block B = {b₁, ..., bₙ} where n ≥ 2 is
verified at compile time to have no data dependencies between branches:
∀ bᵢ, bⱼ ∈ B, i ≠ j : deps(bᵢ) ∩ outputs(bⱼ) = ∅
At runtime, branches execute via asyncio.gather, achieving O(max(tᵢ))
latency instead of O(Σtᵢ) for sequential chains.
CPS Continuation Points. A hibernate node generates a deterministic
continuation ID via SHA-256(flow_name ∥ event_name ∥ source_position). The
executor serializes the full ExecutionState (call stack, step results, context
variables) and halts. On resume(continuation_id), the state is deserialized
and execution continues from the exact IR node — implementing
Continuation-Passing Style at the language level.
II. Design Philosophy — Programming Epistemic States
Traditional LLM frameworks treat every model call identically — the same temperature, the same constraints, the same trust level. This is the equivalent of asking a human to treat brainstorming and sworn testimony with the same cognitive rigor.
AXON rejects this flat model. Epistemic Directives make the confidence state of the AI a first-class construct in the language:
know {
flow ExtractFacts(doc: Document) -> CitedFact {
step Verify { ask: "Extract only verifiable facts" output: CitedFact }
}
}
speculate {
flow Brainstorm(topic: String) -> Opinion {
step Imagine { ask: "What could be possible?" output: Opinion }
}
}
The compiler does not merely label these blocks — it structurally transforms
them. A know block injects citation anchors and drops temperature to 0.1,
making hallucination a compile-time constraint violation. A speculate block
removes all constraints and raises temperature to 0.9, liberating the model.
Parallel Cognitive Dispatch mirrors how human organizations work: delegate independent analyses to specialists concurrently, then synthesize.
Dynamic State Yielding transforms agents from expensive while True loops
into event-driven processes that can sleep for days, weeks, or months — then
resume with full context. The language handles the serialization; the developer
writes hibernate until "event_name" and moves on.
III. Real-World Use Cases
Use Case 1: Legal Document Analysis Pipeline
A law firm needs to analyze contracts with maximum factual rigor, while also exploring creative legal strategies. AXON separates these cognitive modes at the language level:
know {
flow ExtractClauses(contract: Document) -> ClauseMap {
step Parse { probe contract for [parties, obligations, penalties] output: ClauseMap }
}
}
flow AnalyzeRisk(contract: Document) -> StructuredReport {
par {
step Financial { ask: "Analyze financial exposure" output: RiskScore }
step Regulatory { ask: "Check regulatory compliance" output: ComplianceReport }
step Precedent { ask: "Find relevant case law" output: CaseList }
}
weave [Financial, Regulatory, Precedent] into Report { format: StructuredReport }
}
speculate {
flow ExploreStrategies(report: StructuredReport) -> Opinion {
step Creative { ask: "What unconventional strategies could mitigate these risks?" output: Opinion }
}
}
knowguarantees citation-backed extraction (temperature 0.1)parruns 3 analyses concurrently, reducing latency by ~3xspeculateexplicitly relaxes constraints for creative strategy exploration
Use Case 2: Multi-Agent Research & Intelligence System
A BI platform deploys autonomous research agents that run for weeks, hibernating between data collection phases:
flow MarketIntelligence(sector: String) -> Report {
know {
flow GatherData(sector: String) -> DataSet {
step Collect { ask: "Gather verified market data" output: DataSet }
}
}
par {
step Trends { ask: "Identify emerging trends" output: TrendAnalysis }
step Competitors { ask: "Map competitor landscape" output: CompetitorMap }
}
hibernate until "quarterly_data_available"
doubt {
flow ValidateFindings(data: DataSet) -> ValidatedReport {
step CrossCheck { ask: "Challenge every assumption with evidence" output: ValidatedReport }
}
}
weave [Trends, Competitors] into Final { format: Report }
}
- Agent hibernates after initial analysis, costing $0 while waiting
- Resumes automatically when quarterly data arrives (webhook/cron)
doubtmode forces adversarial validation with syllogism checking
Use Case 3: Autonomous Customer Support with Escalation
A SaaS platform handles support tickets with different confidence requirements and automatic escalation via hibernate:
persona SupportAgent {
domain: ["product knowledge", "troubleshooting"]
tone: empathetic
confidence_threshold: 0.8
}
flow HandleTicket(ticket: String) -> Resolution {
know {
flow DiagnoseIssue(ticket: String) -> Diagnosis {
step Classify { ask: "Classify the issue type and severity" output: Diagnosis }
}
}
believe {
flow SuggestSolution(diagnosis: Diagnosis) -> Solution {
step Solve { ask: "Propose a solution based on known patterns" output: Solution }
}
}
if confidence < 0.7 -> hibernate until "human_review_complete"
step Respond { ask: "Draft customer response" output: Resolution }
}
knowclassifies with strict accuracy (no guessing on severity)believesuggests solutions with moderate confidence- Low confidence triggers
hibernate— agent sleeps until a human reviews - Zero compute cost during human review; resumes with full context
IV. Directed Creative Synthesis — the forge Primitive
AXON introduces a sixth paradigm shift: mathematical formalization of the creative process inside LLMs.
The industry suffers from a structural limitation: LLMs can interpolate, but
they struggle to create. forge addresses this by implementing a
compiler-level Poincaré pipeline — the same 4-phase process mathematicians
and scientists use when producing genuinely novel work.
Poincaré-Hadamard Creative Pipeline. A forge block orchestrates four
sequential phases, each mapped to a distinct LLM configuration:
forge(seed, mode, novelty, depth, branches) → result
Phase 1: PREPARATION — Expand the seed via context probing
Phase 2: INCUBATION — Speculative exploration (depth iterations)
Phase 3: ILLUMINATION — Best-of-N consensus crystallization
Phase 4: VERIFICATION — Adversarial doubt + anchor validation
Boden Creativity Taxonomy. The mode parameter maps Margaret Boden's three
creativity types (The Creative Mind, 1990) to concrete sampling-parameter
profiles at compile time:
B : Mode → (τ_base, freedom, rule_flexibility)
B(combinatorial) = (0.9, 0.8, 0.3) — novel recombination of known ideas
B(exploratory) = (0.7, 0.6, 0.5) — structured navigation of possibility spaces
B(transformational) = (1.2, 1.0, 0.9) — rule-breaking synthesis, new paradigms
Novelty, measured — not asserted. Kolmogorov complexity K(x) is
uncomputable, so novelty cannot be computed exactly. forge measures it with
the Normalized Compression Distance — the standard computable approximation
of the Normalized Information Distance, a universal metric grounded in Kolmogorov
complexity (Li, Chen, Li, Ma, Vitányi, IEEE TIT 2004):
NCD(x, y) = [C(xy) − min(C(x), C(y))] / max(C(x), C(y))
ν(output) = NCD(baseline, output) — how much of the output is NOT
already implied by the obvious
reading of the seed
The novelty parameter (0.0–1.0) both blends the incubation temperature AND sets
the fail-closed floor the final output must clear:
τ_eff = τ_base × (0.5 + 0.5 × novelty)
novelty = 0.0 → τ_eff = 0.5 × τ_base (conservative, high utility)
novelty = 1.0 → τ_eff = 1.0 × τ_base (maximum divergence, high surprise)
Usage example — Directed Creative Synthesis:
anchor GoldenRatio {
require: aesthetic_harmony
confidence_floor: 0.70
}
flow CreateVisualConcept(brief: String) -> Visual {
forge Artwork(seed: "aurora borealis over ancient ruins") -> Visual {
mode: transformational
novelty: 0.85
constraints: GoldenRatio
depth: 4
branches: 7
}
}
run CreateVisualConcept("Create a visual concept for a film poster")
What the compiler does:
- Preparation — expands "aurora borealis over ancient ruins" into a rich conceptual foundation via context probing
- Incubation — runs 4 iterations of speculative exploration at
τ_eff = 1.2 × 0.925 = 1.11, pushing beyond obvious associations - Illumination — launches 7 parallel branches, each crystallizing the incubated ideas, then selects the most coherent output (Best-of-N)
- Verification — measures the winning branch's novelty ν = NCD(baseline,
output) and enforces it fail-closed: if ν is below the floor set by
novelty, the forge does NOT return a derivative result — it fails with a structuredforge.novelty_floor_breachederror. Only a synthesis that provably cleared the measured novelty floor (and itsGoldenRatioanchor) is returned.
This is not a prompt template. forge compiles to structured IR metadata
(IRForgeBlock — seed, mode, novelty, depth, branches, constraints) that the
runtime executes as the orchestrated four-phase pipeline above, with a
ForgeSoundness proof-carrying-code certificate checked at the deploy gate. And
unlike every prompt-based "creative mode," its novelty is measured (NCD) and
enforced fail-closed — a derivative result is never passed off as creative.
Honest scope.
forgesynthesizes a typed concept/specification, not a rendered artifact; "novelty" is novelty-relative-to-the-obvious-baseline (a computable proxy for the uncomputable Kolmogorov novelty), not a claim of absolute unprecedentedness. Seedocs/fase/fase_86_forge_creative_synthesis.mdfor the full mathematics and deferred scope.
V. Autonomous Goal-Seeking — the agent Primitive
AXON introduces a seventh paradigm shift: compiler-verified autonomous agents grounded in the Belief-Desire-Intention (BDI) architecture, epistemic logic, and coinductive semantics.
Every existing LLM framework implements agents as Python classes with ad-hoc
while-loops, hidden state machines, and zero formal guarantees. LangChain's
AgentExecutor is a runtime artifact — it cannot be statically analyzed, type-
checked, or budget-bounded at compile time. AXON's agent primitive makes
autonomous goal-seeking a first-class compiled construct with mathematical
semantics.
BDI Coinductive Semantics. An agent declaration compiles to a coinductive
BDI system — a state machine whose behavior is defined by an infinite
observation/transition pair over the epistemic lattice:
Agent ≅ ν X. (S × (Action → X))
where
S = Beliefs × Goals × Plans — cognitive state
Action = Observe | Deliberate | Act | Reflect
ν = greatest fixpoint (coinduction — runs indefinitely)
The ν (nu) operator is the key: unlike inductive data (finite trees), a
coinductive agent is a potentially infinite stream of state transitions,
terminating only when the goal is achieved or a budget is exhausted. This
formalization is not decorative — it determines the compiler's verification
strategy and the executor's loop semantics.
Epistemic Lattice Convergence. At each BDI cycle, the agent's epistemic
state is projected onto the same lattice (T, ≤) used by epistemic directives.
The deliberation phase produces a state σ ∈ {know, believe, speculate, doubt}
and a boolean goal_achieved. The convergence criterion is:
Converge(σ, g) = g = true ∧ σ ≥ believe
Diverge(σ, i, n) = σ = doubt ∧ Δσ = 0 ∧ i ≥ n
where
Δσ = σᵢ - σᵢ₋₁ — epistemic progress between cycles
i = current iteration
n = stuck_window — consecutive stagnation threshold
When Converge fires, the agent terminates successfully. When Diverge fires,
the on_stuck recovery policy activates — escalate raises AgentStuckError,
forge triggers creative re-seeding via the Poincaré pipeline, retry resets
and re-attempts.
Budget Composition. Budget constraints compose from the IR into the runtime as a 4-tuple verified at compile time:
B(agent) = (max_iter, max_tokens, max_time, max_cost)
Terminate when: ∃ b ∈ B(agent) : consumed(b) ≥ limit(b)
The compiler rejects agents with unbounded budgets (max_iterations = 0 without
an explicit on_stuck policy), preventing runaway execution by construction.
Strategy Dispatch. The strategy parameter selects the BDI loop variant at
compile time. Each strategy maps to a specific deliberation/action sequence:
Λ : Strategy → CycleShape
Λ(react) = Deliberate → Act → Observe
Λ(reflexion) = Deliberate → Act → Observe → Reflect
Λ(plan_and_execute) = Plan → (Act → Observe)* → Verify
Λ(custom) = user-defined step sequence
Usage example — Autonomous Research Agent:
persona ResearchAnalyst {
domain: ["market research", "competitive analysis"]
tone: analytical
confidence_threshold: 0.85
}
tool WebSearch {
provider: serper
timeout: 10s
}
tool DataAnalyzer {
provider: internal
timeout: 30s
}
agent MarketResearcher {
goal: "Produce a comprehensive competitive analysis report
with verified data from at least 5 sources"
tools: [WebSearch, DataAnalyzer]
strategy: react
max_iterations: 15
max_tokens: 50000
max_cost: 2.50
on_stuck: forge
return: CompetitiveReport
}
flow CompetitiveIntelligence(sector: String) -> CompetitiveReport {
step Research {
MarketResearcher(sector)
output: CompetitiveReport
}
}
run CompetitiveIntelligence("electric vehicles")
with ResearchAnalyst
What the compiler does:
- IR Generation — the
agentblock compiles to anIRAgentnode containing goal, tools, budget (15 iter / 50k tokens / $2.50), strategy (react), and recovery policy (forge). TheIRAgentis embedded as a step insideIRFlow, preserving compositional semantics. - Backend Compilation — the backend (Anthropic, Gemini) generates a
CompiledStepwithstep_name: "agent:MarketResearcher"and full agent metadata in itsmetadata["agent"]dictionary. The system prompt includes persona traits, tool availability, and epistemic constraints. - Runtime Execution — the executor detects
agent:prefix and dispatches to the BDI loop. Each cycle: deliberate (epistemic assessment via JSON), act (execute step or invoke tool), observe (update beliefs). The loop respects the budget 4-tuple and applieson_stuckwhenDivergefires. - Trace Events — every BDI cycle emits
STEP_START,MODEL_CALL, andSTEP_ENDtrace events, giving full observability into the agent's reasoning trajectory.
Why this matters: The agent is not a Python class that wraps while True.
It is a compiled cognitive primitive — the compiler verifies its budget
boundedness, the type checker validates its return type, the backend generates
strategy-specific prompts, and the runtime executes a formally-defined BDI loop
with epistemic convergence criteria. This is the difference between duct-taping
an LLM into a loop and engineering an autonomous system with mathematical
guarantees.
Agent Use Case 1: Autonomous Legal Research Agent
A law firm deploys an agent that autonomously researches case law until it finds sufficient precedent — or exhausts its budget and escalates to a human attorney:
agent CaseLawResearcher {
goal: "Find 3+ relevant precedents for the contract dispute
with verified court citations"
tools: [WebSearch, PDFExtractor]
strategy: reflexion
max_iterations: 20
max_cost: 5.00
on_stuck: escalate
return: CaseLawReport
}
reflexionstrategy adds self-critique after each cycle — the agent evaluates whether its found precedents are truly relevant, not just keyword matcheson_stuck: escalatemeans if the agent doubts its findings after 20 cycles, it raisesAgentStuckErrorwith full context, so the human reviews exactly where the agent got stuck- Budget cap of $5.00 prevents runaway API costs — the compiler guarantees termination
Agent Use Case 2: Multi-Agent Data Pipeline
A BI platform chains two agents: one gathers data, the other analyzes it. Both execute within the same compiled flow:
agent DataGatherer {
goal: "Collect quarterly revenue data from public filings"
tools: [WebSearch, FileReader]
strategy: react
max_iterations: 10
on_stuck: retry
return: DataSet
}
agent TrendAnalyzer {
goal: "Identify year-over-year growth patterns and anomalies"
tools: [Calculator, DataAnalyzer]
strategy: plan_and_execute
max_iterations: 8
on_stuck: forge
return: TrendReport
}
flow QuarterlyIntelligence(sector: String) -> TrendReport {
step Gather { DataGatherer(sector) output: DataSet }
step Analyze { TrendAnalyzer(Gather.output) output: TrendReport }
}
- Two agents, two strategies:
reactfor data gathering (fast, tool-heavy),plan_and_executefor analysis (structured, plan-then-verify) - Each agent has independent budget tracking — if
DataGatherercosts $0.50,TrendAnalyzerstill has its full budget - If
TrendAnalyzergets stuck,forgetriggers creative re-seeding via the Poincaré pipeline, generating novel analytical angles
Agent Use Case 3: Customer Onboarding Agent with Dynamic Recovery
A SaaS platform uses an agent to guide new customers through a personalized onboarding flow, adapting when it gets stuck:
persona OnboardingSpecialist {
domain: ["product knowledge", "user experience"]
tone: warm
confidence_threshold: 0.80
}
agent OnboardingGuide {
goal: "Complete the customer's onboarding checklist with
personalized recommendations for their industry"
tools: [APICall, Calculator]
strategy: custom
max_iterations: 12
max_tokens: 30000
on_stuck: forge
return: OnboardingReport
step Greet { ask: "Welcome the user and assess their goals" }
step Configure { ask: "Recommend workspace configuration" }
step Train { ask: "Generate personalized tutorial sequence" }
}
customstrategy: the agent follows a user-defined step sequence (Greet → Configure → Train), not a generic loopon_stuck: forge— if the agent can't personalize recommendations (e.g., unknown industry), it triggers creative synthesis to propose novel onboarding paths instead of failing- The
return: OnboardingReporttype is validated by the semantic type checker — the agent must produce a structurally valid report, not just free text
VI. Compile-Time Security — the shield Primitive
AXON introduces an eighth paradigm shift: Information Flow Control (IFC) as a first-class compiled construct, providing compile-time security guarantees against LLM-specific attack vectors.
Every LLM framework treats security as an afterthought — runtime guardrails
bolted on top of applications. AXON's shield primitive makes security a
compiler-verified property of your program, grounded in taint analysis and
Information Flow Control theory.
Trust Lattice (Denning-style IFC). The shield system operates over a trust lattice where data flows from untrusted sources through shield application points to trusted sinks. The compiler statically verifies that every path from an untrusted source to a trusted sink passes through at least one shield:
U : DataLabel → TrustLevel
TrustLevel = Untrusted < Scanned < Sanitized < Trusted
∀ path(source, sink) ∈ Flow :
label(source) = Untrusted ∧ label(sink) = Trusted
→ ∃ shield ∈ path : label(shield.output) ≥ Sanitized
Threat Taxonomy. The scan field declares which threats the shield detects,
drawn from a formal taxonomy of 11 LLM attack categories:
T = { prompt_injection, jailbreak, data_exfil, pii_leak, toxicity,
bias, hallucination, code_injection, social_engineering,
model_theft, training_poisoning }
Detection Strategies. The strategy parameter selects the detection
mechanism, each with different cost/accuracy tradeoffs:
Σ : Strategy → (Cost, Accuracy, Latency)
Σ(pattern) = (low, medium, fast) — regex/heuristic scan
Σ(classifier) = (medium, high, medium) — fine-tuned classifier (Llama Guard)
Σ(dual_llm) = (high, highest, slow) — privileged/quarantined model pair
Σ(canary) = (low, medium, fast) — traceable token injection
Σ(perplexity) = (medium, high, medium) — statistical anomaly detection
Σ(ensemble) = (high, highest, slow) — majority voting across multiple strategies
Capability Enforcement. The compiler statically verifies that agent tool access is a subset of the shield's allow list — preventing privilege escalation at compile time:
∀ agent A with shield S :
tools(A) ⊆ allow_tools(S) — verified at compile time
tools(A) ∩ deny_tools(S) = ∅ — also verified
Usage example — LLM Input Shield:
shield InputGuard {
scan: [prompt_injection, jailbreak, pii_leak]
strategy: dual_llm
on_breach: halt
severity: critical
allow: [web_search, calculator]
deny: [code_executor]
sandbox: true
redact: [email, phone]
confidence_threshold: 0.85
}
persona SecureAssistant {
domain: ["customer support"]
tone: professional
confidence_threshold: 0.80
}
agent SecureBot {
goal: "Answer customer queries safely"
tools: [web_search, calculator]
shield: InputGuard
strategy: react
max_iterations: 10
return: SafeResponse
}
flow SecureSupport(query: String) -> SafeResponse {
shield InputGuard on query -> SanitizedQuery
step Process {
SecureBot(SanitizedQuery)
output: SafeResponse
}
}
run SecureSupport("Help me with my account")
with SecureAssistant
What the compiler does:
- Type Checking — validates all scan categories, strategies, breach policies, severity levels, and confidence thresholds. Detects allow/deny overlaps and invalid configurations at compile time.
- Capability Enforcement — verifies that
SecureBotonly uses[web_search, calculator]which are inInputGuard.allow, and that neither appears indeny. IfSecureBottried to usecode_executor, the compiler would reject the program. - Taint Analysis — verifies that
query(untrusted) passes throughshield InputGuard on querybefore reaching the agent's trusted context. - Runtime Execution — the shield step emits
SHIELD_SCAN_START, scans for prompt injection/jailbreak/PII, and either passes (SHIELD_SCAN_PASS) or raisesShieldBreachError(SHIELD_SCAN_BREACH).
Shield Use Case 1: Financial Data Pipeline with PII Redaction
shield DataShield {
scan: [pii_leak, data_exfil]
strategy: classifier
on_breach: sanitize_and_retry
max_retries: 3
severity: high
redact: [ssn, credit_card, bank_account]
}
flow ProcessFinancialQuery(input: String) -> Report {
shield DataShield on input -> CleanInput
step Analyze {
given: CleanInput
ask: "Analyze the financial data"
output: Report
}
}
- PII fields (SSN, credit card, bank account) are auto-redacted before the LLM sees the data
sanitize_and_retrymeans detected threats are cleaned and re-scanned up to 3 times, not just blocked- The compiler guarantees the LLM never processes raw PII
Shield Use Case 2: Multi-Agent System with Capability Isolation
shield ResearchShield {
scan: [data_exfil, model_theft]
strategy: ensemble
on_breach: quarantine
allow: [web_search, file_reader]
deny: [code_executor, api_call]
sandbox: true
}
agent Researcher {
goal: "Gather market intelligence from public sources"
tools: [web_search, file_reader]
shield: ResearchShield
strategy: reflexion
max_iterations: 15
return: IntelligenceReport
}
ensemblestrategy runs multiple detectors with majority voting — highest accuracy for sensitive operationssandbox: trueruns tool execution in an isolated environment- Capability enforcement: the compiler rejects any agent that tries to use
code_executororapi_call— preventing privilege escalation by design quarantinebreach policy isolates suspicious data for human review instead of blocking operations
VII. Epistemic Tool Fortification — Streaming, Effects & Blame Semantics
AXON introduces a ninth paradigm shift: formal epistemic control over tool invocations, streaming outputs, and foreign-function interfaces — backed by algebraic effect theory, coinductive stream semantics, and Findler-Felleisen blame calculus. The
streamprimitive decouples pure deliberation from the I/O mechanism.
The Hard Argument (Computational Decoupling)
In pragmatic software engineering, Python generators (yield and async for) have become the standard for data streaming. However, under the rigor of formal language theory and category mathematics, this approach has a structural flaw: it inextricably couples "deliberation" (data generation) with the "I/O mechanism" (transmission). AXON resolves this by applying Algebraic Effects and Handlers to streaming. The stream primitive no longer executes I/O; it yields a pure effect (YieldChunk(data)), suspending the continuation k. An external Handler (e.g., SSEHandler) intercepts the effect, executes the I/O side-effect, and then resumes k. This mathematical decoupling ensures the generative core remains functionally pure and independently testable.
The Sweet Argument (Why it's awesome)
Imagine writing streaming logic without ever worrying about the HTTP connection! With the renewed stream primitive, your AI agents don't "push bytes"—they express pure conceptual intentions. You just write your LLM generation logic in the cleanest way possible. Want to switch from Server-Sent Events (SSE) to WebSockets, or maybe just log to a file? The agent code doesn't change a single character! You simply swap the Handler. Your codebase becomes incredibly pristine, blazingly fast to test, and theoretically invincible. It makes streaming feel like pure magic backed by hardcore category theory.
Real-World Use Cases
- Agentic Server-Sent Events (SSE): Stream an agent's intermediate "thoughts" and reasoning steps directly to a React frontend in real-time. If the client drops the connection, the handler manages the disconnection gracefully without crashing the agent's pure deliberation cycle.
- Multi-Channel Orchestration: A single
streamcomputation can be intercepted by a composite handler that simultaneously prints chunks to a CLI, broadcasts to an SSE channel, and persists the flow to a Redis database—all while the business logic remains fully unaware of these I/O burdens. - Deterministic Testing Pipelines: In your CI/CD pipelines, the I/O handler can be instantly swapped out for a
MockHandlerthat accumulates chunks synchronously in memory. This eliminates flaky network-bound streaming tests entirely, allowing you to test complex LLM streaming flows in microseconds.
Every LLM framework treats tool calls as black boxes: a function returns a string, and the framework trusts it unconditionally. Streaming is even worse — partial tokens arrive without any notion of confidence, reliability, or epistemic state. AXON solves this by making every interaction with the external world subject to formal epistemic tracking.
Formal Model — Four Convergence Theorems
CT-1: Coinductive Semantic Streaming. A streaming response is a coinductive process — an infinite observation/transition pair that monotonically accumulates epistemic confidence as chunks arrive:
Stream(τ) = νX. (StreamChunk × EpistemicState × X)
where
StreamChunk = (content: String, index: ℕ, timestamp: ℝ)
EpistemicState = (level ∈ {doubt, speculate, believe, know}, confidence ∈ [0,1])
ν = greatest fixpoint (coinduction — process unfolds indefinitely)
Monotonicity invariant:
∀ i < j : gradient(chunkᵢ) ⊑ gradient(chunkⱼ)
(epistemic level can only rise, never degrade during streaming)
Streaming in AXON is not "tokens arriving". It is a formal epistemic process: each chunk carries its position on the lattice, and the system guarantees that confidence can only increase monotonically until convergence.
CT-2: Algebraic Effect Rows. Every tool declares its computational effects using Plotkin & Pretnar's algebraic effect theory. The compiler statically verifies effect compatibility:
EffectRow(tool) = ⟨ε₁, ε₂, ..., εₙ, epistemic:level⟩
where
εᵢ ∈ {pure, io, network, storage, random}
level ∈ {know, believe, speculate, doubt}
Composition rule:
EffectRow(A ∘ B) = EffectRow(A) ∪ EffectRow(B)
epistemic(A ∘ B) = min(epistemic(A), epistemic(B)) — meet on lattice
The composition rule means: if you chain a network + speculate tool with a
pure + know tool, the combined effect is network + speculate — the system
automatically tracks the least trustworthy component.
CT-3: Blame Semantics for FFI. External tool calls are wrapped in Findler-Felleisen contract monitors that assign blame when pre/postconditions fail:
ContractMonitor(tool) = (Pre, Post, Blame)
where
Pre : Input → Bool — caller's obligation
Post : Output → Bool — server's obligation
Blame : {CALLER, SERVER} — who violated the contract
Blame assignment:
¬Pre(input) → Blame = CALLER (you sent bad data)
¬Post(output) → Blame = SERVER (tool returned bad data)
This is not error handling — this is formal accountability. When a tool fails, AXON tells you who broke the contract, not just that it broke.
CT-4: Epistemic Inference via CSP. The @csp_tool decorator automatically
infers the epistemic level of any Python function by analyzing its effect
footprint using a constraint-satisfaction heuristic:
Infer(f) : Function → EpistemicLevel
If ∄ io/network/random ∈ effects(f) → know
If ∃ network ∈ effects(f) → speculate
If ∃ random ∈ effects(f) → doubt
Otherwise → believe
What Makes This Revolutionary
No LLM framework in existence tracks what a tool does to your epistemic state. LangChain, CrewAI, AutoGen — they all treat tool results as trusted strings. This means:
- A web search result (unreliable) gets the same trust as a database query (reliable)
- A streaming response's first token gets the same trust as the final, validated output
- When a tool fails, you don't know if your input was wrong or the tool was broken
AXON solves all three. The compiler guarantees that:
- Every tool call is tagged with its effect signature and epistemic level
- Streaming outputs start at
doubtand can only ascend monotonically - Tool failures carry blame labels that identify the responsible party
- Data crossing the FFI boundary is automatically tainted — it cannot
reach
knowlevel without passing through a shield or anchor
Use Case 1: Real-Time Financial Streaming with Epistemic Gradient
A trading desk receives streaming market data and needs to distinguish between real-time quotes (speculative) and confirmed trades (factual):
tool MarketFeed {
provider: bloomberg
timeout: 5s
effects: <io, network, epistemic:speculate>
}
flow MonitorMarket(sector: String) -> MarketReport {
step Stream {
stream<QuoteData> {
on_chunk: {
probe chunk for [symbol, price, volume]
output: QuoteSnapshot
}
on_complete: {
validate QuoteSnapshot against: MarketSchema
output: VerifiedQuote
}
}
}
step Analyze {
reason {
given: Stream.output
ask: "Identify anomalous price movements"
depth: 2
}
output: MarketReport
}
}
- Each streaming chunk starts at
doubt— the system treats partial data as unreliable by default on_completehandler validates and promotes tobelieve— only complete, schema-validated data upgrades- The
effects: <io, network, epistemic:speculate>declaration means the compiler knows this tool is never factual — preventing accidentalknow-level assertions from market data
Use Case 2: Multi-Tool Research Agent with Blame Tracking
A research agent uses multiple tools with different reliability levels. When something fails, the system identifies exactly who broke the contract:
tool WebSearch {
provider: serper
timeout: 10s
effects: <network, epistemic:speculate>
}
tool DatabaseQuery {
provider: internal
timeout: 30s
effects: <io, epistemic:believe>
}
tool Calculator {
provider: stdlib
effects: <pure, epistemic:know>
}
flow DeepResearch(question: String) -> ResearchReport {
par {
step Web {
use_tool WebSearch with query: question
output: WebResults
}
step DB {
use_tool DatabaseQuery with query: question
output: DBResults
}
}
step Synthesize {
weave [Web.output, DB.output]
output: ResearchReport
}
}
WebSearchisepistemic:speculate— the compiler knows web results are unreliable and automatically taints downstream dataDatabaseQueryisepistemic:believe— more reliable, but still notknowbecause external I/O is involvedCalculatorispure + epistemic:know— no side effects, deterministic, fully trustworthy- When
weavecombines them, the result's epistemic level ismin(speculate, believe) = speculate— the weakest link determines trust - If
WebSearchreturns garbage, theContractMonitorissuesBlame = SERVERwith full diagnostic context
Use Case 3: Safe External API Integration with @contract_tool
A production system integrates a third-party payment API. The @contract_tool
decorator wraps it with pre/postcondition contracts and automatic epistemic
downgrade:
from axon.runtime.tools import contract_tool
@contract_tool(
pre=lambda amount, currency: amount > 0 and currency in ["USD", "EUR"],
post=lambda result: "transaction_id" in result,
effect_row=("network", "io"),
epistemic_level="speculate"
)
async def process_payment(amount: float, currency: str) -> dict:
return await stripe_api.charge(amount, currency)
flow ProcessOrder(order: Order) -> Receipt {
step Charge {
use_tool process_payment with amount: order.total, currency: "USD"
output: PaymentResult
}
step Verify {
validate Charge.output against: PaymentSchema
if confidence < 0.9 -> refine(max_attempts: 2)
output: Receipt
}
}
precontract: AXON validates thatamount > 0andcurrencyis valid before calling Stripe. If violated →Blame = CALLERpostcontract: AXON validates that the response contains atransaction_id. If violated →Blame = SERVER(Stripe returned bad data)- All payment results are automatically
tainted = True— they cannot reachknowlevel without explicit anchor validation - The
effects: <network, io>declaration prevents this tool from being used inside apurecontext — a compile-time error
VIII. Structured Cognitive Retrieval — the pix Primitive
AXON introduces a tenth paradigm shift: intent-driven tree navigation as a formally grounded alternative to vector-similarity retrieval (RAG), built on information foraging theory, bounded rational search, and full explainability via reasoning trails.
Every RAG system in existence makes the same assumption: semantically close embeddings imply relevance. This works for keyword-style queries, but fails catastrophically for structured documents — legal contracts, technical manuals, medical records — where the answer lives at a specific structural location, not in the nearest embedding vector.
AXON's pix primitive rejects the "embed everything, retrieve by cosine"
paradigm. Instead, it treats documents as navigable trees and retrieval as
a bounded cognitive search — the same process a human expert uses when
consulting a complex document: start at the table of contents, follow the most
promising branches, prune irrelevant paths, and explain every decision.
Formal Model — Rooted Directed Acyclic Tree (DAG→Tree)
Document Tree. A PIX-indexed document D is a rooted tree:
D = (N, E, n₀)
where
N = {n₀, n₁, ..., nₖ} — nodes (sections, subsections, paragraphs)
E ⊆ N × N — directed edges (parent → child)
n₀ ∈ N — root (document-level summary)
Properties:
∀ nᵢ ∈ N \ {n₀} : ∃! nⱼ : (nⱼ, nᵢ) ∈ E — unique parent
height(D) = h — maximum depth
|leaves(D)| = content nodes with full text
Each node carries a summary (generated at index time) and optionally the full section content. Internal nodes hold structure; leaf nodes hold answers.
Information Scent Navigation. Navigation follows Pirolli & Card's
Information Foraging Theory. At each tree level, a scoring function S
evaluates the "information scent" of every child relative to the query:
S : (query, title, summary) → [0, 1]
Navigation rule at depth d:
children_d = {nᵢ : (current, nᵢ) ∈ E}
scored = {(nᵢ, S(q, nᵢ.title, nᵢ.summary)) : nᵢ ∈ children_d}
selected = top_k(scored, k=max_branch) ∩ {(n, s) : s ≥ threshold}
Fallback (no child meets threshold):
selected = {argmax(scored)} if max(scored) > 0 else ∅
The key insight: the scorer replaces embedding similarity. In production it is an LLM call; in tests a keyword-overlap heuristic suffices. Either way, the navigator uses the same bounded-search algorithm.
Bounded Rational Search. Navigation terminates via a budget 4-tuple verified at compile time:
Config(pix) = (max_depth, max_branch, threshold, timeout)
Termination:
depth ≥ max_depth ∨ node.is_leaf ∨ elapsed ≥ timeout
→ append to result leaves
This prevents unbounded traversal — the same principle behind AXON's agent budget enforcement.
Reasoning Trail (Explainability). Every navigation produces a
ReasoningPath — an ordered sequence of NavigationStep records documenting
why each branch was selected or pruned:
Trail = [Step₁, Step₂, ..., Stepₙ]
Stepᵢ = (node_id, title, score, reasoning, depth)
Properties:
|Trail| = total nodes evaluated
depth(Trail) = max(Stepᵢ.depth)
This is not logging — it is formal explainability. The trail is a
first-class data structure accessible via the trail keyword.
What Makes PIX Different from RAG
| Property | RAG | PIX |
|---|---|---|
| Index structure | Flat vector store | Hierarchical tree |
| Retrieval method | Cosine similarity | Bounded tree navigation |
| Granularity | Fixed chunks | Structural sections |
| Explainability | None (black-box) | Full reasoning trail |
| Query type | Keyword/semantic | Intent-driven |
| Relevance model | "Closest vector" | "Most scented path" |
| Compile-time verification | ❌ | ✅ (depth, branching bounds) |
PIX principle: "Lo estructuralmente navegado con intención es lo relevante" — what matters is not what is semantically close, but what a rational agent would navigate to when consulting the document with purpose.
Usage Example — PIX-Navigated Legal Analysis
pix ContractIndex {
source: "contracts/master_agreement.md"
depth: 4
branching: 3
model: "fast"
}
flow AnalyzeContract(question: String) -> LegalAnalysis {
step Search {
navigate ContractIndex
query: question
trail: enabled
as: relevant_sections
}
step Drill {
drill ContractIndex
into "Liabilities"
query: question
as: liability_detail
}
step Explain {
trail relevant_sections
}
step Synthesize {
weave [relevant_sections, liability_detail]
format: LegalAnalysis
include: [answer, sources, reasoning_trail]
}
}
What the compiler does:
- Type Checking — validates
pixparameters (depth ≤ 10, branching ≤ 10), verifies thatnavigateanddrillreference a declaredpix(not apersonaorflow), and guarantees output bindings are unique - IR Generation — compiles to
IRPixSpec,IRNavigate,IRDrill, andIRTrailnodes carrying the full configuration (source, depth, branching, model, effects) - Runtime Execution — the PIX engine indexes the source document into a
DocumentTree, then the navigator performs bounded tree search guided by the scoring function, recording every decision in theReasoningPath - Trail Output — the
trailstep exposes the full reasoning path — every node evaluated, its score, and why it was selected or pruned
PIX Use Case 1: Medical Document Navigation
A hospital system needs to find specific clinical guidelines within a 200-page protocol manual. RAG would chunk the document into 512-token fragments and return the 5 closest embeddings — potentially mixing guidelines from different sections. PIX navigates structurally:
pix ClinicalProtocol {
source: "protocols/surgical_guidelines_v12.md"
depth: 5
branching: 2
model: "precise"
}
flow FindGuideline(procedure: String) -> ClinicalGuideline {
step Navigate {
navigate ClinicalProtocol
query: procedure
trail: enabled
as: guideline
}
step Verify {
validate guideline against: ClinicalSchema
if confidence < 0.9 -> refine(max_attempts: 2)
output: ClinicalGuideline
}
}
depth: 5allows reaching deeply nested subsections (Chapter → Section → Subsection → Paragraph → Note)branching: 2limits exploration to the 2 most relevant children per level — fast, focused retrieval- The trail documents exactly which sections were evaluated and why, which is required for medical audit compliance
PIX Use Case 2: Technical Documentation Q&A
A developer needs to find the exact API method for a specific task in a large SDK documentation. RAG returns 5 chunks that all mention the API but none answer the precise question. PIX drills directly:
pix SDKDocs {
source: "docs/sdk_reference_v3.md"
depth: 6
branching: 3
}
flow AnswerDevQuestion(question: String) -> DevAnswer {
step Browse {
navigate SDKDocs query: question as: overview
}
step Deep {
drill SDKDocs into "API Reference" query: question as: api_detail
}
step Respond {
weave [overview, api_detail]
format: DevAnswer
include: [answer, code_examples, see_also]
}
}
navigatefinds the general area;drillgoes directly into "API Reference"- Combined result gives both context (overview) and precision (api_detail)
- No embedding database needed — the document's own structure is the index
PIX Use Case 3: Regulatory Compliance Audit with Full Trail
A compliance team audits whether a company's data practices satisfy GDPR requirements. The trail provides the auditable decision chain:
pix GDPRRegulation {
source: "regulations/gdpr_full_text.md"
depth: 4
branching: 3
model: "precise"
}
know {
flow AuditCompliance(practice: String) -> ComplianceReport {
step Find {
navigate GDPRRegulation
query: practice
trail: enabled
as: articles
}
step ShowTrail {
trail articles
}
step Assess {
reason {
given: articles
ask: "Does the practice comply with these articles?"
depth: 3
}
output: ComplianceReport
}
}
}
knowblock ensures maximum factual rigor — no speculation about regulations- The
trailprovides a complete record of which GDPR articles were considered and why, satisfying regulatory audit requirements - No vector database, no embedding model, no chunking strategy to tune — the regulation's own hierarchical structure (Part → Chapter → Section → Article) is the retrieval mechanism
Epistemic Vision — Visual Perception for PIX
AXON extends PIX from document-only navigation to deterministic visual perception, treating images as structured data isomorphic to documents. No neural networks. No GPUs. No stochastic outputs. Pure mathematics — and it sees better than any "vision model" at structural tasks.
The Hard Argument — Pure Mathematics
The visual pipeline rests on three mathematically validated pillars:
1. Perona-Malik Anisotropic Diffusion (Regularized). Images are treated as signals on a Riemannian manifold. Noise reduction follows the Catté-Lions-Morel-Coll regularization of the Perona-Malik PDE:
∂u/∂t = div(g(|∇G_σ * u|²) · ∇u)
where
g(s) = 1 / (1 + s/λ²) — Lorentzian conductance (edge-preserving)
G_σ * u — Gaussian pre-smoothing (well-posedness)
CFL condition: Δt ≤ h²/4 — guaranteed numerical stability
This is not a filter — it is a PDE solver that provably converges to a piecewise-smooth signal while preserving edges. Every step is deterministic, reproducible, and CFL-stable.
2. Gabor Phase Encoding (Biomimetic V1). Oriented texture energy is computed via a bank of Gabor filters that model the primary visual cortex:
Ψ(x,y;θ,λ) = exp(-‖x'‖²/2σ²) · cos(2πx'/λ)
where
x' = x·cos(θ) + y·sin(θ) — rotated coordinates
θ ∈ {kπ/n : k = 0,...,n-1} — n orientations
λ ∈ geometric progression — spatial frequencies
The resulting energy map captures oriented structure at multiple scales — the same information a biological visual cortex extracts in its first 50ms.
3. Persistent Homology H₀ (Union-Find, O(N·α(N))). Topological structure is extracted via sublevel-set filtration using computational algebraic topology:
PH₀(f) = {(bᵢ, dᵢ)} — persistence diagram
where
bᵢ = birth value (component appears in sublevel set)
dᵢ = death value (component merges with older component)
β₀ = |{(b,d) : d - b ≥ ε}| — Betti number (significant components)
Persistence diagrams are compared via Bottleneck and Wasserstein distances, providing a metric space over topological signatures. The Union-Find algorithm runs in near-linear time O(N·α(N)), where α is the inverse Ackermann function.
The Sweet Argument — Why This Is Genius
The PIX documental engine uses LLM calls for scoring — each navigation decision costs money, introduces latency, and is inherently non-reproducible.
The visual PIX uses pure mathematics for scoring:
Score(node) = σ(w₁·C_topo + w₂·P_total + w₃·E_gabor)
where
C_topo = β₀ + β₁ — topological complexity
P_total = Σ(dᵢ - bᵢ) — total persistence
E_gabor = mean Gabor energy — oriented texture richness
σ(x) = 1/(1 + e⁻ˣ) — sigmoidal normalization
The result:
- $0.00 per navigation — zero API calls, zero tokens consumed
- 100% reproducible — same image, same result, every time, forever
- Fully auditable — every score is a pure function of measurable quantities
- No GPU required — runs on any CPU, any platform, any environment
The document is a case of structured data. The image is another. PIX navigates
both with the same PixNavigator — the visual extension composes via an
adapter pattern (VisualTree → DocumentTree), reusing 100% of the navigation
logic with zero code duplication.
Three Use Cases
Use Case 1: Industrial Quality Control — Deterministic Defect Detection
A manufacturing plant inspects PCB boards. Traditional CV uses neural networks that require 10,000+ labeled images, a GPU cluster, and produce stochastic results. PIX Visual detects defects via topological invariants:
pix BoardInspector {
source: "camera://line_3"
mode: visual
depth: 3
branching: 4
}
know {
flow InspectBoard(image: Image) -> DefectReport {
step Perceive {
navigate BoardInspector
query: "Locate solder joint anomalies"
trail: enabled
as: regions
}
step Classify {
reason {
given: regions
ask: "Are these topological signatures consistent with known defect patterns?"
depth: 2
}
output: DefectReport
}
}
}
- β₀ anomalies (unexpected isolated components) flag missing solder joints
- Persistence outliers flag micro-cracks invisible to optical inspection
- Every detection is deterministic and auditable — critical for ISO 9001
- Zero training data, zero GPU, zero model drift
Use Case 2: Medical Imaging — Auditable Pathology Navigation
A pathology lab analyzes tissue biopsies. Regulatory compliance (FDA, CE) requires full traceability of every diagnostic decision. PIX Visual provides the reasoning trail that no neural network can:
pix TissueAnalyzer {
source: "pathology://slide_42"
mode: visual
depth: 4
branching: 3
model: "precise"
}
know {
flow AnalyzeBiopsy(slide: Image) -> PathologyReport {
step Survey {
navigate TissueAnalyzer
query: "Identify regions of cellular irregularity"
trail: enabled
as: findings
}
step DeepDive {
drill TissueAnalyzer
into findings.top_region
query: "Characterize cellular morphology"
as: morphology
}
step Report {
trail findings
weave [findings, morphology]
format: PathologyReport
include: [diagnosis, confidence, reasoning_trail]
}
}
}
- Persistent homology captures tissue topology (ductal structures, lobular patterns)
- The reasoning trail satisfies regulatory audit requirements
- Results reproducible across institutions — same slide, same diagnosis
- No black-box model to validate, no adversarial attacks possible
Use Case 3: Geospatial Intelligence — Satellite Imagery Analysis
A defense agency monitors infrastructure changes via satellite imagery. Classified environments prohibit cloud APIs and external model calls. PIX Visual runs entirely on-premise:
pix SatelliteWatch {
source: "geo://sector_7G"
mode: visual
depth: 5
branching: 4
}
flow MonitorChanges(before: Image, after: Image) -> ChangeReport {
par {
step Baseline {
navigate SatelliteWatch query: "Extract structural features" as: baseline
}
step Current {
navigate SatelliteWatch query: "Extract structural features" as: current
}
}
step Compare {
reason {
given: [baseline.topology, current.topology]
ask: "What structural changes occurred between acquisitions?"
depth: 3
}
output: ChangeReport
}
}
- Topological comparison detects structural changes (new buildings, roads, excavations)
- Runs 100% air-gapped — no cloud APIs, no data exfiltration risk
- Bottleneck distance between persistence diagrams quantifies change magnitude
- Parallel navigation compares before/after in O(max(t₁, t₂)) latency
IX. Multi-Document Navigation — the corpus Primitive
AXON introduces an eleventh paradigm shift: formal cross-document navigation with provenance guarantees, epistemic typing, and graph-theoretic bounded reachability — the first retrieval framework with mathematical proofs of soundness, termination, and information convergence.
Every existing retrieval system treats documents as independent objects: embed them, rank them by cosine similarity, return a flat list. This works for keyword queries. It fails catastrophically when the relationship between documents is the answer — a legal brief that cites a statute that cites a prior ruling, a medical diagnosis that cross-references clinical guidelines and lab protocols, a financial audit that chains regulatory filings with accounting standards.
AXON's corpus primitive treats document collections as typed directed
graphs and retrieval as bounded graph navigation with formal guarantees
that no existing framework provides.
A. Hard Mathematical Argument — Three Theorems
Definition 1 (Document Corpus Graph). A corpus is a 5-tuple
C = (D, R, τ, ω, σ) where:
D = {D₁, ..., Dₙ} — finite set of documents
R ⊆ D × D × L — labeled directed edges (cross-references)
τ : R → RelationType — edge type: cite | depend | contradict | elaborate | supersede
ω : R → (0, 1] — edge weight (relationship strength)
σ : D → EpistemicLevel — document epistemic status function
EpistemicLevel = Uncertainty ≤ ContestedClaim ≤ FactualClaim ≤ CitedFact ≤ CorroboratedFact
The ordering on EpistemicLevel encodes justification strength: A ≤ B iff
A is less justified or less informationally supported than B. This is a complete
lattice with ⊤ = CorroboratedFact, ⊥ = Uncertainty, and operations:
join(A, B) = sup{A, B} — strongest justified level (promotion)
meet(A, B) = inf{A, B} — most conservative level (aggregation)
Theorem 1 (Decidability + Bounded Complexity). The bounded graph
reachability problem for MDN is decidable in O(b̄ᵈ · C_eval) where b̄ is
the effective branching factor (typically 2–3 after pruning) and d is
max_depth.
Key insight: since d is a compile-time constant (typically 3–5), the
exponential factor is controlled. With information-gain pruning, practical
complexity is near-linear in corpus size.
Theorem 2 (Strict Information Gain). Under an ε-informative navigation policy, each step strictly reduces conditional entropy:
H(A | Q, D₀, ..., Dₖ) ≤ H(A | Q) - k · ε
where ε > 0 is the minimum information gain per step
Consequence: navigation terminates in at most k ≤ ⌈H(A|Q)/ε⌉ steps.
This is not a heuristic — it is an information-theoretic convergence proof.
Every step provably makes progress toward answering the query.
Theorem 3 (Epistemic PageRank Convergence). The epistemic-weighted PageRank
operator T on a corpus graph converges to a unique stationary distribution:
T(v)ᵢ = (1-α)/|D| + α · ∑ⱼ (ωⱼᵢ · σ(Dⱼ)) / ∑ₖ ωⱼₖ
where α ∈ (0,1) is the damping factor and σ(Dⱼ) is the epistemic weight
Convergence is guaranteed because T is a contraction mapping on the compact
space [0,1]ⁿ (Banach fixed-point theorem). Unlike standard PageRank, EPR
weights authority by epistemic status — a peer-reviewed study propagates more
authority than a contested claim.
B. Sweet Argument — Why This Changes Everything
The mathematical machinery above enables something no other system provides: provenance-guaranteed, epistemically-typed cross-document reasoning.
When AXON returns a result from multi-document navigation, you know:
-
Exactly which path the system followed — not just "these 5 documents are relevant" but "Document A cited Document B which contradicts Document C, and the result is a ContestedClaim with confidence 0.72."
-
The epistemic status of every claim — not all information is equal. A peer-reviewed study (CorroboratedFact) carries more weight than a blog post (FactualClaim). AXON's lattice makes this distinction a formal property of the type system, not a human judgment call.
-
That the search was exhaustive within bounds — Theorem 2 proves that an ε-informative policy doesn't miss relevant paths. If something was within depth 3 and above the relevance threshold, it was found.
-
That contradictions are surfaced, not hidden — when documents disagree, traditional systems return both and let the user reconcile. AXON's epistemic lattice automatically demotes the claim to ContestedClaim and tracks the provenance chain of the conflict.
This is the difference between a search engine and a reasoning engine over interconnected knowledge.
MDN Use Case 1: Multi-Source Medical Diagnosis
A hospital system needs to cross-reference a patient's lab results against clinical guidelines, drug interaction databases, and recent research papers to make a diagnosis. No single document contains the answer — the diagnosis emerges from navigating relationships between sources:
corpus ClinicalKnowledge {
documents: [LabResults, ClinicalGuidelines, DrugDB, RecentStudies]
edges: [
LabResults -> ClinicalGuidelines : cite, weight: 0.9
ClinicalGuidelines -> DrugDB : depend, weight: 0.8
RecentStudies -> ClinicalGuidelines: contradict, weight: 0.7
]
}
know {
flow Diagnose(symptoms: String) -> DiagnosisReport {
step Navigate {
navigate ClinicalKnowledge
from: LabResults
query: symptoms
depth: 3
trail: enabled
as: evidence_chain
}
step Assess {
reason {
given: evidence_chain
ask: "Synthesize a differential diagnosis with provenance"
depth: 3
}
output: DiagnosisReport
}
}
}
- When RecentStudies contradicts ClinicalGuidelines, the system automatically
classifies the conflicting claim as
ContestedClaim— the treating physician sees the contradiction and its provenance, not a false consensus - Epistemic PageRank ranks ClinicalGuidelines (peer-reviewed, widely cited) above RecentStudies (single study, not yet corroborated)
- Trail provides audit-grade provenance: every decision traces back to specific source documents — required for medical malpractice defense
knowblock ensures maximum rigor — no speculation in clinical settings
MDN Use Case 2: Legal Case Building Across Jurisdictions
A law firm builds a case by navigating the citation graph between statutes, case law, legal opinions, and regulatory guidance. The strength of the case depends on the provenance chain — which authorities support each claim:
corpus CaseLawGraph {
documents: [Statute_A, Precedent_B, Precedent_C, RegulatoryGuidance]
edges: [
Statute_A -> Precedent_B : cite, weight: 0.9
Precedent_B -> Precedent_C : elaborate, weight: 0.7
Precedent_C -> Statute_A : cite, weight: 0.8
RegulatoryGuidance -> Statute_A : depend, weight: 0.6
]
}
flow BuildArgument(legal_question: String) -> LegalBrief {
step Research {
navigate CaseLawGraph
from: Statute_A
query: legal_question
depth: 4
trail: enabled
as: authority_chain
}
step Synthesize {
weave [authority_chain]
format: LegalBrief
include: [argument, authorities, provenance_trail]
}
}
- Corroboration detection: when Precedent_C cites back to Statute_A (cycle),
EPR identifies the mutual reinforcement and promotes both to
CorroboratedFact - Citation weight distinguishes primary authority (weight 0.9) from tangential references (weight 0.3) — critical for legal argument quality
- Provenance trail is the chain of authority itself — the legal brief includes not just the conclusion but the formal path through the law that supports it
MDN Use Case 3: Financial Due Diligence Across Filing Networks
An investment firm performs due diligence by navigating relationships between SEC filings, audit reports, analyst notes, and news articles. Contradictions between sources are the most valuable signal:
corpus DueDiligence {
documents: [SEC_10K, AuditReport, AnalystNotes, NewsArticles]
edges: [
SEC_10K -> AuditReport : depend, weight: 0.95
AuditReport -> AnalystNotes: elaborate, weight: 0.6
NewsArticles -> SEC_10K : contradict, weight: 0.8
]
}
doubt {
flow InvestigateRisk(company: String) -> RiskAssessment {
step Traverse {
navigate DueDiligence
from: SEC_10K
query: company
depth: 3
trail: enabled
as: findings
}
step Challenge {
reason {
given: findings
ask: "Identify discrepancies between filings and external reports"
depth: 3
}
output: RiskAssessment
}
}
}
doubtblock forces adversarial analysis — the model is primed to find contradictions, not consensus- When news contradicts the 10-K, the system flags the discrepancy as
ContestedClaimwith exact provenance: "NewsArticles contradicts SEC_10K, edge weight 0.8" - Epistemic aggregation: the overall assessment takes the conservative
meet()of all evidence — if any source is contested, the aggregate drops - Trail produces an auditable investigation chain — every finding traces back to its source documents, satisfying regulatory compliance requirements
X. Memory-Augmented MDN — Structural Learning via Graph Transformation
AXON introduces a twelfth paradigm shift: memory as a functorial endomorphism on the category of corpora — not storage, but a formal transformation of the epistemological space that enables structural learning through interaction history.
Every LLM framework treats memory as a cache: stuff text into a vector store, retrieve by similarity, prepend to prompt. This is computationally trivial and epistemically bankrupt — the system never learns from its interactions. It merely remembers text.
AXON's memory primitive extends the MDN corpus model from C = (D, R, τ, ω, σ)
to a memory-augmented corpus C* = (D, R, τ, ω, σ, H, μ) where the memory
operator μ is a functorial endomorphism that transforms the corpus graph based
on interaction history — preserving topology while adapting continuous parameters
(edge weights, epistemic levels) to reflect accumulated experience.
A. Hard Mathematical Argument — Functorial Endomorphism
Definition 2 (Memory-Augmented Corpus). Extends Definition 1 with:
C* = (D, R, τ, ω, σ, H, μ)
where
H = (Q, Π, O) — interaction history
Q = (q₁, ..., qₙ) — query sequence
Π = (π₁, ..., πₙ) — traversal paths πᵢ ∈ Paths(C)
O = (s₁, ..., sₙ) — outcome scores sᵢ ∈ [0,1]
μ : (C, H) → C' — memory update operator
where C' = (D, R, τ, ω', σ') — same topology, transformed parameters
Three Orthogonal Memory Types. The operator decomposes into three independent subsystems, each operating on different aspects of the corpus:
M_episodic : Π ⊆ Paths(C) — trajectory storage with structural recall
M_semantic : ω'(r) = ω(r) + Δ(r | H) — edge weight adaptation
M_procedural: Bias(D) ∈ ℝ^|D| — navigation policy learning
where
Δ(r | H) = η · Σᵢ γⁿ⁻ⁱ · (sᵢ - s̄) · 𝟙[r ∈ Edges(πᵢ)]
η ∈ (0,1) — learning rate
γ ∈ (0,1) — temporal decay (recent interactions dominate)
s̄ — running baseline (mean outcome)
Theorem 4 (Convergence of μ). Under bounded history and Lipschitz-continuous scoring, repeated application of μ converges to a fixed point:
∃ C∞ : lim_{n→∞} μⁿ(C, H) = C∞
Proof sketch:
(1) Weight clamping: ε ≤ ω'(r) ≤ 1 — bounded, closed set
(2) Temporal decay: γⁿ → 0 — diminishing influence
(3) Banach: ||μ(C₁) - μ(C₂)|| ≤ γ · ||C₁ - C₂|| — contraction ∎
Formal Guarantees:
Identity: μ(C, ∅) = C — empty history preserves corpus
Locality: Δω(r) ≠ 0 ⟹ r ∈ Edges(Π), r ∈ H — only traversed edges change
Monotonicity: σ(Dᵢ) ≤ σ(Dⱼ) ⟹ σ'(Dᵢ) ≤ σ'(Dⱼ) — lattice order preserved
Invariant G4: 0 < ω'(r) ≤ 1 — weight bounds never violated
Generalization: ∃ C, H : Nav(μ(C,H)) ≠ Nav(C) — memory produces new paths
B. Sweet Argument — A System That Learns From Its Own Navigation
The mathematical machinery above produces something no other framework has ever achieved: a knowledge system that structurally improves through use.
When you navigate AXON's memory-augmented corpus:
-
Edges that lead to good answers get stronger. If a citation path (
LabResults → ClinicalGuidelines) consistently produces high-scoring results, its weight increases — making it more likely to be traversed in future queries. This is not heuristic; it's theΔ(r | H)operator applying gradient-like updates to the corpus graph. -
Edges that lead to dead ends get weaker. Contradiction paths with low scores see their weights decay toward
ε— they remain in the graph (no information is destroyed) but are naturally deprioritized. The system learns what not to follow. -
Documents earn their epistemic status. High-scoring documents get promoted on the epistemic lattice (
FactualClaim → CitedFact), while consistently poor-scoring documents get demoted. The system doesn't just tag reliability — it discovers it through interaction. -
Past navigation shapes future navigation. Procedural memory computes a
Bias(D)vector that shifts navigation policy — documents that were historically valuable get a head start in future traversals, creating an adaptive, experience-driven retrieval policy.
This is the difference between a static knowledge graph and a living epistemological system. Every other framework — LangChain's memory, LlamaIndex's history, CrewAI's context — stores text. AXON transforms the geometric structure of knowledge itself.
Memory Use Case 1: Adaptive Medical Decision Support
A hospital system navigates clinical knowledge daily. Over time, the system learns which evidence chains are most diagnostically valuable:
corpus ClinicalKnowledge {
documents: [LabResults, Guidelines, DrugDB, RecentStudies]
edges: [
LabResults -> Guidelines : cite, weight: 0.9
Guidelines -> DrugDB : depend, weight: 0.8
RecentStudies -> Guidelines : contradict, weight: 0.7
]
memory: enabled
}
know {
flow DiagnosticQuery(symptoms: String) -> DiagnosisReport {
step Navigate {
navigate ClinicalKnowledge
from: LabResults
query: symptoms
depth: 3
recall: episodic
as: evidence_chain
}
step Assess {
reason {
given: evidence_chain
ask: "Synthesize differential diagnosis with provenance"
depth: 3
}
output: DiagnosisReport
}
}
}
- After 100 diagnostic queries, the system has learned that
LabResults → Guidelinesis the highest-value path (weight promoted from 0.9 → 0.97), whileRecentStudies → Guidelinescontradictions rarely help (weight decayed from 0.7 → 0.35) - Episodic recall retrieves past trajectories for similar symptoms — the system remembers how it navigated, not just what it found
- Documents earn their status: Guidelines promotes to
CorroboratedFactthrough consistent high-scoring interactions - No manual tuning — the system's edge weights and epistemic levels are empirically grounded, not hand-coded
Memory Use Case 2: Self-Optimizing Legal Research
A law firm's case research system improves with every successful case by learning which statutory paths produce winning arguments:
corpus CaseLawGraph {
documents: [Statute_A, Precedent_B, Precedent_C, RegulatoryGuidance]
edges: [
Statute_A -> Precedent_B : cite, weight: 0.9
Precedent_B -> Precedent_C : elaborate, weight: 0.7
RegulatoryGuidance -> Statute_A : depend, weight: 0.6
]
memory: enabled
max_history: 500
}
flow BuildArgument(legal_question: String) -> LegalBrief {
step Research {
navigate CaseLawGraph
from: Statute_A
query: legal_question
depth: 4
recall: episodic
bias: procedural
as: authority_chain
}
step Synthesize {
weave [authority_chain]
format: LegalBrief
include: [argument, authorities, provenance_trail, memory_influence]
}
}
- Procedural bias: after winning 30 cases using
Statute_A → Precedent_B → Precedent_C, the system gives this path a navigational head start —Bias(Precedent_B) = 0.42vsBias(RegulatoryGuidance) = 0.12 - Semantic weight learning:
Statute_A → Precedent_Bweight grows from 0.9 to 0.98 (consistently high-value citation) - Temporal decay ensures that recent case outcomes matter more than cases from 3 years ago — the law evolves, and so do the weights
memory_influenceoutput field reports exactly how memory transformed the navigation — full transparency on what the system learned
Memory Use Case 3: Learning-Aware Financial Surveillance
A compliance system monitors financial networks and learns which investigation paths reveal genuine anomalies vs. false positives:
corpus FinancialNetwork {
documents: [SEC_Filings, AuditReports, TransactionLogs, IntelReports]
edges: [
SEC_Filings -> AuditReports : depend, weight: 0.95
AuditReports -> TransactionLogs : elaborate, weight: 0.6
IntelReports -> SEC_Filings : contradict, weight: 0.8
]
memory: enabled
max_history: 1000
}
doubt {
flow InvestigateAnomaly(alert: String) -> RiskAssessment {
step Traverse {
navigate FinancialNetwork
from: TransactionLogs
query: alert
depth: 3
recall: episodic
bias: procedural
as: findings
}
step Challenge {
reason {
given: findings
ask: "Is this a genuine anomaly or a known false positive?"
depth: 3
}
output: RiskAssessment
}
}
}
- False positive learning: when investigations resolve as benign (low outcome score), the traversed paths' edge weights decrease — the system learns which patterns are noise, not signal
- True positive reinforcement: genuine anomaly paths see weight increases, making similar future anomalies faster to locate
- Episodic recall surfaces past investigations with similar alert patterns — "we saw this 3 months ago and it was a known vendor discrepancy"
- Procedural bias steers the system toward document types that historically
revealed real issues — if
IntelReportsconsistently surfaces genuine risks, it gets navigational priority doubtblock ensures adversarial stance — the system challenges every finding, preventing confirmation bias even as it learns
XI. Psychological-Epistemic Modeling — the psyche Primitive
AXON introduces a thirteenth paradigm shift: formal psychological- epistemic modeling with Riemannian state dynamics, quantum cognitive probability, and active inference — the first compiled construct that treats mental states as epistemological objects with structured uncertainty and formal safety guarantees.
Every existing AI system treats cognitive biases, emotional states, and mental
load as noise to be filtered out. This is a category error. Human cognition
is not rational-plus-noise — it is a dynamical system on a curved manifold
where affect, bias, and cognitive load are formal modulators of epistemic
inference. AXON's psyche primitive makes this distinction a first-class
language construct.
psyche TherapeuticProfile {
dimensions: [affect, bias, cognitive_load]
manifold {
curvature: { affect: 0.8, bias: 1.2, cognitive_load: 0.5 }
noise: 0.1
momentum: 0.3
}
safety: [non_diagnostic]
quantum: enabled
inference: active
}
A. Hard Mathematical Argument — Three Theorems
Definition 1 (Cognitive State Manifold). A psyche configuration defines a
Riemannian manifold (M, g) where:
M = ℝᵈ — d