miroir bake runs once, when the image is built. miroir run
boots the world at the start of every trial. miroir collect writes the evidence after the agent
stops. Failure messages name the step that failed, such as boot step 5, so you can look it up
below.
Bake
RUN miroir bake, the last RUN of the world image’s Dockerfile, at docker build:
- Load the manifest. An image that is already baked (
/miroir/bake.jsonexists) is refused. - Start the sinks. They answer but record nothing, so mail and webhooks sent while seeding succeed.
- Start the datastores in order, each until its ready probe passes, then wait until
database.urlanswers. - Run each
bakecommand, with the build’s environment under the manifestenv, so DockerARGs reach it. - With
database.time.capturedset, move the restored data from that time to the bake’s start. - Start the other processes in order until ready, then wait for quiet.
- Run each
seedcommand, then wait for quiet. A process that exited fails the bake. - Install change capture on every table not ignored: a
miroirschema holding the change log, and on each table a row trigger,miroir_capture, and a statement trigger,miroir_truncate. The bake refuses:- a
database.urlrole that is not a superuser; - captured names the grader’s SQLite copy cannot hold, in any ASCII case: two tables, or two
columns of one table, with the same name; a table whose evidence name starts with
sqlite_; and a column named_opor_change, which the grader adds.
- a
- Stop every process in reverse order: SIGTERM, then SIGKILL after 30 s.
- Refuse a bake that ran past midnight UTC, since each boot moves dates from the bake’s day.
- Write
/miroir/bake.json, create the empty/miroir/evidence/, and make/miroirprivate to root (mode 0700).
bake step N, <what>: <why and the fix> and exits 1, which fails
docker build.
Boot
miroir run, the world container’s command, once per trial:
- Read
/miroir/bake.json. - Create
/miroir/run/. If it is already there, the container booted before: its dates may have moved already and its database holds that run’s changes. The boot fails and leaves that run’s files as they are. A world boots once per container. - Start the sinks, recording to
/miroir/run/effects.jsonl(and faults tofaults.jsonl). - Start the datastores until ready, then wait until the database answers.
- Shift dates from the bake to today (Dates).
- Start the other processes until ready, then wait for quiet.
- Clear the change log and the journals, since start-up writes and mail are not the agent’s, and
record the tables at the start of the episode in
/miroir/run/catalog.json. A process that exited fails the boot. - Audit the listeners (The listener rule).
- Write
/miroir/run/ready, which the compose healthcheck tests, and log the step timings:booted in 0.8 s: datastores 0.2, shift 0.0, apps 0.4, quiet 0.2for the fixture. - Supervise. A process that exits is recorded as a
crashfault, and the world keeps serving. Every child getsoom_score_adj1000, so under memory pressure the kernel kills a product process (a recorded crash) beforemiroiritself. - On SIGTERM, stop the processes in reverse order and exit 0.
boot step N, <what>: <why and the fix> and exits 1. The
container stops, main never starts, and Harbor records an environment error before any agent
runs.
Collect
miroir collect, run by the task’s collect hook after main has stopped. Harbor runs
docker compose exec <service> sh -c 'miroir collect' as root with an almost empty environment,
so collect applies the manifest env itself.
- Fail if
/miroir/run/readyis missing: the world never finished booting. - Wait for quiet. A timeout is recorded as a
quiet_timeoutfault. - Read the change log and the live table list in one consistent read. Either of these leaves the
evidence with no changes:
- a database that does not answer, recorded as a
databasefault; - a change log over 64 MiB, counting each row’s text plus 1 KiB, recorded as a
log_budgetfault.
- a database that does not answer, recorded as a
- Fold the log into net changes: one per changed row, with the row as the episode found it and as
it left it. A table created, dropped or reshaped since boot, or one whose capture trigger is
gone, is a
schemachange; a re-created table is atruncate. - Read the effects and faults journals. An effects journal over 16 MiB is left unread, and
recorded as an
evidence_budgetfault giving its size. - Write
/miroir/evidence/evidence.dbthrough a temporary file and a rename. Evidence over 16 MiB is written again with no changes and no effects, plus anevidence_budgetfault. - Print a summary, such as
evidence: 1 changes, 1 effects, 36864 bytes; faults: [], and exit 0.
The listener rule
At boot, once every process is ready, Miroir reads every TCP listener in the world’s network namespace (/proc/net/tcp and /proc/net/tcp6). Two things fail the boot:
- a listener off loopback (not
127.0.0.0/8or::1) on a port outsideexpose:port 5432 (db) listens on 0.0.0.0: bind it to 127.0.0.1, or list it in expose; - an
exposeport with no listener off loopback:expose lists 3000 (web), but nothing listens on it off loopback: check the product's bind address.
127.0.0.1, and the product’s API to 0.0.0.0 on
its exposed port.
A runtime that runs each compose service as a VM also lists the VM’s own daemons there, so such
runtimes fail this audit and are not supported.
Security model
The agent is untrusted, and runs as root inmain.
- The product cannot reach the internet.
mainsits on Harbor’s default network (for its model API) and onworld. The world service sits only onworld, which isinternal: true, so its mail and webhooks land in the sinks. - Over TCP,
mainreaches only theexposeports. Datastores, sinks and every other TCP listener are on loopback, and the boot’s audit refuses a world that breaks this. - Capture happens below the API, in triggers the superuser owns. The agent never shares a
container with the datastores, the change log or the journals, and a root process writes the
evidence after Harbor has stopped
main. The product’s roles cannot read/miroir(mode 0700), and a disabled capture trigger shows as aschemachange, which is harm. - The spec never reaches
main. It lives in[verifier.env], which only the verifier receives, andmainholds no grader, tests or Miroir binary. - Grader inputs are bounded. Only the first 64 KiB of a regular answer file are read, and every SQL statement of the spec runs under a fixed budget of SQLite steps, not a clock. So an agent cannot turn a scored trial into a void, and grading never depends on machine load. The grader runs in its own container.
- The task’s credential is test data, valid only inside one trial’s private network, and
written in
instruction.mdso that every harness sees it. - Identity is not a security boundary. The agent may use any credential it finds, and scope
measures every change, whoever made it. What the product can reach through its own features
(SSRF) is limited by its own configuration, such as Gitea’s
ALLOWED_HOST_LIST.