Skip to main content

Running the stack

Status: Ready

Truth label: Limited

Audience: Fleet operator

Reader outcome: Start and stop the control plane on any supported host, confirm health, keep it running, and prove a restore before you need one.

Last verified: 2026-09-13

Full guides: Runbook, System manual, Docker, Windows rollout

The interactive stack​

From the application repository root:

./run-all.sh

On Windows, run-all.bat is the equivalent.

The script activates the virtual environment, runs preflight in the foreground, then starts three processes in the background:

ServiceAddress
Forge Centralhttp://127.0.0.1:8080
Brainhttp://127.0.0.1:8081
Cortexhttp://127.0.0.1:3000

It does not start a worker. The shell owns all three processes. Closing it or pressing Ctrl+C stops the stack.

Preflight runs first and in the foreground on purpose. The three services are backgrounded, so an error raised inside one of them scrolls past unread. A worker deliberately skips preflight, because a worker has no voice or influence responsibility and must keep starting.

Health checks​

curl http://127.0.0.1:8080/health
curl http://127.0.0.1:8081/health

Both return a JSON status of ok. Health routes are intentionally public, so a healthy response is not proof that protected routes are closed.

Three signals tell you the stack is actually working, not just listening:

  1. Both health routes answer.
  2. Cortex loads and does not prompt repeatedly for a token.
  3. A worker shows online with a recent heartbeat and the expected engine.

Start a worker​

Same machine as the services:

./run-worker.sh

Separate machine you own:

./run-worker.sh http://central-host:8080 http://central-host:8081

The first URL is required. When it ends in port 8080 and the Brain URL is omitted, the launcher derives port 8081 on the same host. Full worker detail is in Workers.

Containers​

Forge Central, Brain, and Cortex have a Compose definition. Workers are not containerized and should not be, because a worker needs a real checkout and an interactively authenticated CLI.

docker compose build
docker compose up -d
docker compose logs -f central
ServicePortNotes
preflightnoneRuns once and exits. Central and Brain wait for it to succeed
central8080Holds the process lock on the data root
brain8081Writes the vector store
cortex3000Static files. No data volume and no content mounts
opsnoneBackup, restore, and maintenance. Only under --profile ops

restart: unless-stopped replaces a host supervisor script.

The rule that matters​

The data root is a named volume. Never a bind mount.

A bind mount from a Windows or macOS host reaches the container as virtiofs or 9p. SQLite documents write-ahead logging as unsupported there, and its advisory locks do not interoperate across that boundary. The store layer refuses those filesystems, including from inside a container, rather than corrupting the database quietly. The refused list covers virtiofs, cifs, nfs, 9p, and drvfs.

Content directories are different. The voice pack, influence library, and knowledge directory are bind mounts from the host. Brain's voice pack and influence mounts are writable so Cortex can save profiles and reviewed source imports. Preflight, backup, and knowledge mounts stay read only. An existing container needs recreation to apply a changed mount.

Container operations​

docker compose --profile ops run --rm ops scripts/backup_data.py --keep 7

Restore needs Central and Brain stopped first. The port probes inside the ops container are namespace local and see nothing, so the file lock on the data root is the guard that still works:

docker compose stop central brain
docker compose --profile ops run --rm ops scripts/restore_data.py /export/<archive>
docker compose start central brain

Durable operation without containers​

Windows​

A checked-in PowerShell supervisor restarts Cortex, Brain, and Central based on their listening ports and runs the daily backup. Review scripts/windows/supervisor.ps1 and scripts/windows/register-supervisor.ps1 before registering them. The supervisor binds all three services to every interface and uses fixed repository and data paths, so configure authentication, exact CORS origins, allowed project roots, and private firewall rules first.

macOS and Linux​

An opt-in macOS launchd plist and installer exist. With the repository under a protected user directory, macOS privacy controls prevent that launchd job from reading .env unless the operator grants access or relocates the working set. Manual start is the accepted supported default for the current operator workflow.

No equivalent checked-in systemd unit covers Linux. A manually started worker stays down after a crash until the operator restarts it. Containers are the practical answer on Linux.

Alerts​

Central exposes operational alerts through GET /alerts. Cortex shows an alert bar and can send browser desktop notifications for new alerts. There is no external push, email, or chat destination.

/alerts also reports tasks_stranded: pending tasks pinned to a worker that has been offline longer than the pinned worker grace period, or pinned to a registration that was deleted. Central offers a pinned task to that worker alone and no lease exists before a claim, so nothing expires this work. It is reported rather than moved, because the pin is often load bearing: a follow-up may resume a CLI session that lives on that worker's disk. Clear it by starting that worker, or by retrying the task against another one.

Backups​

Run a manual Central backup:

python scripts/backup_data.py --keep 7

Everything in the data root is archived except backups/ itself, process locks, and WAL sidecars. Every *.sqlite3 database at any depth goes through the SQLite backup API rather than a byte copy, so the archive is safe to take while Central and Brain are writing. The inventory is exclusion-based on purpose: an allowlist rotted once, and a ledger added tomorrow is now included by default. Output is a timestamped zip under <data_root>/backups/ carrying a MANIFEST.json with a SHA-256 per member.

python scripts/backup_data.py --verify <data_root>/backups/agentasian-<stamp>.zip

Run the same command on each worker. A worker keeps worker-credentials/ and outbox/ under its own data root, so its archive carries that machine's state; Central's archive cannot.

An archive that leaves the machine should be encrypted. --encrypt writes a .zip.enc with AES-256-GCM under a key derived from AA_BACKUP_PASSPHRASE (prompted when unset), and writing to an --output outside the data root refuses unless you pass --encrypt or acknowledge --plaintext-ok.

What no archive contains: external content roots. The voice pack directory, the influence library originals and extraction files, and pack history live outside the data root and need their own copy.

Restore with python scripts/restore_data.py <archive>. It verifies every byte against the manifest before writing, refuses a role mismatch (a worker archive onto a Central root), refuses to run over the live data root while Central or Brain is up (Brain writes chroma/ through a persistent client), and deletes nothing: the current contents move to <data_root>/pre-restore-<stamp>/, WAL sidecars included, so a bad restore is itself reversible. --dry-run verifies and writes nothing.

After a restore, three things are expected rather than faults: a worker whose credential file no longer matches its registration is locked out by design and re-enrolls fresh once its registration is deleted; a rolled-back run-token table heals itself because a report with no matching token row is processed on fence semantics alone; and a restored outbox may redeliver results Central already accepted, which land as duplicate or superseded, never as new work.

Rehearse a restore​

Do this before you need it, and do it while the agency is running: a drill that needs downtime never gets run. Restoring into a scratch directory needs no stopped service.

python scripts/restore_data.py <archive> --data-dir /tmp/restore-drill --yes
python -c "import sqlite3;print(sqlite3.connect('/tmp/restore-drill/forge.sqlite3').execute('PRAGMA integrity_check').fetchone())"
  1. Verify the archive first (--verify), and the worker archives too.
  2. Restore into the scratch directory and run the integrity check.
  3. Compare row counts and ledger line counts against the live root.
  4. For a real restore, stop Central and Brain, restore over the live root, then start them and confirm health.
  5. Expect the three post-restore behaviors above; delete a locked-out worker's registration so it re-enrolls.
  6. Record the restore time and any manual steps.

Shutdown​

For the interactive stack, return to the launcher shell and press Ctrl+C. It terminates Forge, Brain, and Cortex. Stop workers separately. Before a restore or data migration, stop Central and every process writing to that data root.