AGENTASIAN architecture design
Status: Ready
Truth label: Current
Audience: System designer
Reader outcome: Understand the component boundaries, contracts, and design constraints that shape every feature.
Last verified: 2026-09-13
1. Purpose
AGENTASIAN is a local-first AI operating environment with two connected systems:
- Brain handles chat, retrieval, memory, response shaping, and constrained task dispatch.
- Forge coordinates projects, tasks, workers, execution attempts, human gates, and operational evidence.
The system is designed for one operator running a distributed fleet of trusted machines. It is not a customer-facing multi-tenant service.
2. Design goals
- Keep the control plane local by default.
- Run coding agents on the machine that owns the project files.
- Preserve work across Central outages and worker restarts.
- Prevent stale attempts from overwriting newer work.
- Put human approval at named delivery boundaries.
- Keep trusted instructions separate from retrieved evidence.
- Record enough lineage to explain cost, context, and outcome.
- Support Windows, macOS, and Linux workers.
3. Non-goals
- Customer login or self-service access
- Per-human role-based access control
- A public internet-facing API
- Automatic conflict resolution between two workers editing one checkout
- A globally shared filesystem
- Automatic promotion of client work into organization knowledge
- Strong process isolation for hostile repositories
4. Runtime context
Operator browser
|
v
Cortex static UI :3000
| registered project
| files
+----------+ ^
| | |
v v |
Brain :8081 Forge Central :8080 <----- Forge Worker
| | poll, claim, renew,
| | log, result
| |
v v
Chroma and Forge SQLite,
CPMI SQLite traces, ledgers
Forge Worker -> Claude Code, Codex, Codex OSS, Antigravity, or legacy engine
Brain and Forge are separate FastAPI processes. Cortex calls both. Workers are outbound clients and do not listen on a port.
5. Component responsibilities
5.1 Cortex
Cortex is a static vanilla JavaScript application. It owns browser state, operator forms, status rendering, checkpoint controls, and analytics panels. It does not contain authoritative business rules.
The browser derives Brain and Forge URLs from the host serving Cortex. It sends the configured fleet bearer to both APIs and stores that bearer in browser local storage.
5.2 Brain
Brain owns:
- chat and streaming chat
- provider and generation-control selection
- LangGraph tool orchestration
- Chroma collections
- canonical project memory indexing and search
- conversations, feedback, rules, and voice examples
- knowledge-candidate review and promotion
- chat-turn traces
Brain does not execute a Forge task. Its Forge tools create and inspect tasks.
5.3 Forge Central
Central is the control plane and source of truth for:
- project registration
- task lifecycle
- worker identity and availability
- route eligibility
- atomic claims and leases
- checkpoint decisions
- sessions, dependencies, and schedules
- pipeline and QA state transitions
- task-run traces and analytics
Central is a single active writer. A process lock rejects a second Central for the same data root.
5.4 Forge Worker
A worker:
- discovers installed execution engines
- registers its identity and capabilities
- polls for eligible work
- claims one task
- assembles bounded execution context
- launches an engine in the project directory
- renews the lease and observes cancellation
- verifies the result
- persists the terminal report to an outbox
- delivers or redelivers the report to Central
A worker processes one claimed task at a time.
5.5 CLI adapters
The shared executor owns process lifecycle, tracing, changed-file detection, verification, cancellation, and result normalization. Each adapter owns engine arguments, permission mapping, streaming-event parsing, and final-result parsing.
Current adapters:
| Adapter | Executable | Session resume | Provider cost report |
|---|---|---|---|
| Claude Code | claude | yes | yes |
| Codex | codex exec | engine-dependent | no normalized provider cost |
| Codex OSS | codex with Ollama | engine-dependent | no normalized provider cost |
| Antigravity | agy | no | no normalized provider cost |
The agentic and legacy engines remain compatibility paths.
6. Control-plane sequence
6.1 Worker enrollment
Worker -> Central: POST /workers/register
Central -> Worker: worker record plus one-time cleartext worker token
Worker -> local disk: restricted worker credential file
Worker -> Central: later requests with X-Worker-Token
Central stores the SHA-256 hash of a random 32-byte credential. Re-registering the same hostname and instance requires the existing token.
6.2 Task claim
Worker -> Central: GET /tasks/next?worker_id=...
Central -> Worker: eligible pending task
Worker -> Central: POST /tasks/{id}/claim
Central: BEGIN IMMEDIATE
Central: recheck worker, pin, engine, capability, parent, and task state
Central: assign worker, run id, fence, and lease
Central: mark worker busy
Central: mint task-and-fence run token when credentialed
Central: COMMIT
Central -> Worker: served task, lease, and run token
The claim transaction is the primary concurrency boundary. The fence is the attempt number. Every later terminal write is checked against it.
6.3 Execution and result
Worker -> Brain: rules, session context, CPMI, and learnings
Worker -> CLI: trusted instructions plus bounded untrusted evidence
Worker -> Central: logs and lease renewals
Worker -> local outbox: terminal payload and run token
Worker -> Central: POST /tasks/{id}/result
Central: authenticate, fence, deduplicate, trace, and apply supervision
Central -> Worker: accepted, duplicate, or superseded
Worker: remove acknowledged outbox entry
Network or authentication failures keep the outbox entry. Non-retryable client errors are preserved as rejected evidence instead of retrying forever.
7. Task state model
pending
|
v
assigned -> in_progress
|
+-> completed
+-> failed
+-> cancelled
+-> checkpoint
|
+-> completed
+-> pending, after approval or revision
+-> failed, after operator rejection
Important state rules:
- Only a pending task can be claimed.
- A claim assigns a new run UUID and increments the fence.
- A terminal state clears the lease.
- A checkpoint has no active lease.
- A stale result is recorded as superseded and cannot change current task state.
- A duplicate task and fence pair is acknowledged without repeating side effects.
- Lease expiry fails an ordinary task unless its retry policy requeues it.
- Pipeline machine failures become human failure holds.
8. Supervision design
| Mode | First successful result | Operator action |
|---|---|---|
autonomous | completed | none |
checkpoint | final checkpoint | approve, revise, or fail |
supervised | plan checkpoint | approve plan, then approve final result |
Supervised stage one is served as safe without changing the stored requested
permission. Approval requeues stage two and resumes the prior CLI session when
the adapter supports it.
Every checkpoint decision is appended to decisions.jsonl. Grades are optional
and feed outcome analytics.
9. Pipeline design
Pipeline templates are reviewed code, not database-authored workflows.
Delivery
scope checkpoint
-> execute
-> QA gate
-> solution audit
-> report checkpoint
Quickfix
execute
-> QA gate
-> summary checkpoint
Each stage declares persona, skill, permission, and supervision. A pipeline may have at most one QA gate. The QA gate can rework only the immediately preceding stage.
The QA result contract uses the final non-empty line:
QA-GATE: PASS
QA-GATE: FAIL: <reasons>
Missing or malformed verdicts revise the QA task itself. A failed work verdict requeues the work stage until the rework budget is exhausted. Exhaustion stops at a checkpoint.
10. Chat and retrieval design
10.1 Trusted instruction layers
- code-owned system instructions
- repository controls read directly from the target project
- active user rules
- reviewed personas and skills
- reasoning lenses and voice registers, loaded from the operator-supplied
voice pack named by
VOICE_PACK_DIRand validated at load - approved voice examples used only for style, from the same pack
10.2 Untrusted evidence layers
- canonical project memory
- Chroma knowledge and notes
- past learnings
- past conversations
- ingested documents and books
- previous task results
Retrieved content is evidence. It must not gain instruction authority merely because search selected it.
10.3 Retrieval stores
Canonical project memory uses SQLite for authoritative records and FTS5 search. Chroma is a semantic projection. Ordinary memory and knowledge collections use Chroma directly.
The intended confidentiality model is query-time project scope resolution:
internalsees internal records- a client sees its own records and internal projects explicitly marked shared
allsees every scope and requires a separate operator token
This model is only partially enforced. Chat auto-retrieval, LangGraph search tools, and direct CPMI record reads bypass the scoped HTTP paths. See the security model and audit report.
11. Persistence design
Forge uses document-per-row SQLite for projects, tasks, and workers. Leases, run-token hashes, and result deduplication have dedicated relational tables. Sessions and schedules remain JSON because the single Central process is their writer.
Trace lineage uses a separate SQLite index. Large or sensitive raw artifacts remain local files referenced by the trace.
See Data and storage for the complete inventory and recovery model.
12. Deployment topologies
12.1 Single machine
Cortex, Brain, Central, and a worker share one host. This is the simplest topology. Loopback access is sufficient, but a worker-launched process can also reach loopback services.
12.2 Trusted LAN
Cortex, Brain, and Central run on one machine. Workers run on other trusted machines and connect outbound. The deployment requires a fleet bearer, exact CORS origins, allowed project roots, and private firewall rules.
12.3 Heterogeneous fleet
Each project path is stored literally. There is no automatic mapping between a Windows checkout and a macOS or Linux checkout. Tasks must be pinned to a worker that can reach the registered path.
12.4 Unsupported topology
Do not share Forge SQLite through WSL drvfs, 9P, SMB, or a general network filesystem. Run Central on the operating-system side that owns a native data path.
13. Reliability properties
| Failure | Protection |
|---|---|
| Concurrent claimers | SQLite immediate transaction |
| Second Central | Exclusive process lock |
| Worker crash | Lease expiry and fence increment |
| Central outage after execution | Durable worker outbox |
| Duplicate delivery | Task and fence deduplication |
| Late result | Superseded outcome |
| Operator delay at checkpoint | Lease already cleared |
| Brain unavailable during task setup | Context degrades; CLI execution continues |
These controls protect task state. They do not protect two workers from editing the same checkout through two different tasks.
14. Security boundaries
Implemented controls include loopback default access, a shared fleet bearer, CORS allowlisting, project-root allowlisting, worker credentials, run tokens, permission ceilings, and opt-in provider-key distribution.
The current security model does not safely isolate an agent process from the operator control plane. CLI children inherit the worker environment, and sensitive operator routes use the same fleet bearer as service traffic.
No confidential multi-client deployment should proceed until the P0 findings in the audit report are closed and tested end to end.
15. Architecture constraints and debt
- Operator and service authorization are not separated.
- Retrieval scope is not enforced at every path.
safeis an engine convention, not an OS-enforced boundary.- Project path mapping is manual.
- Project paused and archived states do not stop routing.
- Chroma requires one controlled writer.
- Distributed raw traces remain on the worker that produced them.
- Central backups do not include all ledgers, credentials, or worker outboxes.
- Dependencies are not locked to a reproducible set.
- Alerts reach Cortex and browser desktop notifications, but not an external push or chat destination. macOS launchd files exist, but the current repo path is blocked by TCC; manual start is the accepted default under DEC-20260825-01.
16. Related records
- State transaction design
- Worker credential design
- Checkpoint design
- Pipeline design
- Client ACL design
- Learning-loop design
- Root decision register