# Tehas - The Lean Software Factory > Tehas is The Lean Software Factory, and a Pi software factory: a GitHub issue > goes in and a reviewed pull request comes out, built by the Pi coding agent and pi-rukas in a sandbox, on > self-hosted models. GitHub issues and labels are the only control plane. A > human merges; tehas never merges, deploys or touches production. This host is > one running factory and its operating manual. ## What tehas is - Tehas is the factory around the agent: a dispatcher that reads the queue, a check of who authorized the work, a sandbox with limits, a dashboard and a live console. It is several Rust programs (the console, the dispatcher, the cycle supervisor, the state store and others), shell glue and a few containers on one host. - Pi (https://pi.dev, source https://github.com/earendil-works/pi) is the coding agent. Tehas runs it in a container through pi-rukas's headless runner: `pi-rukas-headless work` for a cycle, `pi-rukas-headless plan` for a planning turn. - pi-rukas (https://github.com/trail-openers/pi-rukas) is the Pi extension that runs the work cycle: explore, plan, develop, the repository's own gates, an adversarial pass, a pull request and a six-pass review. - One instance is one host serving one product repository, with as many cycles side by side as `TEHAS_MAX_CYCLES` (the host's CPUs minus one by default) and the slice's room allow. - The same host takes work by hand: a person with an account there types `tehas dev` and gets an interactive Pi session with pi-rukas in the cycle's sandbox, on the factory's models, with their own name on the commits. - Tehas is its own project. It is not part of Pi or endorsed by its maintainers. - viiwork (https://github.com/janit/viiwork) is a flexible meshed inference platform for both home and enterprise grade hardware. It is the model backend of the example instance. Tehas does not require it: any OpenAI-compatible endpoint works. - Source: https://github.com/tehas-app/tehas - [The Lean Software Factory](https://tehas.app/lean-software-factory.md): what makes tehas lean: pull, limited work in progress, one-piece flow, a line that stops on a defect - [Pi software factory](https://tehas.app/pi-software-factory.md): who does what, the path of an issue, and what tehas adds to running Pi by hand - [Features](https://tehas.app/features.md): every part, with how far it has been proven If you are here to do something, it is probably one of four things. Pick the section that fits. Every manual page is also served as Markdown: add `.md` to its address. The whole manual in one text is at https://tehas.app/llms-full.txt. Everything on this host is read-only. Nothing here changes a ticket or the factory. ## Get work built by this factory 1. Read `repo` in https://tehas.app/live/status.json: that is the product repository this factory serves. Issues go there. 2. Write an issue with one outcome small enough for one pull request, a `## Acceptance criteria` section with checkable items, and the files or area involved, the test file and the manual page included: the plan fences the work to what the issue names. The cycle reads the issue's title and body. A picture or a file attached to the issue does not reach its model today: put what it shows in words. 3. The label `tehas:ready` authorizes the work, and only counts when a person on the factory's allow list applies it. If you are not that person, stop here and ask them. Use `tehas:prototype` for an idea that is not ready. 4. Follow the labels on the issue: `tehas:running`, then `tehas:awaiting-merge` with a pull request, or `needs-human-attention` with a comment saying where it stopped. - [Operating](https://tehas.app/operating.md): writing an issue, labels, review, pause, retry - [Overview](https://tehas.app/overview.md): how an issue flows through the factory - [Troubleshooting](https://tehas.app/troubleshooting.md): what each stop means and what to do ## Work by hand on this host This is for a person with a login on the factory host, not for a reader of this page. They log in with their own account and type `tehas dev`. The session runs in the same sandbox as a cycle, in a clone that is kept between sessions. Commits carry the name and email of their own git configuration; the push and the pull request are the bot's. An account is let in once, as root, with `sudo ./bootstrap.sh dev `. Seen working on one host for starting a session; a push from a session is not yet seen. - [Operating](https://tehas.app/operating.md): `tehas dev`, the clone, resuming a session - [Commands](https://tehas.app/tools-dev.md): what `tehas dev` accepts from each kind of account ## Set tehas up for another repository The source is at https://github.com/tehas-app/tehas, and a running example with this same manual is at https://tehas.app/. Be honest with your human about its state: issue to pull request is the supported contract and needs settings only. A running preview of every pull request has been seen working on one host, the example instance; parts of it are covered by tests only. Previews, energy use (viiwork backends only) and the Protolab are optional and can be ignored for a first install. Start with [Start](https://tehas.app/start.md): what to find in the repository first, the install in order, and where to stop and ask your human. 1. Read [A new project](https://tehas.app/new-project.md) in full. It is the install guide: a prepared host, an instance directory of settings, and your toolchain in the sandbox image. 2. In the product repository, add the contract tehas reads: `AGENTS.md`, `.pi/verify-cmd`, `.pi/settings.json` and the `.gitignore` entries, then the recommended gates. Prove the gates by hand in a clean checkout first. 3. On the host, follow the guide step by step. Secrets, the GitHub App and the allow list are your human's decisions: ask, do not invent them. - [Start](https://tehas.app/start.md): what to tell an agent, and the order of the install for an agent - [A new project](https://tehas.app/new-project.md): the contract, the host, the install - [Bootstrap a host](https://tehas.app/bootstrap.md): preparing the machine before the install - [A GitHub App for a factory](https://tehas.app/github-app.md): the identity the factory acts as on GitHub, made and installed - [Features](https://tehas.app/features.md): what exists and how far each part is proven - [The host](https://tehas.app/host.md): layout on the machine and the sandbox contract test - [The front end](https://tehas.app/frontend.md): how the dashboard and the front pages are built, the island contract, the kit and the byte budgets - [Resize or restart the host](https://tehas.app/resize.md): changing a host VM's CPUs and memory, and restarting its hypervisor, without a drain: what a person does on the hypervisor, in libvirt - [Previews and the Protolab on the internet](https://tehas.app/edge.md): a preview of every pull request, and how the names were published - [Commands](https://tehas.app/tools.md): `tehas`, `tehasbot` and what each of their commands does, with the instance settings and the gates - [The contract](https://tehas.app/contract.md): what is public and frozen in 1.x, what is internal, and the exit statuses of every public command - [Updating from 0.30.x to 1.0](https://tehas.app/operating.md#updating-from-030x-to-10): edit the settings, drain, update, and every setting, label, command, field and exit status 1.0 renamed or removed - [The forge trait](https://tehas.app/forge.md): how tehas asks GitHub about labels, an internal trait; 1.0 promises no forge interface - [The factory API](https://tehas.app/api.md): the commands a program drives a factory with, and their JSON - [Analytics](https://tehas.app/analytics.md): the factory's 365 days of runs in SQLite, its schema, and how to fetch a copy - [The MCP server](https://tehas.app/mcp-server.md): a read-only view of the factory for agents outside the host, behind API keys - [Outsource, the model proxy](https://tehas.app/outsource.md): the one way a contractor's cycle reaches the factory's model, and what it refuses - [Plugins](https://tehas.app/plugins.md): plugins, still being built: how one is set up and run, what each capability gives, and what no grant gives ## Ask this factory over MCP Every tool is read only. The server is at https://tehas.app/mcp, over Streamable HTTP, and every request needs the header `Authorization: Bearer `. A key comes from the factory's owner, who makes one with `tehas mcp key` on the host. Ask your person for it and never guess one. A request without a key gets 401. - `factory_status`: whether the factory works, the queue, the running cycles, whether it is paused - `factory_issues`: the issues in one stage, such as `queued`, `running` or `stopped` - `factory_endings`: the cycles that ended last, and the failed ones among them - `factory_console`: the tail of one running cycle's console - `factory_stats`: the ten-day report the dashboard shows - `factory_issue`: one issue's story: its stage, its title, the running cycle and every run of the last 30 days - `factory_sessions`: the runs of the last 30 days, newest first, with filters such as `outcome` - `factory_session`: one run in full: steps, roles, logs and links - `factory_log`: one log of a run, masked, plain in pieces or whole as gzip - `factory_search`: the lines of the runs of the last 30 days that hold a string you give, of one issue or of the runs you name - `factory_events`: the dispatcher's and refresh's events after a cursor, to follow the factory by polling - `factory_failures`: the work runs of the last 30 days per tehas and pi-rukas version pair, with their most common causes - `factory_outcomes`: how the factory has done further back than 30 days, as counts per tehas and pi-rukas version pair or per UTC week - `factory_park`: why an issue's last stopped run stopped: the step, the failure kind, the cap, the park signature, the runner's error and the failing check lines, masked - `factory_decisions`: the dispatcher's last decisions, start, skip, wait, hold and drop (of a refresh request), each with its issue and reason; a hold line says why a parked issue does not start To see what went wrong, call `factory_failures`, then `factory_sessions` with `outcome` set to `failed`, then `factory_session` for one of them, then `factory_log` for one of its logs. For a parked issue, `factory_park` with the `issue` gives the step and the failing checks in one call. Sessions cover the last 30 days and logs are masked. Ask for `gzip: true` to get a transcript whole; read a plain log in pieces with `offset`. To look for a string across the runs instead of reading one log, call `factory_search` with the `text` to find and either the `issue` or the `ids` to look in; it gives the `offset` of each line, which is where `factory_log` reads from. To ask how the factory has done over a year rather than a month, or whether a release changed the park or failure rates, call `factory_outcomes` with `by` and a window: it counts, and says nothing of any issue. - [The MCP server](https://tehas.app/mcp-server.md): the tools, their arguments, the logs and the limits - [For agents](https://tehas.app/agents.md): a client config to paste ## Live data - [Health](https://tehas.app/health): JSON, 200 when the factory is healthy and 503 when it is not - [Queue snapshot](https://tehas.app/live/status.json): the repository, open issues by state, whether the factory is paused - [Cycles](https://tehas.app/live/running.json): the issues being worked on and the cycle that finished last, each with its status; a cycle's console is `/live/console-.txt` ## Optional - [For agents](https://tehas.app/agents.md): this file as a manual page, with a prompt a person can paste - [Factory floor](https://tehas.app/floor): the dashboard people look at --- Address: https://tehas.app/agents # For agents A coding agent can pick tehas up from one address: [`/llms.txt`](/llms.txt) on this host. It says what tehas is, how to get work built by this factory, how to set tehas up for another repository, where the live data is, and how to ask a factory over MCP. ## Hand it to your agent To set tehas up for a repository, tell your agent to go to [Start](/start): it is the order to do the install in and where to stop. To work with this factory, paste one of these, with this host's address in place of ``: ``` Read http:///llms.txt, then write an issue this factory can build for: ``` ``` Read http:///llms.txt, then set tehas up for this repository. Ask me before deciding anything about secrets, accounts or who may authorize work. ``` Away from this host, start from the README of the [public repository](https://github.com/tehas-app/tehas) instead. A running factory to look at is the public dashboard at . ## What an agent can read here | Address | What it is | | --------------------------------------- | -------------------------------------------------------------- | | `/llms.txt` | The entry point: a summary and links, as plain text | | `/.md` | Any manual page as Markdown, for example `/new-project.md` | | `/llms-full.txt` | `/llms.txt` followed by every manual page as Markdown, each under its address, in one text | | `/health` | Factory health as JSON; 503 when unhealthy | | `/live/status.json` | The queue snapshot: repository, issues by state, how many are in planning, how many closed issues carry `tehas:shipped`, paused or not, and the most used words of all its issues | | `/live/epics.json` | The open epics, issues with sub-issues, newest first: each with its count of sub-issues and how many are closed, and its sub-issues in this repository with their state; `unlinked`, the open issues labelled `epic` with no sub-issues | | `/live/running.json` | The running cycles and the one that finished last | | `/live/endings.json` | The last ten cycles that ended, oldest first | | `/live/console-.txt` | That cycle's console, with tokens, keys, passwords and the host's secret settings masked | All of it is read-only. Work is submitted and authorized in GitHub, as [Operating](/operating) describes. ## Ask this factory over MCP A factory can also answer questions about itself over MCP, when its owner has switched that on. Every tool is read only. The server is at `https:///mcp`, over Streamable HTTP, and every request needs the header `Authorization: Bearer `. A key comes from the factory's owner, who makes one with `tehas mcp key` on the host. Ask your person for it and never guess one. A request without a key gets 401. - `factory_status`: whether the factory works, the queue, the running cycles, whether it is paused - `factory_issues`: the issues in one stage, such as `queued`, `running` or `stopped` - `factory_endings`: the cycles that ended last, and the failed ones among them - `factory_console`: the tail of one running cycle's console, masked - `factory_stats`: the ten-day report the dashboard shows - `factory_issue`: one issue's story: its stage, its title, the running cycle and every run of the last 30 days - `factory_sessions`: the runs of the last 30 days, newest first, with filters such as `outcome` - `factory_session`: one run in full: steps, roles, logs and links - `factory_log`: one log of a run, masked, plain in pieces or whole as gzip - `factory_events`: the dispatcher's and refresh's events after a cursor, to follow the factory by polling - `factory_failures`: the work runs of the last 30 days per tehas and pi-rukas version pair, with their most common causes; `by: image` splits a pair by the sandbox image build - `factory_outcomes`: how the factory has done further back than 30 days, as counts per tehas and pi-rukas version pair or per UTC week - `factory_park`: why an issue's last stopped run stopped: the step, the failure kind, the cap, the park signature, the runner's error and the failing check lines, masked - `factory_decisions`: the dispatcher's last decisions, start, skip, wait, hold and drop (of a refresh request), each with its issue and reason; a hold line says why a parked issue does not start To see what went wrong, call `factory_failures`, then `factory_sessions` with `outcome` set to `failed`, then `factory_session` for one of them, then `factory_log` for one of its logs. For a parked issue, `factory_park` with the `issue` gives the step and the failing checks in one call. Sessions cover the last 30 days and logs are masked. Ask for `gzip: true` to get a transcript whole; read a plain log in pieces with `offset`. To ask how the factory has done over a year rather than a month, or whether a release changed the park or failure rates, call `factory_outcomes` with `by` and a window: it counts, and says nothing of any issue. A client config to paste, as an example. Your client's file and field names may differ: ```json { "mcpServers": { "tehas": { "url": "https:///mcp", "headers": { "Authorization": "Bearer " } } } } ``` The tools, their arguments and the limits are in [The MCP server](/mcp-server). ## What an agent may not decide - **Authorizing work.** `tehas:ready` spends compute and only counts from an account on the allow list. An agent writes the issue; a person labels it. - **What the factory proposes for itself.** An issue labelled `tehas:improvement` was filed by the factory, such as the findings of a review run. It is a proposal like any agent's issue: a person decides, and a person applies `tehas:ready`. - **Merging.** Nothing merges on its own. - **Secrets and accounts** when installing: the bot's token, the allow list and the model endpoint are the owner's to choose. --- Address: https://tehas.app/analytics # Analytics Every factory records each run it makes, with the tehas and pi-rukas versions it ran, in one SQLite file: `~/tehas/state/analytics.db`. It keeps 365 days. The question it answers first is "was the last release better than the one before". The plain dashboard shows a ten-day report from it; a program can fetch a copy and do deeper analysis elsewhere. This is about how the factory works, not about the product: nothing in it says what changed in which file. It is not the visitor analytics of `TEHAS_SITE_ANALYTICS_SRC`, which counts visits to the pages. ## What is recorded, and when | What | Written by | When | | --- | --- | --- | | A work run, its steps and its roles | `tehasbot cycle` | As the cycle ends, after its history line and before its files are cleaned up | | A planning turn, as a run of kind `plan` | the dispatcher | As the turn ends. No token usage: the answer tehas keeps from a turn holds none | | The issue events `ready` and `started` | the dispatcher | `ready` with the time `tehas:ready` was accepted, `started` as a cycle starts | | The issue event `ended` | `tehasbot cycle` | As a cycle ends | | The issue events `awaiting`, `merged`, `closed` and `stopped` | `tehasbot status` | The first time a run of it sees the issue in that state, by comparing with its last snapshot | | A sample | the dispatcher | At the end of a poll that wrote to GitHub, started, stopped or turned anything: about every two minutes on a busy factory, and also when a cycle ends. A poll that changed nothing takes none, so an idle factory writes no row rather than the same reading again. Some 720 rows a day on a working one | | `meta` | the program | When it makes the file | Each event is stored once per issue, the first time. A second run of an issue adds no event; every run is in `runs`. Samples are the clock of the ten-day report: `availability` credits each row with the time to the next one, at most ten minutes, and `energy` with the same span, so a stretch with no row - a paused or held factory, an idle week - counts as not available and as no draw rather than as one reading held. A fall in `availability` or in a report's `n` after a long pause means the factory did no work, not that the dispatcher is down. The commands run `~/tehas/libexec/analytics`, a Rust program with SQLite built in, which holds all of the SQL; `install.sh` builds it. Each call from a cycle or a poll has a limit of 5 seconds and only warns when it fails: a locked or broken database costs a missing row, never a cycle. Analytics never changes a cycle's outcome, label or comment. It adds no mount and no variable to a cycle's container: it runs on the host after the container has gone. ## 365 days Rows older than 365 days are deleted on every write, and the file never holds more than 365 days of runs. A run is as old as its end. The events of an issue that started and has not ended are kept at most a day longer. 365 days is fixed and is not a setting. A file made when it was ten days says 365 in `meta` after its next prune; what was deleted before stays deleted. Two things a write does not do belong to `analytics prune`: the sweep of the `analytics.db.schema-` files a migration left beside the database, and SQLite's `PRAGMA optimize`. Until #1769 the poll ran that command itself about every two minutes; nothing schedules it now, so both go undone until someone asks for them: ``` ~/tehas/libexec/analytics prune ``` The rows need neither - the writes bound the tables - so this is the command that clears the aside files of [The file](#the-file) below. When it cannot delete an expired aside file, or its `-wal` or `-shm`, it deletes the others, names those it could not in one `WARN` line on standard error and exits 73. ## The file `~/tehas/state/analytics.db`, mode 600, in WAL mode, with its `-wal` and `-shm` beside it. It is not under `live/` and is not served. Times are UTC Unix seconds and durations are seconds, as integers, except `runner_ms` and `run_roles.ms`, which are milliseconds. `PRAGMA user_version` is the schema version, today 4. Within one version columns are only added. A change of a column's meaning raises the version. v0.30.0 wrote 4 already, so this release migrates no older file: a file at 1, 2 or 3 is kept aside under its version, as any other version is, and a new one is made. A file at 4 that lacks a column added within 4 since, `runs.contractor_id` from v1.0.0, gains it, empty, the first time it is opened; nothing else in it changes. - **A file that is not a database**, or fails SQLite's check, is moved to `analytics.db.broken` and a new one is made. The data is at most 365 days deep. - **A database of another schema version** is moved, with its side files, to `analytics.db.schema-`, where a reader can still fetch it, and a new one is made. It is deleted 365 days after its last write. That goes for a version newer than the program too: after a rollback to a release of schema 3, the file at 4 goes aside whole. Move it back by hand before going forward again: nothing says it is still aside, and a second rollback renames the file then at 4 over it, which loses the runs it held. - Any other failure, a full disk or a lock held too long, leaves the file as it is. A move is said once on standard error, in the log of the command that met it. The schema is `console/analytics/src/schema.sql` in the source, with a pinned copy `schema.pinned` beside it that a test compares it with. A reader may pin that copy too. A change to the schema is agreed first with the programs that read it, as for the JSON of [the factory API](/api). ## The tables The columns that came after schema 1 are named by the schema in `Since`; the rest came in schema 1. A column without a value is NULL. ### runs One row per run, written when the run ends. A work run takes its facts from the cycle, which gathers them into a private file for the call (`tehas-cycle after`): the line of history the cycle made of its end and the attempt the state store gave its start, and from the state store `at`, `how` and `driver` of the approval that start used, read before the end goes on record because a start that never ran takes its approval with it, the run's `settings` snapshot, the image's pi-rukas commit and, for a cycle run on a contractor, the contractor's name. It reads the rest from the host: the headless runner's result, `progress.json`, the preflight log, `state/cycles/.lean-state.json` for a lean run, and `docs/version.txt`. The lean note is the cycle's copy of the driver's own record of its steps, and its steps stand for the run's steps in place of the stream's; only a cycle whose analytics are on keeps one, and the next cycle of the issue removes it as it starts. A run that has no result (killed, stalled, timed out) is stored with tehas's status and its times. A planning turn takes its session on the state store as its facts, in the shape its record file had before the store (running, turns, `startedAt`, label, answers), read before the turn's end is recorded, and reads the turn's output `state/plan-.json.out` from the host. What docker said of the sandbox image as the dispatcher started the turn is in `state/plan-.json.image` until the turn's end reads it. Facts that are missing, a link, over 16 MiB or not JSON record nothing, as a run without a history line records nothing. The private file is `~/tehas/tmp/analytics-facts.*`, removed after the call; one that a caller killed during the call leaves is removed by `tehasbot clean` once it is old. | Column | Source | Since | | --- | --- | --- | | `id` | `--`, unique | 1 | | `kind` | `work` or `plan` | 1 | | `issue` | The issue number | 1 | | `attempt` | The run's number for this issue: the attempt the state store gave its start, counting from 1, a start refused or by hand included. Work runs only | 1 | | `how` | What started it: `label`, `retry-tick`, `outage-retry`, `millwright` (`fixer` on a run recorded before the rename), `host` (an approval of `tehas start`) or `refresh`, from the approval the start used, else the history line, which says `hand` for a cycle run by hand. A planning turn: `label` for the first turn, `refine` for the first turn of a session `tehas:refine` started, `answer` or `millwright` for a later one | 1 | | `started`, `ended`, `seconds` | The run's start, its end and the wall time between: the history line's `started` and `at`. A planning turn ends when the poll collects it | 1 | | `queue_wait` | `started` less when `tehas:ready` was accepted (the approval the start used) | 1 | | `outcome` | `pr`, `merged`, `handoff`, `parked`, `failed`, `refused` or `stopped`, below | 1 | | `status`, `exit_code` | The runner's status and exit code, or tehas's own (`killed`, `stalled`, `timeout`), from the history and the result | 1 | | `last_step`, `failed_step` | The step it was in last, and the step that failed, from the result and the history | 1 | | `cap` | The cap that stopped it, from the result or the history | 1 | | `park_reason` | Why it was parked, from the result or the history | 1 | | `review_held` | 1 when the review held the pull request, from `progress.json` | 1 | | `failure_kind` | The failure's kind, from the history or the result | 1 | | `failure_cause` | The failure's cause, cut to 200 characters and masked as the console masks: hosts, addresses and keys are replaced | 1 | | `provider_outage` | 1 when the run stopped because the model provider was out | 1 | | `endpoint` | `main` or `backup`: whether the model endpoint was on its backup, from the preflight log | 1 | | `pr` | The pull request's number, parsed from its URL; the URL is not kept | 1 | | `tehas_version`, `tehas_commit` | `~/tehas/docs/version.txt` as the run ended, `vX.Y.Z` and the seven-character commit | 1 | | `rukas_version`, `rukas_commit` | The result's `buildVersion` and `buildCommit`; else the commit of the sandbox image's `tehas.rukas` label | 1 | | `image` | The sandbox image's id, `sha256:`: for a work run the one its container started from, for a planning turn the one the image name pointed at as the dispatcher started the turn | 1 | | `input`, `output`, `cache_read`, `cache_write`, `turns`, `dispatches`, `cost` | The result's `usage`. For a planning turn `turns` is its turn in the session, and the rest is NULL | 1 | | `oom_kills`, `forks_refused` | Processes killed for memory and forks refused in the container, as `tehasbot cycle` reads them | 1 | | `concurrent` | How many other cycles ran when it started, from `settings` | 1 | | `runner_ms` | The result's `durationMs`, in milliseconds | 1 | | `result_schema` | The pi-rukas result's schema number, 3, 4 or 5 | 1 | | `gate_runs` | How many runs of the product's gate the cycle made, from its stream. NULL when the stream held none, which is no gate rather than a gate of no time; 0 is not stored, so a run whose rows the runner timed of nothing keeps no count either | 2 | | `gate_ms` | Their milliseconds in all, as the runner timed each of them: the gate's own time, not the wait for another run of it that held the container's CPU share. A single run of it of more than three runs of `TEHAS_VERIFY_TIMEOUT` is no figure, and NULL with no run of it | 2 | | `driver` | The driver the start's approval bound: `classic` or `lean`. NULL where the approval holds no driver or another word, on every run from before the column, and on a planning turn. NULL reads as classic | 3 | | `tool_calls`, `tool_errors` | The result's `usage.toolCalls` and `usage.toolErrors`: the tool calls the run's children started, a codemode script's nested calls included, and those that ended in an error. NULL where the result has none: a pi-rukas before v0.14.66 (`features.usageTools`), a result that could not count them, a planning turn | 4 | | `result_driver` | The result's `driver`: the engine that ran the issue, `classic` or `lean`, beside `driver`, the one the approval bound. NULL where the result names none or another word | 4 | | `contractor_id` | The name of the contractor that ran the cycle, from the facts the cycle gives. NULL for a cycle run in-house, on every run of an instance with outsource off, on a planning turn and on every run from before the column. Outsource is still being built, so no instance writes one yet. The column is frozen with schema 4 | 4, v1.0.0 | The outcome of a work run: | Outcome | Meaning | | --- | --- | | `merged` | The issue's pull request was merged | | `stopped` | The issue was closed while it ran, or it was interrupted | | `refused` | No cycle ran: the runner refused, or `tehas work` started none | | `pr` | It left an open pull request and was not parked | | `handoff` | The runner handed off to a person | | `failed` | tehas stopped it, the runner aborted, or a failure other than a cap stopped it | | `parked` | Any other end that needs a person, such as a cap | A planning turn is `handoff` when it asked its question, `stopped` when Pi no longer had the session, `refused` when no turn ran, and `failed` otherwise. ### run_steps The steps of a run, from the result's `steps`, else from the `step-started` lines of the runner's progress log. | Column | Source | Since | | --- | --- | --- | | `run_id` | The run's `id` | 1 | | `step` | The step's name | 1 | | `round` | The step's turn in the run: 1 the first time it ran, 2 the second | 1 | | `started`, `ended`, `seconds` | The step's start, end and duration | 1 | The key is `(run_id, step, round)`. ### run_roles The usage of each role in a run, and the model it was given. | Column | Source | Since | | --- | --- | --- | | `run_id` | The run's `id` | 1 | | `role` | The role's name | 1 | | `model`, `provider` | The role's model and provider in the run's settings snapshot (on the cycle's record in the state store, in the run's facts) | 1 | | `dispatches`, `turns`, `input`, `output`, `cache_read` | The result's `usage.byRole`, else `progress.json` | 1 | | `cache_write`, `cost` | The result's `usage.byRole` | 1 | | `ms` | The role's time, in milliseconds, from `usage.byRole` | 1 | | `tool_calls`, `tool_errors` | As on `runs`, for the role, from `usage.byRole`. NULL where the role's row has none | 4 | The key is `(run_id, role)`. ### run_gate_runs The runs of the product's gate that the cycle made, from the stable `verify-completed` lines of the runner's progress log -- the newest `logs/work--