Skip to main content

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.

ProcessDefault portEntry pointResponsibility
Cortex UI3000Static files in cortex-ui/Browser interface for chat, memory, projects, tasks, checkpoints, rules, schedules, workers, and analytics
Brain API8081brain.api:appChat, provider routing, RAG, CPMI, rules, feedback, voice controls, and conversation traces
Forge Central8080forge.central.api:appProjects, task routing, transactional claims, leases, checkpoints, sessions, schedules, and run traces
Workernonepython -m forge.workerPolls 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 the claude CLI
  • codex, using codex exec
  • codex-oss, using Codex with Ollama
  • antigravity, using the agy CLI

The legacy agentic and legacy in-process engines remain available for compatibility.

Task data flow​

  1. A client creates a project and task through Forge.
  2. A worker registers or re-registers with a persisted per-worker credential.
  3. The worker polls GET /tasks/next with its identity and capability set.
  4. Claiming a task is one SQLite transaction. Central changes task and worker state, assigns a run UUID, increments the fence, and creates a lease.
  5. A credentialed claim also returns a claim-bound run token.
  6. The worker reads target-repository controls, retrieves bounded CPMI history, loads selected skills, and builds the CLI prompt.
  7. The CLI runs in the registered project path. The worker streams supported progress events and renews the lease while watching for cancellation.
  8. The worker runs the optional verification command.
  9. The terminal result is written to a local disk outbox before delivery.
  10. Central authenticates the run token, checks the fence, deduplicates redelivery, records trace and ledger data, and applies the supervision gate.
  11. 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:

  • autonomous completes a successful run without human approval.
  • checkpoint holds the successful final result for approval.
  • supervised runs 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.

DataStore
Forge projects, tasks, workers, leases, result deduplication, run tokensforge.sqlite3
Task and chat lineage indextraces.sqlite3
Raw task and chat artifactstraces/raw/
Derived CPMI records and lexical indexcpmi.sqlite3
Semantic memory and CPMI projectionchroma/
Worker terminal-result outboxoutbox/<worker_id>/
Worker credentialsworker-credentials/*.token
Sessions and schedulesJSON files under the data root
Run, usage, decision, and alert ledgersJSONL 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 paused and archived states 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: