Skip to main content

Operating the daemon

ailang-worldd serve is one local process over one SQLite store file. It serves REST, MCP and A2A on a loopback address.

Flags​

ailang-worldd serve --db <path> [--bind host:port] [--ailang-bin <path>]
[--workspace-root <dir> --tool-ailang-bin <path>]
[--examples-dir <dir>]
[--workspace-module-root REL] [--workspace-episode-module-root EP=REL ...]
[--workspace-package-cache <dir>]
[--run-allow-caps Env,Net,Declassify]
[--run-net-allow 127.0.0.1:PORT ...] [--run-net-allow-http]
[--exec-profile <file> ... --exec-sandbox <dir>]
[--exec-episode-project EP=PROJECT ...] [--exec-node <path>]
[--exec-max-output-bytes N]
[--proof-key-file <file> --proof-required-identity NAME ...]
FlagDefaultMeaning
--dbrequiredThe world store database. Its parent directory must already exist.
--bind127.0.0.1:7644Loopback listen address. A non-loopback host is refused; there is no override.
--ailang-binnoneThe interpreter (PIN, v0.41.0) to archive and pin at startup. Without it, transitions cannot be invoked: the A2A and MCP surfaces answer transition invocation is not available in this daemon.
--workspace-rootnoneDirectory holding one worktree per episode, at <dir>/<episode>. Must not contain the store, its archive, its rendered policies or its tool cache.
--tool-ailang-binnoneThe AILANG binary the coding tools run (TOOL). Must be AILANG v0.54.15. Archived and hash-verified like --ailang-bin.
--examples-dir~/.ailang/examples if it existsThe AILANG examples corpus examples-search reads, passed to the tool as AILANG_EXAMPLES. Must be outside --workspace-root.
--workspace-module-rootnone (., the worktree)The AILANG sandbox and module root of every episode is <workspace-root>/<episode>/REL, so bare imports among a project's modules resolve. REL is clean and relative and must already be a real directory, or that episode's tools are refused. Independent of an exec profile's root. Needs --workspace-root.
--workspace-episode-module-rootnoneEP=REL, repeatable: one episode's module root, overriding --workspace-module-root.
--workspace-package-cachenoneA read-only snapshot of registry packages (<ns>/<name>/<ver>/ailang.toml), linked as every episode's package cache so pkg/ imports resolve. Must be outside --workspace-root and the state directory and hold no symlink and nothing writable (chmod -R a-w); refused when the daemon runs as uid 0. Restart serve after rebuilding it. See QUICKSTART §11, "Projects with a module root and registry packages".
--run-allow-capsnoneEnv,Net,Declassify: extra capabilities an ailang-run may request beyond IO and FS. An Env run is the effect Ailang.RunEnv and a Net run Ailang.RunNet; each needs its own session grant.
--run-net-allownoneA loopback IP:PORT a Net run may reach (repeatable; required with Net). Every other host, port and redirect hop is refused; a bare host, a name or a non-loopback address is refused at startup.
--run-net-allow-httpoffAllow plain http to the --run-net-allow pairs.
--exec-profilenoneAn operator exec profile (world/exec-profile/v1 JSON; repeatable, one per project): the commands workspace-exec may run, sandboxed by srt. Needs the workspace tools and --exec-sandbox. Read once at startup; it, srt, node and every cache seed must lie outside --workspace-root and the state directory. Each profile must pass the seven-arm startup probe or serve refuses. Without it, workspace-exec is still bound but refuses every call no exec profile configured. See QUICKSTART §10, "Build and test non-AILANG projects".
--exec-episode-projectnoneEP=PROJECT, repeatable: run episode EP's workspace-exec under the profile whose project is PROJECT (optional with one profile, which every episode then uses).
--exec-sandboxnoneThe node_modules holding @anthropic-ai/sandbox-runtime 0.0.78 (its dist/cli.js must hash to the pin). World archives the whole tree and re-verifies it before every call. Required with --exec-profile.
--exec-nodenode on PATHThe node (20.11 or later) that runs srt and the probe client, resolved once.
--exec-max-output-bytes67108864 (64 MiB)Kill a workspace-exec command whose stdout or stderr passes N bytes.
--proof-key-filenoneA file holding exactly 32 bytes: the MAC key the workbench grade validator authenticates stored proof envelopes under. Needs --ailang-bin and at least one --proof-required-identity; read once at startup and never logged. Unset, every object page reads "no canonical host projection".
--proof-required-identitynoneAn identity every validated proof must verify (repeatable; needs --proof-key-file).
--workbench-stillfalseSuppress only the workbench live.js script for static captures of recorded history. All server-rendered regions remain; reload to refresh.

The coding tools are served only when both --workspace-root and --tool-ailang-bin are set. With one but not the other, startup logs:

ailang-worldd: workspace tools disabled: --workspace-root and --tool-ailang-bin must both be set; every effect-declaring transition is refused

--addr is a client flag. It is refused with serve (use --bind).

Exit codes: 0 ok, 1 usage or client error, 2 fatal startup.

What startup does​

In order, within a 9 s startup budget:

  1. Refuses if AILANG_REGISTRY_API_KEY is set (see below).
  2. Refuses a non-loopback --bind host (allowed: 127.0.0.1, ::1, localhost).
  3. Resolves --workspace-root and --examples-dir and refuses a workspace root that contains the daemon's own state, or an examples corpus inside the workspace root.
  4. Opens the store and takes the writer lock.
  5. Archives --tool-ailang-bin (if given) and refuses any release but AILANG v0.54.15.
  6. Archives --ailang-bin (if given) and builds the invocation coordinator.
  7. Bootstraps the epoch registry (world/epoch-registry/v1) for the interpreter's release. A registry head naming different bytes is a fatal divergence, never silently rewritten.
  8. Runs a bounded integrity scan of log and world rows.
  9. Binds the socket and prints ailang-worldd listening on http://127.0.0.1:7644.

A startup failure prints daemon startup failed at <stage>: <detail>: <cause> and exits 2. The stages are config, store-open, archive, registry-bootstrap, bind-policy and listen.

For each episode the first tool call constructs the episode's handler: it renders the policy at <db-dir>/policies/<episode>.toml (mode 0600), creates the tool cache at <db-dir>/cache/<episode>, and runs one policy-tool summary to verify the binary honours the policy. If that fails, the daemon logs ailang-worldd: workspace tools unavailable for episode "<ep>": … and the episode gets no tools.

One writer per store​

Each store file permits exactly one writer process. Open takes a non-waiting exclusive OS lock on <db>.writer.lock before any SQLite write handle. A second writer fails immediately:

ailang-worldd: daemon startup failed at store-open: another process already holds writer authority for this database (single-writer is enforced, not conventional): …

This covers every writer, not only a second daemon. Stop the daemon before running session new, session mint, session revoke, world-publish transitions, world-publish epoch nominate or any other world-publish verb that opens the same store. Read-only store users (session list, for one) may coexist.

The operator sequence is therefore always: serve, stop, do the attended step, serve again.

The registry-credential guard​

ailang-worldd: broker: AILANG_REGISTRY_API_KEY is set in the process environment: move it to a mode-0600 file outside the working tree and unset it (see design_docs/planned/w-self-mod-vertical.md Decision 4)

The check runs before flag parsing, so it applies to serve and to every client verb. The message names the variable, never its value. Fix it with unset AILANG_REGISTRY_API_KEY in the shell that starts the daemon. The publish credential belongs in a file named by world-publish --credential-file, and nowhere else.

Logs​

  • stdout: the listening on line, then integrity warnings only if the scan found a hole or could not finish (integrity_hole …, integrity_scan_incomplete …). A clean scan prints nothing.
  • stderr: one line per internal error with its route (the HTTP client sees only internal store failure), A2A and MCP refusal causes (ailang-worldd: a2a refusal: tasks/send <invocation-id>: "<cause>" and ailang-worldd: mcp refusal: tools/call <invocation-id>: "<cause>"), and workspace-tool messages.

Run serve in a terminal you can see, or redirect both streams to a file. When it is backgrounded, stop it by PID (the smoke script keeps a pidfile), not by shell job control from another shell.

Bounds​

BoundValue
Store read per GET request10 s, then 503 Timeout
Commit store work3 s, then 503 Timeout or 503 CommitUncertain
Credential lookup3 s
One transition invocation (MCP or A2A)20 s
Plan phase4 s
Finish phase2 s
Tool handlerat most 10 s; the rendered policy's own timeout_ms is 8 s
Post-effect writes and commit4 s, detached from the caller's deadline
HTTP read / write timeout30 s / 30 s
Commit body8 MiB (413 PayloadTooLarge)
A2A request body1 MiB
MCP request body4 MiB
Log range and object pagesdefault 100, maximum 500
Shutdown drain10 s

Health​

ailang-worldd health

returns status, daemon_version, db_path, interpreter_ref and interpreter_version (interpreter_ref is empty when serve ran without --ailang-bin). With --workspace-root, it also lists degraded_episodes: episode directories that are not git worktrees (adopted with session new --allow-non-git); the key is absent when there are none.

The workbench​

GET /workbench is a read-only HTML renderer for operators: the log, worlds, objects and the references between them. It accepts the query parameters world, object, from, entry, payload (0 or 1), refsAfter and commitsAfter. It is not part of the frozen v1 API and its HTML may change.

Shutdown​

SIGINT or SIGTERM drains in-flight requests (bounded at 10 s) and releases the writer lock. A clean drain prints nothing.