TEHAS

Operating tehas

Everything on this page is done in GitHub unless a command is shown. Commands run on the host as the tehas user (in the example, ssh boss@tehas-tehas).

Prototypes: before the factory

Optional. The factory needs no prototype stage: an issue can be written and labelled tehas:ready directly, as in step 1 below. Skip this section if you do not use the label.

A prototype is an ordinary issue with the label tehas:prototype. The label puts the ticket at the prototype stage: an idea that is still being worked out. That work can happen anywhere, with other tools and systems, for as long as it takes. tehas does not act on tehas:prototype: the dispatcher never starts a cycle because of it.

The label counts when an account in TEHAS_ALLOWED_LABELERS applied it, which is the same rule tehas:ready follows. A tehas:prototype applied by anyone else, the bot included, counts as no label at all: the ticket gets no page, a page it had is removed, and the Protolab's log names the issue and the account. An account in a cycle holds the bot's token, and the bot can label, so the account behind the label is what is checked, not the label itself. The check only means something while the bot's own login is outside TEHAS_ALLOWED_LABELERS, and the Protolab stops with an error when it is not. The label must also be the one tehas labels pinned, as the granting labels are (see label pins), and a title changed since the labelling by an account outside the list is not published: the page stays as it was until an allowed account applies the label again.

With TEHAS_ISSUE_TYPES mapping prototype to an issue type, the type puts a ticket at the stage in place of the label, by the same rule: see Kinds as issue types.

The Protolab is where tickets at the prototype stage are kept. It is a small site of its own, on port 8081 of the host, with a page for every open prototype: the title, a link to the issue, and what is attached to the issue. On the factory floor the Protolab panel lists the same tickets and each row opens its page.

To put something on a ticket's page, attach it to the issue on GitHub, in the issue text or in a comment, the way any file is attached there. The page has it within about five minutes. It takes:

A prototype zip may carry instructions for language models on what it holds, for example a prototype.md; the lab serves it like any other file and does not define what it says.

The limits:

The page and its files go when the ticket is closed, loses the label, or carries it from an account the instance does not allow. They are copies: GitHub keeps what was attached.

A prototype goes to the factory when it is ready for implementation, which means:

Attachments

What is attached to an issue reaches three parts of tehas, each by its own rule. A cycle works from words first: anything it must know is safest in the issue text.

What A cycle A planning session The Protolab
The issue's title and body Read Read, at the start The title
Comments on the issue Not given, except on a retry with comments (below) Replies by an allowed account to its question, as answers Not shown
A png, jpg, webp or gif linked in the body Fetched and mounted with TEHAS_WORK_IMAGES=on; shown to explore and plan when the sandbox image says its pi-rukas reads them The same Shown
The same image linked in a comment With TEHAS_WORK_COMMENTS=on, when an allowed account wrote it before the label or the retry tick and nobody edited it since When a reply to its question links it Shown
The text of comments, on a retry with comments comments.json beside the images, when Retry with the issue and all its comments was ticked: what allowed accounts that may write said on the issue and its pull requests up to the tick. Read by the sandbox image's pi-rukas or its polyfill Not given Not shown
The spec an issue's Spec: line names, and the approved title and body With TEHAS_SPEC_PIPE=on, still being built: the spec, held to the sha256 its approval pinned, and approved.json, beside the images and named in the manifest. A spec needs a sandbox image whose pi-rukas lists issueSpec Not given Not shown
md, txt, csv, json, yaml, log, html, css or js linked in the body Fetched and mounted with TEHAS_WORK_FILES=on; pi-rukas does not read them yet The same html, css, js, json and txt shown, html in a frame
svg, avif, a video Not given Not given Shown
A zip Unpacked with TEHAS_WORK_ZIPS=on, its files given as above The same Unpacked, its files shown as above
Any other file, such as a pdf Not given Not given Left out

The rules behind each column:

So for a picture, write the words too: name the element by its selector and its visible title, and say where in it the thing goes.

And when the picture is not there yet, do not leave its place marked. A body that says SCREENSHOT GOES HERE, or IMAGE_GOES_HERE, while its text links no attachment at all is held by the dispatcher: the same line of logs/dispatch.log says the words it found. Nothing on the issue changes.

1. Write an issue tehas can build

The cycle reads the issue's title and body; see Attachments for the rest. Give it:

Name the tests and the pages even when they seem obvious: the plan fences the work to what the issue names, and a cycle that changes a file outside the fence parks with verify-failed:develop (see Troubleshooting). A deliverable that creates a file that install.sh installs must name install.sh and test/install_lib.sh among its paths as well: a new installed file has to be added to the files= array of the first and the files= list of the second, and one test compares a fresh install against the list in the second file exactly (test/install_fresh_test.sh), so a plan that leaves the two out parks hours later on a file nobody was allowed to edit.

The Out of scope section of the issue's spec is part of that fence, not a note. It is the section the refine brief tells the planner to write (see Refining a request). Write one path per entry, not a sentence: the driver splits one entry on , and ;, so the paths you put in one bullet are separate entries. Keep the section to the files the cycle must not touch, and name a file a deliverable creates by exact path in that deliverable instead: a deliverable never lifts an Out of scope entry that is still in the section, so removing the entry is what opens the file.

The plan carries every Out of scope entry into the fence, and the pi-rukas driver matches an entry as a git pathspec. test/, test/** and test/* all fence the whole directory; test/*_test.sh fences every file that pattern matches. The driver bounds the entries: a long one is cut, and a cut entry can then match a whole subtree; a section past its ceiling of 50 entries loses the rest. The driver may also lift a fence your own acceptance criteria name as a requirement, and lifts the docs and test fences of a plan with one workstream, so what parks is the fence the plan kept, not the section you wrote.

A park can name a file your own issue named. A deliverable that says "tests in test/work_test.sh (new)" beside an entry that matches that path parks the cycle with fix-pass-park in the fix pass after the adversarial review, after the work is written and the whole gate has passed. Two lines of the runner's progress, ~/tehas/logs/work-<issue>-<time>.jsonl, say what the fence lost: a log line whose message holds outOfScope bounded names each entry the driver cut or dropped, and a fence-lifted line names each file the driver let through anyway. Neither is in the cycle's record, so read the progress itself with jq -r 'select(.kind=="log") | .message' and jq -r 'select(.kind=="fence-lifted") | .event | "\(.workstreamId) \(.file)"', as under "What did the driver say?" in Troubleshooting. A body that names many files also trips TEHAS_SIZE_MAX_FILES: the dispatcher counts the paths in it and holds the issue out before any cycle starts.

Vague issues park at the first step with "underspecified", and the factory then refines them once on its own (see Refined on its own). Text in the issue is treated as untrusted input: it shapes the plan (the fence, the paths, the deliverables) but cannot reach the gates or the mounts the container is given, and the cycle halts if its patch touches .pi/, .github/, CODEOWNERS or agents.json. An edit to AGENTS.md or CLAUDE.md is not halted: it ships, and you see it in the diff. What the cycle is judged against is the doctrine at the commit it started from, so an edit of its own changes nothing for that cycle.

2. Authorize it

Apply the label tehas:ready. That label is the authorization to spend compute on the issue.

The factory works on open issues only. A closed issue is never taken, and the number of a pull request is never taken, open, merged or closed. A label does not change that. Before it marks an issue tehas:running the dispatcher asks GitHub what the number is, and tehasbot cycle asks the same before it changes a label or starts a container, whether the poll started it or a person did. An issue closed between the poll's list and its start is skipped, with one line in the log: skip #N: it is closed, and a closed issue is never taken. A cycle that came up and then found its issue closed says so in its own log and does nothing on the issue; it leaves tehas:running behind, and the next poll takes that mark off without a word. The queue and the dashboard list open issues, so a closed one that still carries a factory label is not counted in line or as being worked on.

The control issue, the one TEHAS_CONTROL_ISSUE names and the one that carries tehas:pause, is never worked on. It holds the pause switch and no outcome, so a cycle on it would spend a slot and model time on the switch itself. Whoever applies tehas:ready or tehas:plan to it, and whoever ticks a retry box on its question, starts nothing: no cycle, no planning turn, no retry. The poll changes no label of it, and says so once, in one line of logs/dispatch.log as it says a label from an account that is not allowed: skip #N: the control issue is never worked on. The dashboard and tehas status do not count it in line.

3. What happens next

Watch it on the factory floor or the plain dashboard: the queue, the issue being worked on with its console streaming live, and what is waiting for you.

Unless TEHAS_ANALYTICS=off, the plain dashboard also has a section Last 10 days, from live/analytics.json (see tehasbot status): a row of figures (shipped, with a bar a day; planned, with its trend; runs by how they ended; first-pass yield; lead time; cycle time; machine time; tokens; availability; and energy per shipped issue where the mesh reports it), a chart of shipped issues and failed runs per day with the cycle-minutes as a line, the five most common stop reasons, the share of runs that got through each step, and one row per tehas and pi-rukas version pair. Every figure says its count as n=: ten days make small numbers. A pair with fewer than three runs shows its count only. The section is hidden where there is no file, and the page reads it at most once a minute. What the file means is worked out by one module, host/fun/analytics-data.js; the plain dashboard's island, host/fun/factory/tehas-factory-days, draws it.

Optional, and only when the model backend is a viiwork mesh with tehas-energy.service enabled: the factory floor also has a section Energy use: what the machines serving the factory draw now, their kWh over 24 hours and 30 days, the last 30 minutes as a chart, and the factory's models with their busy slots. The figures are the mesh's own and are good to about 15%. Only machines that are online and serve a model the factory uses are counted; other machines of the mesh and other models are left out. A counted machine's draw is all of it, including any other model it serves. While the section is there, the panel that opens the first screen carries a live meter: the draw now, and the tokens the mesh produced for the factory's models in the last minute. The tokens are the mesh's count for those models, so other users of the same models are in it. On a wide screen, 1440px and up, it is a card of its own beside that panel, over the column the work order monitor stands in; below 1440px it stands at the right end of the panel, over its title and the lines under it, and below 900px it lies across the foot of that panel instead. It leads to Energy use. With any other backend the section and the meter are simply not there, and nothing else changes. To turn them off on a viiwork mesh, see the energy sampler.

The dispatcher takes the ready issues of the start order first, in the order given, then refreshes of its own pull requests, then the other ready issues, lowest number first. With no order, ready issues start lowest number first. A person sets the order with tehas order set --issues 12,8, and it lasts until it is cleared unless --for or --until gives it an expiry; a program that runs the factory may set it on every poll instead. With --only, a ready issue the order does not name waits, and the log says wait #N: not in the start order (--only); refreshes do not wait. An order that expired or cannot be read is no order, and the log says so. The order only sorts: an issue starts only on a tehas:ready or tehas:blocked from an allowed account, and every hold below applies as without it. tehas status prints an order line while one is set. See tehas order. The dispatcher takes issues as many at a time as the host's ceiling and the slice's room allow (see Limits that hold work back). A running cycle is never stopped to make room for one higher in the order. The dashboard lists the queue by issue number, not the order the dispatcher will work it in.

An issue with an open native blocked-by link is not started, whatever label asks for it: add the link under the issue's Relationships on GitHub ("Mark as blocked by"). The page each poll reads carries the count of open blockers (issueDependenciesSummary), so the hold costs no call of its own, and the log says wait #N: a blocked-by link holds it: 1 blocker is open. A link only holds an issue back. It never starts one: once every blocker is closed the issue starts under the usual approval rules, so tehas:ready from an allowed labeller, or a tehas:blocked whose marked comment counts, is still needed. Apply tehas:ready with the link and the issue starts when its last blocker closes. A link and a marked comment both hold: the issue waits while either names an open blocker. A forge that answers no such field holds nothing by links, and the marked comment below is all that names blockers there.

To keep two issues that change the same files apart, hold one of them out of the start order: tehas order set --only --issues 12,15 lets only #12 and #15 start and holds every other ready issue, #14 among them, so a host that runs the factory leaves #14 out until #12's pull request is merged and then names it again.

The marked comment of tehas:blocked keeps working for one release, then the links replace it. An issue with tehas:blocked is not started while an issue it names is open, so its slot goes to work that can move. Once every issue it names is closed, it starts. Apply tehas:blocked on its own and leave tehas:ready off: the dispatcher starts the issue when its blockers close, on your approval, as if you had applied tehas:ready then. The label counts from an allowed labeller or the millwright, when the latest event of the label applies it, with one difference: on its own it starts work, so it counts only from an allowed labeller, and only while the text is the one it approved, as tehas:ready does, and only while the label is the one the factory pinned (see label pins). A tehas:blocked the millwright applies holds an issue but does not start one, and so does one the pins refuse. On an issue tehas is already working on, one with tehas:running, tehas:awaiting-merge, tehas:question, tehas:planning, tehas:refreshing, tehas:plan or tehas:refine, it starts nothing. The blockers are named in a comment by an allowed labeller or the millwright that holds the marker:

Blocked by #12 and #34.

<!-- tehas:blocked by=12,34 -->

Up to 20 numbers, separated by commas and no spaces. The newest such comment among the last 100 counts; one by anyone else is ignored. Only comments are read: a marker in the issue's body names nothing. When the label counts and no such comment is there, the issue is held by the label alone: it names no blockers and never starts until an allowed labeller or the millwright comments a marker, or a person takes tehas:blocked off. The log says so at every poll, and tehas status lists such issues on a blocked line and in demand.labelAlone. The issue also waits, and the log says why, when the newest one does not hold a marker that reads, when it was last edited by another account, or when GitHub does not give the state of a number it names. Once every blocker is closed the issue starts, and the start takes tehas:blocked off with tehas:ready. The label stays on until that start, so an issue whose blockers have closed while it waits for a slot or another hold still carries tehas:blocked: the hold is over, and the label is what asks for the start. When an allowed labeller's tehas:blocked clears and the issue does not start in that poll, the dispatcher says so once in a comment that holds <!-- tehas:hold-cleared -->. Only the bot's own such comment counts as said. A newer marker comment is a new hold, and its clearing is said again. A blocker that is closed already holds nothing: name one that is still open, or reopen it. To start a blocked issue anyway, swap tehas:blocked for tehas:ready. To stop it starting, take the label off.

An epic is never started: an issue with open sub-issues is a plan broken into issues, not a change one cycle can make, and a cycle on it spends a slot and its tokens before it parks as too large. When tehas:ready is applied to such an issue, the dispatcher takes the label off, says so in one comment and starts nothing; a retry ticked on one starts nothing and the log says why. The count comes from the issue GitHub already answers for, so a GitHub without sub-issues is unaffected. Read the plan and apply tehas:ready to one of its sub-issues instead; a sub-issue with no open sub-issues of its own is started as any other issue. A tehas:plan session on an epic is allowed: planning an epic is what it is for. With TEHAS_MILLWRIGHT_EPICS=on and a millwright, your tehas:ready on an epic is not lost: it approves the epic's open sub-issues for the millwright, which plans each one that needs it and applies tehas:ready to it, and the comment says so. Close the epic, or put needs-human-attention on it, to take that back. Tehas's own removal of the label keeps the approval; a removal by anyone else ends it.

An open issue whose title starts with an epic marker gets the epic label at the next poll, so the board says what it is. The marker is the word epic in any case at the very start of the title, or after one opening bracket, followed by :, a closing bracket or a space: EPIC: Billing rework, Epic: ..., (Epic) ... and [EPIC] ... match; feat: WS-A child of epic 412: ..., Epicenter map and epics view polish do not, so a part that names its epic is never labelled as one. tehas only adds the label. Take it off an issue and tehas leaves it off: the poll reads the issue's label events, and a removal by any account but the bot's is final. The control issue is never labelled, and a paused poll labels nothing. The label is for people: what makes an epic for the dispatcher and the epics panel is still GitHub's sub-issue links, so a labelled issue with no sub-issues is started as any other issue and is not on the panel. tehasbot health warns about such an issue, the common miss when a plan's parts were filed and never linked: open the epic and add its parts as sub-issues. Run tehas labels once after an update so the label exists.

With TEHAS_SIZE_MAX_FILES set on the instance, an issue whose own body names more files than that number is not started either. The dispatcher reads the count off the approved text itself: a path is what stands between two ticks and holds a / or ends in .sh, .rs, .md, .json, .toml or .yml, and one path counts once however often it is written. Such an issue is a stack of changes wearing the shape of one issue, and a cycle on it spends its explore and its plan before it parks. The dispatcher takes tehas:ready off, puts needs-human-attention on, and says the count, the setting and the way out in one comment: narrow the issue to the part one cycle can make, or split it into issues of that size, then apply tehas:ready to one of them. The hold belongs to tehas:ready alone, so it holds nothing else back: a ticked retry, a refresh of the bot's own pull request and a tehas:plan session start as they did. Unset, the dispatcher never asks, and a wide issue starts as any other.

Label on the issue Meaning Your move
tehas:ready Queued Wait, or remove the label to withdraw it
tehas:running A cycle owns it; with TEHAS_ASSIGNEE set, the issue is assigned to that account too Leave the issue and its branch alone
tehas:awaiting-merge Pull request open, only the merge left Review and merge
tehas:shipped A merged pull request closed it, or GitHub's own list of pull requests closing it holds a merged one Nothing; the poll's tidy and tehasbot status give it
needs-human-attention The cycle stopped Read the comment; see below
tehas:plan A planning session is asked for Wait for the first comment
tehas:refine A refining session is asked for: planning with the refine brief Wait for the first comment
tehas:planning A planning turn is running Wait
tehas:replaced Closed: a refine filed the issue that replaces it Work on the issue named in Replaced by
tehas:refined A refine filed its first part; later parts remain Apply tehas:refine for the next part, or close it
tehas:question The factory asked something Tick a box; in a planning session you may reply instead
tehas:improvement Filed by the factory, a proposal Read it; apply tehas:ready if it should be built
tehas:millwright-escalated The millwright left it to a person Read the millwright's note; decide, or take the label off to hand it back
tehas:lean The lean driver is chosen for it. See Choosing the driver Take it off to run the issue on classic
tehas:classic Under TEHAS_DRIVER=lean: the classic driver is chosen for it. See Choosing the driver Take it off to run the issue on lean
tehas:blocked Started once every blocker it names is closed Close the blockers; swap it for tehas:ready to start it now
tehas:refreshing On a pull request: a refresh works on it Do not merge or push to it now; it comes off when the cycle ends
tehas:finish Asks the factory to open the draft pull request of a stopped cycle. See Finishing a stopped cycle Wait: the next poll takes it off and comments with the URL or why not

With TEHAS_ASSIGNEE set on the instance, the call that marks an issue tehas:running for a cycle also assigns it to that account, so GitHub shows the issue as taken and nobody starts on it by accident. GitHub assigns no app's bot, which is why the owner is a person. The owner is never unassigned: a closed issue's assignee does not matter, and a parked one is with the person who acts on it. A refresh does not assign again, and neither does a planning turn. When GitHub refuses the assign, the dispatcher marks the issue running without it, starts the cycle, and says so in logs/dispatch.log: WARN: could not assign #N to <owner>, marking it running without an assignee. Unset, nobody is assigned.

tehas:ready from an allowed labeller starts a fresh cycle whatever else the issue carries. So does one from the millwright, within its grant. tehas's labels of the earlier outcome go when the cycle starts. needs-human-attention stays until the cycle runs: the cycle starts with --restart, and pi-rukas takes the label off as it begins. The dashboard counts an issue with tehas:running as running, whatever else it carries. On an issue whose cycle is still running, the label waits: a fresh cycle starts when that one has ended. Remove the label before then to withdraw it.

Once an issue is closed, the next poll takes tehas's state labels off it: tehas:running, tehas:awaiting-merge, tehas:question, tehas:planning, tehas:refreshing, tehas:blocked, tehas:ready, tehas:plan and tehas:refine. needs-human-attention and the labels a person chooses, such as tehas:lean and tehas:classic, stay. The list, the two searches, the decision of what comes off which issue and the edits are the console's (console tidy run, console/ops/src/tidy.rs).

The same edit puts tehas:shipped on an issue that a merged pull request closed: from the close event's merged pull request, or, when that event names no pull request as its closer, from a merged pull request GitHub lists as closing the issue. That list is what GitHub derives from the text and the links of the issue, not what the close event recorded, so a pull request that merely names the issue in its text is on it. console tidy run reads what closed the issues it tidies and adds the label in the call that strips their state labels, so the label says one thing, that a merge closed the issue, whatever the queue's list happened to hold. Two commands put the label from a merged closer, and both make the one read of the query of console/ops/src/shipped.rs and go by the same rule: console tidy run in the edit that takes the state labels off, and tehasbot status from its own read of the list for any issue missing it. console tidy run is the one that says what it did in ~/tehas/logs/dispatch.log. Neither gives it to the control issue. An issue that already carries the label is not labelled again, and one that the read could not answer is never labelled on a guess: its state labels still come off and the tidy line says no merged pull request was read as the closer, or, when the whole read failed, that the read failed once for the poll.

The pages' Shipped figure counts the closed issues that carry tehas:shipped, and not the hundred most recent items of the queue's list: an issue a person closes as completed without a merged pull request does not carry the label and is not counted. The count is the completedCount of the queue snapshot; where the snapshot has none, the figure is the length of that list.

When the cycle starts and when it ends, the bot comments on the issue. The token usage per agent role is posted on the pull request.

The console on the factory floor and on the plain dashboard shows one cycle at a time. When several are running, or one is running and an earlier one can still be read, a row of tabs above it names each by its issue number.

A timer polls every two minutes, and a cycle that ends starts a poll at once. A poll that fails does not stop the polling: the timer counts from the last start as well as the last end, so the next poll comes two minutes later whatever this one exited with. TEHAS_POLL_SECS sets another interval, from 30 to 3600 seconds: tehas setup and tehas update write it to the drop-in ~/.config/systemd/user/tehas-dispatch.timer.d/poll.conf, which sets all three of the timer's times, and restart the timer. Back at 120, or unset, they remove the drop-in. Each poll costs GitHub API calls, so a quiet host can poll less often and let another program wake it with tehas wake (see the factory API), the same ask as tehas dispatch --soon. To see the factory's state, or to see or force a poll by hand on the host:

tehas status                 # taking work? the queue, the current or last cycle, the slice's room
tehas status --json          # the same for a program, with the demand (see the factory API)
tehas top                    # the same overview, on one screen that redraws itself
tehas dispatch --dry-run     # what would it do?
tehas dispatch               # do it (returns once the cycle is started)
tehas dispatch --soon        # ask for a poll from the timer's units, return at once
systemctl --user status 'tehas-cycle@*'   # which cycles are running
tehas stop 12                             # end the cycle for issue 12, clear what it left
systemctl --user stop tehas-cycle@12      # stop the cycle for issue 12

A stop ends the container. The issue gets needs-human-attention, and the console shows the cycle as interrupted.

tehas stop 12 asks that unit to stop and takes away what the cycle left on the host: its container, its workspace, its transcripts, and the files in ~/tehas/state that make this host think the cycle still runs, is owed, or is parked. It keeps the cycle's record and its logs. Its last step is the issue's own: when the host part went clean, tehas:running comes off it, with no other label added and nothing written there. See tehas stop.

tehas is the one command to type on the host; tehas help lists what it does. See Commands.

Choosing the driver

The lean driver is a feature still being built (lean in tehas api --json flags). A release runs every cycle on classic: TEHAS_LEAN=on and TEHAS_DRIVER=lean each stop every command with 78 and name the feature, and tehas work --driver lean exits 78. tehas:lean starts nothing and does not fall back to classic: the poll takes tehas:ready off and says lean is still being built; an allowed account takes tehas:lean off to run the issue on classic. A retry, an outage retry or a refresh that follows a lean start is refused the same way. tehas:classic works as before. The rest of this section is how the driver is chosen once lean is on.

A cycle runs on the classic driver unless a person chooses lean for that issue with tehas:lean. The label starts nothing: tehas:ready still does that.

TEHAS_DRIVER in the instance sets the default: classic, the default, or lean. With TEHAS_DRIVER=lean an approved start with no driver label runs lean when the issue's text holds a pi-spec v1 block (the same check as below: one fence of valid JSON), and classic when it does not, since lean declines an issue without one. The poll logs which it chose and why: start #N on lean: TEHAS_DRIVER=lean and its text holds a pi-spec v1 block, or start #N on classic: .... A person still chooses for one issue: tehas:classic runs it on classic, and tehas:lean on lean, block or not (a new lean start without the block is still refused, as below). Both labels are read as tehas:lean is under the classic default: from an allowed account only, read from the label's events, and the rules below hold for either. Under the classic default tehas:classic agrees with it and chooses nothing. An issue that carries both labels starts nothing, whatever the default: the poll takes tehas:ready off, says why once, and an allowed account takes one of them off. Each approval record binds the driver its start ran.

A lean start runs pi-rukas-headless work-lean in the same container classic work gets, which needs a sandbox image of pi-rukas v0.14.47 or later (pi-rukas#1920). On an image that cannot run it, the start is refused and parked, and classic does not run in its place. Whether lean merges is the product's .pi/work.json autoMerge, which tehas leaves alone. A lean start is never a refresh: no --continue-pr. By hand, tehas work <issue> --driver lean runs lean without the label (tehas work).

What a lean run does, as pi-rukas's docs/lean.md describes it:

What a poll costs

Under its factory line, tehas status shows what the polls cost:

poll      last 24 s wall, 3.1 s CPU, 12 gh (0 writes); last hour 14 polls, 41 s CPU, 2 writes

Each poll that holds the dispatcher's lock records these figures in the state store as it ends, however it ends. A dry run records nothing.

~/tehas/libexec/store poll-show gives the same figures as JSON, with the writes of the last poll by kind. store poll-show --api --now <unix> shapes them in the names tehas api prints them under, with the last poll's age in minutes counted from <unix>; tehas api --json carries that as its poll field, and its plain output prints the line of words below the millwright's. store prune drops the records with the other old rows of the store. With no poll on record there is no poll line.

~/tehas/libexec/store poll-idle --since <seconds> [--budget <spec>] answers one object over the polls of the last <seconds> that started no cycle: {"polls": n, "cpu_ms": m, "wall_ms": m, "writes": m}, the three m being the median of those polls. The writes figure is left out when none of them had a write log, and {"polls": 0, "over": []} is the answer when no idle poll is on record. A poll with no starts on its row is not one of them.

--budget is cpu=<seconds>,wall=<seconds>,writes=<count>, any part of it left out, each figure a whole number of at most 9 digits: the answer gains "over": [...], the names of the figures whose median was over its budget, and without --budget the answer has no over. When over is not empty the answer also has "over_polls": {...}, how many of those polls were over each of its figures on their own. tehasbot health calls the verb with TEHAS_POLL_BUDGET (default cpu=5,wall=30,writes=0) for the poll_cost check, and warns when the list is not empty; see tehasbot health.

The report in Rust

tehas-cycle cycle reports a cycle in its own process once tehas work has ended: the report of libexec/cycle in bash is gone, and so is TEHAS_CYCLE_REPORT. An instance that still sets it to a value, rust too, stops with 78 until the line is taken out; a blank value is ignored. The report goes by the settings the cycle started with and does not load instance.env again: a file changed or broken during a cycle does not stop it. A host without libexec/tehas-cycle starts no cycle: tehasbot cycle stops with 78. There is no way back to the bash report short of installing a release that still has it.

The report makes the writes the bash report made, in the same order, with the same tries: three, and one bounded try after a stop. What it does that the bash did not:

The shadow that decided beside the bash report is gone with it. ~/tehas/state/cycle-shadow.on, ~/tehas/state/cycle-shadow/ and ~/tehas/logs/cycle-shadow.log are read by nothing now, and can be removed.

4. Review and merge

The pull request comes from the bot (the factory's app or bot account) against the product's default branch (in the example, main). It has passed the product's fast gate, its full gate, its smoke command and pi-rukas's six-pass review, but none of those is a human reading the diff. Nothing merges on its own.

Each finding of the six-pass review has a severity: CRITICAL, HIGH, MEDIUM or LOW. Which severity stops a cycle is the product's decision, not the reviewer's and not pi-rukas's. pi-rukas reads it from the product repository's doctrine (AGENTS.md, or CLAUDE.md when the product has one), at the commit the cycle started from, so a cycle cannot lower its own bar mid-run. Where the doctrine states none, pi-rukas takes its own default, which is HIGH from v0.14.50 and was MEDIUM up to v0.14.49. This repository's AGENTS.md states no bar, because rule 7 gives that file to a person, so a cycle here blocks at HIGH: pi-rukas's default is what applies today. The bar the platform repository decided is recorded in docs/adr/0002-review-severity-policy.md, a record in the source rather than a file on a host; the ADR still names MEDIUM, the bar of the pi-rukas release that defaulted to it, so a person updating it to HIGH and adding the sentence below to AGENTS.md is what makes the decided bar the one a cycle reads. A finding at the bar or above sends the change back to a fix step and the review runs again, up to two rounds from pi-rukas v0.14.49 (three before it). Only LOW findings may be deferred: they are notes on the pull request and start no fix round. A CRITICAL finding blocks whatever the bar says.

The sentence AGENTS.md has to carry is one pi-rukas can read: one sentence that names the bar with a relation, This repository blocks at HIGH severity and above. pi-rukas takes the severity out of the sentence the judge quotes and checks that sentence against the file word for word, so a paraphrase that names the severities without the relation is a silent no-op and the cycle takes the default again. While the sentence is missing a cycle's log records the verdict as unstated.

An instance can set the bar itself with PI_ENSEMBLE_REVIEW_THRESHOLD, which wins over what the product says (see Commands). tehas passes that line through without checking it, and pi-rukas honours it only when it reads as one of the four severities: a value that is not one of them is ignored, not refused with 78. With neither, pi-rukas's default: MEDIUM up to v0.14.49, HIGH from v0.14.50. Because the default moved, the drivers table gives each pi-rukas version its own entry, so runs of the two bars are never read as one figure.

Two rounds is the most a review takes from pi-rukas v0.14.49, three before it. A CRITICAL finding parks the cycle. A round cap reached with only MEDIUM and HIGH findings left, an approving adversarial review, and those findings posted as a comment on the pull request, carries on to the gate with the findings named on the pull request instead of parking; a post that fails parks. A review that runs out of its time budget parks whatever the findings are.

With TEHAS_SPEC_PIPE=on and a start whose approval pins a spec, a pull request waits only for a merge when its body holds a spec block that names the sha256 of that pin. Without one, or with a block of another sha256 or one tehas cannot read, the issue parks with needs-human-attention instead of tehas:awaiting-merge, and the pull request stays open. See a pull request that does not answer to the spec.

A pull request that waits while other work merges may start to conflict with the branch. Where the instance turns refreshes on, the factory merges the branch into it on its own.

After merging, the issue closes and leaves the queue. If you close a pull request without merging, remove tehas:awaiting-merge from the issue by hand; Tehas does not notice a rejected pull request yet.

5. When a cycle stops

needs-human-attention means the cycle parked. The bot posts one comment: the status, the last step, the cap pi-rukas stopped on, the log file on the host, and then pi-rukas's own handoff, with the reason and what to do next. pi-rukas posts no handoff of its own: tehas runs it with PI_ENSEMBLE_HANDOFF_CHANNEL=host and posts the one it renders. The comment's first line is pi-rukas's hidden marker, <!-- pi-rukas:handoff issue=N cap=... -->.

What a handoff with an open pull request leaves on the issue depends on why pi-rukas handed off:

A runner that died before it wrote its result leaves no verdict of its own, so tehas reads the cycle's own run log for the step it reached and asks GitHub for the bot's pull request of the branch commit-pr pushed. With one there the comment is Tehas cycle handed off with its pull request open and its review unfinished: needs-human-attention, the pull request named, and no boxes, because a clean retry redoes what the open pull request already holds. With none, the issue is parked as any other that stopped without a pull request. The comment names the runner's own exit, not the exit of tehas work, and says the step was read from the log. See the runner died and wrote no result.

A cycle that stops with the bot's pull request of its branch open, say at commit-pr after it opened a draft, is parked with the comment Tehas cycle stopped with pull request #<N> open, and (draft) after it when GitHub lists the pull request as a draft. The comment ends with its address. Read it before you retry: the work in it is not lost. A cycle with no open pull request of its branch says Tehas cycle stopped without a pull request.

An issue never ends a cycle with both labels.

A cycle that reaches its deadline parks with the cap deadline. tehas gives pi-rukas a deadline the handoff's 8 minutes before the end of TEHAS_WORK_TIMEOUT: after it, the cycle starts no new step and hands off with its branch and pull request, instead of being stopped in the middle of one.

To try again after fixing the cause (often: make the issue clearer), tick a retry box in the bot's comment. Tick Leave it parked to take the question away and keep the issue as it is. Both retries start over in a new workspace.

The comments box is offered only when the sandbox image gives a cycle the comments: its pi-rukas lists issueComments in --capabilities (trail-openers/pi-rukas#2020), or its tehas.rukas.polyfills label carries issue-comments@<version> (tehas-app/tehas-polyfill). Otherwise the comment offers the text-only retry and Leave it parked. On the polyfill alone a comments retry runs with PI_ENSEMBLE_REPEAT_PARK=0 where the image takes it, since the polyfill's comments do not reach the repeat-park guard, and the end comment says the comments were given to the cycle's agents. With the native reader it says how many the runner read, or that it did not and why. A comment posted before this release has the old boxes, Retry from a clean start and Retry from the issue alone: they still count, as the comments retry and the text-only retry. A label works as well: apply tehas:ready. needs-human-attention does not have to be removed first. A cycle started that way takes tehas:question off the issue, and the old boxes no longer do anything.

A cycle that parks at child-timeout:develop, its developer stopped at its time bound, first writes a note into the issue's body, because a cycle reads the body and none of the comments. The note sits at the end, between <!-- tehas:last-attempt base=... --> and <!-- /tehas:last-attempt -->, under the heading "The last attempt ran out of time". It says how long each step took, whether the gate last passed, what was left in the workspace, and the files the plan named, and asks the next cycle for a smaller change. All of it comes from what pi-rukas's driver recorded, none from an agent's words. A later develop timeout replaces the note. Edit or delete it as you like. The note is written as the bot, so the issue shows an edit by the bot, and a retry on it approves the text with the note. A note that cannot be written is a warning in the log, and the park is posted as before.

When the note is there and the rest of the body has not changed since it was written, a second develop timeout does not write it again, and its park comment has no retry box at all, only Leave it parked: the same text would run into the same bound. The comment says to split the issue with tehas:plan, or make the body smaller and apply tehas:ready. A tehas:ready on the unchanged text is held as below, the millwright's too. The note and the check need libexec/tehas-cycle; without it the park is posted as before.

A new tehas:ready on an issue whose last cycle parked asks for nothing while the issue still carries the body that cycle ran on. The dispatcher compares the hash of the body that cycle's approval bound, as the state store keeps it for the park, with the issue's text now, and when they are equal and the park was not a provider outage it starts no cycle, leaves the park and the labels as they are, and says so in the poll's log. Once per park it also posts one comment: edit the body, or tick a retry box. The tick is the park's own ask and is never held, so a retry on the same text starts as it did, and so does a start after any change to the body. A retry ticked by an allowed account also lifts the hold of a new tehas:ready, so taking tehas:question off by hand after the tick does not lose it; the log then says lifted on the Retry <account> ticked. A park with no question on record (taken off by a start that did not happen, for one) has no box a tick could start, so it holds nothing either: the log says lifted as its park has no question on record to tick. A park of a provider outage is held by its own rule instead, and a park of a cycle started by hand, which no approval bound to a body, holds nothing. A park that cannot be read holds the issue for that poll.

The millwright's own tehas:ready is the one label a park lets through without a change to the body, when its comment says the next run is not the run that stopped. The hold is lifted when the label came from the millwright, the instance gives a cycle images or files (TEHAS_WORK_IMAGES=on or TEHAS_WORK_FILES=on), and the note the record would take from that account is one carrying <!-- tehas:millwright issue=<n> action=change -->: its newest marked comment of the ten minutes before the label, saved by nobody after the label and by no other account. A newer action=retry comment takes the lift away: that ask is the run again. Comments that cannot be read keep the hold for that poll, nothing is said on the issue, and the log says why. The start the lift let through counts against TEHAS_MILLWRIGHT_MAX_RETRIES as any millwright start does, and it is held when the grant itself refuses, which a start of no person's approval or a body changed since the approval is. The poll's log says lift #<n>: ... lifted on the fixer's guidance comment and the approval record carries the comment under park_lifted, beside the retry_context the cycle is given; rests_on still names the person's approval the refresh reads. The hold and its comment are unchanged for anyone else's label.

An issue closed since its cycle stopped is not work. Neither the tick nor a new tehas:ready starts anything on it, and the poll's log says so.

A cycle that a provider outage parked says so in its comment: parked by a provider outage, with the cap. Only the cycle's own result names the outage, so the park is recorded under its cap like any other and waits for a tick or a label: tick the retry box once the model endpoint answers. A park an earlier version recorded as provider-outage still owes its one retry: once the model endpoint answers, the dispatcher starts the issue again on its own and says so on the issue, on the word of whoever started the cycle that parked. tehas stop on the issue gives up that one retry.

When the bot cannot post the boxes, it posts a plain comment that gives the label to apply. When the boxes are posted and the label tehas:question cannot be added, a second comment says that the boxes cannot be used, tells you to run tehas labels on the host, and names the label.

A cycle that was killed outright cannot report, for example when the host lost power. The next poll finds its issue: open, marked tehas:running, and no cycle on the host behind it. It takes tehas:running off, adds needs-human-attention and says so in a plain comment without boxes. Look for a pull request the cycle may have opened, then apply tehas:ready to retry. The poll starts nothing for it by itself. A closed issue in that state only loses tehas:running.

A tick counts only from an allowed labeller, and only while the issue is parked and open: it carries needs-human-attention and neither tehas:running nor tehas:awaiting-merge. It is used once. The poll first marks the issue tehas:running; if GitHub refuses that, the tick stays and the next poll tries again. Once the issue is marked the question is no longer on record, so the same tick cannot start a second cycle, and the bot unticks the box to show it was taken. A box ticked by anyone else, or more than one box, is unticked and the bot says so in a comment. A retry ticked on an issue that is not parked is unticked too, and the bot says that nothing was started. A paused factory, one with every slot taken, or one at the cap of TEHAS_MAX_AWAITING, holds the retry back as it holds any cycle. The tick stays and is used when there is room.

The host keeps the id of the question it posted when the cycle stopped. A tick counts only in that comment; a box in any other comment does nothing. On an issue for which the host has no question on record, a box ticked in a comment of the bot that looks like a question is unticked, and the bot says that the question is not one the factory is waiting on and names the label.

The next cycle starts in a fresh workspace, with --restart when the issue carries needs-human-attention. That flag is the answer the label asks for: pi-rukas lets the cycle past its check of the label, and the cycle takes the label off on the host before its runner starts. Branches and commits the earlier attempt pushed are kept on GitHub. What it left only on the host, such as commits on worktrees that were never pushed, is moved to ~/tehas/work/tehas-<issue>.before-retry and stays there until the retry it was kept for ends, whatever its end: merged, handed off or parked. Only the latest stopped attempt is kept: a second retry replaces it, unless the attempt before cloned no workspace, which leaves the older copy beside the new one. Recover what you need from a stopped cycle before you retry twice. Nothing is kept for ever: the dispatcher's poll removes an issue's kept workspaces at once when the issue is closed, since a closed issue never resumes, and otherwise once no cycle has run on it for TEHAS_WORKSPACE_KEEP_DAYS days (7 by default), three issues a poll at most, and logs each removal. With them go what the cycle left outside its workspace: the agents' transcripts in ~/.pi/agent/ensemble-runs/issue-<issue>, the console ~/tehas/live/console-<issue>.txt, and the transcripts of the issue's planning session, ~/.pi/agent/ensemble-runs/plan-<issue>. An issue whose workspace is already gone loses those three on their own, on the same rule: the issue's lock free and none of them touched for that many days, or the issue closed. The lock has to be a lock file: as with tehas stop, one that is a link or a directory says nothing about the issue, and the poll removes nothing of it and says so. An issue the poll cannot date is kept too, as tehasbot clean keeps what it cannot date, and is tried again on a later poll. Only the names of that one issue go, and the dated directories of ~/.pi/agent/ensemble-runs are the runner's, not tehas's, so the sweep leaves them for a person.

A label or a tick approves the text of the issue as it was at that moment. If someone other than an allowed labeller changes the title or the body afterwards, the issue is skipped and the dispatcher's log says who changed it. Read the new text. Then approve it again: for the label, remove tehas:ready and apply it again; for a retry tick, untick the box and tick it again.

Finishing a stopped cycle

A cycle can finish its change and still stop on something outside it: a flaky test in a file the change does not touch, a review lane out of disk, the gate's time bound. Its workspace is kept, and the factory can open what it holds as a draft pull request with tehas-cycle finish. To ask for that from the issue, with no access to the host:

  1. Write a comment whose first line is <!-- tehas:millwright issue=<n> action=finish -->, with <n> the issue's number, and why the failure is outside the change after it. The reason goes into the draft's body as written.
  2. Within ten minutes, apply tehas:finish from the same account.

Who may ask:

The poll's finish step takes no slot and starts no agent and no cycle. It runs after the poll's own decisions, at most three asks a poll, and not on a poll that is paused, dry or that failed. An ignored label does not count toward the three. For each ask it checks the rules above, the comment (the asker's newest marked one, written in the ten minutes before the label and edited by nobody after it), and that no cycle of the issue is running. Then it takes tehas:finish off and runs tehas-cycle finish <n> --home <home> --repo <repo> --default <TEHAS_BRANCH> --reason <the reason>. Taking the label off first means one ask runs one finish.

What comes back on the issue is one comment of the bot's:

An ask whose label events, comments or approval record cannot be read waits with the label on for the next poll. Each ask taken leaves one line in ~/tehas/logs/dispatch.log, finish #<n>: opened <url>, asked by <who> (<label|millwright>): <reason> or finish #<n>: refused, asked by <who>: <why>, which the MCP server's factory_decisions answers as the decision finish. A refusal on a command's failure is preceded by the finish of #<n> was refused, the command said: <its first line>.

A cycle whose push or pull request GitHub failed

When the last GitHub steps of a cycle fail, the cycle's report records which one in ~/tehas/state/cycles/<n>.end-failed.json: the push, the pull request or the handoff comment, and whether the failure was GitHub's. GitHub's is an HTTP 5xx, a 429, a 403 that names a rate limit, a timeout or a connection error. Any other 4xx, such as a 422 or a 403 for a missing permission, is the request's own, and so is a failure that names none of these. A later cycle of the issue replaces the record, or removes it when its end failed nothing. A record with a field missing or of the wrong type does not read: the poll tries nothing on it and tehas status does not list it. A record the report cannot write, or an earlier one it cannot remove, is ERROR: the failed end of #N is not on record: <why> or ERROR: the failed end of an earlier cycle of #N is still on record: <why>, where the why names the file and the error, and the cycle ends with exit 70 rather than 0: without the record the poll tries nothing and tehas status shows nothing.

The push and the pull request are made in the cycle's container, so the host knows of their failure only from the cycle's own result. The record says so ("host": false), and the poll finishes nothing on it: the cycle waits for an ask with tehas:finish, and tehas status says only the cycle's own result says so. The handoff comment is the host's own call ("host": true).

For a push or a pull request that the host saw fail on GitHub's side, the poll runs the same tehas-cycle finish an ask runs, from the kept workspace, with no ask:

Nothing else is finished on its own: a request's own 4xx, a handoff comment that failed, a failed test, a review or a park still wait for the ask. The step runs where the ask's step runs, after it, and not on a poll that is paused, dry or that failed. Each try leaves one line in dispatch.log: auto-finish #<n>: opened <url>, try <k> of 3: ..., auto-finish #<n>: try <k> of 3 failed on GitHub's side: ..., auto-finish #<n>: stopped: ... or auto-finish #<n>: dropped: .... tehas status lists each record on a finish line, with the poll's next try or why it does not try.

Planning on an issue

A planning session is a conversation with pi-rukas's planner that ends in a plan: written onto the issue itself, or filed as a new one. It runs on the issue, so you can steer it from a phone. Write your notes on an issue, let the planner work on them, and build that same issue: the discussion stays in the comments, and the issue's text becomes the plan. The agent is not asked to build code, and the awaiting-merge limit does not hold a planning turn back. Its container has the same access as a work cycle's, token included, so treat tehas:plan as you treat tehas:ready. It can start a build: see A plan with no open points.

An issue is in one flow at a time. Applying tehas:ready to an issue with an open planning session starts nothing until the session is ended. The dispatcher's log says so.

  1. Write an issue that says what you want planned.

  2. Apply tehas:plan. As with tehas:ready, only a label applied by an allowed account counts, and it approves the text as it was when you applied it. From any other account it is taken off the issue with a comment, as tehas:ready is.

  3. The bot comments that the session has started. Each turn ends in a comment with what the planner found. A turn is one run of pi-rukas's headless planner and can take many minutes. When it needs a decision, the comment ends in a question with one checkbox per choice, a last box End this planning session, and the label tehas:question is on the issue. When the agent offers more than 20 choices, the first 20 get a box and a line says how many were left out; reply to name another one. The last box and the label come after every turn, whether or not the agent asked something, and a reply or the last box works either way. When the agent asks more than one question in a turn, the comment lists them all, numbered, with their choices as text and no box for them: answer them in a reply. A turn that ends on an issue a person closed in the meantime is dropped: the poll reads the state before it posts, and a closed issue gets nothing of the turn, its session closes, and one line in the log says planning #N dropped: the issue is closed. A state the poll cannot read holds the post to the next poll rather than close the session on no answer.

  4. Answer by ticking one box, or by replying in a comment when none of the boxes fits. If you do both, the reply counts, and the agent is told which box was ticked as well. The next poll that is free continues the session with your answer, and the issue carries tehas:planning while the turn runs. The turn runs as its own unit, tehas-plan-<issue>.service, and the polls go on meanwhile: cycles start as usual, and the turn's end starts the poll that posts its outcome. The unit holds ~/tehas/state/plan-<issue>.json.lock while the turn runs, so no poll starts a second turn on the issue, and tehas status shows the turn on a plan line. One planning turn runs at a time, so while another runs, your answer waits until it ends, which is up to two hours (TEHAS_PLAN_TIMEOUT). A running work cycle does not hold an answer back. A poll also handles one answer or one planning start and then stops, and it does nothing while the model endpoint does not list the model.

  5. A drafted plan with open points, or one of the cases under A plan with no open points, is shown to you before anything is written: one comment holds its title and spec and lists its open points with the planner's proposals, and the comment after it holds the question and the boxes, among them Update this issue. Reply to change the plan, and the next turn drafts it again. Every turn of a session works on the commit the session started on.

    • Update this issue makes the plan, exactly as shown, proposals included, the issue's title and text, and ends the session. No container runs for it. The bot's last comment says so and holds the text the plan replaced, folded. The plan is written with the bot's token. A plan whose own title or text says nothing of the issue is refused instead: the issue keeps the text it holds, the session stays open, and the bot's comment names the rule the text failed, masked of tokens, keys and the host's private addresses as the planner's other words are. Reply to change the plan, and the next turn drafts it again.
    • A tehas:refine session also offers File as a new issue, which files the plan as shown as one new issue that replaces this one. A session files once.
    • A plan the checks of the issue's text refuse is not offered at all: the comment still shows it, and the question names the rule it failed and lists its open points, with no box but End this planning session. Besides the checks under A plan with no open points, a plan is refused whose text has lines that end in [context param], the request or the briefs echoed back, or whose Acceptance criteria are pi-rukas's placeholder for none ("derive the testable outcomes from the investigation findings"). Reply to change the plan, or end the session.

    After either box nothing is started on its own: read the plan and apply tehas:ready to the issue you want built. The label approves the text as it is when you apply it. A tehas:ready from any account outside the list, the bot's included, is taken off.

A plan with no open points

A tehas:plan session from an allowed person that drafts a plan with no open points needs no tick. The bot makes the plan the issue's title and text, as Update this issue does, ends the session and starts a cycle. The cycle is credited to you: your tehas:plan approved this build, so apply it only to what you would apply tehas:ready to. The plan is not shown first, and no person reads it before the cycle starts. The pull request still waits for a person. To stop the cycle before it starts, take tehas:ready off.

The session asks, as in step 5, when:

The poll logs planning #N asks: with the reason.

The bot's tehas:ready counts only on the record the poll wrote for that one issue, ~/tehas/state/plan-start/<issue>.json: the account and a sum of the title and text. No container is given that directory, and nobody can write it from GitHub. The poll that starts the cycle checks the label events again, and any change to the title or text since the plan was written, by anyone, stops it. So does tehas:ready taken off and applied again. The bot then takes the label off and says why, and you read the plan and apply tehas:ready yourself. All the other checks of a start apply, and a start spends the record.

pi-rukas's record of a session is kept on the host, in ~/tehas/work/<name>-plan-<issue>.keep/plan-sessions, and carried into each turn. If it is gone, for example after the host was rebuilt, the session cannot go on: the bot ends it and says so. Apply tehas:plan again to start a new session.

Only answers from allowed labellers count, and the millwright's within its grant (see The millwright's grant). A box ticked by anyone else, or more than one box, is unticked and the bot says so. A reply counts only if its author is an allowed account and, when it was edited, its last editor is too. Replies from others are ignored. Only the question the session is waiting on counts, which is the one whose id the host has on record. Any other comment with boxes, older or newer, does nothing. An answer runs a turn only while GitHub says the issue is open: on an issue closed since the turn that asked, a box and a reply do nothing.

Where the instance gives a cycle the images an issue links (TEHAS_WORK_IMAGES=on), a planning session is given them too, by the same rules, once at its start, and with TEHAS_WORK_FILES=on its text files. The bot says what it fetched, which it left out, and whether the session was shown them. If one cannot be fetched, no session starts and the bot says so. A reply can carry a picture or a file too: the next turn adds what the reply links to the session's images, by the same rules and limits, and tells the agent their names. What it leaves out the bot says. If one cannot be fetched, the turn does not run, and the bot says so; reply again to run it. The planning agent is shown the images when the sandbox image's label says its pi-rukas reads them. See Attachments.

What the agent writes in the bot's comments is posted on the issue. On a public repository that is public. Secrets and private network addresses are masked there, as on the dashboard, and the mask catches accidents only. The issues the agent files are written directly and are not masked: they are public as written. Do not put anything in the issue that should not be public.

If you tick a box in a planning question and nothing happens, the labels may be missing from the repository. The bot finds its questions by tehas:question, so without that label the boxes are posted and ticking them does nothing. Run tehas labels on the host, as described in Commands.

While a question waits, the factory works on other issues. A session ends when you tick the last box, when an answer arrives after TEHAS_PLAN_MAX_TURNS turns (20 unless the instance says otherwise) have run, or when the issue is closed or loses tehas:question. The first two remove the factory's labels from the issue, needs-human-attention included, and say so in one comment. To plan again, apply tehas:plan again.

If a turn does not finish, for example because the host restarted, the bot says so in a comment that names the log, and the issue gets needs-human-attention next to tehas:question. Reply to run the turn again with your reply as the next message. That holds for a first turn too, when it failed after its session had come into being, for example by running out of time. If a first turn fails before that, or is cut off by a restart of the host, there is no session to continue: the bot says so, the issue gets needs-human-attention, and you apply tehas:plan again.

The bot (the app's login) is never one of the allowed labellers. If it is listed in TEHAS_ALLOWED_LABELERS, the dispatcher stops with an error rather than let the bot approve its own work: every poll reads its own login first, before it reads a label or changes one. The Protolab refuses the same list, with an error before it reads, builds or removes a page. A poll or a pass that cannot read its own login stops there and does nothing else. A cycle acts as the same login from inside its container, so there is no second account to refuse.

The dispatcher in Rust

Every poll is ~/tehas/libexec/tehas-dispatch poll, handed to it once console run has checked the settings and the checkout. A file that is no program counts as not installed, so an empty one is not a poll that exits 0, and either way tehasbot dispatch stops with exit 78. The poll checks the model keys before it acts. tehas help dispatch is the whole of the rules. A poll is, in order: the lock, the snapshot of the queue (one GraphQL query in pages of 25; GitHub can answer a large page with an issue's label events left out or cut short, so an issue whose labels and timeline disagree (one it carries whose newest event in the timeline is not an application, or that has no event at all) has its events read on their own; so does a candidate whose newest tehas:ready or tehas:blocked on the page is no newer than the approval its last cycle started on, since that start took the label off and a timeline cut right after it still ends on an application; an issue the page gave no timeline at all is always read again, and the only label the queue does not ask about is tehas:running, which the bot applies itself and whose park rests on the lock file rather than the timeline; the control issue is asked about with no label exempt, because its tehas:pause history holds the whole factory), the decision, the actions, and the end every poll that held the lock has. Each write to GitHub goes through the state store's action journal first, and a poll begins by settling the writes a poll before it left open there: each is read again on GitHub and recorded as done or as not done, and never made again. A write that timed out, that GitHub answered with a 5xx, or whose connection broke after it was made, may have reached GitHub: its row is left open as unknown, the log says may have been posted, and the next poll reads it the same way before anything is sent again. What the read finds decides the write when the poll decides it again: found done, it is done and not sent (a park tell or a hold's note is then on record as said); not found, it is abandoned and the poll sends it once; a read that failed leaves the row open and the write is not sent that poll. An edit of an issue's text, such as a plan written onto its issue or a cycle's note, is found done only when the body is the text it wrote: a title the plan kept, or a body that says Replaces #, does not count. A read of GitHub that failed on a bad minute (a 5xx, a bare 403, or its bound) is tried once more after a short wait, at most six times a poll; tehasbot status and console tidy run follow the same rule for their reads. A read that still failed is a line that names gh's error by words of a fixed list only (HTTP 502, rate limit, timed out), and goes on ~/tehas/state/github-failures, the record of the last ten minutes that health counts: three or more warn, and tehas status prints a github line. A read that still failed ends the poll where a decision rests on it, as before the retry.

The bash poll is gone. TEHAS_DISPATCHER=bash in instance.env, or any value but rust and blank, is exit 78 until the line is taken out.

What follows from that shape:

Refining a request

A parked issue is not held back: tehas:refine or tehas:plan from an allowed account starts the session there too, and the start takes tehas:question off, as a tehas:ready cycle start does.

Every planning session, tehas:plan and tehas:refine alike, gives the planner the issue brief, ~/tehas/lib/issue-brief.md, after the issue's text. It says what a plan must be, since it may become the issue's own text: grounded in the code first, its files by exact path, a named test file for each acceptance criterion, what is out of scope, decisions and not options, nothing under .github/ or .pi/, and no inventory of the request. Its title starts with its classification as a conventional-commit type, feat:, fix:, chore:, docs:, test: or refactor:, keeping one the request already has; pi-rukas gives the cycle's pull request the same type, where a title without one becomes chore(work):. The issue's title is handed to the planner as what to plan without its type (feat: , fix(dispatch): ), so the drafted title does not carry it twice, and the type goes to the planner as its own --type: feat is a feature, fix and bug a bug, chore and refactor a chore, research a spike and EPIC an epic. A type with none of these (docs:, perf:) leaves the planner to read the kind of work from the title's words, as a title with no type does. A planner image that takes no --type keeps chore, refactor, research and EPIC in the title, where it finds them. When the issue's text has a pi-spec v1 block with criteria and no Acceptance criteria heading of its own, the planner is also given those criteria under ACCEPTANCE CRITERIA:, one bullet each, which is where pi-rukas reads the request's criteria from: it reads none inside the block.

tehas:refine starts the same planning session with one difference: between the issue's text and the issue brief, the planner is given the refine brief, ~/tehas/lib/refine-brief.md. It tells the planner to plan the request into one issue that a single /work cycle finishes: one behaviour change, about one or two code files and one test file. When the refine brief is missing or cannot be read, no session starts and the dispatcher logs an ERROR line that names it; the next poll tries again. A session files one issue, so for a larger request the planner files the first part and lists the rest under "Later parts". Apply tehas:refine again to the original issue to plan the next part. The label is checked like tehas:plan: only an allowed account's counts. An issue with both labels is planned, not refined. The filed part is never started on its own: read it and apply tehas:ready. Run tehas labels once after an update that brings this label.

When a refine files, the session is over: pi-rukas files once per session. The filed issue gets Replaces #<n> as its first line and is linked as a sub-issue of the original. If the plan lists no later parts, the original gets tehas:replaced and is closed as not planned. If it does list them, or its body cannot be read, the original stays open with tehas:refined: apply tehas:refine to it for the next part, and close it when nothing is left. Either way the original then gets a comment Replaced by #<m> with the planner's words. A sub-issue link that cannot be made is a warning in the log; the first line of the filed issue says the same, and a poll that cannot write that line tries again on the next. A tehas:plan session that files is posted as before.

Refined on its own

A cycle that parks at explore as intent-park with the reason underspecified or too-large is not yet one cycle's work. The next poll refines it once without a label, on the strength of the tehas:ready (or the retry) that started the cycle, and says so in the session's first comment. It does not wait for a free cycle slot. A box of the park ticked first wins, even one the factory holds for a free slot. It does not refine when:

Then the issue stays parked for a person, as before, and the log says why. A park is refined at most once: the state store spends it when the session starts, or when the poll finds it cannot. An automatic session that reaches its turn limit, or that pi-rukas lost, ends with needs-human-attention, so the issue reads as parked again. One you end yourself ends as any other. Its lines in tehas history carry auto.

Pause and resume

Two switches stop the factory. Either one is enough.

tehas pause [--reason TEXT] sets the switch on this host: a flag, ~/tehas/state/pause.json, holding who set it, when and why, in a file only the account that ran the command can read. It asks GitHub nothing, so a host can be paused when GitHub cannot be reached. tehas pause again succeeds and keeps the first flag. tehas resume removes it, and the name the flag is written through with it, and says so when the factory stays paused for the other switch.

tehas:pause on the control issue, the one TEHAS_CONTROL_ISSUE names (in the example, issue 1), is the switch that works from away from the host. It works one way. Anyone who may label the repository may apply it, because stopping is the safe direction. Only an account in TEHAS_ALLOWED_LABELERS lifts it: when the label is gone and the tehas:pause event with the latest stamp on the control issue is a removal by anyone else, names nobody, or is an application no event took back, the poll starts nothing and says what it found. Deleting or renaming the label itself is the last of those: no account was asked to lift the pause, so it holds. To resume from away, an allowed account applies tehas:pause and takes it off again. A poll that cannot read the control issue's label events starts nothing.

While either switch is set the poll starts nothing: no cycle, no planning turn, no answer to a planning question, no retry by a tick. A cycle already running finishes, and the poll still gives up work that is finished: it stops a cycle whose issue is closed or whose pull request is merged or closed, stops one nobody has heard from, and clears an issue marked tehas:running with no cycle behind it. A paused factory therefore keeps no slot and no model time for work it has already done. tehas status prints a line for each switch that is set, with when the flag was written and why; the dashboard and the front page say the factory is paused and, while a cycle is still running, that it is finishing that issue.

The reason is written to the flag and shown on pages that may be public, so write nothing in it that should not be read in public. The account that set the flag is not published.

All hands

tehas:all-hands on the control issue asks for all hands on this project. It counts while it is on the issue and the account that applied it last is in TEHAS_ALLOWED_LABELERS. A label anyone else applies is ignored and said once in the dispatcher's log. On its own it changes nothing in this factory: no cycle starts or waits because of it. tehas status prints an all-hands line, its JSON says "allHands": true and the dashboard shows "all hands". What it means for other factories is up to the program that runs them, such as an industry of factories. Take the label off to end it.

Read-only

With TEHAS_READ_ONLY=on in instance.env the instance reads its product's issues and code and runs cycles as usual, but writes nothing to GitHub: no label, comment, reaction, issue edit, pushed branch or pull request. It is meant for a factory on a developer's laptop that points at a repository a shared factory also serves. Off unless the instance turns it on; an instance that does not set it is unchanged.

One guard decides every write. On the host each gh goes through the shim in ~/tehas/shim, which env.sh puts first on PATH for a read-only instance whether or not it names a GitHub App, and its console runs no call that writes. It prints read-only: would gh issue edit acme/widget#7 instead, exits 0 so the command goes on as if the write was made, and keeps the line in state/read-only.log. A read goes to GitHub as before. A shim with no console to ask runs nothing at all. tehas-cycle finish and tehas init-product say what they would have pushed and push nothing. The line in state/github-writes.log is only for a write that reached GitHub, so none is written.

A cycle's container is told so too (TEHAS_READ_ONLY=1 in its environment). Its git pushes to origin land in the workspace's own repository, so the push check before a cycle and the cycle's own pushes succeed and the branch stays in ~/tehas/work/<name>-<issue>; a push that names a URL of github.com fails. The image's gh refuses every call that may write, by the same rule: what reads is a short list (issue view, pr list, api with no method and no field, a graphql query that names no mutation, and a few more), and anything else is a write. A gh pr create it refuses leaves the title, the branch and the body in .git/tehas-read-only-pr.md of the workspace. The image's gh has this only from the release that brought the setting: rebuild the image with install.sh before you turn it on. The token the container is given writes nothing either: its Contents, Pull requests and Issues are read, so a request that passes neither guard, a curl to the API or a push to a URL with a user name in it, is refused by GitHub. A token kept from before the instance turned read-only is not handed on: the next ask makes a new one. tehas update makes the cycle token and asks it for no push, and says Cycle token: OK (read-only: ...).

The labels that hold the queue are never written, so tehas:ready stays on an issue after its cycle starts. The dispatcher keeps each start that worked in state/read-only/<issue>.json instead, and starts nothing more on an issue that has one, a cycle or a planning session: a dry run says skip #7: read-only, and this host started it before. Remove the file to start the issue again.

tehas status --json says "readOnly": true, so a program that starts the factory can confirm it first. The dashboard shows "read-only" and a list of read-only results: each start, its branch and workspace, and the pull request it would have opened.

Limit and drain

A limit caps what this factory starts, until it expires or is cleared. It keeps a host quiet for a weekend, or leaves the models to another project:

tehas limit set --cycles 1 --plan off --for 7200 --reason "the models are busy"
tehas limit                  # what is set
tehas limit clear            # back to no limit

--cycles is the most cycles at once; --plan off also holds new planning sessions, though an answer to a planning question still runs. Without --for or --until the limit stays until cleared. Running cycles are never stopped. A limit that has expired, or a file that cannot be read, holds every start until it is set again or cleared, and tehas status says so. Pause is a separate switch: a paused factory stays paused under any limit.

Before a reboot or a disk change:

tehas drain --wait 3600      # start nothing new, wait up to an hour for the cycles
tehas limit clear            # afterwards

Drained means no poll can still start a cycle: drain waits for the poll that is running before it says no cycle is, so a cycle a poll had already decided to start is counted rather than left behind.

Most of the time you do not need it. The machine's CPUs and memory change while it runs, and a hypervisor restart saves the virtual machine with its cycles in it, so what runs goes on where it stopped: Resize or restart the host is that, and it names the four changes that still need a drain. That is a VM host: a factory that is a container on another project's machine has no hypervisor to save it, so a restart of the machine under it is always a drain.

A program that drives factories uses the same commands: see the factory API.

Panels on the dashboard

A panel puts a page of the project on the dashboard: a support chat, a status page, a feedback form, a manual kept elsewhere. It is an item in the menu of both front pages; pressing it opens the page in a dock at the side, full screen on a phone, with a link to open it in a new tab.

tehas panel set support --label "Ask us" --url https://support.example.org/f/acme
tehas panel                  # what is set
tehas panel clear support    # take it away

Up to four. The URL is public, as everything the dashboard reads is, so it holds no secret. It may not be on the factory's own domain, TEHAS_DOMAIN, because the frame would then share the dashboard's origin; a name under it, such as support.<domain>, is fine. The dashboard asks the page for nothing until a person presses the item, and passes it nothing but the URL. A page that refuses to be framed shows an empty dock; its new-tab link still works.

A program sets panels with the same command: see the factory API.

Reading what ended

The records of a finished cycle stay on the host. Two commands read them; both take a cursor, so a program that keeps what it was last given reads each line once.

tehas history                    # what ended, oldest first
tehas history --json --after 1760700000-12-41

One line for each cycle and each planning turn, kind telling them apart: when it ran, how it ended, where it stopped, who asked for it. The same lines in JSON with --json. It reads only what the units wrote, takes no lock a running cycle holds, and writes nothing, so it is safe to run while the factory works.

tehas export --after 1760700000-12-41 ~/archive

Copies the result, the logs, the agents' transcripts and the Protolab page of every cycle since that cursor into ~/archive, one directory each. Every text file goes through the console's mask, so a token or a private address that reached a log does not reach the copy. An export is never written under ~/tehas, not even through a link, and the mask catches accidents rather than everything: an export is still a copy of what a cycle wrote, so where it goes is still a decision.

The last 365 days

The factory records every run it makes, with the tehas and pi-rukas versions it ran, and keeps 365 days of them. Two commands read them:

tehas analytics report                    # the ten-day report in the terminal
tehas analytics copy --to copy.db --json  # a copy of the database, to fetch

The report is the one on the plain dashboard. The copy is for deeper analysis elsewhere; it holds no token, host or address. What is in it, column by column, is on Analytics. TEHAS_ANALYTICS=off stops the recording, and both commands then say so and exit 78.

Limits that hold work back

The review cap, the new pi-rukas, the room, the pressure, a red branch and a sandbox that cannot push hold back cycles only. Planning turns still run. tehas status shows the room in its slice line, as the dispatcher's last poll read it, and tehas dispatch --dry-run reads it afresh. A hold is written to ~/tehas/logs/dispatch.log once, when its reason changes, and released: cycles may start again once when it ends.

The gate's bound and the cycles at once

TEHAS_VERIFY_TIMEOUT bounds one run of the product's gate, the whole gate on the combined tree included (pi-rukas's PI_ENSEMBLE_VERIFY_SUITE_TIMEOUT_MS, which tehas sets from it). How long a run takes depends on how many cycles share the host. Each container's quota is the host's CPUs less one, but busy gates share those CPUs about equally: with TEHAS_MAX_CYCLES cycles running their gates at once, each gets about the host's CPUs less one over that count. Three numbers have to agree:

A bound below the gate's time under load parks cycles with verify-timeout:<step> for code that was never judged. On 26 Oct 2026 three cycles shared a quota of 15 CPUs with a bound of 30 minutes: the load average was about 21, the whole gate ran 26 and 47 minutes, neither run gave a verdict on the code, and each of the two cycles spent more than 2 hours to park.

The host records each run of the gate in ~/tehas/state/analytics.db (see Analytics). The longest runs, by the number of other cycles running when the cycle started:

sqlite3 ~/tehas/state/analytics.db "SELECT r.concurrent, g.tier, count(*), max(g.ms) / 60000 AS max_minutes FROM run_gate_runs g JOIN runs r ON r.id = g.run_id GROUP BY 1, 2"

When max_minutes at the cycles you run is near the bound or above it, do one of two things, and write the number in instance.env with the measurement beside it:

What this repository's own gate takes is measured on The host.

A step can take more than one bound today. The pi-rukas the factory pins was seen to start the whole gate on the combined tree after the fast gate had already been stopped at the bound, so one step spent two bounds, and its gate-hang report said hung in no named test while it listed the processes still alive. Both are for pi-rukas to change: on a bound kill, go to the handoff with what it has, and name the test file still running. Until then, size TEHAS_WORK_TIMEOUT for two bounds a step.

Kinds as issue types

Optional. Two labels say what an issue is rather than where it is: tehas:improvement, a proposal the factory filed, and tehas:prototype, a ticket at the prototype stage. An organisation can use its own issue types for them instead. Without the setting, the labels work as described above.

To set it up:

  1. As an owner of the organisation, add the issue types in its settings, under Planning, Issue types: for example Improvement and Prototype. tehas never creates them.

  2. Map each kind to its type in instance.env, one kind=Type pair for each, separated by a space. A kind left out stays its label:

    TEHAS_ISSUE_TYPES="improvement=Improvement prototype=Prototype"
    
  3. Run install.sh, or wait for the next poll: the setting is read at each run.

What changes:

A type the organisation does not have fails closed: the poll or the Protolab pass that reads the setting stops with 78 before it writes anything, and the log names the type and the repository. A repository of a personal account has no issue types, so the setting is not for it. To go back to the labels, remove the setting; issues keep their types, and a person relabels the ones that should still carry the label.

The review loop

Still being built in this release, and never seen working on a host. A release refuses TEHAS_REVIEW=on and a TEHAS_REVIEW_REPO line with exit 78 and names review; install.sh does not install tehas-review.service or tehas-review.timer, and tehasbot review exits 0 at once. A host that set either line under an earlier release takes it out before it updates. What the feature leaves visible meanwhile is in the contract. The rest of this section says what it is meant to do once a release ships it.

Once a week, on Monday morning, a model reads what the default branch gained since the commit the last review read and reports what it would change. It is the same six lens reviewers a cycle's own review runs, in one headless turn over a clone made for the run, with no token: the run writes nothing to the tracker but its findings.

Once shipped, the two lines TEHAS_REVIEW=on and TEHAS_REVIEW_REPO turn it on. install.sh then installs the units; a first install enables the timer, and on a host installed before, a person does with systemctl --user enable --now tehas-review.timer. ~/tehas/logs/review-timer.log says what the runs did and ~/tehas/logs/review-<time>.json holds one run's document. See tehasbot review for the container, the record and the exits.

A host that has tehas-review.timer from an earlier release keeps the unit files, for the release that ships the feature. While review is off, install.sh and tehas update stop and disable the timer if it is enabled, and say so on a systemd: line; --check names it as drift.

The cleaner

A full disk stops previews and fails clones, and most of what fills it is something the next build makes again. tehasbot clean, from tehas-clean.timer once an hour (the first time 15 minutes after boot), removes what has not been used for TEHAS_CLEAN_AFTER hours, 24 by default:

One line per removal and a closing line with the bytes freed go to ~/tehas/logs/clean.log, and the same lines are printed, so a run by hand shows them in the terminal. When the age rule passes, an issue is left alone for one of two reasons, and the line says which: kept the build output of #<issue>: no lock to hold, so nothing of it was removed when something was there to remove and no lock was there to hold it, and nothing to remove in #<issue> when none of its trees held build output at all. Two other lines each name a reason of their own, one before the age is asked and one because it could not be answered: kept the build output of #<issue>: its lock is held, for an issue a cycle is running, and kept the build output of #<issue>: git could not name the gitdir of one of its worktrees, for a worktree whose record git no longer answers for - a stale worktree, a moved clone, or a .git file that names nothing. The second is why a worktree record that went stale keeps an issue's build output on the disk: the cleaner takes what it dated, and a tree it could not date is not taken. Commands carries the wording of all four. A timer run prints to the journal: what it refuses to do before it can open the log - settings it will not accept, another run holding its lock, a state directory it could not make - is in journalctl --user -u tehas-clean and in no log file. The command starts no work, so the pause label does not hold it. A step that fails is logged as a warning, the other steps still run, and the exit status is non-zero.

To turn it on, enable the timer, which install.sh and tehas update install but do not start:

systemctl --user enable --now tehas-clean.timer
tail ~/tehas/logs/clean.log
journalctl --user -u tehas-clean

Run it once by hand with tehasbot clean, or with tehasbot clean --dry-run to see what it would remove. To turn it off, systemctl --user disable --now tehas-clean.timer; a toolchain the cleaner does not know about is added to TEHAS_CLEAN_DIRS in instance.env rather than left unmanaged.

The poll's sweep also removes the lock file of an issue nothing has used for 30 days, three a poll: one no cycle holds, whose last cycle on record ended 30 days ago, or that has no cycle on record and is that old.

Backups and restore

A plain copy of ~/tehas/state/tehas.db is not a backup: the store runs in WAL mode, and the newest rows can be in tehas.db-wal. The cleaner makes a consistent copy once a day with store backup, as ~/tehas/state/backup/tehas-<YYYYMMDD>.db (mode 0600), and keeps the newest seven. tehasbot health warns (checks.backup) when there is none or the newest is more than two days old, and says when the last upkeep failed and the store's word for why (checks.upkeep). The copies install.sh makes before a migration, tehas-<schema>-<time>.db, are kept beside them and never removed.

To restore a copy:

tehas drain --wait 3600         # start nothing, wait for the running cycles
systemctl --user stop 'tehas-*.timer' 'tehas-*.path' tehas-energy.service tehas-mcp.service
systemctl --user list-units 'tehas-*' --state=active   # wait until no service is listed
cd ~/tehas/state
mv tehas.db tehas.db.broken; rm -f tehas.db-wal tehas.db-shm
cp backup/tehas-<YYYYMMDD>.db tehas.db && chmod 600 tehas.db
tehas state check
systemctl --user start tehas-energy.service tehas-mcp.service
systemctl --user start $(systemctl --user list-unit-files 'tehas-*.timer' 'tehas-*.path' --state=enabled --no-legend | cut -d' ' -f1)
tehas limit clear

Every unit that reads or writes the store is stopped first: one left running keeps the old file open and goes on writing to it. tehas state check must say integrity ok. The next poll reconciles the labels on GitHub against what the copy holds; a cycle that ran after the copy was made is not in it.

The millwright's grant

Optional. The millwright is an account that decides on parked issues from outside the factory: start one again, start it again working differently, or leave it to a person. It may also answer some planning questions. What runs as that account is not part of tehas. The factory says what the account may do, and this section is that.

The millwright was called the fixer. Its old names are no longer read: a TEHAS_FIXER_* setting stops every command with 78 and names the new one, and the label tehas:fixer-escalated and the marker <!-- tehas:fixer issue=<n> action=... --> count for nothing. The state store's schema 16 writes millwright in every row that still said fixer (a start, a line of history, an approval, a refused note), so tehas history and tehas export name the millwright one way, and the MCP session tools answer millwright for a run recorded under the old word. The plan.json of tehas export lists an answer's mark as millwright alone. tehas api lists only the new names: millwright-grant and millwright.

Refreshes

A pull request the factory opened waits in tehas:awaiting-merge for a person. While it waits, other work merges, and it may start to conflict with the branch. A refresh is a cycle that merges the branch into that pull request, resolves the conflicts and pushes to the same branch: the same pull request, its review kept. Never a rebase, a force-push or a second pull request. It needs a sandbox image whose pi-rukas takes --continue-pr and says so with features.continuePr in its --capabilities (pi-rukas#1468, in v0.14.0); until then a refresh starts nothing and the dispatcher says so.

Who asks. The factory does not look for conflicts on its own. What schedules its refreshes (an industry, an operator, a script) asks for one pull request at a time with tehas refresh --pr N (see tehas refresh). It reads that pull request now and keeps it when it is the bot's, closes exactly one open issue carrying tehas:awaiting-merge, or needs-human-attention after a handoff that left the pull request open, without tehas:running and not the control issue, is the only open pull request that closes it, and comes from a branch of the repository. A draft is read as any other pull request. When GitHub says it is CONFLICTING or UNKNOWN it writes a request, ~/tehas/state/refresh/<issue>.json, with "asked": "pr"; otherwise it exits 3 and says why. Each run writes one line to ~/tehas/logs/refresh.log:

2026-10-18T09:00:00Z asked for pull request #50: wrote the request of #7

The dispatcher starts every request it finds as below and counts it in the demand of tehas status, whoever wrote it. A request left by the timed scan of an earlier version, without "asked", is checked the same way: it starts when its pull request still qualifies and goes when it does not.

When it starts. The dispatcher checks each request again at the start, and starts it on the word of the person whose approval the pull request's cycle rests on (the by of the approval of the issue's last start, or the person's approval it rests on after the millwright):

A request that fails a check goes, and the dispatcher's log says why. At the cap or after a parked refresh the bot says so on the issue, once: a person resolves the conflict, or closes the pull request and then applies tehas:ready. While the pull request is open, tehas:ready starts nothing: it is taken off, as for any issue whose open pull request closes it. A pull request that carries tehas:refreshing waits.

The refresh lane. Refreshes run in a lane of their own, so a conflicting pull request is refreshed while every cycle slot is busy. At most TEHAS_REFRESH_SLOTS refreshes run at once (1 unless the instance says otherwise), and they do not count against TEHAS_MAX_CYCLES. The slice holds TEHAS_SLICE_CONTAINERS containers whatever the slots say, so new cycles leave room in it for the lane: while the lane has a slot free, a cycle does not take the last room of the slice. On a host with TEHAS_MAX_CYCLES=4 and one lane slot that is three cycles and one refresh. The poll says holding: tehas.slice has room for 1 more and the refresh lane keeps 1, or holding: 3 of 4 free slots start: ... the refresh lane keeps 1. With every cycle slot busy the hold line ends the refresh lane has 1 of 1 free, and a request that finds the lane full waits: wait #<issue>: the refresh lane is full (1 of 1). tehas status shows the lane's free slots on the slice line. TEHAS_REFRESH_SLOTS=0 turns the lane off: refreshes then take the cycles' slots, and no room is kept. Otherwise the room is kept only while a request waits or a refresh runs; the rest of the time the cycles have every slot. On an image that cannot refresh a waiting request still keeps the room: ask for no refreshes on such a host. Each container's CPU share and pids limit count the lane's slots beside the cycles, so they are the same whether a refresh runs or not.

Pause, the limit, the slots of the lane and the slice's room hold a refresh as they hold any start; the limit of tehas limit counts refreshes and cycles together. TEHAS_MAX_AWAITING does not: the pull request is open already, and the start takes tehas:awaiting-merge off. A refresh goes after the ready issues of the start order and before the other ready issues. A refresh that waits for room counts in the demand of tehas status.

After a handoff. The refresh takes a handed-off pull request, draft or not: a handoff leaves needs-human-attention and tehas:question on the issue, and neither keeps the refresh away. The refresh of a handed-off issue is a restart, as a person's tehas:ready would be: the cycle takes needs-human-attention off as it starts, the refresh's start takes tehas:question off, and how the refresh ends labels the issue, tehas:awaiting-merge or a new handoff. The handoff comment stays on the issue, and the pull request keeps the draft state it had.

While it runs the pull request carries tehas:refreshing: do not merge or push to it. The dispatcher applies it before it marks the issue, and a start whose label change fails starts nothing. tehasbot cycle takes it off when the cycle ends, whatever the outcome. The dispatcher takes it off a pull request whose issue has no cycle running, and one applied by any account but the bot. It looks for such marks while a refresh of this host is on record, runs or waits as a request; a host that never refreshed reads no list of them. Both directions go through GitHub's REST issues endpoint, not gh pr edit, which asks GitHub a GraphQL question the bot's token may not answer (see issue #120); a 404 is read as a label that is not there, so a mark already gone needs no retry.

The record and the cycle. The approval record has how: "refresh", the person's by and at, rests_on, refreshes (the count since that approval), refresh_of (pr, head_sha, base_sha, branch) and one retry_context entry, source refresh, that tehas writes itself:

This pull request conflicts with main. Merge main into its branch, resolve the conflicts so the change still does what the issue asks, run the gate in .pi/verify-cmd, and push to the same branch. Do no other work.

No comment text reaches the cycle this way. As with the millwright's note, it reaches the cycle in comments.json, source refresh. tehas work passes --continue-pr for a refresh, and refuses a refresh with 78 on an image that does not take it. Nothing else about the container changes. The outcome is read as any cycle's: a refresh that pushed goes back to tehas:awaiting-merge with the same pull request, one that parks parks the issue, and no refresh of it starts again on its own.

A refresh that conflicts. pi-rukas up to v0.14.58 cannot finish a refresh that has a conflict to resolve. Its develop step verifies a tree it builds by putting the worktree's commits back onto the branch's tip, and for a continued pull request those are the pull request's own commits and the merge: they conflict there as the merge did, however the conflict was resolved, and the cycle stops on consolidated-verify-conflict. On tehas-tehas from 2026-10-24 to 2026-11-07, 13 of 16 refreshes stopped on that cap and none of the other three pushed. So on an image whose --capabilities does not set features.continuePrMergeVerify, tehas work first asks git, in the fresh workspace and before the push check, whether the pull request's head at the request merges with origin/main (git merge-tree). When it conflicts, no container starts: the files go to state/cycles/<issue>.refresh-conflict, the command exits 78, and tehasbot cycle parks the issue as a stopped refresh, reason refresh-conflict, with the files named:

Tehas ran no refresh: pull request #1453 conflicts with main in console/dispatch/src/text.rs. ...

The park counts as a parked refresh, so none starts again on its own. A person merges main into the branch and resolves the conflict there. A merge that is clean runs the refresh as before, and so does one made by a git that has no such read of its own - it says the usage of merge-tree, or that the command is not there - with what git said in the cycle log.

A read that judged nothing starts no container. It is the run this check exists to prevent, and no note is written for a conflict nobody saw. tehas work exits 78 and says in the cycle log which part of the answer was missing: the read ran out of time, git could not be started, the request's record holds no pull request, the head of the record is no commit, git wrote no tree object and named the side it could not merge, or git wrote a tree object and answered a status that is no answer. The same fault sits on the preflight log of the cycle: a name that cannot be opened for the push check or for the product's install ends the start with 78 and says the name and what the system answered, and is not told as a sandbox that refused to push.

What it does not do. Failing checks and requested changes, pull requests the bot did not open, from forks or closing several issues, and conflicts between two open pull requests of the factory: each is resolved against the branch when the other merges.

No timed scan. Earlier versions also ran tehasbot refresh on tehas-refresh.timer and looked for conflicts every TEHAS_REFRESH_EVERY minutes when TEHAS_REFRESH_CONFLICTS=1. That scan is gone: install.sh stops and disables the timer and removes its two unit files. Neither name is a setting any more. A line with a value they took (0 or 1, and 1 to 1440 minutes) still loads and does nothing, so take it out when you can; any other value stops every command with 78. Both are rows of api/renames-1.0.tsv, so tehas update --check lists such a line.

Updating tehas

An update is a person's choice: nothing updates tehas on its own. Run tehas update --check to see the version installed, the newest release and the Adopter action of each release between, do what they ask, then run tehas update. tehas update --to <version> goes back (see Rolling back tehas). An update does not wait for the running cycles and needs no drain: each cycle and planning turn runs from its own copy of the code, so it ends on the version it began on, and the next one starts on the new version (see Updating tehas). The one exception is the update from 0.30.x to 1.0: see Updating from 0.30.x to 1.0. This release updates a host on v0.30.0 or later: 0.30.x, 0.31.x or 0.32.x. A host on an older release updates to a v0.30 release first: the store refuses an older database, and the record files a tehas before the state store kept are no longer imported. While such a file is still in state/, every poll stops with exit 78 and logs ERROR: records of an older tehas at <path>; this release does not import them: move it out of state/. A v0.30 release cannot import it either once this release has migrated the store, as it refuses the newer schema. How it works is in Updating tehas. A host installed from a checkout keeps pulling it until it is moved: see Move a checkout host to releases.

Updating from 0.30.x to 1.0

1.0 renames and removes settings, labels, command forms and fields of the --json objects, changes exit statuses, and migrates the state store. Every renamed or removed public name is one row of api/renames-1.0.tsv in the release. tehas does not edit instance.env: it is a checkout of your settings. 1.0 updates a host on 0.30.x, 0.31.x or 0.32.x. A host on 0.31.x or 0.32.x already refuses every setting below, so its instance needs no rename. A 0.30.x host can name only a release candidate or the release with --to, not an alpha or a beta; From v0.30.x, v0.31.x or v0.32.x has the rest and a known limit for a factory a program manages. The steps:

  1. Be on 0.30 or later. 1.0 migrates a store that v0.30.0 or later wrote. A host on an older release runs tehas update --to v0.30.6 first; 1.0 refuses an older store with exit 78 and installs nothing.
  2. Edit the settings. Change instance.env and ~/.config/tehas/env from the tables below, or from the 1.0 Adopter action that tehas update --check prints. On 0.30.x, --check is 0.30's own check: it prints the release notes and the version it would switch to, and lists no setting.
  3. Drain. Run tehas drain --wait 3600 and wait for it to say no cycle runs. On 0.30.x it exits 1 when cycles still run at the end of the wait (3 from 1.0 on): wait, and run it again. This update changes the store's schema and the settings a running cycle reads, so it is the one update that asks for a drain.
  4. Update. Run tehas update. It asks 1.0's settings check before it switches ~/tehas/current. While a line is left to fix, it stops with 78, names every such line at once and switches nothing: fix them and run it again.
  5. Labels. Run tehas labels: it makes and pins tehas:classic and gives tehas:improvement its new description.
  6. Start. Run tehas limit clear.

Settings renamed. Same values, new names, in instance.env:

Was Is
TEHAS_INDEXING TEHAS_SITE_INDEXING
TEHAS_ANALYTICS_SRC TEHAS_SITE_ANALYTICS_SRC
TEHAS_ANALYTICS_SITE TEHAS_SITE_ANALYTICS_NAME
TEHAS_ANALYTICS_COOKIE TEHAS_SITE_ANALYTICS_COOKIE
TEHAS_CONCURRENCY TEHAS_WORKSTREAMS
TEHAS_TICKET_CONCURRENCY TEHAS_MAX_CYCLES
TEHAS_REFRESH_MAX TEHAS_REFRESH_MAX_PER_PR
TEHAS_OWNER TEHAS_ASSIGNEE

In ~/.config/tehas/env, the program that manages the factory writes TEHAS_MANAGER_VERSION in place of TEHAS_INDUSTRY_VERSION. The old name is ignored, not refused.

Settings removed. Take these lines out of instance.env. Set to a value, most stop every command with 78; the exceptions are noted:

Settings that changed.

Labels.

Command forms. Change scripts and notes that call the old forms:

Was Is
tehas setup --labellers "a b" tehas setup --labelers "a b"
tehas setup --token-file, --app-installation Gone. Unknown options, exit 64
tehas analytics export <file> tehas analytics copy --to <file>
tehas pause <reason> tehas pause --reason "<reason>"
tehasbot refresh --pr N tehas refresh --pr N. The old form stays through 1.x
tehasbot github-token --check tehas github check
tehasbot github-writes tehas github writes

Fields. A program that reads tehas's --json objects or the MCP tools reads the new names. Each one is a row of kind field, value or word of api/renames-1.0.tsv:

Exit statuses. Every public command now uses one scheme, with the exceptions the contract names: 0 done, 1 failed, 3 the command worked and the answer is no or not yet, 64 a bad argument, 78 settings missing or malformed or a feature that is off, 141 standard output closed. A script that reads the old numbers reads:

The contract has every command's statuses.

The Protolab. Files linked by a member or collaborator who is not in TEHAS_ALLOWED_LABELERS leave the Protolab at the first pass after the update. Add the person to the list, or have an allowed account link the files.

The speed lane

The speed lane is a self-hosted GitHub Actions runner with the label speedlane and not tehas, on a machine that runs nothing else, one job at a time. An ordinary verify job asks for [self-hosted, tehas] and never takes it, so a release gate or an urgent batch does not wait behind them or share the machine's cores.

Two things run there:

How a release is gated and tagged

scripts/tag-release.sh gates the head of the default branch before it tags it. It looks for a green release-gate run whose title names that exact commit; a run on another commit does not count. With one, it runs no gate of its own. With none, or only red ones, it starts one (gh workflow run release-gate.yml --ref main -f commit=<sha>) and waits for it; a run already going is waited for. It looks every TEHAS_GATE_POLL seconds (30) for up to --gate-wait minutes (90). A run it waited for that fails, or no green run in time, tags nothing and exits 1. tag-release still pushes the tag itself, so release.yml starts as before.

--local-gate runs scripts/verify.sh on the laptop instead, as before the lane: use it when no speedlane runner is online. --no-verify runs no gate at all. The gate before a pull request tag-release opens (polyfills, changelog fragments, pins) still runs where tag-release runs.

Registering a speedlane runner

On the lane's machine, as an account that is not a tehas host's account (the image build moves that account's tehas/pi-rukas tags), with the tools verify.yml's runner has (cargo at the RUST_VERSION of host/versions.env, bash, git, curl) and Docker:

  1. In the organization's settings, Actions, Runners, New self-hosted runner, take the registration token.
  2. Run the runner's ./config.sh --url https://github.com/<org> --token <token> --labels speedlane. The runner carries self-hosted, its OS and architecture, and speedlane, and not tehas.
  3. Run one runner on the machine, so it takes one job at a time, and start it as a service (./svc.sh install && ./svc.sh start).

The lane keeps its cargo build in ~/.cache/tehas-target/<runner name> and its pi-rukas clone in ~/.cache/tehas-speedlane/repos/pi-rukas between runs.

Registering a kani runner

The release gate's proofs jobs ask for [self-hosted, kani]. Up to three runners are used at once, so register one on each of up to three machines. Give each a machine with 8 or more cores, 16 GB or more free for the job, and network access to GitHub and the Rust toolchain servers, and an account of its own that holds nothing else: no tehas settings, no SSH keys, no gh login. The job runs the gated commit's code as that account.

  1. Make the account and give it rustup and cargo at the RUST_VERSION of host/versions.env.
  2. Take a registration token: the organization's or the repository's settings, Actions, Runners, New self-hosted runner, or gh api -X POST repos/<org>/<repo>/actions/runners/registration-token.
  3. As the account, unpack the runner and run ./config.sh --url https://github.com/<org>/<repo> --token <token> --labels kani. It carries self-hosted and kani, and not tehas or speedlane, so no other job takes it. Write the account's cargo directory first in the runner's .path file, since a service does not read a login shell.
  4. Run one runner on the machine and start it as a service (sudo ./svc.sh install <account> && sudo ./svc.sh start).

The first run installs Kani at the job's KANI_VERSION into the account's ~/.cargo/bin and ~/.kani, from a bundle checked against KANI_BUNDLE_SHA256; later runs reuse it until the pin moves.

Run one issue by hand

Skips the queue, the labels and the comments:

tehas work 123            # exit 0 merged; 10, 11, 20, 21, 30 or 40 are the runner's own:
                          # handoff, handoff for clarification, aborted, interrupted,
                          # a crash or its time limit, refused to start. 2 means this
                          # command stopped it as stalled or at the limit, or the runner
                          # ended without a result
                          # (see tehas work: console/cycle/src/work.rs)
tehas work 123 --restart

It does not take the dispatcher's lock, so a poll can start a queue cycle while yours runs. Apply tehas:pause first, or check that nothing is ready. It does take the issue's own lock: for an issue whose cycle is running it refuses with exit 5 and touches nothing, and while yours runs the dispatcher starts no cycle for that issue.

Watching a running cycle

A cycle cannot be attached to or made interactive. It is pi-rukas run headless: its one-shot runner, pi-rukas-headless work <issue>, with no terminal and no Pi session of its own: it starts a Pi process for each agent. There is no prompt to type at and nothing waits for an answer.

What you can do is watch it, on the factory floor or on the host:

tail -f ~/tehas/live/console-123.txt     # the console the dashboard shows
tehas top                                # the same console, with the queue and the cycles
tail -f ~/tehas/logs/work-123-*.jsonl    # the runner's NDJSON progress
docker exec -it tehas-work-123 bash      # a shell in the cycle's container

The shell is beside the session, not in it, and it is in the workspace the agents are working in: what you change there changes the cycle. Do not use docker attach. It shows the runner's output, not a Pi interface, and an interrupt typed there reaches the runner and ends the cycle as interrupted.

To steer a cycle, let it park or stop it, make the issue clearer and apply tehas:ready again. To work with pi-rukas interactively, start a session of your own, as below.

Work by hand on the host

The host that runs the factory is also a place to work yourself. Log in with your own account and start a session:

ssh alice@tehas-tehas
tehas dev              # a session in your clone, under your name
tehas dev -- -r        # resume an earlier session

That is an interactive Pi with pi-rukas, in the sandbox, on the factory's models. There is nothing to configure in your account: the image, the models, the limits and the bot's token are the factory's own, and your name comes from your own git configuration. An administrator lets an account in once, with sudo ./bootstrap.sh dev; see Bootstrap a host.

One session per clone at a time. What the session's container is given is on The host.

Logged in as the tehas user itself, the same command takes a name for the clone and an author, because that account is shared and has no name of its own to offer:

tehas dev alice --author "Alice Example <[email protected]>"   # the first time
tehas dev alice                                                # from then on

Without an author the commits carry the bot's name, and the command says so when it starts.