scripts.build is iii call sandbox::build worker=<container>
and whose scripts.run is iii call sandbox::start worker=<container>. To set one up, see
Using iii / Compose. For how its builds and runs behave, see
Understanding iii / Compose.
Which containers run in a VM
Compose checks every rule but the last when it loads the file.
iii compose build checks them too,
with or without --frozen, before it downloads anything, so a CI job catches them without an
engine. It skips the Windows rule, but that does not let Windows build a project with VM
containers: the adapter package has no Windows build (see Worker kinds).
A line counts as one of these when its first three words are iii call sandbox::start or
iii call sandbox::build. Compose checks every rule when it loads the file, before any call.
A project needs the adapter when a container’s scripts.run starts with iii call sandbox::start,
or when engine.sandbox names the project’s own namespace. Compose then adds the generated adapter
container, marked # added by compose::add, when the file does not declare one. The start order on
the adapter is in start_after, in the file.
These rules apply after Compose rewrites a file from an older release: a missing scripts.build, a
missing adapter in start_after, a bundle without scripts.run, or a container with
runtime.base_image and no scripts.run is rewritten, not refused. See
Upgrading / VM workers.
compose::add, and the rewrite, append the adapter’s container key to start_after, after the keys
already there, which keep their order and comments. Adding onboarding, which already starts after
state, in a project whose adapter container is sandbox-libkrun, writes
start_after: [state, sandbox-libkrun]. An adapter in a container named vm-adapter is written as
vm-adapter: a container is named by its key, never by the package it runs.
A bundle runs on the host when its scripts.run is a host command. It runs scripts.build and
scripts.run in .iii/workers/<container>/, and gets III_PACKAGE_DIR and III_PACKAGE_NAME.
Binary packages keep their working directory. Both moves are edits of scripts, and later runs
leave them alone, with or without a lock.
Binary packages
Abinary package runs its host build as a child process. It runs in a VM when its container sets
runtime.base_image, the image the VM build starts from, since a binary package names none.
- Build. The container gets the Linux build of the host’s architecture,
<arch>-unknown-linux-musl, or<arch>-unknown-linux-gnuwhen the package publishes no musl build. A package with neither fails withUNSUPPORTED_PLATFORM. A static musl build runs on any base image; a glibc build needs a glibc image, such as Debian. - Lock. Its
worker-compose.lockentry hasvm: true. The entry already lists every build the registry published, and each machine picks the Linux build of its own architecture, so one lock serves every machine. Moving the worker between the host and a VM resolves it again, and fails under--frozenwithCOMPOSE_LOCK_OUT_OF_DATE. - Run.
.iii/workers/<container>/holds the Linux build. The guest runs its executable, the first regular executable file in it, root first and in name order, with no arguments. - Host scripts. On the host, a binary package may set
scriptslike any worker.scripts.runreplaces the published executable, in the worker’s usual working directory. - Not on the host. Unlike the manifest’s key, the container’s
runtime.base_imagenever keeps a worker on the host: with ascripts.runother thaniii call sandbox::start, or ascripts.buildother thaniii call sandbox::build(""included), it fails withBASE_IMAGE_WITHOUT_VM.
The project tree
.iii/workers/and.iii/build/are always in the.iii/beside the compose file, also whenIII_COMPOSE_STATE_DIRmoves Compose’s state: the sandbox adapter reads only under the compose file’s directory and the package cache. Nothing of Compose’s lands at the project root, and a VM never sees either directory,path://.included..iii/workers/is rebuilt fromworker-compose.lock, and.iii/build/by a build. Both stay out of git likenode_modules. Compose writes a.gitignorecontaining*in each, so a migrated project is covered without editing its own.gitignore, which keeps the rest of.iii/, such asproject.ini..iii/workers/<container>/is a copy of the extracted package from the global cache, which keeps its own layout..iii/workers/.packages.jsonrecords which artifact each directory holds. It is stored outside the package directories, so no guest can write it.- One copy runs at a time: the daemon and
iii compose buildboth hold.iii/workers/.lockwhile they copy packages. A directory whose record matches the lock stays as it is, with what a host build wrote into it. Compose removes only what it made: the directories of containers no longer locked, the trees an earlier run replaced, and the temporary copies an interrupted run left. - A directory is replaced through a copy made beside it. Its entry leaves
.packages.jsonbefore the directory changes and comes back once the copy is in place, so an interrupted copy is made again by the next run. - The replaced tree stays aside, as
.<container>.replaced-<id>, until the next run removes it, whether its process still runs or not. A host bundle that runs through the swap keeps what it reads relative to its working directory. What it resolves through an absolute path (III_PACKAGE_DIR, Node’srequire, Python’ssys.path) comes from the new tree until the container restarts. - When Compose copies a container’s package directory again because it was missing or its record
could not be read, it deletes that container’s host-build
build.json, so the next start runs the first build again. A package update keeps the record and rebuilds. A VM build keeps its record: its image holds its own copy of the package. - The image is one file,
image.erofs, never a directory tree: a Linux tree on a case-insensitive filesystem (APFS) would be corrupted.
.iii/workers/.packages.json
build.json
.iii/build/onboarding/build.json
path:// container records "source": { "kind": "path", "dir": "./link" }: the declared path,
relative to the compose file. A host build writes the same keys without image.
- Every hash is written
sha256:<hex>. Times are RFC 3339 UTC. dependency_filesholds the hash of each of these files that exists at the root of the worker directory:package.json,package-lock.json,pnpm-lock.yaml,yarn.lock,bun.lockb,requirements.txt,pyproject.toml,uv.lock,poetry.lock,Cargo.toml,Cargo.lock,go.mod,go.sum.image.build_idis what the adapter wrote inimage.id.adapterandcontractare what Compose’s ownadapter::inforeports.image.base_image.declaredis the container’sruntime.base_image, else the manifest’s, ornullwhen the adapter chose the image.referenceis the image the build asked for, the declared one, empty when there is none.digestisnull: the image the adapter resolved is in the answer ofsandbox::build, which Compose does not read. The out-of-date check comparesdeclaredonly.- Compose writes
build.jsononcescripts.buildexited 0, for a VM build as for a host build. For a VM build, the adapter has renamed the new image into place by then. - Compose reads the container’s
sourcebefore the build and again before it writesbuild.json. If aniii compose buildin another process replaced the package meanwhile, the build records nothing and fails withBUILD_INPUT_CHANGED. Build again to record the new package. - Writes are atomic: a temporary file beside
build.json, then a rename. Leftover temporary files are swept. Abuild.jsonwhosebuild_iddoes not match the image fails the run with S508. The fix is a rebuild.
Error codes
The sandbox adapter adds the S-codes S507,
S508, and S509.
Log lines
Sandbox adapter
sandbox-libkrun 0.5.0 is the first release with sandbox contract 1.4: worker.build,
worker.binary, and worker.prune. Compose needs that contract for VM workers, and
compose::update moves the adapter container only within ^0.5.