Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Episode database

The episode database is a SQLite file, /miroir/episode.db, emptied at each reset. Checks with db: episode query it, and command checks find its path in MIROIR_EPISODE_DB. JSON columns hold text; read them with SQLite’s json_extract.

CREATE TABLE actions (seq INTEGER PRIMARY KEY, tool TEXT NOT NULL, app TEXT, method TEXT,
                      path TEXT, status INTEGER, latency_ms INTEGER NOT NULL,
                      arguments TEXT NOT NULL, result TEXT, via TEXT);
CREATE TABLE effects (seq INTEGER PRIMARY KEY, kind TEXT NOT NULL, data TEXT NOT NULL);
CREATE TABLE changes (app TEXT, tbl TEXT NOT NULL, op TEXT NOT NULL, pk TEXT NOT NULL,
                      before TEXT, after TEXT, columns TEXT);
CREATE TABLE answer (value TEXT);

changes

The episode’s net changes, written before the checks run.

ColumnWhat
appthe app, when several have a database; else NULL
tblthe table, schema-qualified outside the default schema
opinsert, update, delete, truncate or schema
pkthe row’s key columns, as a JSON object; {} for a table without a key
beforethe row before, as a JSON object; NULL for an insert
afterthe row after, as a JSON object; NULL for a delete
columnsfor an update, the columns that changed, as a JSON array

effects

The emails and HTTP calls the sinks caught, in order.

kinddata
emailfrom, to, cc, bcc (lists of addresses), subject, text, html
httpmethod, path, query (an object), headers (without Authorization), body

actions

Every tool call, in order. arguments and result are JSON; result holds the error when the call failed. Calls the agent didn’t make itself have a via:

viatoolWhat
NULLthe toola call of the agent
run_codeapi_requesta request the agent’s code sent
coworkercoworker_replya coworker’s reply
eventeventa clock event

answer

The submitted answer, in its normal form when the task has an answer form.

Examples

-- Only invoice 4001 changed.
SELECT count(*) = 0 FROM changes WHERE tbl = 'invoices' AND json_extract(pk, '$.id') <> 4001;

-- Marcus got exactly one email.
SELECT count(*) = 1 FROM effects
WHERE kind = 'email' AND json_extract(data, '$.to[0]') = 'marcus@acme.test';

-- The payment provider was charged 1,250.00 once.
SELECT count(*) = 1 FROM effects
WHERE kind = 'http' AND json_extract(data, '$.path') = '/stripe/v1/payment_intents'
  AND json_extract(data, '$.body.amount') = 125000;

-- The answer is 3.
SELECT value = '3' FROM answer;