Architecture
Status: Ready
Truth label: Current
Audience: New builder, System designer
Reader outcome: Read the architecture overview: the four parts, their ports, and the data flow between them.
Last verified: 2026-09-13
This document describes the current AGENTASIAN runtime. It was verified against the source on 2026-08-24.
Runtime topology
Browser
|
| HTTP 3000
v
Cortex UI
|----------------------|
| |
| HTTP 8081 | HTTP 8080
v v
Brain API Forge Central
| ^
| | poll, claim, renew, log, result
| rules and learnings |
|------------------- Worker
|
| subprocess in project directory
v
Claude Code, Codex, Codex OSS, or Antigravity
The standard launchers bind Cortex, Brain, and Forge to 127.0.0.1 by
default. Workers are outbound clients and do not open an inbound port.
| Process | Default port | Entry point | Responsibility |
|---|---|---|---|
| Cortex UI | 3000 | Static files in cortex-ui/ | Browser interface for chat, memory, projects, tasks, checkpoints, rules, schedules, workers, and analytics |
| Brain API | 8081 | brain.api:app | Chat, provider routing, RAG, CPMI, rules, feedback, voice controls, and conversation traces |
| Forge Central | 8080 | forge.central.api:app | Projects, task routing, transactional claims, leases, checkpoints, sessions, schedules, and run traces |
| Worker | none | python -m forge.worker | Polls Central, builds execution context, launches a coding CLI, verifies work, and reports results |
Component boundaries
Cortex
Cortex is a no-build vanilla JavaScript application. The browser derives the Brain and Forge URLs from the hostname serving the page. It never contacts a worker directly.
Brain
Brain owns conversational reasoning and knowledge retrieval. Its LangGraph agent can search knowledge and dispatch work to Forge through constrained tools. It does not execute Forge tasks itself.
Brain supports Ollama, OpenAI, Anthropic, and Google for chat. Embeddings are
configured independently through EMBEDDING_PROVIDER and
EMBEDDING_MODEL so changing a chat model cannot silently change an existing
vector space.
Forge Central
Forge Central is the control plane. It owns task state and decides which task
a worker may claim. Tasks, workers, projects, leases, result deduplication, and
run-token hashes live in forge.sqlite3.
Central takes an exclusive process lock next to the database. A second Central against the same data root refuses to start. SQLite is also rejected across a WSL drvfs or 9P boundary, where locking and WAL behavior are unsafe.
Workers
Shared AGOR policy and portable tools ship with Agent Asian. Workers validate the bundled policy at startup and include it in every executor prompt. Each project keeps authoritative, editable local memory files; Brain holds derived indexes. See worker governance.
A worker registers its capabilities and every installed CLI backend. The startup engine is a default, not a permanent restriction. A task may request any backend installed on that worker.
Current CLI backends:
claude-code, using theclaudeCLIcodex, usingcodex execcodex-oss, using Codex with Ollamaantigravity, using theagyCLI
The legacy agentic and legacy in-process engines remain available for
compatibility.
Task data flow
- A client creates a project and task through Forge.
- A worker registers or re-registers with a persisted per-worker credential.
- The worker polls
GET /tasks/nextwith its identity and capability set. - Claiming a task is one SQLite transaction. Central changes task and worker state, assigns a run UUID, increments the fence, and creates a lease.
- A credentialed claim also returns a claim-bound run token.
- The worker reads target-repository controls, retrieves bounded CPMI history, loads selected skills, and builds the CLI prompt.
- The CLI runs in the registered project path. The worker streams supported progress events and renews the lease while watching for cancellation.
- The worker runs the optional verification command.
- The terminal result is written to a local disk outbox before delivery.
- Central authenticates the run token, checks the fence, deduplicates redelivery, records trace and ledger data, and applies the supervision gate.
- Accepted terminal results leave the outbox. Superseded results are ledgered but cannot overwrite the newer attempt.
See How It Works for the full sequence.
Supervision
Supervision is enforced by Central:
autonomouscompletes a successful run without human approval.checkpointholds the successful final result for approval.supervisedruns a read-only planning stage, holds it for approval, then runs and holds the final stage.
Operators approve, request revision, or fail held tasks from the Cortex
Checkpoints tab. Decisions are appended to decisions.jsonl.
Storage
The default data root is ~/.agent_asian.
| Data | Store |
|---|---|
| Forge projects, tasks, workers, leases, result deduplication, run tokens | forge.sqlite3 |
| Task and chat lineage index | traces.sqlite3 |
| Raw task and chat artifacts | traces/raw/ |
| Derived CPMI records and lexical index | cpmi.sqlite3 |
| Semantic memory and CPMI projection | chroma/ |
| Worker terminal-result outbox | outbox/<worker_id>/ |
| Worker credentials | worker-credentials/*.token |
| Sessions and schedules | JSON files under the data root |
| Run, usage, decision, and alert ledgers | JSONL or log files under the data root |
Legacy project, task, and worker JSON registries are imported once into SQLite
and renamed with a .migrated suffix.
Security boundaries
- Without
AA_API_TOKEN, Brain and Forge accept only loopback clients. - LAN use requires the shared bearer token, an explicit browser origin list, allowed project roots, and firewall rules scoped to the trusted network.
- Workers receive a per-worker token on first registration. Only its hash is stored by Central.
- Credentialed claims receive a separate run token bound to the task fence.
- Cloud-key distribution is disabled unless
AA_ALLOW_KEY_DISTRIBUTION=true. - Raw trace artifacts and worker credentials are sensitive local files.
The shared bearer token is still a fleet perimeter credential. It is not per-user authorization. Project client fields and scoped CPMI and learning searches exist, but chat auto-retrieval, LangGraph search tools, and direct record reads bypass that filter. The current build does not provide a complete client confidentiality boundary. See Security model.
Reliability and operations
Forge uses leases, fencing, idempotent result handling, and the worker outbox to cover worker crashes, Central outages, and stale reports. The Windows supervisor can restart Central, Brain, and Cortex, write flap alerts, and run a daily SQLite-consistent backup.
Important limits remain:
- Project paths are literal machine-local paths. Pin tasks to a worker that can reach the registered path.
- Project
pausedandarchivedstates are descriptive and do not stop queue routing. - Chroma writes need a single writer.
- Distributed workers do not upload raw trace artifacts to Central.
Repository map
brain/
api.py Brain HTTP routes
chat.py Chat and streaming orchestration
agent/graph.py LangGraph tool loop
llm/ Provider routing and generation controls
memory/ Chroma, ingestion, CPMI, conversations
cortex-ui/
index.html Static application shell
src/api.js Brain and Forge client
src/main.js UI state and rendering
src/styles/main.css Styling
forge/
central/ Forge API, queue, registries, schedules, ledgers
worker/agent.py Poll, claim, execute, renew, report loop
worker/outbox.py Durable terminal-result delivery
worker/credentials.py Per-worker credential persistence
worker/executors/ CLI adapters
shared/
config.py Forge settings and project-path validation
schemas.py Shared domain models
security.py API and token helpers
store.py Transactional Forge SQLite store
trace_store.py Task and chat lineage
Detailed contracts live in:
- Brain
- Forge
- Cortex
- Configuration
- GL-01 state transactions
- GL-03 worker credentials
- GL-04 checkpoint approval