Forge
Status: Ready
Truth label: Current
Audience: Fleet operator, System designer
Reader outcome: Start Forge Central and a worker, and know the task lifecycle, supervision modes, routing, backends, persistence, and operations.
Last verified: 2026-09-13
Forge is AGENTASIAN's distributed task control plane and worker runtime.
- Forge Central is the FastAPI service at
forge.central.api:app. - Forge workers run with
python -m forge.worker. - Workers make outbound HTTP requests and do not listen on a port.
Start Forge
# Central
python -m uvicorn forge.central.api:app --host 127.0.0.1 --port 8080
# Worker
python -m forge.worker --engine claude-code
The all-in-one launchers start Central, Brain, and Cortex. They do not start a worker.
One worker is one slot. For concurrent runs on a single machine, run one worker per engine, each pinned to its own:
./agents.sh start # start, stop, restart, status, logs
or by hand:
python -m forge.worker --name claude --engine claude-code --pin-engine
python -m forge.worker --name codex --engine codex --pin-engine
Central responsibilities
Central owns:
- project registration and path validation
- priority task routing
- worker registration, credentials, heartbeats, and removal
- transactional claim state
- task leases, fencing, and expired-run recovery
- checkpoint approval
- sessions and dependency ordering
- recurring schedules
- task logs, run lineage, decisions, and egress analytics
Task lifecycle
pending
|
| claim transaction
v
assigned -> in_progress
|
| success
v
autonomous: completed
checkpoint: checkpoint -> approve, revise, or fail
supervised: plan checkpoint -> execution -> final checkpoint
Any active state can reach failed or cancelled.
Each claim creates:
- a UUID
current_run_id - an incrementing
run_attempt, also used as the fence - a server-owned lease
- a claim-bound run token for credentialed workers
The worker renews its lease while the CLI runs. Central's reaper checks every 15 seconds and fails claims that exceed the lease TTL or maximum wall-clock limit. A stale result cannot overwrite a newer attempt because Central checks the fence before applying state.
Supervision modes
| Mode | Behavior |
|---|---|
autonomous | A successful run completes immediately |
checkpoint | A successful final result is held for operator review |
supervised | Central serves a safe planning run first, then holds both the plan and final result |
Checkpoint actions:
POST /tasks/{id}/approvecompletes a final checkpoint or releases the supervised execution stage.POST /tasks/{id}/rejectacceptsaction: reviseoraction: fail.- Revisions add bounded feedback to the task and do not consume the automatic retry budget.
- Human rejection never triggers automatic retry.
- Decisions are appended to
decisions.jsonl.
The default project supervision mode is checkpoint.
Routing
A task may constrain routing by:
assigned_worker_idenginerequired_capabilitiesparent_task_id
Central offers a task only when:
- the worker pin is empty or matches the polling worker
- the worker reported the requested CLI engine
- every required capability is present
- the parent task is complete
Project paths are literal strings registered with the project. They are not translated between Windows, macOS, and Linux. Pin cross-platform tasks to a worker that can reach the path.
Execution backends
The worker backend registry is in forge/worker/executors/registry.py.
| Engine | Command | Login or key | Resume | Live progress |
|---|---|---|---|---|
claude-code | claude -p ... --output-format stream-json | Claude CLI login | Yes | Yes |
codex | codex exec ... --json | Codex CLI login | No | Parsed final JSONL events |
codex-oss | Codex with --oss --local-provider ollama | Local Ollama | No | Parsed final JSONL events |
antigravity | agy -p ... --output-format stream-json | Antigravity login | Yes | Agent and tool events |
agentic | In-process LangChain tool loop | Provider key | No | Legacy |
legacy | In-process single-shot generation | Provider key | No | Legacy |
The startup --engine is the default for tasks that do not name one. A
worker can execute a task through any installed backend it advertised.
Workers report each advertised CLI's own version at registration, and Cortex
shows it in the fleet panel. python scripts/upgrade-clis.py upgrades the
CLIs on one box; see the runbook for what it will and will not upgrade.
Permission mapping
| Forge level | Claude Code | Codex and Codex OSS | Antigravity |
|---|---|---|---|
safe | plan mode | read-only sandbox | plan mode |
write | accept edits | workspace-write sandbox | sandbox with tool approval bypass |
yolo | skip permission checks | bypass approvals and sandbox | skip permission checks |
The worker's --max-permission is a hard ceiling. A task that requests more
authority is clamped and the event is logged.
safe is not an OS-enforced no-side-effect boundary. Claude plan mode permits
selected test commands, and the worker runs the configured verification
command independently after the CLI. Repository code can therefore execute in
a nominally safe workflow.
Worker flow
- Load
.env, discover installed backends, and validate the bundled AGOR policy before registration. - Register hostname, instance name, capabilities, engines, and the version each advertised engine's CLI reports.
- Save the one-time worker credential under
<data_root>/worker-credentials/. - Drain any terminal results left in the local outbox.
- Poll
GET /tasks/next?worker_id=.... - Claim the selected task.
- Read current target-repository controls in full, create only missing memory within effective write permission, and refresh derived CPMI history.
- Build a prompt with task identity, persona hint, selected skills, active rules, session context, project controls, and untrusted history.
- Launch the requested CLI in
project_path. - Renew the lease, watch cancellation, and ship supported logs.
- Run the task's optional verification command.
- Persist the result in the outbox and post it to Central.
- Report a learning to Brain.
Bundled governance
Agent Global Operating Rules ship with Agent Asian's code and distributions. Every executor receives the bundled policy. Project-local memory files remain authoritative; Brain only indexes and retrieves them. Writable tasks create missing memory and native entrypoints without replacing existing content. Read-only tasks perform no governance setup writes. Oversized or unreadable controls stop dispatch instead of losing rules. Run metadata retains policy identity and the current control digest. See worker governance for operating details.
Credentials and result delivery
The shared bearer token protects the API perimeter. Forge adds two narrower worker credentials:
- The worker token identifies one hostname and instance. Central stores only a SHA-256 hash.
- The run token is minted at claim and bound to
task_idplus fence.
The worker token is sent on registration, heartbeat, poll, and claim. The run token is sent on lease renewal, logs, and results.
If a worker credential file is lost, Central refuses takeover of the existing
identity. Stop the worker, delete its old registration through Cortex or
DELETE /workers/{id}, then restart it to enroll again.
Before the first result POST, the worker writes
outbox/<worker_id>/<task_id>-<fence>.json. It removes the entry after
accepted, duplicate, superseded, or task-gone outcomes. Transport
and authentication failures keep the entry for later delivery.
Persistence
SE_MANAGER_DATA_DIR defaults to ~/.agent_asian.
| Data | Storage |
|---|---|
| Projects, tasks, workers | JSON documents in forge.sqlite3 |
| Leases, result deduplication, run-token hashes | Relational tables in forge.sqlite3 |
| Sessions | sessions/sessions.json |
| Schedules | Recurrence tables in forge.sqlite3; retained legacy schedules.json migration input |
| Incremental task logs | Files under logs/ |
| Run summaries | runs.jsonl |
| Checkpoint decisions | decisions.jsonl |
| Trace lineage | traces.sqlite3 and traces/raw/ |
Central uses SQLite WAL, BEGIN IMMEDIATE mutations, and an exclusive process
lock. Do not put the live database on a WSL drvfs or 9P mount.
On first startup after GL-01, empty SQLite tables import the old project, task,
and worker JSON registries. Imported files are renamed with .migrated.
API reference
Projects and workers
| Method | Route | Purpose |
|---|---|---|
| GET/POST | /projects | List or create projects |
| GET/PATCH/DELETE | /projects/{id} | Read, update, or remove a project |
| POST | /workers/register | Enroll or refresh a worker |
| POST | /workers/{id}/heartbeat | Mark a worker alive |
| GET | /workers, /workers/{id} | Inspect workers |
| DELETE | /workers/{id} | Remove an idle registration |
| GET | /workers/types | List personas and skills |
Tasks
| Method | Route | Purpose |
|---|---|---|
| GET/POST/DELETE | /tasks | List, create, or clear tasks |
| GET/DELETE | /tasks/{id} | Read or remove one task |
| GET | /tasks/pending | Pending tasks in route order |
| GET | /tasks/next | Find work for a worker |
| POST | /tasks/{id}/claim | Transactional claim |
| POST | /tasks/{id}/lease | Renew lease and read cancellation |
| POST | /tasks/{id}/cancel | Request cancellation |
| POST/GET | /tasks/{id}/log(s) | Append or read live logs |
| POST | /tasks/{id}/result | Report a fenced result |
| POST | /tasks/{id}/approve | Approve a held checkpoint |
| POST | /tasks/{id}/reject | Revise or fail a held checkpoint |
Sessions, schedules, and analytics
| Route group | Purpose |
|---|---|
/sessions* | Group tasks, aggregate context, rename, complete, and delete |
/schedules* | Create and run interval, daily, or weekly task templates |
/analytics/egress | Usage and cost summaries |
/runs/{run_id}/trace | Task-run lineage, including current raw result content in outcome |
/tasks/{task_id}/runs | Attempt history for one task |
/status, /health | Operational status |
The API's OpenAPI document at /docs is the exact request-field reference.
Operations
On Windows, scripts/windows/supervisor.ps1 can keep Central, Brain, and
Cortex running, log restarts, emit flap alerts, and invoke
scripts/backup_data.py daily. Register it with
scripts/windows/register-supervisor.ps1 after reviewing the hard-coded
repository and data paths.
The backup script uses SQLite's backup API and rotates timestamped zip files. It is safe to run while Central is active, but the current allowlist omits decision, scope-audit, candidate-resolution, worker-credential, and outbox state. See Data and storage.
Known limits
- Paused and archived projects reject new tasks and are omitted from polling, but work already assigned or running is not stopped; cancel it separately.
- There is no automatic project-path mapping across workers.
- Raw task artifacts remain on the worker that ran the task unless the data root is shared.
- The shared fleet bearer authorizes most operator routes, and CLI children inherit the worker environment unless separately isolated.
- Client-scope filtering is not applied to every Brain retrieval path.
- Antigravity now streams progress. IDE quality parity still requires matched operator comparisons; see AGY parity.
- The two legacy execution engines have a wider and older trust model.
See Runbook for operations and Configuration for settings.
Recurring tasks now have a Cortex editor, timezone previews, overlap policies and durable occurrence evidence. Manual runs preserve the next appointment.
Reconcile local task ledgers
Use the bundled governance migration commands for older projects with two task ledgers. migrate-plan takes an explicit root and private state directory and returns an inspectable diff and record coverage. migrate-apply takes that plan, checks both ledgers, preserves source states and retires the old filename to a pointer. The private receipt retains original bytes. migrate-rollback previews recovery and writes only with --apply; later edits are preserved as a conflict. Repeating an intact migration has no effect. See task-ledger migration for the full workflow. No Brain service or extra governance installation is required.
Native startup setup
Workers carry native setup in their ordinary code. Startup initializes absent instruction globals for installed Claude, Codex and Antigravity CLIs, or upgrades a block that matches its active private receipt. It preserves unrelated text. Unowned files, native overrides, edited blocks and restrictive budgets are reported for review. No credentials or native permission settings change. Owned Claude advisory hooks use a separate recoverable settings projection; unrelated hooks remain intact. Private receipts are stored under the normal data root and support interrupted setup recovery. Task metadata and Cortex show the startup observation separately from native loading proof. See native account instructions.
Advisory Claude hooks
Claude feedback ships with Agent Asian and uses its existing Python runtime. Session start supplies a bounded memory reminder. File-tool and shell edits are checked through Git status and file metadata, including untracked files. Known memory documents receive format and changed-prose checks. Source contents and transcripts are not collected. Limited or unavailable inspection is reported for manual review.
Final feedback is a user-facing warning at most once per session. It cannot block completion, start another model turn or replace the requested artifact. Native permissions remain unchanged. The bundled hook setup and rollback commands retain unrelated settings and extra hooks; reviewed legacy advisory entries have private recovery evidence. Cortex lists configuration and implementation hashes separately from execution proof.
Policy identity is visible in rendered text because native readers can remove comments. A file hash, a supplied native instruction and a successful standalone read remain distinct evidence. A denied native read stays unverified.