iii compose iii compose --up ``` The daemon is a worker named `compose`, so every project operation is a [function call](./functions#call-a-function) to `compose::*`. `iii compose --up` is about the same as running `iii`, `iii compose`, and `iii call compose::up` separately. Run `iii` and `iii compose` separately when the engine needs its own lifecycle. See [The daemon and its processes](../understanding-iii/compose#the-daemon-and-its-processes). ```bash iii compose --up --namespace dev -f wo...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Using Iii?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/iii-hq-using-iii-350b42a1)
<!-- generated by iii-skill-render. DO NOT EDIT (changes here are overwritten on the next render). Edit docs/next/using-iii/compose.mdx. -->
Compose runs a group of workers as one project. The daemon reads a `worker-compose.yaml`, starts and
stops each worker in dependency order, and supervises the running workers.
## The daemon
```bash
# Start the daemon only. It serves compose::* calls.
iii compose
# Start the daemon, the engine, and every worker in worker-compose.yaml.
iii compose --up
```
The daemon is a worker named `compose`, so every project operation is a
[function call](./functions#call-a-function) to `compose::*`. `iii compose --up` is about the same
as running `iii`, `iii compose`, and `iii call compose::up` separately. Run `iii` and `iii compose`
separately when the engine needs its own lifecycle. See
[The daemon and its processes](../understanding-iii/compose#the-daemon-and-its-processes).
### Starting a project with the daemon
```bash
iii compose --up --namespace dev -f worker-compose.dev.yaml
```
| Option | Description |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--engine <URL>` | Existing engine WebSocket address. Overrides the compose file and III_URL. The local default is used when none of them supplies a URL |
| `-n, --namespace <NS>` | Namespace this daemon answers `compose::*` in and applies to every project it loads. Several daemons attach to one engine; this is what tells them apart |
| `--up` | Serve with one project brought up first, starting its declared engine unless `--engine` selects an existing one |
| `--frozen` | With `--up`, require the compose file and existing lock to match and skip package resolution |
| `-f, --file <PATH>` | The compose file. Only valid with `--up`. Defaults to `./worker-compose.yaml`, the same fallback `compose::up` uses when a call names no file |
`Ctrl^C`, `SIGINT`, `SIGTERM`, and `SIGHUP` stop the daemon, its workers, and the engine it started
with `--up`. [`compose::stop`](#stopping-the-daemon) does the same from a function call. An engine
Compose did not start keeps running.
### Process names on Linux
```bash
ps -p <PID> -o pid,ppid,comm,args
```
The daemon is labelled `iii:c:<namespace>` and an engine it started `iii:e:<namespace>`. For example,
`iii compose --namespace orders --up` shows:
```text
iii:c:orders
+-- iii:e:orders
```
`comm` abbreviates a namespace longer than nine characters. Read the full namespace in `args`. See
[Process names](../understanding-iii/compose#process-names).
### Compose logs
```bash
iii compose logs # last 100 lines from every worker
iii compose logs queue --tail 200 # one worker
iii compose logs queue --follow # keep waiting for new output
iii compose logs queue --stream stderr # only stderr
iii compose logs queue --namespace dev --engine ws://127.0.0.1:49134
```
| Option | Description |
| ---------------------- | ------------------------------------------------------------------------------------- |
| `[WORKER]` | Worker to read. Omit to read every worker in the project |
| `--engine <URL>` | Existing engine WebSocket address. The compose file and III_URL are used when omitted |
| `-n, --namespace <NS>` | Namespace of the Compose daemon that owns the project |
| `-f, --file <PATH>` | Compose file path on the daemon host. The daemon's default file is used when omitted |
| `--tail <TAIL>` | Number of recent lines to show before following new output [default: 100] |
| `-F, --follow` | Continue waiting for new output until interrupted |
| `--stream <STREAM>` | Restrict output to one process stream [possible values: stdout, stderr] |
Each line starts with the worker name. The files are in `logs/` of the
[state directory](#where-compose-keeps-state), and the managed engine writes `engine.log` there. See
[Log files](../understanding-iii/compose#log-files).
### Running it in the background
Compose does not daemonize itself. Use shell backgrounding:
```bash
iii compose --namespace dev --engine ws://127.0.0.1:49134 >> ~/iii-compose.log 2>&1 &
```
Or a systemd unit:
```ini
[Unit]
Description=iii compose
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/iii compose --namespace prod --engine ws://127.0.0.1:49134
Restart=always
[Install]
WantedBy=multi-user.target
```
<Warning>
Use `Type=simple`. `Type=notify` waits for an `sd_notify` readiness message, which compose does
not send.
</Warning>
## The `compose::*` functions
These functions control a running daemon and edit `worker-compose.yaml`:
```bash
iii call compose::up --namespace dev file=./worker-compose.yaml
iii call compose::up --namespace dev file=./worker-compose.yaml frozen=true
iii call compose::up --namespace dev file=./worker-compose.yaml container=api
iii call compose::status --namespace dev file=./worker-compose.yaml
iii call compose::logs --namespace dev file=./worker-compose.yaml worker=api tail=100
iii call compose::down --namespace dev file=./worker-compose.yaml
iii call compose::list --namespace dev
iii call compose::add --namespace dev file=./worker-compose.yaml worker=database worker=web
iii call compose::remove --namespace dev file=./worker-compose.yaml worker=state
iii call compose::restart --namespace dev file=./worker-compose.yaml
iii call compose::build --namespace dev file=./worker-compose.yaml worker=onboarding
iii call compose::schema --namespace dev function_id=compose::up
iii call compose::stop --namespace dev
```
| Function | Takes | Returns |
| ------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `compose::up` | `file`, `container`, `frozen`, `stderr` | An operation result; with `stderr`, its progress first. |
| `compose::down` | `file`, `container`, `stderr` | An operation result; with `stderr`, its progress first. |
| `compose::status` | `file` | Namespace, file, state directory, daemon pid, host targets, worker states. |
| `compose::ps` | `file` | The daemon pid and the operating-system processes of its projects. |
| `compose::logs` | `file`, `container`, `cursors`, `tail`, `stream`, `wait_ms`, `follow`, `stdout`, `stderr` | Bounded stdout/stderr entries and one cursor per worker; with streams, the lines as text. |
| `compose::list` | nothing | The daemon name, namespace, pid, host targets, and every project it holds. |
| `compose::validate` | `file` | A validation report. |
| `compose::add` | `file`, `workers`, `stderr` | An accepted operation; with `stderr`, its progress, then its outcome. |
| `compose::remove` | `file`, `workers`, `prune`, `stderr` | An accepted operation; with `stderr`, its progress, then its outcome. |
| `compose::restart` | `file`, `container`, `stderr` | The `down` and the `up`, or one worker's restart; with `stderr`, its progress first. |
| `compose::update` | `file`, `workers`, `stderr` | An accepted operation; with `stderr`, its progress, then its outcome. |
| `compose::build` | `file`, `worker`, `operation_id`, `stderr` | An accepted operation; with `stderr`, its progress and build lines, then its results. |
| `compose::stop` | nothing | The daemon name, its pid, and the projects it is about to stop. |
| `compose::schema` | `function_id` | Request/response JSON Schemas, descriptions, timeouts, and retry safety. |
`file` is optional when the daemon holds one project. A relative `file` is relative to the daemon's
directory, not yours; an absolute path also works. See
[Which project a call reaches](../understanding-iii/compose#which-project-a-call-reaches).
### Progress from `iii call`
From `iii call`, the functions that change a project (`compose::up`, `down`, `restart`, `add`,
`update`, `remove`, and `build`) show their progress and answer once the operation finished.
`iii call` binds its standard error to the `stderr` stream of the request and says what its terminal
is in `terminal`, and Compose draws each worker the operation moves into the stream: a spinner per
worker, redrawn in place, on a terminal, or one line per change when standard error is a pipe or a
file. Workers the operation leaves as they are, such as those already running, are not listed.
```text
$ iii call compose::add worker=state worker=queue
⠹ adding 2 workers (4.2s)
✓ state ready (1.2s)
⠼ queue waiting for engine registration (3.0s)
```
- The call exits with `0` once the operation succeeded, or when a worker that is not required did
not start, which the last line names. It exits with `1` when a required worker failed or the
operation was cancelled, and `iii call` prints the `Error:` with its code.
- `--print-result` prints the answer. `up`, `down`, and `restart` answer as they do without a
stream. `add`, `update`, `remove`, and `build` answer `status: "succeeded"` with the operation's
`outcome`, or the build's `results`.
- `compose::build` also prints each line its builds write, labelled `<worker> │`, above the
progress.
- The first `Ctrl+C` cancels the operation, as `compose::cancel` does, and the call exits once the
operation stopped.
- Without a `stderr` stream, as from an SDK, the ADE, or `iii call --no-follow`, each function
answers as it always did. `add`, `update`, `remove`, and `build` answer
`{ operation_id, status: "accepted", requested }` at once and finish in the background: follow
them with `compose::operation` or by observing `compose::on-operation-progress`.
### Starting a project
```bash
# Start every worker in dependency order.
iii call compose::up
# Start one worker and the workers it depends on.
iii call compose::up container=api
# Start from the lock only.
iii call compose::up frozen=true
```
| Field | Description |
| ----------- | -------------------------------------------------------------------------------------------- |
| `file` | The project to start. |
| `container` | Starts that worker and the workers it depends on, and nothing else. |
| `frozen` | Requires a current lock for the selected compose file and does not resolve package selectors when `true`. |
Workers that are already ready stay as they are. A container with no build yet gets
[its first build](../understanding-iii/compose#the-first-build) before it runs.
#### compose::up failures
Make a worker's failed start fail the operation:
```yaml
containers:
database:
worker: path://./workers/database
required: true
```
Or set the fallback for every container in the file. A container's own value wins:
```yaml
required_default: true
containers:
queue:
worker: package://queue
version: "0.21.9"
required: false
state:
worker: package://state
version: "0.22.5-rc.1"
```
A worker is not required by default: its failure is listed in `not_required_failures`, and the
operation still returns `status: ok` with no top-level `error`. A required failure ends the operation
with `PROJECT_DID_NOT_START` and rolls back the partial start in reverse dependency order. See
[Saying it in the file](../understanding-iii/compose#saying-it-in-the-file).
#### Retrying a worker that fails
```yaml
containers:
api:
worker: path://./workers/api
restart: on-failure
```
Or, to change the limits:
```yaml
containers:
api:
worker: path://./workers/api
restart:
condition: on-failure
delay: 500ms
max_delay: 30s
max_attempts: 5
window: 60s
```
| Field | Description | Default |
| -------------- | ------------------------------------------------------------------------------- | ---------------------- |
| `condition` | Required in the object form. Accepts `no`, `on-failure`, or `always`. | `no` in the short form |
| `delay` | Base delay for exponential backoff after a replacement fails. | `500ms` |
| `max_delay` | Maximum delay between replacement attempts. | `30s` |
| `max_attempts` | Maximum replacement attempts after the original process fails. | `5` |
| `window` | Time a ready worker must stay active before its run-time attempt budget resets. | `60s` |
`no` is the default. `on-failure` retries a failed start or a non-zero exit. `always` also restarts a
worker that exits successfully after it was ready. See
[Retry policy](../understanding-iii/compose#retry-policy).
### Stopping a project
```bash
# Stop the project in reverse dependency order.
iii call compose::down
# Stop one worker and the workers that depend on it.
iii call compose::down container=api
```
| Field | Description |
| ----------- | ---------------------------------------------------------------------- |
| `file` | The project to stop. |
| `container` | Stops that worker and the workers that depend on it, and nothing else. |
### Adding workers
```bash
# A registry package, pinned to its latest version.
iii call compose::add worker=state
# A package version and a local directory in one call.
iii call compose::add worker=state@0.21.4 worker=./workers/api
```
To set container fields, pass a JSON list that mixes names and container objects:
```bash
iii call compose::add --namespace dev file=./worker-compose.yaml --json '{
"workers": [
"database",
{
"worker": "./workers/api",
"start_after": ["database"],
"scripts": {
"pre_run": "pnpm build",
"pre_run_timeout": "60s",
"run": "pnpm start",
"post_run": "echo stopped"
},
"config_name": "api",
"config_override": { "port": 3000 },
"working_dir": "./workers/api",
"environment": { "NODE_ENV": "development" },
"env_file": ["./api.env"],
"startup_timeout": "30s"
}
]
}'
```
| Field | Description |
| --------- | ------------------------------------------------- |
| `file` | The project to edit. |
| `workers` | A JSON list of worker names or container objects. |
| `worker` | One worker. Repeatable on the CLI. |
A container object accepts these fields:
| Field | Description |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `worker` | Required. A package name, `name@version`, registry reference, or local path. Also accepts `package://` and `path://` sources. |
| `version` | Package version. Must agree with a version included in `worker`. |
| `start_after` | Container keys to start first. Compose adds the package's resolved dependencies to this list. |
| `scripts` | `pre_run`, `pre_run_timeout`, `build`, `build_timeout`, `run`, and `post_run`. |
| `runtime` | `base_image`: the image of the worker's VM, over its manifest's. A `binary` package needs it to run in a VM. |
| `config_name` | Name of the worker's base configuration. |
| `config_override` | Configuration value applied over the base configuration. |
| `working_dir` | Working directory, relative to the compose file. |
| `environment` | Environment variables with string values. |
| `env_file` | List of environment file paths, relative to the compose file. |
| `startup_timeout` | Maximum wait for worker registration, such as `30s`. |
The container key is the last part of the worker name or path: `ade` for the private worker
`@acme/ade` (see [Private workers](./workers-registry#private-workers)). A selector such as
`state@next` stays as written in the file. For an existing container, a supplied field replaces that
whole field; use `{}` or `[]` to clear it. A VM worker gets its `scripts` and `start_after` written
for it (see [VM workers](#vm-workers)). See
[How compose::add edits a project](../understanding-iii/compose#how-composeadd-edits-a-project).
From `iii call`, `compose::add` shows each worker it starts and answers once the operation
finished. See [Progress from `iii call`](#progress-from-iii-call).
### Package lock
```bash
# CI: require the compose file and its lock to match.
iii compose build --frozen
# Start from the lock without resolving selectors.
iii compose --up --frozen
iii call compose::up frozen=true
```
| Compose file | Lockfile |
| --- | --- |
| `worker-compose.yaml` | `worker-compose.lock` |
| `worker-compose.dev.yaml` | `worker-compose.dev.lock` |
| `worker-compose.prod.yml` | `worker-compose.prod.lock` |
| `config/local.yaml` | `config/local.lock` |
Commit the lock so development, CI, and deployments use the same package content. Files that differ
only by extension share one lock; use different stems when you need independent locks. See
[The package lock](../understanding-iii/compose#the-package-lock).
### Removing a worker
`compose::remove` removes a worker from the compose file and stops it. The other workers keep
running.
```bash
iii call compose::remove worker=onboarding
# Remove two workers at once.
iii call compose::remove worker=onboarding worker=link
# Also delete the data of a VM worker.
iii call compose::remove worker=onboarding prune=true
```
| Field | Description |
| --------- | ----------------------------------------------------------------- |
| `file` | The project to edit. |
| `worker` | The worker to remove. |
| `workers` | Optional non-empty list of workers. Takes precedence over `worker`. |
| `prune` | Also delete the data of the worker's VM. Defaults to `false`. |
Removing a worker does not remove the workers that were added with it. Remove them explicitly.
A VM worker keeps its data unless you pass `prune=true`, and a container added again under the same
key boots with that data. See
[Removing a VM worker](../understanding-iii/compose#removing-a-vm-worker).
### Restarting one worker
`compose::restart` stops a worker and starts it again. The other workers, its dependencies
included, keep running. A restart never runs `scripts.build`.
```bash
# Restart one worker.
iii call compose::restart worker=state
# Restart the whole project, about the same as compose::down followed by compose::up.
iii call compose::restart
```
| Field | Description |
| -------- | ----------------------- |
| `file` | The project to restart. |
| `worker` | The worker to restart. |
Restarting the sandbox adapter (`worker=sandbox-libkrun`) also restarts every VM worker it runs.
See [Restarting the sandbox adapter](../understanding-iii/compose#restarting-the-sandbox-adapter).
### Updating workers
`compose::update` moves declared registry workers to newer versions, together with their
dependencies. To add a worker, use [`compose::add`](#adding-workers).
```bash
# Update every registry worker to its latest version.
iii call compose::update
# Update one worker within the selector the file declares: a tag, a range, or a version.
iii call compose::update worker=state
# Update two workers.
iii call compose::update worker=state worker=queue
# Move a worker to a version or a tag. This is also how you downgrade.
iii call compose::update worker=state@0.21.4
iii call compose::update worker=state@latest
```
| Field | Description |
| --------- | ----------------------------------------------------------------- |
| `file` | The project to edit. |
| `worker` | Optional worker spec: `name` or `name@version`. |
| `workers` | Optional non-empty list of specs. Takes precedence over `worker`. |
`path://` workers have no version: an update skips them, and a restart picks up their changes.
<Note>
An update that changes package content or graph topology restarts the whole project once.
</Note>
For what an update resolves, downloads, and rebuilds, see
[Updating packages](../understanding-iii/compose#updating-packages).
### Building workers
`compose::build` runs `scripts.build` again for one container, or for every container that declares
one. The running container keeps its current build until it restarts, so restart it once the build
is done:
```bash
iii call compose::build worker=link
iii call compose::restart worker=link
```
| Field | Description |
| -------------- | ------------------------------------------------------------------------ |
| `file` | The project to build. |
| `worker` | A container key. Omitted, every container that declares `scripts.build`. |
| `operation_id` | Optional, as for other mutations. |
- From `iii call`, each line of the build is printed as it comes, labelled `<container> │`, above
its progress, and the call exits with how the build ended. See
[Progress from `iii call`](#progress-from-iii-call).
- Without a stream, as from an SDK or `iii call --no-follow`, the call answers at once with an
`operation_id`. The container's logs show the build, each line with the `[build] ` prefix.
- A container whose `scripts.build` is `""` is reported as `skipped`.
- `compose::cancel` with the operation id, or `compose::down`, stops the build.
The finished operation carries one result per container:
```text
results: [{ worker, status: "built" | "failed" | "skipped", build_id?, error?: { code, message } }]
```
For what a failed or cancelled build leaves, see
[Rebuilds](../understanding-iii/compose#rebuilds).
### Checking status
```bash
iii call compose::status --namespace dev file=./worker-compose.yaml
```
Each worker has its `state`, `version` (the locked version, or `local` for a `path://` worker),
`requested` selector, `pid`, `owned`, `log_path`, and `last_error` when there is one. `owned` is
`false` for a worker the daemon knows about but did not start. See
[What compose::status reports](../understanding-iii/compose#what-composestatus-reports).
```json
{
"namespace": "default",
"file": "/srv/app/worker-compose.yaml",
"state_dir": "/srv/app/.iii/compose/default",
"daemon_pid": 4242,
"target": "x86_64-unknown-linux-musl",
"targets": ["x86_64-unknown-linux-musl", "x86_64-unknown-linux-gnu"],
"containers": [
{
"container": "state",
"state": "ready",
"version": "0.22.8",
"requested": "latest",
"pid": 81234,
"owned": true,
"log_path": "/srv/app/.iii/compose/default/logs/state.log"
},
{
"container": "api",
"state": "ready",
"version": "local",
"pid": 81240,
"owned": true,
"log_path": "/srv/app/.iii/compose/default/logs/api.log"
}
]
}
```
#### Worker states
| State | Meaning |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `starting` | Spawned. The engine has not registered it yet. |
| `ready` | Registered in the engine under `(namespace, container)`. |
| `restarting` | Waiting for the next configured retry. No process or PID is active. |
| `failed` | Exited unsuccessfully with no eligible retry, exhausted its retries, failed to start during `up` or a restart before it registered (a failed `pre_run` hook included), or did not register again within its `startup_timeout` after an engine reconnect and was stopped. After a daemon restart, also a worker that exited while the daemon was away or while it was being adopted, or whose live PID Compose cannot prove is the one it started. That process is left running and never signalled. `last_error` says why. |
| `stopped` | Stopped by the daemon, or exited successfully without an eligible restart. |
### Listing processes
```bash
iii call compose::ps --namespace dev file=./worker-compose.yaml
```
Lists the daemon, its managed engine, every worker, and the processes those workers started. Omit
`file` for every project of the daemon. Each entry has `pid`, `ppid`, `kind` (`engine`, `compose` or
`worker`), `name` (the worker's container key), `ports`, `compose_file`, `orphan`, `started_at`
(seconds since the Unix epoch), and `command`. `orphan` is `true` for a worker of the project that no
Compose daemon supervises. For every iii process on the machine, use
[`iii ps`](#finding-and-stopping-iii-processes).
### Viewing logs
```bash
iii call compose::logs --namespace dev worker=api tail=200
iii call compose::logs --namespace dev worker=api follow=true
iii call compose::logs --namespace dev worker=api stream=stderr wait_ms=5000 --no-follow
```
| Field | Description |
| --------- | ------------------------------------------------------------------------------------ |
| `file` | The project to read. |
| `worker` | One worker. Returns every compose-orchestrated worker when omitted. |
| `tail` | Recent lines returned when no cursor is sent. Default 100, maximum 1000. |
| `cursors` | The `cursor` from the last response, keyed by worker. The call continues from there. |
| `stream` | `stdout` or `stderr`. Omit for both. |
| `wait_ms` | Wait this many milliseconds for new output. Maximum 5000. |
| `stdout` | A stream to write the lines into as text instead. `iii call` binds its own. |
| `stderr` | A stream to write the stderr lines into as text. `iii call` binds its own. |
| `follow` | With a stream, keep writing new lines until the caller leaves. |
The response holds one entry per worker with `container`, `entries` (each with `stream` and
`message`), `cursor` (`generation` and `offset`), and `truncated`, which is `true` when the cursor
sent is older than the retained archives.
From `iii call`, `compose::logs` writes the lines as text rather than answering with them: stdout's
lines to standard output and stderr's to standard error, each labelled `<worker> │` when every
worker is read. With `follow=true` it keeps writing new lines until `Ctrl+C`. `--print-result`
prints the cursors to resume from, and `--no-follow` gives the JSON response above.
### Listing projects
```bash
iii call compose::list --namespace dev
```
Returns the daemon name, namespace, pid, `target` and `targets`, and every project it holds with its
namespace, file, and worker states.
### Validating a file
```bash
iii call compose::validate --namespace dev file=./worker-compose.yaml
```
Validation is offline and never edits the file: `package://` workers are listed under
`deferred_packages`, not resolved. When the next `up` would rewrite containers into the explicit VM
mode, a warning names them (only packages the lock already records as bundles):
```text
migration due: <c>, <c>; the next up rewrites them
```
#### Validation reports
| Field | Type | Description |
| ------------------- | ------ | --------------------------------------------------------- |
| `namespace` | string | Namespace the project's workers register in. |
| `start_order` | array | Worker names in dependency order. |
| `deferred_packages` | array | `package://` workers, which need the registry to resolve. |
| `warnings` | array | Warnings, such as the containers the next `up` rewrites. |
### Stopping the daemon
```bash
iii call compose::stop --namespace dev
```
Stops every project and worker of the daemon, the engine it started with `--up`, and then the daemon
itself. It answers first with its name, pid, and the projects it is about to stop.
<Warning>
There is no `compose::start` equivalent to `compose::stop`. Stopping a compose daemon means it
must be restarted from the server it is running on.
</Warning>
### Viewing schema
```bash
iii call compose::schema --namespace dev
iii call compose::schema --namespace dev function_id=compose::up
iii call compose::schema --namespace dev function_id=worker-compose.yaml
```
With no `function_id`, it returns every `compose::*` schema. The pseudo-id `worker-compose.yaml`
returns the file's JSON Schema as `request` and a small example as `response`. Each entry holds
`function_id`, `description`, `request`, `response`, `default_timeout_ms`, and `idempotent`, as
`engine::functions::info` does.
## Configure a namespace
```yaml
namespace: dev
```
Or override it when you start the daemon:
```bash
iii compose --namespace dev
```
Use the same namespace in calls and observers that target the project's workers and its
`compose::*` functions. See
[Three names, three jobs](../understanding-iii/compose#three-names-three-jobs).
### Precedence
| Value | Sets |
| ------------------------ | ----------------------------------------------------------------------------- |
| `-n, --namespace <NS>` | The daemon namespace, and the project namespace of every project it loads. |
| `namespace:` in the file | The daemon namespace when `--namespace` is absent, and the project namespace. |
| Neither | `default`. |
### What a namespace may hold
Only lowercase `a-z`, `0-9`, `-`, and `_`. Anything else, uppercase included, fails with
`INVALID_NAMESPACE`.
### One daemon to a namespace
<Warning>
Only one Compose daemon can serve a namespace on a iii engine. A second one fails with
`DAEMON_ALREADY_SERVING`. Give each daemon its own namespace when several share one engine.
</Warning>
## `worker-compose.yaml`
Below is an example of version 1 of a worker compose file. Unknown keys and duplicate keys are
errors. Durations can specify a unit such as: `500ms`, `30s`, `2m`.
```yaml
namespace: shop
startup_timeout: 60s
stop_timeout: 10s
engine:
url: ws://127.0.0.1:49134
workers:
configuration:
adapter:
name: fs
config:
directory: ./config
containers:
database_1: # Worker names do not need to match package names
worker: package://database
version: "0.21.4"
api:
worker: path://./workers/api
start_after: [database_1]
config_name: shop-api
config_override:
log_level: debug
env_file: [./.env] # specify .envs, later in list overwrites earlier declarations
environment:
RUST_LOG: info # specify environment variables directly
MY_ENV: ${MY_ENV:-defaultValue} # assign an environment variable from the execution environment
scripts:
pre_run: npm run migrate
pre_run_timeout: 2m
run: npm start
post_run: ./scripts/cleanup.sh
state:
worker: package://state
version: "0.21.4"
```
### Top-level fields
| Field | Type | Default | Description |
| ------------------ | ------- | ------- | --------------------------------------------------------------------------------------------- |
| `namespace` | string | absent | Namespace the project's workers register in. A project that declares none lands in `default`. |
| `startup_timeout` | string | `60s` | Readiness budget for every worker. A worker may override it. |
| `stop_timeout` | string | `10s` | Grace between the polite stop and the forced kill. |
| `required_default` | boolean | `false` | Fallback for workers that omit `required`. An explicit worker value wins. |
| `engine` | map | absent | Present when this Compose invocation owns and configures the engine. |
| `containers` | map | empty | Project workers. May be empty only when `engine:` is present. |
### Engine fields
| Field | Type | Default | Description |
| --------------------------------- | ------- | ---------------------- | --------------------------------------------------------------------------------------------------------- |
| `url` | string | `ws://127.0.0.1:49134` | Managed engine endpoint used by Compose and its workers. |
| `registration_namespace_grace_ms` | integer | engine default | Namespace-registration grace passed to the engine. |
| `observers` | map | engine defaults | Observer limits and timeouts passed to the engine as written. See [Observers](./configuration#observers). |
| `workers` | map | empty | Direct configs for engine-owned workers. Values must be mappings; use `{}` for defaults. |
| `sandbox` | map | absent | Binds the engine's `sandbox::*` router to an adapter. See below. |
Allowed worker keys are `configuration`, `iii-worker-manager`, `iii-http-functions` (deprecated;
still accepted), and `iii-stream` (deprecated; still accepted). Use `#instance` for another instance
of an allowed type, for example `iii-worker-manager#rbac`. The engine injects
`iii-engine-functions`, `iii-telemetry` for anonymous usage analytics, `iii-observability` for
OpenTelemetry traces, metrics, and logs, and the `iii-sandbox` router. Do not declare these workers.
A file that declares `iii-sandbox` under `engine.workers` fails with `SANDBOX_CONFIG_MOVED`, which
prints the replacement; see [Upgrading to the sandbox worker](../upgrading/sandbox-worker).
`engine.sandbox` takes `adapter`, the adapter's function prefix (`sandbox-libkrun` by default), and
`namespace`, where the adapter runs (this project's namespace by default). A managed engine is bound
to an adapter whether or not the section is present. Setting the section, with `namespace` unset or
this project's, also makes Compose install that adapter, as does a container whose `scripts.run`
starts with `iii call sandbox::start`, or `iii call compose::add worker=iii-sandbox`. See
[Sandboxes](../creating-workers/sandboxes).
<Warning title="Deprecated">
`iii-stream` is deprecated (iii-stream) and will be removed in an upcoming release. Behavior is
unchanged for now. See [Migrate from iii-stream and pubsub](../upgrading/migrate-from-streams).
</Warning>
<Note>Changes to these worker configurations take effect only after the engine restarts.</Note>
#### Which engine Compose uses
Compose takes the engine address from the first of these that supplies one: the `--engine` flag, the
`III_URL` environment variable, the `engine:` section of the compose file, then
`ws://127.0.0.1:49134`.
An address from `--engine` or `III_URL` names an engine that already runs, so Compose connects to it
and starts no engine of its own, even with `--up`. Only the compose file can give Compose an engine
to own, and only `--up` takes it: an `engine:` section carries the engine's whole configuration, not
only an address.
### Worker fields
Each key under `containers` is the name the worker registers under. It also names the container's
directories, `.iii/build/<key>/` and `.iii/workers/<key>/`, so it must be a plain directory name: a
key that is empty, holds `/` or `\`, starts with `.`, or holds a NUL fails with
`INVALID_CONTAINER_KEY`.
| Field | Type | Default | Description |
| ----------------- | -------------- | -------------------- | ---------------------------------------------------------------------------------------------------------- |
| `worker` | string | required | `path://<dir>` or `package://<name>`. A package may name its registry: `package://<registry-host>/<name>`. |
| `version` | string | absent | Version range. Required, and not empty, for `package://`. A `path://` worker ignores it. |
| `start_after` | array | empty | Workers that must start first (ie. a worker dependency). Self-dependencies and cycles are rejected. |
| `config_name` | string | absent | The [configuration worker](./configuration) entry this worker owns. |
| `config_override` | mapping | absent | Merged on top of the fetched configuration; a mapping whose `name` changes is replaced whole. |
| `working_dir` | path | the worker directory | Resolved against the compose file's directory. |
| `environment` | map | empty | Environment variables for this worker. |
| `env_file` | array of paths | empty | Read at start time, in declaration order. A later file wins on conflicting entries. |
| `startup_timeout` | string | the file's value | Readiness budget for this worker. |
| `required` | boolean | `false` | Whether a failed start fails the operation. `false` reports the failure and lets the operation carry on. |
| `restart` | string | `no` | What happens after a failed start or a run-time exit. `no`, `on-failure`, or `always`. |
| `scripts` | mapping | absent | See below. |
| `runtime` | mapping | absent | `base_image`: the image of the worker's VM. See [Binary packages in a VM](../reference/vm-workers#binary-packages). |
A private package has a scoped name, `package://@acme/ade` or
`package://api.workers.iii.dev/@acme/ade`, and needs a registry token. See
[Private workers](./workers-registry#private-workers).
`path://` directories resolve against the compose file's directory. A missing directory fails with
`MISSING_WORKER_DIRECTORY`, and a missing `env_file` fails with `MISSING_ENV_FILE` during
validation.
A `path://` worker runs as a host process unless its `scripts` run it in a VM. A non-empty
`runtime.base_image` in its `iii.worker.yaml` is the base image of its VM build. Such a worker stays
on the host only when it declares its own `scripts.build`; without one, Compose rewrites it into the
VM. See [VM workers](#vm-workers). An invalid image reference fails instead of falling back to the
host or to another image.
`sandbox-libkrun` 0.3.1 and later hide the `.iii` directory, which holds Compose's state and the
project's token, from a VM, both in its copy of the worker's directory and in the source share that
copy is made from. Earlier versions do not, so there a VM worker whose directory contains the
compose file, such as `path://.`, can read that token. Its disk keeps those bytes after the upgrade,
so stop Compose and run `iii compose --up` once to replace the token: updating or restarting the
adapter keeps it.
A managed engine also writes `data/` and `config/` in the directory `iii compose --up` runs from,
and `data/` holds the payloads of traced function calls. A VM worker whose directory contains them
can read them on any version. So keep the compose file and the directory you start Compose from
outside the worker's directory, as in `path://./api`. `III_COMPOSE_STATE_DIR` moves Compose's state
and the token, but not `data/` or `config/`. Point it outside the worker's directory, because only
the name `.iii` is hidden.
### Worker kinds
Worker packages can be released in multiple different "kinds". A kind compose cannot run fails with
`UNSUPPORTED_PACKAGE_KIND`.
| Kind | How it runs |
| -------- | ------------------------------------------------------------------------------------------------ |
| `binary` | A child process on the host, or a VM when its container sets `runtime.base_image`. |
| `bundle` | A VM, through `iii call sandbox::build` and `iii call sandbox::start`, or the host when `scripts.run` says so. |
| `path` | A path to a worker stored locally on disk. |
A VM worker runs in the `sandbox-libkrun` worker, a container of the project that the VM worker
names in `start_after`. Compose adds that container when the project needs it. Its guest and its
build VM receive the container's `environment` and `env_file` variables and the reserved `III_*`
variables, not the host's environment: declare under `environment` what the worker needs, such as a
provider key. The adapter is built for three targets only: `aarch64-apple-darwin`,
`x86_64-unknown-linux-gnu` and `aarch64-unknown-linux-gnu`. On a musl Linux or Intel Mac host
Compose fails with `UNSUPPORTED_PLATFORM`. On Linux the user running Compose needs read and write
access to `/dev/kvm`, and `libcap-ng0` must be installed. Every other worker kind is unaffected.
On Windows, a bundle fails with `BUNDLE_NEEDS_A_VM` before anything is downloaded, and Compose
refuses a container whose `scripts.run` is `iii call sandbox::start` with
`SANDBOX_UNSUPPORTED_PLATFORM`. `iii compose build`, frozen or not, cannot build or lock such a
project there either: the `sandbox-libkrun` package it resolves ships no Windows build, so it
stops with `UNSUPPORTED_PLATFORM`. Lock and build a project with VM containers on Linux or macOS.
Run compose under WSL, where the VM still needs `/dev/kvm` and a guest rootfs to boot. Every other
worker kind runs on windows as it always has.
Bundle support can be refused machine-wide with `III_BUNDLE_WORKERS_DISABLED=1`, which compose
honours.
### Scripts
| Field | Type | Default | Description |
| ----------------- | ------ | ------- | -------------------------------------------------------------------- |
| `pre_run` | string | absent | Runs to completion before the worker is spawned, after any build. |
| `pre_run_timeout` | string | `60s` | Budget for `pre_run`. Rejected without a `pre_run`. |
| `build` | string | absent | Build command. `""` declares that there is no build step. See below. |
| `build_timeout` | string | `20m` | Budget for `build`, outside `startup_timeout`. |
| `run` | string | absent | Start command. For a `binary` package, replaces its executable. |
| `post_run` | string | absent | Runs after the worker's exit is confirmed. |
Both hooks run with the worker's environment, working directory, and their own process group. A
`post_run` runs after the worker stops but before the compose daemon exits. The top-level
`stop_timeout` argument is a global timer for a compose daemon to stop. If this time is exceeded all
scripts will be exited along with the compose daemon.
A path worker's start command is `scripts.run` in `worker-compose.yaml`, or `scripts.start` in the
worker's own `iii.worker.yaml` when `run` is absent. A worker with neither fails with
`MISSING_START_COMMAND`.
#### `scripts.build`
| Property | Value |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Type | A shell command, run like `scripts.run` (`sh -c` on Unix). |
| Working directory | The container's working directory, as for `scripts.run`. |
| Environment | The container's environment, as for `scripts.run`. For `iii call sandbox::build`, the guest of the build VM gets the same variables as the worker's guest, not the host's environment. |
| Timeout | `scripts.build_timeout`, default `20m`, outside `startup_timeout`. Compose passes it to `sandbox::build` as `timeout_ms`, in `III_CALL_DEFAULTS`. |
| Output | Captured into the container's logs (`compose::logs`), each line prefixed with `[build] `. |
| Nothing to build | `scripts.build: ""` declares that there is no build step: nothing runs and no `build.json` is written. |
| Failure | `BUILD_FAILED`. From `iii call sandbox::build`: the code and message of its `Error:` line. From any other command: code `EXIT_<status>` (or `TIMED_OUT`), message the last 20 lines of output. |
| When | The [first build](../understanding-iii/compose#the-first-build), [`compose::build`](#building-workers), and a [package update](../understanding-iii/compose#rebuilds). |
### Configuration precedence
Lowest to highest: the configuration a package ships, the entry in the configuration worker, then
`config_override`. Maps merge key by key; arrays and scalars replace. A mapping whose `name` the
override changes is replaced whole: the keys beside `name` belong to the variant it picks. The
merged result is delivered through `configuration::set` with `flush: false` before the worker
starts, unless it is null: an injected null would hide the stored entry, including the default a
worker seeds there with `configuration::ensure`. `III_CONFIG_NAME` identifies the entry read through
`configuration::get`. Compose does not create an execution snapshot file or set `III_CONFIG`. The
persistent `config/<id>.yaml` remains unchanged by this memory-only update. `configuration::ensure`
seeds defaults only into the base and preserves the active value. `configuration::set` with
`flush: true` (the default) persists the complete submitted object, including values originally
supplied by an override. Both forms notify consumers. Each start reads the current configuration
with `configuration::get` and `raw: true`, then applies the declared override. Removing a field from
the override keeps its current value; it does not restore the value from disk. Stopping a worker
leaves the active value available. Restarting the configuration service discards unsaved memory
values and reloads its adapter. Read or update failures stop startup with `CONFIG_FETCH_FAILED`,
rather than silently falling back to defaults.
### Readable configuration names and migration
Without an explicit `config_name`, the entry id is exactly `<namespace>-<container-key>`. For
example, `default` plus `harness` uses `default-harness` and the filesystem adapter stores
`config/default-harness.yaml`. The id must match `[a-z0-9_-]{1,64}`. Compose rejects an invalid or
long generated name with `INVALID_CONFIG_NAME` and asks for an explicit `config_name`; it never
sanitizes, truncates, or adds a hash. Explicit names remain unchanged and are never auto-migrated.
Before reading configuration or starting the child, Compose asks the configuration authority to
migrate the exact hashed id produced by the previous algorithm for that namespace and key.
`default-harness-a14f3656efb8d5ea` therefore becomes `default-harness`. Stored raw values (including
`${VAR}`, `false`, `0`, and `null`), name, description, metadata, and available schema are
preserved. The filesystem adapter updates both filename and internal id, and the authority updates
its caches and notifies subscribers. It re-reads the source so manual edits awaiting the watcher are
retained.
Migration gives the legacy source priority over an existing destination. After that, the `default`
namespace adopts the exact bare container key (`state` becomes `default-state`), even when the
destination already exists. The bare source replaces the whole destination entry, preserving raw
values and metadata rather than merging defaults. Another container's explicit ownership blocks this
adoption; other namespaces and explicit `config_name` values never adopt bare entries.
After publishing the destination, the fs adapter archives the original source as `<source>.yaml.bak`
(for example, `state.yaml.bak`). The previous destination is replaced, not backed up. Files ending
in `.yaml.bak`, `.bak.yaml`, or `.bkup.yaml` are ignored during loading, watching, and legacy
directory migration. Repeated starts with no source perform no writes. An existing identical backup
permits recovery after interrupted cleanup; a conflicting backup is never overwritten and stops
migration with an error.
Migration commits the complete destination before archiving the source. I/O failures stop startup;
failure after publication can leave two recoverable copies. The filesystem adapter requires
same-directory hard-link support and may normalize YAML formatting or remove comments on the one
migration rewrite; values and unknown document fields are retained. Stop source consumers before
migration: Compose checks that the child is not already registered, and its restart path stops the
old child first. Do not run two configuration authorities against the same directory or edit the
source concurrently with migration.
The bridge delegates migration to the remote authority. Upgrade that authority together with
Compose: an absent `configuration::migrate` or unsupported adapter fails with
`CONFIG_MIGRATION_FAILED`, never a read/copy/delete fallback that could reset stored values.
Within one project, a generated name colliding with another container's explicit name is rejected
before startup. Sharing is allowed only when both names are explicit. Across namespaces, `a-b` / `c`
and `a` / `b-c` both produce `a-b-c`; choose unambiguous namespaces or distinct explicit
`config_name` values. Readable names do not claim cross-project ownership.
## The worker environment
```yaml
containers:
api:
worker: path://./workers/api
env_file: [./.env, ./.env.local] # a later file wins
environment:
NODE_ENV: development # wins over the env files
```
From lowest to highest precedence, a worker gets:
1. The machine environment of the Compose daemon, except `III_REGISTRY_TOKEN`. Non-Unicode names and
values are skipped.
2. The worker's `env_file` entries, in declaration order. Later files override earlier files.
3. The worker's `environment` map. Nonempty values override env files; an empty string preserves an
existing env-file value, or supplies an empty value when no env file defines the key.
4. The reserved variables, which the daemon owns.
Export machine variables before you start the daemon, and only start workers you trust with that
environment, credentials included. See
[Where a worker's environment comes from](../understanding-iii/compose#where-a-workers-environment-comes-from).
| Variable | Value |
| ----------------------- | ------------------------------------------------------------------------------- |
| `III_URL` | The engine address the daemon is connected to. |
| `III_NAMESPACE` | The project's namespace. |
| `III_COMPOSE_NAMESPACE` | The supervising Compose daemon's namespace for explicit `compose::*` routing. |
| `III_COMPOSE_FILE` | Canonical path of the compose file that owns this worker. |
| `III_COMPOSE_DIR` | Canonical directory that contains the owning compose file. |
| `III_WORKER_NAME` | The key under `containers`. |
| `III_CONFIG_NAME` | The explicit configuration id or `<namespace>-<container-key>`, always present. |
Declaring a reserved variable in `environment` or an `env_file` fails with `RESERVED_ENV_OVERRIDE`.
A VM container's scripts get the requests of `iii call sandbox::build` and
`iii call sandbox::start` in `III_CALL_DEFAULTS`, described in
[Sandboxes / Environment variables](../creating-workers/sandboxes#environment-variables). Compose
also sets these reserved variables:
| Variable | Value |
| ------------------------ | -------------------------------------------------------------------------------- |
| `III_CALL_DEFAULTS` | The requests of the two calls, for a VM container. |
| `III_BUILD_DIR` | `<project>/.iii/build/<container>`, for a VM container. |
| `III_BUILD_COMPOSE_FILE` | The compose file's canonical path, as in `III_COMPOSE_FILE`, for a VM container. |
| `III_PACKAGE_DIR` | `<project>/.iii/workers/<container>`, for a package container. |
| `III_PACKAGE_NAME` | The package's name, for a package container. |
| `III_PACKAGE_KIND` | The package's kind, `bundle` or `binary`, for a package container on the host. |
A package container on the host gets the three package variables when it is a bundle or declares
`scripts`: a host `scripts.run` of a binary package finds its build in `III_PACKAGE_DIR`. A VM
container gets `III_PACKAGE_DIR` and `III_PACKAGE_NAME`, and the package's kind is in
`III_CALL_DEFAULTS`. `III_BUILD_TIMEOUT_MS` and `III_BUILD_BASE_IMAGE` are reserved too, and not
set.
### Expanding values from environment variables
```yaml
containers:
queue:
worker: path://${WORKERS_DIR}/queue
environment:
RUST_LOG: ${RUST_LOG:-info}
```
`${VAR}` references expand in any value, not only in `environment`.
| Written | Means |
| -------------- | ----------------------------------------------------------------------------------------------- |
| `${VAR}` | The value from compose's own environment. Unset, the file is refused with `UNDEFINED_VARIABLE`. |
| `${VAR:-text}` | The value, or `text` when it is unset. `${VAR:-}` makes it optional and empty. |
| `$VAR` | Nothing. A bare name is left alone, so a `scripts.run` holding `$PWD` still reaches the shell. |
| `$${VAR}` | A literal `${VAR}`. |
<Warning>
`config_override` is never expanded, all values are treated as literals.
```yaml
config_override:
# Reaches the worker exactly as written.
api_key: ${ANTHROPIC_API_KEY}
```
</Warning>
## VM workers
A VM worker runs in a microVM. Its `scripts.build` builds an image in the sandbox adapter, and its
`scripts.run` boots that image. Both lines name the container's own key:
```yaml
scripts:
build: iii call sandbox::build worker=<container>
run: iii call sandbox::start worker=<container>
```
A project with VM workers, and one worker that stays on the host:
```yaml worker-compose.yaml
namespace: default
engine:
url: ws://127.0.0.1:49134
containers:
# added by compose::add
sandbox-libkrun:
worker: package://api.workers.iii.dev/sandbox-libkrun
version: "0.5.0"
state:
worker: package://api.workers.iii.dev/state
version: "0.23.0"
# A registry bundle in a VM. compose::add writes start_after and scripts.
# added by compose::add
onboarding:
worker: package://api.workers.iii.dev/onboarding
version: "0.2.0"
start_after: [state, sandbox-libkrun]
scripts:
build: iii call sandbox::build worker=onboarding
run: iii call sandbox::start worker=onboarding
environment:
OPENAI_API_KEY: ${OPENAI_API_KEY} # the guest gets only what is declared
# A local worker in a VM: the base image comes from runtime.base_image in its iii.worker.yaml.
link:
worker: path://./link
start_after: [sandbox-libkrun]
scripts:
build: iii call sandbox::build worker=link
run: iii call sandbox::start worker=link
# A registry binary in a VM: its Linux build, on the image the container names.
# added by compose::add
indexer:
worker: package://api.workers.iii.dev/indexer
version: "1.2.0"
start_after: [sandbox-libkrun]
runtime:
base_image: docker.io/library/alpine:3.20
scripts:
build: iii call sandbox::build worker=indexer
run: iii call sandbox::start worker=indexer
# The same kind of worker on the host: moving it is an edit of scripts.
api:
worker: path://./api
scripts:
build: npm ci && npm run build
run: node dist/index.js
```
The sandbox adapter (`sandbox-libkrun`) is a container like any other: Compose adds it when a
container needs it. For how builds and runs behave, see
[Understanding iii / Compose](../understanding-iii/compose#vm-workers). For the rules, the files
Compose writes, and the error codes, see [Reference / VM workers](../reference/vm-workers).
### Run a worker in a VM
```bash
# A registry bundle: compose::add writes its scripts and start_after.
iii call compose::add worker=onboarding
# A registry binary: name the image its VM starts from.
iii call compose::add 'workers=[{"worker":"indexer","runtime":{"base_image":"docker.io/library/alpine:3.20"}}]'
```
A local worker whose `iii.worker.yaml` sets `runtime.base_image` runs in a VM: when its container
declares no `scripts.build`, Compose writes the two lines for it.
### Keep a worker on the host
A local worker whose manifest sets `runtime.base_image` stays on the host when its container
declares `scripts.build`, `""` when there is nothing to build:
```yaml
link:
worker: path://./link # its iii.worker.yaml sets runtime.base_image
scripts:
build: ""
run: node index.js
```
A registry bundle stays on the host when its `scripts.run` is a host command. Moving a worker
between the host and a VM is an edit of its `scripts`.
### Rebuild a VM worker
The running worker keeps its current image until it restarts. Build, then restart:
```bash
iii call compose::build worker=link
iii call compose::restart worker=link
```
Rebuild after you add a dependency: dependencies come from the build, so edit `package.json`, or the
worker's other dependency file, then build and restart. When the dependency files or the base image
changed since the last build, the worker's logs say so and name this command. Compose rebuilds by
itself when `compose::add` or `compose::update` changes a worker's package.
### Reset a VM worker's data
A VM worker's data disk keeps what the worker writes across restarts and rebuilds. To start again
from empty data, remove the worker with `prune=true` and add it again:
```bash
iii call compose::remove worker=onboarding prune=true
iii call compose::add worker=onboarding
```
### Upgrade a project from an older release
On its first `up`, Compose rewrites the VM containers of a compose file from an older release. See
[Upgrading / VM workers](../upgrading/explicit-vm-workers).
## Build registry packages
```bash
iii compose build --file worker-compose.yaml
iii compose build --file worker-compose.yaml --frozen
iii compose --up --file worker-compose.yaml --frozen
```
| Option | Description |
| ------------------- | ---------------------------------------------------------------------------------------- |
| `-f, --file <PATH>` | Compose file whose registry packages should be downloaded [default: worker-compose.yaml] |
| `--frozen` | Require an existing current lock and skip package selector resolution |
`iii compose build` writes the lock and downloads every `package://` worker into the cache
`compose::up` uses, without an engine, workers, or hooks. It does not run `scripts.build`;
[`compose::build`](#building-workers) does. If it fails with `BUILD_PLAN_STALE`, run it again. See
[How iii compose build prepares packages](../understanding-iii/compose#how-iii-compose-build-prepares-packages).
A private worker needs a registry token: `III_REGISTRY_TOKEN`, or the token `iii registry login`
saved. `iii compose build` reads the variable from its own environment, while `compose::*` functions
read it from the environment the daemon started with. Compose keeps the token to itself: workers,
hooks, and build steps never inherit it. See [Private workers](./workers-registry#private-workers).
## Readiness
```bash
iii call compose::status
```
A worker is `ready` once the engine reports a worker of that name in the project's namespace, within
the worker's `startup_timeout`. When it is not, the operation fails with one of these codes:
| Outcome | Code |
| -------------------------------------------------------------- | ---------------------------------- |
| The worker never appeared. | `STARTUP_TIMEOUT` |
| The process exited while compose was waiting. | `CHILD_EXITED_BEFORE_REGISTRATION` |
| It registered in `default` instead of the project's namespace. | `WORKER_IGNORED_NAMESPACE` |
| It registered under a different name in the right namespace. | `WORKER_NAME_MISMATCH` |
| Its functions landed outside the project's namespace. | `FUNCTIONS_IN_WRONG_NAMESPACE` |
| Another worker already held that name in the namespace. | `CONTAINER_NAME_TAKEN` |
See [Engine observed readiness](../understanding-iii/compose#engine-observed-readiness) for how
Compose watches a worker after it is ready.
## Where compose keeps state
```bash
iii call compose::status --namespace dev file=./worker-compose.yaml
# ... "state_dir": "/home/you/shop/.iii/compose/dev"
ls /home/you/shop/.iii/compose/dev/logs/
```
State is in `<project-dir>/.iii/compose/<namespace>/`, beside the canonical compose file. For a
read-only project directory, set `III_COMPOSE_STATE_DIR` to a writable directory. Add
`**/.iii/compose/` to `.gitignore`.
| Path | Contents |
| -------------------- | ------------------------------------------------------------- |
| `engine.lock` | Lock for the managed engine in this project and namespace. |
| `engine-config.yaml` | Generated engine configuration, removed after clean shutdown. |
| `engine.log` | Rotating stdout and stderr for the managed engine. |
| `state.json` | Child process records for the project. Owner-only. |
| `config/` | Resolved worker configuration files. |
| `logs/` | Rotating stdout and stderr for project workers. |
See [Why state belongs to the project](../understanding-iii/compose#why-state-belongs-to-the-project)
and [The project tree](../reference/vm-workers#the-project-tree).
## Finding and stopping iii processes
```bash
# List every iii process you run.
iii ps
iii ps --json
# Stop the engine on a port, its Compose daemon, and its workers.
iii kill --port 49134
```
```text
$ iii ps
PID KIND NAME PORT STATUS UPTIME COMPOSE
41200 engine - 49134 running 2h5m ~/shop
41198 compose - 49134 running 2h5m ~/shop
41260 worker api 49134 running 2h5m ~/shop
38811 worker cron 5202 orphan 3d2h ~/billing
```
`STATUS` is `orphan` for a worker whose Compose daemon is gone, and `no engine` for a worker whose
engine port has no engine listening.
| Option | Stops |
| ------------------ | ---------------------------------------------------------------------------------------------- |
| `--port <PORT>` | The engine listening on `PORT`, the Compose daemon that manages it, and every worker using it. |
| `--compose [PATH]` | A project's daemon, managed engine and workers. `PATH` is the compose file or its directory. |
| `--orphans` | Every worker whose Compose daemon is gone. |
| `--force` | Sends `SIGKILL` at once instead of waiting for a graceful exit. |
`iii kill` exits with `1` when nothing matches or a process is still running afterwards. See
[How iii ps and iii kill find processes](../understanding-iii/compose#how-iii-ps-and-iii-kill-find-processes).
## Error codes
Compose can output the following error codes:
| Area | Codes |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Compose file | `COMPOSE_FILE_UNREADABLE`, `INVALID_COMPOSE_FILE`, `EMPTY_CONTAINERS`, `INVALID_DURATION`, `UNKNOWN_DEPENDENCY`, `SELF_DEPENDENCY`, `DEPENDENCY_CYCLE`, `UNSUPPORTED_WORKER_SOURCE`, `UNDEFINED_VARIABLE`, `INVALID_REFERENCE`, `UNTERMINATED_REFERENCE`, `INVALID_CONTAINER_KEY` |
| Worker declaration | `MISSING_VERSION_FOR_PACKAGE`, `INVALID_BASE_IMAGE`, `BASE_IMAGE_WITHOUT_VM`, `NOT_A_PACKAGE_CONTAINER`, `PRE_RUN_TIMEOUT_WITHOUT_PRE_RUN`, `RESERVED_ENV_OVERRIDE`, `MISSING_ENV_FILE` |
| Worker resolution | `MISSING_WORKER_DIRECTORY`, `MISSING_START_COMMAND`, `INVALID_MANIFEST`, `INVALID_WORKER_SPEC`, `WORKER_SOURCE_CHANGED`, `ENGINE_WORKER_IS_BUILTIN`, `INCOMPATIBLE_ENGINE` |
| Packages | `REGISTRY_UNREACHABLE`, `PACKAGE_NOT_RESOLVED`, `PACKAGE_NOT_INSTALLED`, `PACKAGE_DOWNLOAD_FAILED`, `PACKAGE_DIGEST_MISMATCH`, `PACKAGE_ARTIFACT_EMPTY`, `REGISTRY_NAME_REFUSED`, `REGISTRY_AUTH_FAILED`, `REGISTRY_CREDENTIALS_INVALID`, `UNSUPPORTED_PACKAGE_KIND`, `UNSUPPORTED_PLATFORM`, `BUNDLE_NEEDS_A_VM` |
| Start and readiness | `SPAWN_FAILED`, `HOOK_SPAWN_FAILED`, `HOOK_FAILED`, `HOOK_TIMEOUT`, `STARTUP_TIMEOUT`, `CHILD_EXITED_BEFORE_REGISTRATION`, `WORKER_IGNORED_NAMESPACE`, `WORKER_NAME_MISMATCH`, `FUNCTIONS_IN_WRONG_NAMESPACE`, `CONTAINER_NAME_TAKEN`, `CONFIG_FETCH_FAILED`, `CONFIG_PUBLISH_FAILED`, `ENGINE_CALL_FAILED`, `PROJECT_DID_NOT_START` |
| Managed engine | `ENGINE_SECTION_REQUIRES_MANAGED_START`, `ENGINE_ALREADY_OWNED`, `ENGINE_RESTART_REQUIRED`, `ENGINE_WORKER_IS_INJECTED`, `UNSUPPORTED_ENGINE_WORKER`, `INVALID_ENGINE_WORKER_CONFIG`, `INVALID_MANAGED_ENGINE_URL`, `MANAGED_ENGINE_ENDPOINT_MISMATCH`, `MANAGED_ENGINE_LISTENER_UNAVAILABLE`, `ENGINE_SPAWN_FAILED`, `ENGINE_STARTUP_TIMEOUT`, `ENGINE_EXITED` |
| Daemon and project | `NO_COMPOSE_FILE`, `COMPOSE_FILE_AMBIGUOUS`, `WRONG_DAEMON`, `INVALID_NAMESPACE`, `UNKNOWN_CONTAINER`, `UNKNOWN_PROJECT`, `INVALID_STATE_FILE`, `STATE_DIR_UNAVAILABLE`, `DAEMON_ALREADY_SERVING`, `DAEMON_NAMESPACE_TAKEN`, `IO_ERROR` |
| VM workers | `VM_SCRIPTS_MISSING`, `SANDBOX_ADAPTER_NOT_DECLARED`, `SANDBOX_ADAPTER_TOO_OLD`, `SANDBOX_BUILD_UNSUPPORTED`, `SANDBOX_BINARY_UNSUPPORTED`, `SANDBOX_RUN_NOT_A_VM_WORKER`, `SANDBOX_BINARY_WITHOUT_BASE_IMAGE`, `SANDBOX_BUILD_WITHOUT_RUN`, `SANDBOX_RUN_WITHOUT_BUILD`, `SANDBOX_WORKER_MISMATCH`, `SANDBOX_UNSUPPORTED_PLATFORM`, `SANDBOX_CONTRACT_UNSUPPORTED`, `BUILD_INPUT_CHANGED`, `BUILD_FAILED`, `OPERATION_CANCELLED` |
| Command line | `FILE_REQUIRES_UP`, `BUILD_CONFLICTS_WITH_SERVE_OPTIONS`, `BUILD_PLAN_STALE` |
These are literal diagnostic identifiers emitted by Compose, not worker categories.
`ENGINE_WORKER_IS_BUILTIN` reports that a worker declared under `containers` is already supplied by
the engine. Its name is retained for compatibility; it does not define a separate worker type. All
workers follow the same model: a worker hosts functions, which are called and observed.
## Related
<Note>
For why compose is a worker see [Understanding iii / Compose](../understanding-iii/compose). For
understanding namespaces see [Understanding iii / Namespaces](../understanding-iii/namespaces).
For the `iii compose` entry in the command tree, see the [CLI
reference](../cli-reference/index#iii-compose).
</Note>