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:
- images (png, jpg, gif, webp, svg, avif) and videos (mp4, webm, mov), shown as they are,
- HTML files, shown in a frame with a link to open them full size,
- the style sheets, scripts and data an HTML file refers to (css, js, mjs,
json, txt). Attach them to the same ticket and refer to them by name, as
<script src="app.js">, - a zip, unpacked into a folder of its own; its files count against the same
limits. It takes the types above and md files, kept in their folders, so
index.htmlin a zip can refer todata/sample.jsonin it. Links, paths that leave the zip, paths more than six levels deep and locked files are left out. At most 200 entries of a zip are read, and once a file of it is over the 10 MB, nothing more of it is unpacked.
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:
- 10 megabytes a ticket, counted in the order the files were attached, and at most 40 files. What does not fit is left out, and the page lists it under "left out" with the reason.
- Static files only. Nothing is run on the host for a prototype.
- Only a label from an allowed account puts the ticket here, as said
above: the most recent
tehas:prototypelabelling is by an account inTEHAS_ALLOWED_LABELERS. - Only files linked by an allowed account are taken: in text an account
in
TEHAS_ALLOWED_LABELERSwrote and nobody off the list edited last, and not on a quoted line. Links by anyone else, the bot included, are counted on the page and not fetched. - An HTML prototype runs in the browser's sandbox, apart from the dashboard
and from every other prototype. Scripts work; storage in the browser
(
localStorage, cookies) does not.
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:
- the issue body has a good description, written as in step 1 below,
- reference material is attached where it helps: images, or a zip of a prototype built elsewhere,
- no line of it says a file goes there. A body left with
SCREENSHOT GOES HERE, orIMAGE_GOES_HERE, where the picture should be, is a handover that stopped short: the dispatcher holds such an issue and says so in one line oflogs/dispatch.lograther than spend a cycle on something no container was given. Attach the file, or write out what it shows, and then label. - someone applies
tehas:ready, as in step 2.
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:
- A cycle is given the issue's title and body. With
TEHAS_WORK_IMAGES=ontehas work also fetches the images the body links, at most 8 and 10 MB, and mounts them read-only in the cycle's container with a manifest. They are taken when an allowed account labelled the issue, whoever opened it, or when an owner, member or collaborator opened it. The dispatcher records at the start what the label approved, andtehas workfetches only those links. Whether the explore and plan steps are shown the images is what the sandbox image's own labeltehas.rukas.imagesanswers. Upstream pi-rukas merged the reader on 2026-10-14, and the host follows its main, so an image built since then says yes. One that says no holds every issue whose text links an attachment while the setting stands; the other issues start. The steps after plan read the plan, not the pictures. WithTEHAS_WORK_DESCRIBE=onthe model also describes each image in words, intoimages.mdbeside them, and names the issue inX-Tehas-Issueon each of those requests; withTEHAS_WORK_FILES=onthe text files come too. pi-rukas reads neither yet.TEHAS_WORK_COMMENTS=onadds the attachments of comments, by the rule in the table. - A zip reaches a cycle with
TEHAS_WORK_ZIPS=on, and needsTEHAS_WORK_IMAGES=onorTEHAS_WORK_FILES=on: what comes out of an archive goes into the directory of one of those. It is taken by its first bytes, not by a name ending in.zip: a link named.zipthat holds something else is left out and said. At most 2 archives per issue, each downloaded at most 4 MB. Every file inside one then goes through the same checks as a file the issue links, an image by its first bytes and a text file by its extension and its encoding, and counts against the same limits. An svg, a nested archive or any other binary is left out with its path in the archive and the reason. The files are named on from the linked ones, and the archive is not kept. See tehas work. - A planning session is given the same images and files by the same rules, once at its start, and is shown the images when the same label says so. A reply to its question can carry more. See Planning on an issue.
- The Protolab shows what is attached to an issue labelled
tehas:prototypeby an allowed account, in the body or in a comment, from an owner, member or collaborator, as said under "Prototypes" above.
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:
- one outcome, small enough for one pull request,
- a
## Acceptance criteriasection with checkable items, - the files or area involved, if you know them,
- the test file and the manual page the change will touch,
- an
Out of scopesection naming the nearby files it must not touch.
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.
- Only a label applied by an allowed account counts: the logins in
TEHAS_ALLOWED_LABELERS(in the example,janit). Atehas:readyapplied by the bot or anyone else is no one's request for a cycle: the dispatcher takes it off the issue, says in a comment on the issue who applied it, and logs it. An account inTEHAS_ALLOWED_LABELERSapplies it again to ask for a cycle. There is one exception, for one issue at a time: a plan with no open points. GitHub has no permission per label: any account that can write to the repository can apply any label, so the list is enforced here, at the next poll, and not by GitHub. - The application must still stand: the newest event of the label is that
application. A label the issue's events say was taken off since approves
nothing, even when the poll's list of the issue's labels still has it; the
log says
skip #<n>: tehas:ready was taken off by '<who>' since it was applied, and nothing on the issue changes. Of two events in one second the removal counts as the later. The same holds fortehas:blocked,tehas:plan,tehas:refine,tehas:finish, the driver labels andtehas:prototype. - The label must be the one the factory pinned. A label event names the
label by its current name, so a renamed label would carry its old
applications with it. The dispatcher keeps the GitHub id of each granting
label (
tehas:ready,tehas:plan,tehas:refine,tehas:finish,tehas:blocked,tehas:lean,tehas:classic) in~/tehas/state/labels, written bytehas labelswhen it makes the labels, and an application of a label with another id, or of a granting label with no pin, counts as nobody's. The poll logs each refusal with the label's name and both ids. See label pins. - An allowed account is its login and its GitHub user id, as
install.shandtehas updaterecorded them. A label from the login with another id, after the login changed hands, counts as nobody's; so do a tick, an answer and a comment. See Accounts by user id. - To start it ahead of other ready issues, put it first in the start order:
tehas order set --issues N. The order only sorts; the issue still needs itstehas:ready. See tehas order. - On the host,
tehas start Napproves issue N in place of the label, as the host and not as a GitHub account. The next poll starts it under every rule above and below, and the record, the start comment,tehas historyandtehas statussay it was started from the host.tehas start N --cleartakes the approval back while no cycle has used it. See tehas start.
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).
- It counts only from an account in
TEHAS_ALLOWED_LABELERS, read from the label's events. The millwright's does not count. - From any other account nothing starts, classic included. The poll takes
tehas:ready, andtehas:blockedwith it, off and says why once.tehas:leanstays on: an allowed account applies it again, or takes it off for classic, and then appliestehas:ready. A retry over such a label starts nothing either and says why. - The same holds when another account takes an allowed account's
tehas:leanoff: the choice stands and nothing starts. An allowed account applies the label again, and for classic takes it off itself. - The start binds the choice in its approval record. A retry (a ticked box, the
retry after a provider outage, the millwright's
tehas:readyor a refresh) runs the driver of the start it follows, so a label added since changes nothing until a person appliestehas:readyagain. A person'stehas:readythat a park holds counts too: the ticked box then reads the label. - With the label off, the next start is classic, retry or not.
- The park of a refused lean start asks for the label to come off first. A
Retry ticked there while
tehas:leanis on starts nothing: the poll logs that it waits for the label, and the tick stays. Once the label is off, that tick starts the cycle on classic. UnderTEHAS_DRIVER=leanthe park asks fortehas:classicinstead: the tick waits until an allowed account applied it, then starts the cycle on classic. - A lean start takes
needs-human-attentionoff with its other labels. A classic start leaves it to the cycle's--restart;work-leantakes no restart. - A new lean start also needs a
pi-spec v1block in the issue's text: one fence with that info string, holding valid JSON. With none the poll starts nothing, takestehas:readyoff and says why once, as for a label from an outside account; a retry runs the driver of the start it follows and asks nothing of the block. Tehas checks only that the block is there and reads as JSON; what it holds is the driver's to judge. A plan written over an issue byUpdate this issueholds the block pi-rukas assembled for the plan, at the top, when the drafted plan opens with one under## Spec (pi-spec v1); any otherpi-spec v1fence in the plan is renamedpi-spec-example v1. A plan with no such block keeps the block the issue had, at the top. - The block is the only text the lean driver reads, so the words a person adds
to the issue plan nothing: what goes inside the fence is the whole brief, and
its fields are pi-rukas's to define. pi-rukas's
/planwrites one, and Troubleshooting says what to do when the block is missing. A second block, or one that is no JSON, counts as none. - Once lean runs,
tehasbot cyclereads how it ended from its result, as it does for classic, and its end comment names the driver:driver `lean`. Exit 0 with a merged pull request takes the cycle's labels off. A green pull request that lean says isreadygoes totehas:awaiting-merge; a draft, a red run or a run with no pull request parks with lean's reason. Exit 11, not ready, parks and asks for api-spec v1block lean accepts. Tehas posts the one comment: when lean posted its own report on the issue, tehas does not repeat it. Lean writes no step lines to its stream, so the console of a running lean cycle shows no steps, and a lean runner that died is looked up on its branchlean/issue-<N>. - The driver keeps its own record of the steps it ran, in
.pi/lean-state/<issue>.jsonin the workspace. Before the cycle's report clears what the container wrote,tehas-cycle reportcopies it to~/tehas/state/cycles/<issue>.lean-state.json, and the analytics program'srun(~/tehas/libexec/analytics run) takes its steps as the run's steps, which the drivers table reads for the hand-back by step. A classic cycle keeps no such file, nor does a cycle of a host withTEHAS_ANALYTICS=off: the note exists only to feed that program. A lean cycle whose copy could not be written says so once, and its run keeps the steps of its stream. The copy is a plain file of the workspace, no link on the way, of no more than 4 MiB. The next cycle of the issue removes the copy as it starts.
What a lean run does, as pi-rukas's docs/lean.md describes it:
- It works from the issue's
pi-spec v1block alone. Its steps: ready (read the block and the repository's.pi/work.jsonat the base), specify (tests that fail on the base, then frozen), build, challenge, verify, publish, review, ci and land. The tests frozen in specify are what the build is measured against. - It ends one of three ways. Landed: lean merged the pull request (exit 0).
Handed back: lean stopped and says why (exit 10); tehas parks the issue with
that reason, or, for a green pull request lean calls
ready, moves it totehas:awaiting-merge. Not ready: lean refused the spec block (exit 11), and tehas parks the issue with the rules it failed. - Lean merges only when
.pi/work.jsonat the run's base commit says"autoMerge": true. The repository decides, not tehas. Without it a green run is handed back with its pull requestready, and it waits for a person's merge intehas:awaiting-merge. - A check that goes red while lean watches the pull request is lean's: it
builds once more, and a second red hands back. A pull request that conflicts
or falls behind after the run is tehas's, not lean's, and it is never
refreshed with
--continue-pr: a lean refresh is refused with 78 as above. - The cycle's time limit,
TEHAS_WORK_TIMEOUT, covers the whole run, the wait for the pull request's checks included.
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.
- wall: the time from when the poll took the lock to its end.
- CPU: user and system time of the poll and of the commands it waited for,
as the kernel counts them for the dispatcher,
console tidy runamong them. - gh: the calls the dispatcher made to
ghitself. Calls of the commands it runs, such astehasbot statusandconsole tidy run, and a call undertimeout, are not counted. - writes: the lines of the host shim's write log,
~/tehas/state/github-writes.log(see GitHub App identity), dated from the second the poll started to its end, by kind:label,comment,editand other. They are the writes of the whole host in that time, a cycle's included. What the shim counts as a write is what a call asks GitHub to do, not how it asks it: agh api graphqlcall sends POST whether it reads or writes, and the shim logs it only when the query names amutation. An idle poll reads and writes nothing, and its figure is 0. Without that log, on a host with no GitHub App, the writes are not counted and the line leaves them out. - starts: the cycles the poll started, 0 when it started none. A poll of an older tehas keeps no answer for that, which is not the same as 0.
- last hour: the polls that ended in the last hour, their CPU time and their writes added up.
~/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:
- Every write to GitHub goes through the action journal, as a poll's does, and
each try is a row of its own. The row names the cycle. A poll leaves the open
rows of a cycle whose lock is held, and settles the rows of one that is gone.
A store that will not record a write, after three tries, does not stop it:
the report logs
WARN: the journal will not record the report of #Nonce, and that write and the rest of the report's writes go to GitHub with no row. A poll's write in that case is not made, as its next read decides again; nothing decides a report again. - A write that timed out, that GitHub answered with a 5xx, or whose connection
broke after it was made (a reset, an EOF) may have reached GitHub, so the report reads it back before it tries again: a comment by its
text, a label by name. Found, it is done. Not found, it is sent again with
the tries it has left; a park question that was not found gets the plain
park comment, as a refused one does. Only when that read fails too does the
write stay as it is: its row stays open as
unknown, the report logsWARN: a write on #N may have been posted, a park question is not followed by the plain park comment, and a handoff comment is not recorded as a failed end. The first poll after the cycle reads the row and settles it. - Bodies go to gh on standard input, not as an argument.
- A call to GitHub has a bound of two minutes.
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:
- Only the merge is left (cap
awaiting-human-merge):tehas:awaiting-merge, a short comment on the issue, and pi-rukas's handoff with the token usage on the pull request. - Any other cap, no cap, a review that ran out of its rounds with findings
still open, or an issue that carries
needs-human-attentionat the end:needs-human-attentiononly. The comment names the cap and links the pull request. Read the pull request before you retry.
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.
Retry with the issue and all its commentsgives the cycle what allowed accounts wrote on the issue and on the bot's pull requests for it up to the tick: issue comments, pull request comments, review bodies and inline review comments. A comment counts when its author is inTEHAS_ALLOWED_LABELERSand may write to the repository at the tick (write, maintain or admin, asked of GitHub once per author), and nobody edited it after the tick. The bot's own comments are left out. An author whose permission cannot be read is left out with a warning in the log, and the start comment names them. The dispatcher records the comments at the tick;tehas workwrites them tocomments.jsonbeside the images, each cut at 4,000 characters and the whole at 64 KB with the oldest dropped and counted, and mounts that directory even when the instance gives a cycle no images or files. It needs no setting: the tick is the opt-in. WithTEHAS_WORK_COMMENTS=onthe images and files those comments link come too, by the usual rules.Retry with the issue text onlygives the cycle the title and body, nothing else: its approval names no comment of the issue or of the pull request, so the cycle is given the approved body and the links of that body alone. Neither poll reads the issue's comments or its pull request for such a start.
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:
- 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. - Within ten minutes, apply
tehas:finishfrom the same account.
Who may ask:
- An account in
TEHAS_ALLOWED_LABELERS. - The millwright, within its grant: a person
approved a cycle of the issue, the body is still the body that person
approved, nobody outside the list changed the title or text since, and the
millwright has started no more than
TEHAS_MILLWRIGHT_MAX_RETRIEScycles on it since that approval. A finish starts no cycle, so the last cycle the cap allowed may still be finished. - Anyone else is ignored: the label stays, nothing runs, and the log says
ignore #<n>: tehas:finish was applied by '<who>', not an allowed account. So is an ask whose label the events say was taken off since:ignore #<n>: tehas:finish was taken off by '<who>' since it was applied.
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:
<!-- tehas:finish issue=<n> result=opened -->and the draft's URL when the finish opened it.<!-- tehas:finish issue=<n> result=refused -->and the one line of why when it did not: no kept workspace or branch, no commit of its own, an open pull request of the issue, a rebase that conflicts, a cycle still running, no marked comment, or a rule of the grant not met. The label comes off here too. To ask again, write a new marked comment and apply the label again. The line is the rule's own words, with at most the HTTP status, limit, timeout or connection words of what git or gh said. What the command said can quote a commit subject of the cycle, so it goes to the log only.
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:
- The first try is at the next poll, each next one at least 10 minutes after the one before, 3 tries at most, all within an hour of the failure.
- A try that opens the draft removes the record and comments
<!-- tehas:finish issue=<n> result=opened by=poll -->with its URL. The issue keepsneeds-human-attention, as after an ask: the draft's gate did not pass. - A try that GitHub fails again is counted. A refusal of anything else, the
third try failed, or the hour over, stops the tries. The issue is told once,
with
<!-- tehas:finish issue=<n> result=stopped by=poll -->, and the cycle waits for an ask withtehas:finish. - An issue that carries
tehas:finishis the ask's: the ask runs its finish and removes the record, so the finish runs once. A running issue waits. An issue that is closed, carriestehas:ready,tehas:runningortehas:awaiting-merge, or no longer carriesneeds-human-attention, has its record removed and nothing runs.
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.
-
Write an issue that says what you want planned.
-
Apply
tehas:plan. As withtehas: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, astehas:readyis. -
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 labeltehas:questionis 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 saysplanning #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. -
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:planningwhile 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.lockwhile the turn runs, so no poll starts a second turn on the issue, andtehas statusshows the turn on aplanline. 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. -
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:refinesession 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:readyto the issue you want built. The label approves the text as it is when you apply it. Atehas:readyfrom 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 plan has an open point, or is too long for the issue to hold whole;
- the session is a
tehas:refineone; tehas:plancame from the millwright, or the millwright answered in the session;- the label events do not name the allowed account the session is on record for, or cannot be read;
- the issue is closed or carries
tehas:ready; - the plan links an attachment the issue's text did not;
- the checks of the text of an issue
refuse the plan's own title or text: a title of nothing but a prefix, a
word said twice, a title that only names the issue it plans
(
feat: Plan issue #608), the planner's brief copied as the plan, a text with no line of the issue's own in it, lines of the planner's context echoed back with[context param], or placeholder Acceptance criteria. The session is not ended and no cycle is credited, so a reply that changes the plan is the only answer that moves it on.
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:
- A poll systemd stops with TERM ends without its cost record and tidy; the next poll's tidy covers it.
- The open planning sessions are read once, with the queue.
- A closed issue is not in the query, so the poll says nothing of it.
- A paused poll reads the queue and what its clean-up needs, and no more: not the comments, parks, approvals and blockers of the issues it would decide on.
- An open issue marked
tehas:planningwith no planning session on record getsneeds-human-attentionin place of the mark and a comment that says to applytehas:planagain, as an issue markedtehas:runningwith no cycle does. GitHub can make a label change and still answer it as failed: the poll then takes its turn back, and the mark would stay with nothing behind it. The issue is read again first.
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:
- the factory is paused (it does once the factory is resumed),
- the issue is closed, or no longer carries
needs-human-attentionandtehas:question, or the park's question was answered, - a person added
tehas:ready,tehas:blocked,tehas:planortehas:refine, or the issue carriestehas:running,tehas:refinedortehas:replaced, - the issue has had a planning session before, or a planning session filed it
(its first line is
Replaces #<n>), - the cycle was run by hand or by the millwright, or the account that started it may no longer label,
- the text was changed since the cycle began, by anyone: a person at work on it decides.
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
-
A limit set with
tehas limit, when there is one: see Limit and drain. -
At most
TEHAS_MAX_CYCLEScycles at a time. It is a ceiling, not a promise: the dispatcher starts fewer when the slice has no room. With refreshes on, refreshes have a lane of their own (see refreshes) and do not count here. The setting is a whole number. -
No new cycle while the host runs short of disk: less than
TEHAS_CYCLE_MIN_FREE(10g by default) free on the file system of~/tehasor on the one Docker keeps its images on, whichever has less. The poll reads both withdf; space it cannot read is held on as well, and the log saysholding: <n> GiB free on the disk, under TEHAS_CYCLE_MIN_FREE=<value>: no cycle startsorholding: the free disk space could not be read: no cycle starts. Neither figure is ever taken for the other: whendfanswers nothing for one of the two file systems, the poll holds rather than guess. Running cycles are not touched, and a planning turn is not held, so what the host already works on finishes; only new cycles wait. On 2026-10-20 a host's disk filled and every running cycle died, which is why the check is there. Previews have their own, lower, bound inTEHAS_PREVIEW_MIN_FREE. -
Room in
tehas.slice, the systemd slice every sandbox container runs in. A cycle starts only while the slice's memory limit, less what every container in it is promised or uses, leaves one moreTEHAS_CYCLE_RESERVE(2g by default). A container counts at its reserve or at what it uses, whichever is more, so a dev session, a planning turn and the indexer take room like a cycle does. A cycle that has started and has no container yet counts at one reserve, also when the slice is empty and systemd has removed its directory. File cache and other memory the kernel can take back do not count. -
No more containers in the slice than their ceilings fit in its limit: a container may use the slice over
TEHAS_SLICE_CONTAINERS, a quarter by default, so four. Every container counts, a refresh, a dev session, a planning turn and the indexer as well, and a cycle that has no container yet. Room by use alone would let in cycles that are small in their first steps and may each grow to their ceiling later; then the whole slice reclaims and the kernel kills in the biggest container. So at mostTEHAS_SLICE_CONTAINERScycles run at once, whateverTEHAS_MAX_CYCLESsays, and a dev session or a planning turn takes one of them. The number is a setting of its own, notTEHAS_MAX_CYCLES: containers that are not cycles would still oversubscribe the slice, and on a host with many CPUs the ceiling would fall below the reserve. To run more cycles side by side, raise it and the host's memory together: 6 on a 64 GiB host gives each container 8 GiB. -
No new cycle while the whole slice stalls on memory:
full avg60of its memory pressure above 10 while more than half of the slice is promised. Below that the pressure is one container at its own ceiling, which a new container does not make worse, so it holds nothing. -
No cycle and no planning turn while the slice is missing, has no limit, or Docker cannot place containers in it.
tehas statusthen sayswarn. See Troubleshooting. -
No cycle, no planning turn and no retry while there are no resources: the model endpoint does not answer, or does not offer the configured model, and nor does its backup where there is one. The dispatcher asks it at every poll.
tehas statussayswarn: No resourcesand the dashboard saysno resourcesuntil it is back. -
No new cycle while the sandbox cannot push. A start whose push check is refused leaves
~/tehas/state/push-fault.json(see the sandbox cannot push), and while that file stands the poll starts no cycle and logsholding: the sandbox cannot push: <git's line> (<login>)once, so every ready issue does not fail the same check in turn.tehas statussayspush the sandbox cannot push: <git's line> (<login>)andtehasbot healthfails the page with it, so the host says it without anyone reading the log. Once the file is ten minutes old the poll asks the sandbox itself, before it reads the queue, with no cycle spent on it. It runs the dry-run push a start runs, with the App's cycle token, in a fresh copy of the product checkout under~/tehas/state/push-probethat it removes after, bounded like a start's check. No container is given the checkout itself, and the image is not pulled inside the poll (--pull=never). It asks only when the poll could start a cycle: not while the factory is paused or nothing is ready or approved. A check that passes takes the file off and the queue starts. One that is refused writes the fault fresh, and the hold starts again from that moment. When the poll cannot ask at all (no sandbox image, no cycle token, docker or its daemon not there), it records nothing, logsWARN: the sandbox could not be asked whether it can push: ..., and starts as it would with no fault: the start's own check decides. Running cycles, planning turns and refreshes are not held by it: what a refresh pushes already stands on the remote. -
With
TEHAS_WORK_IMAGES=on, no cycle for an issue whose text links an attachment while the model does not read images. The dispatcher asks the model with a one-pixel image only when such an issue could start now, at most once a poll. The issue stays queued, the log sayshold #N: ..., and issues without images start as usual. A planning turn is not held by it. -
No cycle for an issue whose text says a file goes there (
SCREENSHOT GOES HERE,IMAGE_GOES_HERE,the image goes here) while its text links no attachment at all. The instance giving a cycle images or not makes no difference: either way the cycle would be given no file and no word of the gap, and would spend its explore on a premise it cannot see. The log sayshold #N: its text says <the words> and links no attachment, so the cycle would be given none; the issue keeps every label it has and gets no comment, because what is left to do is the owner's: attach the file, or write out what it shows. A planning turn is not held by it, and neither is a retry tick or a refresh held by anything else about it. -
No cycle while the code index is rebuilt. On a host where no cycle runs and the branch has moved, the poll that would start cycles starts the index run as
tehas-index.serviceinstead, and the log saysholding: the code index is refreshed first. It takes seconds to minutes. Its end starts the poll that starts the cycles. Planning turns are not held by it. -
A slot is never kept by work that is done. Each poll stops a running cycle whose issue is closed, or whose pull request, opened by the bot since the cycle began, is merged or closed. It is stopped as stopping its unit does: the container goes, the lock is released and
tehas:runningcomes off. The log saysstop #N: <reason>. A merged one is reported as merged, one whose issue was closed only losestehas:running, and one whose pull request was closed is parked without the retry boxes. What the cycle had not pushed is nowhere else, so a cycle stopped this way keeps its workspace, and its comment names the workspace it left (~/tehas/work/tehas-<issue>) when there is one, and says the cycle left none when there is not. tehas removes a workspace only when the cycle ends with its change merged, or hands off with its pull request open for a human to merge. A poll that cannot read the issue or the pull requests ends there: it stops nothing, starts no cycle and sweeps no kept workspace, so a cycle is never given up on a guess and holds its slot until a later poll can ask. The slot is filled on the same poll. And a cycle that ends starts a poll at once (tehas-dispatch.service), so its slot does not wait for the timer. If a poll is running then, systemd takes that start as the running poll, which may have counted the cycle as still running. So the cycle also leaves~/tehas/state/dispatch.again, andtehas-dispatch.pathstarts the next poll as soon as that one ends.tehas dispatch --soonwrites the same file for anything else that wants a poll.tehas-dispatch.serviceremoves the file before the poll runs, so a poll that stops on bad settings does not leave it to start the next one at once. If systemd still fails the path unit, for example at the service's start limit,tehasbot healthwarns (checks.units, which isnullwhen that read did not answer rather than empty), and the nextinstall.shresets it and starts it again. -
Nothing else. A new pi-rukas commit runs at full concurrency from its first cycle, so a bad one can fail up to
TEHAS_MAX_CYCLEScycles at once. Those issues end labelledneeds-human-attention, as any failed cycle does, and the time limits bound the cost. -
When a poll starts fewer cycles than there are free slots and issues waiting, the log says why on every such poll, and
tehas statusshows the same line:holding: <n> of <free> free slots start: ...when the awaiting-merge limit or the slice's room cut it, else the hold that stopped all of them. -
Inside a cycle,
TEHAS_WORKSTREAMSworkstreams side by side: 1 by default, and more only with one cycle at a time. See The host. -
No new cycle while
TEHAS_MAX_AWAITINGissues carrytehas:awaiting-mergeor are being worked on. The default isTEHAS_MAX_CYCLESplus 2, so every slot can be used while two pull requests wait. Unreviewed pull requests are the queue you control. -
A self-hosted model endpoint has few real slots per model, so a cycle takes a while; the six-pass review is the slowest part.
-
No new cycle while the branch is red, when the instance sets
TEHAS_BRANCH_CHECK: each poll asks GitHub, in one call that may take 30 seconds, for that check on the head commit of the branch work lands on. When it failed, timed out or could not start, the poll starts no cycle, no retry and no refresh, and saysholding: main is red at <sha>, with the branch's name and the first 12 characters of the commit. A cycle started then would find the gate red on its base and park hours later. Running cycles go on. When the check is pending, missing or cannot be read, cycles start as before, so an outage at GitHub does not stop the factory; the log says why it could not tell, once each time that changes.
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:
- the gate's wall time on this host, measured with that many cycles running;
TEHAS_VERIFY_TIMEOUT, at or above that time with a margin;TEHAS_MAX_CYCLES, no higher than keeps the gate inside the bound.
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:
- Raise
TEHAS_VERIFY_TIMEOUTto the longest run plus a margin. KeepTEHAS_WORK_STALLabove it, which the settings check enforces, and leaveTEHAS_WORK_TIMEOUTroom for the gate runs of every step. - Or lower
TEHAS_MAX_CYCLESuntil the gate fits the bound. Fewer cycles run, and each gate gets a bigger share.
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:
-
As an owner of the organisation, add the issue types in its settings, under Planning, Issue types: for example
ImprovementandPrototype. tehas never creates them. -
Map each kind to its type in
instance.env, onekind=Typepair for each, separated by a space. A kind left out stays its label:TEHAS_ISSUE_TYPES="improvement=Improvement prototype=Prototype" -
Run
install.sh, or wait for the next poll: the setting is read at each run.
What changes:
- improvement: the dispatcher holds an issue of the type exactly as it
holds one labelled
tehas:improvement: the millwright does not start it. The label still holds where a person left it, so turning the setting on lets nothing start that was held. The review still files under the label. - prototype: the Protolab lists the open issues of the type, and a ticket
counts when an account in
TEHAS_ALLOWED_LABELERSmade the newest change to its type, the change that set it. A type set by anyone else, or a change the Protolab cannot see, counts as no type, as a label from anyone else does. With the setting on,tehas:prototypeputs nothing in the lab.
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.
- Where the findings go is
TEHAS_REVIEW_REPO, a repository of their own: one issue per run, labelledtehas:improvementand nevertehas:ready, so a finding starts no cycle until a person says so. Loading refuses the product repository,TEHAS_REPO: a model writes these from what it read, and a person triages them into tickets first. While one of those issues is still open, a later run's findings are a comment on it rather than a second issue. - What it reads is the whole range since the last review, kept in
~/tehas/state/review.json. With no record it starts at the commit 7 days back. A run that failed records nothing, so the next one reads the same commits again: the point is the range, not the schedule. - What it costs is one container in
tehas.slice, bounded byTEHAS_PLAN_TIMEOUTlike a planning turn, and the model requests one headless review turn takes. Nothing about a cycle changes, and no issue of the product is written by it.
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:
- the build output of a kept workspace: every directory anywhere under
~/tehas/work/<name>-<issue>whose name is one ofTEHAS_CLEAN_DIRS, the toolchain names listed in Commands, and<name>-<issue>.state/cache, the cycle's copy of the code index. The trees beside the workspace are walked as roots of their own:<name>-<issue>.before-retry, the workspace a retry moved aside, and the worktrees of a cycle under either. The runner of this host makes them in a directory of its own inside the workspace, two levels under its root, and that depth is the reach of the listing: a runner that nested them a level deeper would leave their build output where it stands, with the log still reporting the issue walked. A cycle makes its worktrees in the workspace it was given, under a dot-name, and leaves them with a clone of their own and that clone's build output under them, so the walk of the workspace, which enters no dot-name, reaches none of them. An issue kept only by the tree a retry moved aside - the workspace of the cycle that merged is gone - is walked too. A worktree that is a symlink is not walked: a link there stands outside the workspace and is left while the roots beside it are taken. A kept workspace is never built in again - every cycle clones fresh - and the dispatcher's sweep takes the whole of it later. A directory that holds cargo'sCACHEDIR.TAGis build output whatever name an agent gave it, here and at a cycle's end. The issue's lock is held while they go, so no cycle starts in it, and a workspace touched within the age is left alone, the tree of a retry and the worktrees beside it being part of that age rule. Nothing is removed under a lock that is not there: an issue whose lock file is gone is left alone, because the cleaner cannot tell a finished cycle from a removed lock..git, the sources, uncommitted changes,memoryandsessionsstay for a person to read, and no dot-name is entered. A cycle that ends takes the same build output itself, under the lock it still holds, so the age rule only catches what a cycle killed before its end left behind. The same run removes what a killed cycle left underTEHAS_SCRATCH_DIR, whatever its age, once the issue's lock is free. - Docker's build cache of that age, with
docker builder prune. This is the build cache of the whole host's Docker daemon: tehas is one project on one host, and the cache of anything else on it is made again too. No image and no volume is removed by this step. - the host's scratch: old files under
~/tehas/tmp/dland~/tehas/tmp/node-compile-cache, old~/tehas/tmp/analytics-facts.*files an analytics call left when its caller was killed, old~/tehas/tmp/tehas-test.*directories, and the copy of the sandbox recipe -~/tehas/sandbox/sandbox-uid.Dockerfile, or itssandbox-uid.Dockerfile.XXXXXXtemporary - that a build killed before its cleanup ran left beside the build script. Nothing outside those four directories under~/tehas, and nothing outside it: not~/tehas/dev, so nothing under a manual session's<name>.stateis walked for a build-output name. The last step names that tree of its own. - the build output a manual session keeps,
<name>.state/targetof every clone under~/tehas/dev, only underTEHAS_CLEAN_MIN_FREEand once it has gone untouched forTEHAS_CLEAN_AFTERhours; above that figure a clone keeps its build. It goes only of a clone no session holds: the locktehas devtakes for the whole session,~/tehas/state/dev/<name>.lock, and the container namedocker psanswers,tehas-dev-<name>, both say so, and a docker that will not say keeps the build. Nothing else under<name>.stateis ever named, so the clone, its memory, sessions, transcripts, code index, author and images stay.du -sh ~/tehas/dev/*.state/targetsays what the sessions hold, andrm -rfof that path clears one clone's build by hand (see tehas dev). - the sandbox image's dated tags before the newest two builds, whatever their
age, each with its own
docker rmi: the current build and the one before it stay, a<date>-productcounted with its<date>, and so does any tag a container or auidtag was made from: a cycle or a preview still running from an image keeps it whatever its age. The build's own sweep keeps the same. - the base image a sandbox build pulled from upstream before the base was built
on the host, of that age and made no
container, removed by its own name with
docker rmi. Nothing else is offered to docker: the step never asks for the images that have lost their tag, which is how a preview image oftehasbot previewand the rollback tag of an update stay untouched. Volumes are a person's call. A docker that answers no image list, or nothing about the host's containers, removes no image: an unknown is never a reason to take one away. - the logs of cycles, planning turns, index runs and reviews in
~/tehas/logsolder than 7 days, and the analyst logs an earlier version left. The long-lived logs stay:dispatch.log,refresh.log,review-timer.log,preview.log,protolab.log,clean.logand~/tehas/state/github-writes.log. Each one past 64 MiB is copied to a single.1and emptied. - the state store's upkeep: a copy a day (see below), and rows past 90 days
removed with
store prune --days 90: cycle endings, settled actions of the journal, old heartbeats of cycles that have ended, and the cycle and plan history of issues whose cycle ended that long ago. Each of those issues keeps its last row of each history, sotehas historystill says how it ended, and the issue whose cycle ended without a history row of its own keeps all of them. The 90 isPRUNE_DAYS, the windowstore upkeepprunes with. A cycle's own record stays.
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.
- It is the bot. The millwright is the factory's GitHub App, the login in
~/tehas/state/github/login; it is not a setting.tehasbot github-token --checkprints it (acting as <slug>[bot]), and so doestehasbot github-token --login. GitHub's REST API names an App with[bot]and its GraphQL API without, so tehas takes the two as one account, and no other. Because every agent posts as the bot, atehas:readyfrom the bot counts only within the grant below, and never as a person's approval. It is never one ofTEHAS_ALLOWED_LABELERS: loading the settings stops with 78. Before the app's login is known there is no millwright, and the account's labels count as any outsider's.TEHAS_MILLWRIGHT_LOGINis not a setting: a line ininstance.envstops every command with 78. The approval record names the millwright without[bot]. - Or a second app.
TEHAS_MILLWRIGHT_APP=<slug>[bot]ininstance.envmakes that app the millwright in place of the factory's own. The factory still acts as its own app, and its bot'stehas:readythen counts as any outsider's: agents post as the bot, so they cannot use the grant.tehas updaterecords the second app's user id beside the labellers' (see Accounts by user id). - Its
tehas:readystarts a cycle only within its grant: a person approved an earlier cycle of the issue, the body is still the body that person approved, nobody outside the list changed the title or text since, and the millwright has started fewer thanTEHAS_MILLWRIGHT_MAX_RETRIEScycles on it since that approval (2 unless the instance says otherwise). Otherwise the label comes off and the issue says why. So the millwright never starts work nobody asked for: it never readies atehas:improvementproposal. - With the feed, it may start an issue a person wrote. Optional, off
unless
TEHAS_MILLWRIGHT_FEED=on, and only in the Rust dispatcher. On an issue no person approved a cycle of, the millwright'stehas:readystarts the first cycle when an account inTEHAS_ALLOWED_LABELERSwrote the issue, nobody outside the list changed its title or text since, it carries none oftehas:improvement,needs-human-attentionandtehas:millwright-escalated, and no allowed labeller tooktehas:readyoff it before. Writing the issue is the person's approval of its text. A body the millwright reshaped is not the author's, so it needs a person'stehas:ready. At mostTEHAS_MILLWRIGHT_MAX_FEEDScycles the feed started run at once (2 unless the instance says otherwise): past that the label stays and the issue waits. When the running ones cannot be counted, it waits too. A fed cycle rests on no person's approval, so once it ends the millwright's grant cannot retry it: a person approves the next cycle. The other checks of any start still apply: epics, the size limit, the slots. - With epics, it may start and plan an epic's parts. Optional, off
unless
TEHAS_MILLWRIGHT_EPICS=on. An allowed labeller'stehas:readyon an epic (an issue with open sub-issues) approves its open sub-issues while the epic stays open, keeps open sub-issues and carries noneeds-human-attention. The approval is read from the epic's own label events on every poll; nothing else keeps it. On a sub-issue of such an epic, the millwright'stehas:readystarts the first cycle, and itstehas:planortehas:refinestarts a planning session, when an allowed account or tehas itself wrote the issue and last changed its title and text (tehas's planner writes a sub-issue's plan as tehas), nobody else changed them since the millwright's label, and the issue carries none oftehas:improvement,needs-human-attentionandtehas:millwright-escalated. Otherwise the label comes off and the issue says why. An issue whose edit record could not be read is refused the same way: it is not taken as never edited. The start is recorded as the person's label on the epic,how: "label"by that person, and the session as theirs, so the millwright answers its questions within its grant and retries the cycle as it would any a person approved. These starts are not fed cycles: they do not count againstTEHAS_MILLWRIGHT_MAX_FEEDS. The other checks of any start still apply. - The approval record says so. A millwright start has
how: "millwright",rests_on, the person's approval it rests on, andmillwright_starts. A person's start counts again from none. Its other limits are the dispatcher's as for any start: the slots, the cap of waiting merges and the slice's room. - Its comment reaches the cycle. The millwright's newest comment on the issue
that starts with
<!-- tehas:millwright issue=<n> action=retry -->oraction=change, written in the ten minutes before its label and edited by nobody after, goes into the record asretry_context.tehas workwrites it tocomments.json, sourcefixer, in the directory it mounts for the cycle's attachments, mounted for it alone where the instance gives a cycle no images or files. The park's hold is lifted by theaction=changeone of them alone, and only where the instance gives a cycle images or files, as parking says. - It may answer a planning question, by a tick or a reply, only when
no person has answered the same question: a person's tick or reply wins,
whichever came first. And only in a session an allowed account's
tehas:planstarted, fewer thanTEHAS_MILLWRIGHT_MAX_PLAN_ANSWERStimes in the session (3 unless the instance says otherwise), and never for two turns in a row, so a person sees every second question at most. It may not tickEnd this planning session. Its reply starts with the line<!-- tehas:millwright issue=<n> action=answer -->, and the agent is told the answer is the millwright's. A comment of its account that does not start with that line is no reply at all, and nothing is said of it: the millwright is the bot, so the host's own notes are its comments too. A tick that breaks a rule above is unticked and the bot says why; a marked reply that breaks one is ignored and the bot says why once. GitHub says who last saved a comment, not who ticked a box, so a tick the millwright saved after another account edited the question is held: it is neither used nor unticked, and the bot asks a person, once, to tick again or reply. To overrule it, reply or tick before the next poll, or reply to the next question. The session on the state store (plan-show) keeps who started it and who answered each turn, and whether the millwright did. - It may ask for a finish of a stopped cycle with a marked comment and
tehas:finish, within the same grant, as finishing a stopped cycle says. tehas:millwright-escalatedis the millwright's word that a person decides. The factory does nothing on it; a start takes it off.- It may hold issues with
tehas:blocked, and name the blockers in a marked comment, as an allowed labeller may (see What happens next). That starts nothing: an issue still needs atehas:readythat counts. When to apply it, and how often, is the millwright's to decide, not the factory's. No label orders the queue: the order ready issues start in is set on the host with tehas order, by a person or by a host program that runs the factory. A millwright that runs as such a program orders the queue that way. - Each cycle's end leaves a line of history in the state store
(
~/tehas/state/tehas.db), the last 50 of each issue: when, its status, last step, cap, park reason, failure, whether a provider outage stopped it, whether it parked, its pull request, who started it and how. A planning turn leaves one of its own in the store too, withkindplan.tehas historylists both, oldest first, andtehas exportcopies what a cycle left behind. A millwright reads GitHub, not these records. - A park that repeats the park before it says so. A cycle that parks the
way the issue's previous end parked, on the same step, cap, park reason,
failure kind and failure cause, is one of a run of parks. Its comment carries
the host's line above the boxes, which names the place in the run, the step
and the cap, and says that a retry on the same text will likely stop the same
way.
tehas historysays the same of a line:repeatin--jsonandrepeat <n>in the plain listing, on the park of a run only, and counted from what the store keeps of each end rather than from anything the comment left behind. Only the end just before a park puts it in a run: a merge, a handoff or any end that was not a park breaks the run, and a park of a provider outage is neither a repeat nor the park a run is counted from, because an outage has its own rule of retries. Nothing about a run changes what the cycle does: it parks, asks and waits as it would have. - The park comment carries the park's facts. The bot's park comment,
with boxes or without, has the line
<!-- tehas:park issue=<n> step=<step> kind=<failure kind> provider=<0|1> sig=<sha256> -->.stepandkindare the history line's, cut to[a-z0-9-], and empty when the cycle had none.provideris 1 when a provider outage stopped it.sigis the sha256 of the history line'sstep|cap|park_reason|failure_kind|failure_cause, each field as the store keeps it: its characters outside the field's set, then its first bytes up to the field's bound (step40 of[A-Za-z0-9_.-],cap80 of those and:,park_reasonandfailure_kind40 of[a-z-],failure_cause60 of the set ofcap). Two parks with the samesigstopped the same way. The free text of a park stays out of the marker. Only the bot's comments count: a reader ignores the line in anyone else's.
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):
- the issue is open, carries
tehas:awaiting-mergeorneeds-human-attentionand none oftehas:running,tehas:millwright-escalated,tehas:plan, and no cycle or planning session is open on it. A handed-off issue that carriestehas:readygets the fresh cycle a person asked for, not a refresh; atehas:questionthe handoff left behind is no bar, and the start takes it off; - its body is the body that person approved, and nobody outside
TEHAS_ALLOWED_LABELERSrenamed or edited it since; - the pull request is still the bot's, the one open pull request that closes
the issue, at the head the request named, and GitHub still says
CONFLICTING. A person who pushed to it since is handling it; - fewer than
TEHAS_REFRESH_MAX_PER_PRrefreshes of it since that approval (2 unless the instance says otherwise), and none that parked. A start that failed counts as none: where the mark of a refresh could not be put on the pull request, or the cycle never ran, the dispatcher writes the record back as it found it and asks again on the next run. The count is what the bot itself saw start.
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. Mergemaininto 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
maininconsole/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:
- 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.6first; 1.0 refuses an older store with exit 78 and installs nothing. - Edit the settings. Change
instance.envand~/.config/tehas/envfrom the tables below, or from the 1.0 Adopter action thattehas update --checkprints. On 0.30.x,--checkis 0.30's own check: it prints the release notes and the version it would switch to, and lists no setting. - Drain. Run
tehas drain --wait 3600and 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. - 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. - Labels. Run
tehas labels: it makes and pinstehas:classicand givestehas:improvementits new description. - 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:
TEHAS_IMPROVE_REPO,TEHAS_IMPROVE_RUKAS_REPO,TEHAS_IMPROVE_RUKAS_SKIP,TEHAS_IMPROVE_MAX_OPEN: the improvement loop is removed. The update removes its timer.~/tehas/tmp/improveand~/tehas/logs/improve.logstay on the host until you remove them.TEHAS_CYCLE_REPORT: the cycle's report has one form.TEHAS_EASY_MERGE: every refresh is the full refresh cycle. A blank value and0are ignored.TEHAS_CONTAINER_MEMORY,TEHAS_CYCLE_CPUS,TEHAS_CYCLE_CEILING: the automatic cycle count is removed.TEHAS_MAX_CYCLESsets the count.TEHAS_BOT_LOGIN,TEHAS_MILLWRIGHT_LOGIN: the bot and the millwright are the GitHub App's login, or the appTEHAS_MILLWRIGHT_APPnames.TEHAS_GITHUB_APP_INSTALLATION: the installation is looked up fromTEHAS_GITHUB_APP_ID.TEHAS_REFRESH_CONFLICTS,TEHAS_REFRESH_EVERY: nothing looks for conflicts on its own. Have the program that runs the factory ask for a refresh withtehas refresh --pr N. A value they took before still loads and does nothing; any other value stops every command with 78.
Settings that changed.
TEHAS_DRIVER=leanstops every command with 78: the lean driver is still being built. Take the line out or set it toclassicbefore updating.TEHAS_ENERGYin~/.config/tehas/envtakeson,off,1or0like every switch. Any other word stops every command with 78.TEHAS_RELEASE_REPO: an instance that names a repository whose releases are signed with another key can no longer update from it. Take the line out to update from tehas's own releases.TEHAS_CLONE_DEPTHis new: a workspace's clone keeps that many commits, 100 by default. SetTEHAS_CLONE_DEPTH=0to keep full history, as before.- Some values are checked more strictly. If a command stops with 78 after the
update and names
PI_ENSEMBLE_HOST_ALIASES,TEHAS_WORK_REPO,TEHAS_HOME,TEHAS_INSTANCE_DIR,TEHAS_UPDATE_LOCK_WAIT, aTEHAS_MODEL_KEY_<NAME>or an MCP setting, fix that line as the message says.tehas diskandtehas setuprefuse a value in a settings file that holds a$or a backtick outside single quotes. - A limit file whose
cyclesis not plain digits, such as1.0or01, reads asunreadable. Step 6'stehas limit clearrewrites it.
Labels.
cross-projectis no longer used. It stays on GitHub until you delete it.tehas:improvementstays, described as filed by the factory.tehas:classicis new;tehas labelsmakes it.tehas:leanstarts nothing while the lean driver is still being built: the poll takes off the label that asked for the start and says why once.tehas:leanstays on until you take it off; take it off any issue that should run on classic.
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:
tehas status --json: the step fields ofrunning[](step,stepNumber,stepTotal,round,roundLimit,stepSince) are underrunning[].progress.room.slotsis gone.tehas history --jsonandtehas export --json:runs, notcycles, with the step of a line underruns[].progress. A run recorded asfixersaysmillwright. Inplan.jsonoftehas export,answers[].millwrightreplacesanswers[].fixer.tehas start --json:approval.bodySha256andapproval.titleSha256.tehas refresh --pr N --json:headSha, nothead_sha.tehas disk --json,live/disk.jsonand the MCP toolfactory_disk:time, notgeneratedAt.factory_diskno longer hasdockerRoot.- The MCP tool
factory_status:manager, notindustry. Health'schecks.industryischecks.manager.factory_sessionsfilters byhow: "millwright", notfixer. tehas api --json:millwrightreplacesfixer, and the featuresmillwright-grant,state-copy,refresh-prandhost-messagereplacefixer-grant,store-copy,refresh-pr-starts,refresh-pr-lane,refresh-pr-jsonandhost-message-health.
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:
- 3 where it read 1 from
tehas status,tehas drain,tehas update --check(something to update) andtehas start(no such open issue); - 3 where it read 78 from
tehas check-product; - 78 where it read 69, and 1 where it read 70 or 73, from
tehas analytics; - 1 where it read 78 from a
tehas setupwhose product check failed.
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:
- The release gate,
.github/workflows/release-gate.yml. Started by hand (workflow_dispatch) with the full commit id to gate, it checks out that commit, runsscripts/verify.shwithTEHAS_TEST_JOBSandTEHAS_TEST_MEMORY_MAXset from the runner's own cores and memory, then builds the sandbox base image and the sandbox image withhost/sandbox/build.sh, as a host builds them, and runs vipune, jq and codebase-memory-mcp in the image offline. A second job checks the names list on a GitHub-hosted runner, so the list never reaches the lane. A third runs the Kani proofs beside the code (#[cfg(kani)]modules), with Kani at the version it pins, on a runner of its own,[self-hosted, kani]. It is three jobs,proofs (1)toproofs (3): each takes every third harness and checks four at a time, so with threekanirunners they run side by side, and with fewer they queue. The proofs run only here, not inscripts/verify.shor on pull requests. With nokanirunner online the jobs wait, and the run is not green until all three have run. The run's title isrelease-gate <commit>. An alpha or a beta skips the proofs:tag-releasestarts its run withproofs=false, titledrelease-gate <commit> without proofs, and such a run gates only an alpha or a beta. A release candidate or a release needs a run with the proofs. - Express batches.
verify.ymlruns a pull request whose title starts withExpress Laneon[self-hosted, speedlane]. Every other pull request into main or arelease/branch, and every push to them, runs where it always has. A pull request onto another branch runs no gate.
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:
- In the organization's settings, Actions, Runners, New self-hosted runner, take the registration token.
- Run the runner's
./config.sh --url https://github.com/<org> --token <token> --labels speedlane. The runner carriesself-hosted, its OS and architecture, andspeedlane, and nottehas. - 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.
- Make the account and give it rustup and cargo at the
RUST_VERSIONofhost/versions.env. - 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. - As the account, unpack the runner and run
./config.sh --url https://github.com/<org>/<repo> --token <token> --labels kani. It carriesself-hostedandkani, and nottehasorspeedlane, so no other job takes it. Write the account's cargo directory first in the runner's.pathfile, since a service does not read a login shell. - 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.
- Where you work. A clone named after your login, made the first time
from the product checkout, at the tip it last fetched. It is yours and it
stays: tehas never resets or removes it. Pull inside the session if it is
behind. It is in the tehas user's home,
~/tehas/dev/alicethere, so you reach it through a session and not from your own shell. - Whose name is on the commits.
user.nameanduser.emailof your own account, read from your git configuration every time you start. Every commit of the session carries them, yours and the agents'. Nothing else of your configuration is used: no aliases, no signing key, no credentials. - Who runs it. The session runs as the tehas user, through
sudo. You get the session and nothing else of that account: no shell, no Docker, none of the othertehascommands. - Who pushes. The bot. The push and the pull request go through its token, so GitHub shows the bot as the author of the pull request and your name on the commits. The author is a label, not a proof: it is whatever your git configuration says. A rule that needs a review from somebody other than the pull request's author looks at the bot, so read the commit authors before you approve.
- The factory beside you. Nothing is paused. A session and a cycle share
the model endpoint, and the command tells you when a cycle is running. Apply
tehas:pausefirst if you want the models to yourself. The energy section and the token meter count a session, because they measure the models; the factory floor does not show it. - Outside the queue. No labels and no bot comments. The dispatcher does not know the session exists.
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.