The host
One Linux machine and one Unix user. In the example: tehas-tehas, user boss
(ssh boss@tehas-tehas), 8 CPUs and 15 GB of memory. That user is in the
docker group, which makes it root-equivalent on the host. The boundary that
matters is the sandbox: agents only ever run inside it, without the Docker
socket.
Preparing a fresh machine is on the bootstrap page. What of a factory is public and stays compatible through 1.x, and what is internal, is on the contract.
Layout
| Path | Content |
|---|---|
~/tehas/env.sh |
Environment for every tehas process, its tool directories taken from lib/paths.sh; sourced from ~/.bashrc |
~/tehas/lib/config.sh |
Asks libexec/console to load and check the instance settings; sourced by every command |
~/tehas/lib/paths.sh |
The home of each tool this host installs, and the PATH that finds them. env.sh, bootstrap.sh and install.sh all take the list from here |
~/tehas/lib/github-app.sh |
With a GitHub App: puts the gh shim first on PATH and gives git its credential helper; sourced by env.sh |
~/tehas/bin/ |
The two commands on PATH: tehas for a person, tehasbot for the units, each a few lines that run the console's front (console/src/front.rs), which chooses the command. Without a console both stop with exit 78, except tehas setup, which builds one. Plus gh |
~/tehas/libexec/ |
The scripts behind the two commands, and the programs they run. Three bash scripts (dev-login, setup and update) and the Rust programs install.sh builds: the console, analytics, the MCP server, the state store, the attachment checker, the dispatcher and the cycle supervisor, and while outsource is on the model proxy and the contractor program. Every other command is a verb of one of those programs. Not on PATH |
~/tehas/run/ |
One copy of bin/, libexec/ and lib/ for each running cycle (cycle-<issue>-<pid>) and planning turn (plan-<issue>-<pid>), as hardlinks, so an update leaves the code of what runs as it started. The next start removes the copies whose process has ended |
~/tehas/platform |
Checkout of this repository; install.sh runs from it and tehas update pulls it |
~/tehas/repos/tehas |
The product checkout, on the default branch. Cycles are cloned from it; no container is given it |
~/tehas/work/tehas-<issue> |
The cycle's workspace: a fresh clone made for each cycle, of the default branch alone and TEHAS_CLONE_DEPTH commits of its history. Removed after a cycle that merged or left a pull request, otherwise kept, and moved to tehas-<issue>.before-retry when that issue is retried. A start that stopped before the container ran keeps the clone it made, as does the one it moved aside. The .before-retry goes when the retry it was kept for ends. A kept workspace and what else is left beside it go at once when its issue is closed, and otherwise once no cycle has run on the issue for TEHAS_WORKSPACE_KEEP_DAYS days (7 by default). Its build output goes sooner: tehasbot clean removes what it names as build output once nothing of the issue has been touched for TEHAS_CLEAN_AFTER hours, in this tree, in the one a retry moved aside, and in the worktrees of a cycle under either at the depth the runner lays them out, and the 7-day sweep still takes the rest. ~/tehas/work/tehas is only its path inside the container |
~/tehas/work/tehas-<issue>.state |
The cycle's own: cache, a copy of the code index the host built; memory, what its agents learn; sessions, Pi's session files. Made fresh for each cycle, mounted in its container, removed with the workspace. A cycle reads no memory an earlier cycle wrote, even one of the same issue, so a vipune search at its start answers {"results": []}. ~/tehas/work/tehas-plan-<issue>.state is a planning turn's, removed after the turn. Of these, only cache is build output: tehasbot clean removes it when the issue has been idle for TEHAS_CLEAN_AFTER hours, and memory and sessions stay |
~/tehas/work/tehas-<issue>.images |
With TEHAS_WORK_IMAGES=on, the images of the cycle's issue and their manifest.json, and with TEHAS_WORK_DESCRIBE=on the model's descriptions of them, images.md. With TEHAS_WORK_FILES=on, the issue's text files too, file-<n>.<ext>, with or without the images. Made for each cycle, read-only in its container at ~/tehas/work/tehas.images, removed when the cycle is over |
~/tehas/work/tehas-plan-<issue>.images |
With TEHAS_WORK_IMAGES=on or TEHAS_WORK_FILES=on, a copy of a planning session's images and files for one turn, read-only in its container at ~/tehas/work/tehas.images, removed after the turn |
~/tehas/work/tehas-plan-<issue>.keep |
What a planning session carries from one turn to the next: the approved text, the commit it began at, pi-rukas's record of the session, the last turn's exit status, the issue's images, and a later turn's answer as answer.md. Removed when the session ends. No container is given it; each turn copies what it needs into its workspace |
~/tehas/dev/<name> |
A person's clone for working by hand, named after their account, made and used by tehas dev, never removed. <name>.author next to it holds whose name its commits carry, <name>.state its memory, sessions, transcripts, code index and cargo build output (target, kept so a later session of that clone builds on what an earlier one built; see tehas dev), and <name>.images the images and files of the issue named by --issue, read-only in the session's container |
~/tehas/repos/pi-rukas |
pi-rukas, at the commit PI_RUKAS_FOLLOW names |
~/tehas/docs/, ~/tehas/fun/ |
This site's pages and the front page, installed from host/ |
~/tehas/sandbox/, versions.env |
Sandbox image definition, build script, the Playwright npm pin, and the pinned tool versions |
~/tehas/edge/ |
The docs server (docs.compose.yaml) and the edge router (router.compose.yaml) |
~/tehas/protolab/ |
The Protolab's pages and the files of each prototype, written by tehasbot protolab |
~/tehas/wiki/ |
The product wiki's builds, one directory each named <date>-<8 hex of the commit>, and current, a link to the current one. The docs server serves a build at /wiki/<id>/ while the wiki is on |
~/tehas/preview/ |
The state of each preview, and a bare clone the pull requests' commits are fetched into, written by tehasbot preview |
~/tehas/logs/, state/, live/, tmp/ |
Logs, state, dashboard data, scratch. state/ holds the dispatch lock, status files, the files a planning turn passes on (plan-<issue>.json.out, .json.rc, .json.lock and .json.image), the state store (tehas.db), which holds what each start rests on, each cycle's record and its history, each park and the id of its question, each planning session and the history of its turns, and the manifest of each start's images (cycles/<issue>.manifest.json, with cycles/<issue>.images.md and cycles/<issue>.comments.json when the cycle had them). What each approved start measured is kept in state/sizes.jsonl, one line per start, mode 600: when, which issue, and the four counts of its approved body, the last 500 lines. The report's size figures read it. What each refining session filed is kept beside it in state/refined.jsonl, likewise the last 500 lines. What the last real poll decided of each issue it could start, and the holds between issues it read, is state/starts.json, mode 600, which tehas order --json and tehas blockers read. No cycle, planning or manual container is given it; the indexing container is given state/index to write |
~/tehas/mcp/ |
The two files tehasbot status asks analytics to write for the MCP server: the sessions snapshot sessions.jsonl and the outcomes counts outcomes.jsonl, each with a .stamp line beside it that says why it need not be written again. Mode 700: the snapshot holds what the agents saw, and neither is published |
~/tehas/state/tehas.db, state/backup/ |
The state store's database and the copies made of it before each migration. See The state store |
~/tehas/state/imported-<YYYYMMDD>/ |
The record files of an older tehas that a v0.30 install.sh imported into the state store that day, each under its path in state/. Nothing reads them, and this release imports nothing; remove the directory once satisfied. See The state store |
~/tehas/state/index |
The code index tehas index builds, under the name of the tree it was made from. The indexing container is given it to write; no cycle, planning or manual container is given it, and a cycle is given a copy of it in its own state directory |
~/.pi/agent/ |
Pi user configuration (models, MCP servers) |
~/.config/tehas/ |
Secrets and the instance-dir pointer. Never in git |
The cleaner. tehasbot clean, from tehas-clean.timer once an hour, removes
what the host can make again once nothing has touched it for
TEHAS_CLEAN_AFTER hours (24 unless the instance says otherwise): the build
output of a kept workspace - every directory anywhere under it whose name is one
of TEHAS_CLEAN_DIRS, the toolchain names listed in Commands - and the
cycle's cache, its copy of the code index. The same step walks the trees beside
the workspace that hold build output of their own: tehas-<issue>.before-retry,
the workspace a retry moved aside, and the worktrees of a cycle under either - a
worktree being a directory at the depth the runner lays them out whose .git is
a file naming a gitdir, which is what a cycle makes inside the workspace it was
given and leaves where it stands with a clone of its own and that clone's build
output under it. A worktree
sits under a dot-name, so the walk of the workspace never reaches it: each is
asked as a root of its own, and one that is a symlink is not walked at all. An
issue with no workspace left, only the tree a
retry moved aside, is asked too, since that is all of it the disk still holds.
What the workspace keeps is what a person reads: .git, the sources, what the
agents wrote there, uncommitted changes, and the memory and sessions of its
.state. The cleaner runs no git command in a workspace except one: git -C <worktree> rev-parse --absolute-git-dir, the call that names a worktree's gitdir
for the age rule, in a tree a cycle wrote. Git and the bound around it are named
by absolute path and run under a cleared environment that reads no config file at
all, and the answer is used only when it names an existing directory under
~/tehas/work; an issue is left whole when git cannot answer. It follows no
symlink, and enters no dot-name, which is what
keeps those trees out of the removal. It holds the issue's lock while it removes,
so no cycle starts under it, and it removes nothing for an issue whose lock file
is not there to hold, or whose lock the probe cannot tell: a link, a directory or
a lock no one can open is read as a lock a cycle holds, because a lock is held by
descriptor and a name of its own proves nothing about the file that was locked.
The probe is the one the library keeps (tehas_core::lock,
console/core/src/lock.rs), the same one the dispatcher, the health page and the
store ask, so the four of them agree about one lock. When the age rule passes, an issue is left alone for one of
two reasons and the log line names which: kept the build output of #<issue>: no lock to hold, so nothing of it was removed when its trees held build output and no
lock could be taken, and nothing to remove in #<issue> when none of its trees held
build output at all. Two more lines name a reason of their own: its lock is held, for an issue a cycle is running before the age is asked, and git could not name the gitdir of one of its worktrees, for a worktree record that no longer
matches a tree. The 7-day sweep of the dispatcher still takes the workspace
itself. The build output of a manual session, ~/tehas/dev/<name>.state/target,
goes only under TEHAS_CLEAN_MIN_FREE, of that age, and nothing else under
<name>.state is ever named: it goes only of a clone whose session lock, ~/tehas/state/dev/<name>.lock, no
tehas dev holds and whose container docker ps does not name, so a running
session keeps its build and a docker that will not answer keeps every one (see
tehas dev).
The same run prunes Docker's build cache of that age with docker builder prune.
That is the build cache of the whole host's Docker daemon, not only tehas's:
tehas is one project on one host, and the cache of anything else on it is made
again too. When less than TEHAS_CLEAN_MIN_FREE (30g by default) is free on the
file system of ~/tehas or on Docker's own, whichever has less, these two steps
run whatever the age - the cache is pruned whole and the log says clean: low on disk: <n> GiB free, under TEHAS_CLEAN_MIN_FREE=<value>: build output and build cache go whatever their age - while the other three steps keep the age, and a
free figure that cannot be read changes nothing; the setting sits above
TEHAS_CYCLE_MIN_FREE, so space goes before the poll stops starting cycles.
It removes images in two steps, and no volume. The first takes the dated tags of
the sandbox image past the newest two builds, whatever their age, keeping any tag
a container or a uid tag was made from: the current build and the one before
it, for a rollback. A build's <date> and <date>-product count as one build. The second lists the sha- tags
of upstream's base repository, the image a build pulled before the base was
built on the host, and removes those of that age with one docker rmi each: the current
commit's base, a base a container was made from, and a base a kept release-
tag of the sandbox image stands on all stay: the kept releases are the
release- tags of that image in docker's own list, so no version is assumed,
none is left out, and a host that holds two of them keeps the base of each. Nothing else is offered to docker:
every name it is handed is a tag of that one repository, and the step never
removes the images that have lost their tag. A container is what keeps an image
here: tehas work runs its cycles from the sandbox image, so one an existing
container was made from stays whatever its age. Preview images are
tehasbot preview's and no step here touches them; a docker that answers no
image list, or nothing about the containers on the host, removes nothing, since
an unknown is never a reason to take an image away. Volumes are a person's call.
The third step is the host's scratch: old files under ~/tehas/tmp/dl, where
bootstrap.sh keeps what it downloads, and under ~/tehas/tmp/node-compile-cache,
old ~/tehas/tmp/analytics-facts.* files a killed analytics call left, the
~/tehas/tmp/health.* report a health run killed by the poll's bound left
unpublished, old
~/tehas/tmp/tehas-test.* directories a run left behind, and the copy of the
sandbox recipe - ~/tehas/sandbox/sandbox-uid.Dockerfile, or its
sandbox-uid.Dockerfile.XXXXXX temporary - of that age a build killed before its
cleanup ran left beside the build script. Nothing else under ~/tehas outside
those directories is touched, and nothing outside ~/tehas: not
state, logs, dev, repos, preview or protolab. One line per removal and
a closing line with the bytes freed go to ~/tehas/logs/clean.log; tehasbot clean --dry-run logs what it would remove and removes nothing. The cleaner starts
no work, so the pause label does not hold it.
In the example the platform and the product are the same repository. They are
still two clones. A merged pull request changes the running factory only when a
person pulls ~/tehas/platform and runs install.sh.
What a factory machine needs
A factory is one machine. Nothing of it is shared with another factory: not the Docker daemon, not the ports the edge publishes, not the Unix user, not the name it is known by. A program that creates factories, such as an industry of factories, gets one machine per factory and runs the same two commands a person does.
| Needs | Why |
|---|---|
| systemd, and lingering on for the tehas user | The dispatcher is a systemd user timer. loginctl enable-linger is what lets it poll when nobody is logged in. sudo ./bootstrap.sh root enables it |
| A Docker daemon of its own | Every cycle, planning turn and index run is a container here. Sharing a daemon with another factory would put its containers in this factory's slice, and let one factory stop another's cycles |
| The published ports to itself | The docs server answers on port 8080 of TEHAS_HOST_ADDR and the edge router on 8081. Two factories on one host would want the same ports |
One Unix user who is in the docker group |
Everything tehas runs belongs to that user. The group makes it root-equivalent on this host, which is why the host is not shared |
~/.config/tehas/env, mode 600 |
The bot's GitHub token, the model endpoints' tokens, and the energy switches. Never in git. See Secrets and trust |
| An instance directory of its own | instance.env and models.json, found through ~/.config/tehas/instance-dir. See Instance settings |
Its own TEHAS_DOMAIN |
The edge makes uat-<pr>. and lab-<issue>. names under it. Two factories under one domain answer each other's previews |
The model gateway's baseUrl and key, when it uses one |
baseUrl of the provider in models.json, with the token as $TEHAS_MODEL_KEY_<NAME> in ~/.config/tehas/env. See A backup model endpoint |
TEHAS_ENERGY_URL, when the model is behind a gateway |
The energy sampler asks <baseUrl>/v1/cluster with the model's token. A gateway that does not pass that path through needs the cluster URL named here, asked with no token. See tehasbot energy |
TEHAS_ENERGY_SOURCE_URL, when the energy page should link a source |
The energy page ends with DATA SOURCE: <name>. This setting names the address that line links, and the page shows the name as plain text without it. Only an https:// address is used. See tehasbot energy |
| Disk for the sandbox image | What docker image inspect --format '{{.Size}}' tehas/pi-rukas:uid$(id -u) reports for the host's image, with room above that for the base a build makes and the layers it writes, and room for one image of a rollback. Before the first build the image is not there to be measured, and its size is upstream's base plus these steps: Bootstrap. A second instance user of one host builds its own image for its own uid and shares the layers of the first: What two instance users of one host share |
| Room to grow into, when the machine is a VM | The host runs as one virtual machine on a hypervisor, so its CPUs and memory are set at its maximum once, with room above what the factory needs today: <vcpu current='N'>MAX</vcpu> and memory as a virtio-mem device. Everything under the maximum then changes while the machine runs, and a restart of the hypervisor saves the VM with its cycles in it. No tehas command takes part in any of it. See Resize or restart the host. The other shape is a factory that is a container on another project's machine, as tehas-tehas is: it gains that room, and loses the live resize and the save, so a restart of the machine under it needs a drain first |
Installing a factory
A new host installs from a release: the installer, then tehas setup, as
A new project describes. The installer unpacks the
release into ~/tehas/versions/<version>, points ~/tehas/current at it and
runs that release's bootstrap.sh root <user>; tehas setup writes the
instance and runs ~/tehas/current/install.sh.
Underneath are the two commands below, the same from a release and from a platform checkout, run in this order, and run again as often as the platform changes. Neither asks a question, so a program can run them with nothing on standard input and nothing to answer:
sudo ./bootstrap.sh root <user> # packages, Docker, the docker group, linger, the slice, then the pinned tools as <user>
./bootstrap.sh check # one line per tool, and one each for the slice, its rule and its reload unit
# the instance's instance.env and models.json are in place, and
# ~/.config/tehas/instance-dir names the directory, or instance.env sits in
# ~/.config/tehas itself; the bot's token and the model tokens are in
# ~/.config/tehas/env, mode 600
./install.sh # copy what this checkout has that the host lacks
./install.sh --check # must exit 0 on a machine installed as the instance says
install.sh takes the instance from the host, as every command does: from
TEHAS_INSTANCE_DIR, else the one-line ~/.config/tehas/instance-dir, else
~/.config/tehas itself. It takes no argument, so the first install and the
hundredth are the same command. See Instance settings.
Re-running them is safe. install.sh copies only the files that differ, keeps
the old one as <name>.prev, and takes ~/tehas/state/update.lock so two runs
cannot overlap; a run that dies partway leaves its follow-ups owed and
--check says so. bootstrap.sh leaves a tool it did not install alone.
What an unattended run refuses to get past, and what each one means:
| The run stops with | What the machine is missing |
|---|---|
tehas: <NAME> is not set (see …/instance.env), exit 78 |
The instance directory, or a setting of it. Nothing is installed and nothing is written |
tehas: cargo is not installed… |
./bootstrap.sh user has not run, so the build tools are not there. install.sh puts the tool directories bootstrap.sh user used on PATH itself, so it finds them without a login shell |
tehas: no slice file on this host |
sudo ./bootstrap.sh slice, which is root's, and --check stays red until it has run |
| a tool directory named as writable by everyone or not owned by the user | One of the directories the tools live in (~/.cargo/bin among them). The run builds nothing until its mode is fixed (chmod o-w), because what cargo builds there is installed where every cycle runs it |
| a model key finding | ~/.config/tehas/env does not hold a TEHAS_MODEL_KEY_<NAME> that models.json names |
tehas: the commit of <tree> is not known… |
The tree is neither a git checkout with a commit nor a release with a COMMIT file. Nothing is installed. See The state store |
tehas: this release cannot migrate …; nothing was installed, exit 78 |
The store's line above it says why: a store older than v0.30, a damaged file, or a backup it cannot write into state/backup. Nothing is installed and the database is not changed. See The state store |
tehas: the store could not init… or …migrate…, exit 1 |
The store's line above it says why: corrupt, unreadable, future or busy. The files are installed and the database is not changed. See The state store |
--check exits 0 only when the instance loads, the slice file is the one this
checkout ships, the installed files match it, and no follow-up is still owed.
The lines it prints and what each one reports are in
Configuration comes from git.
Whether this really works on a machine no one has prepared by hand is proven on the features page; the test there is the first acceptance test of a program that creates factories, and what it finds broken is fixed here.
install.sh refuses a TEHAS_HOME it cannot prove is tehas's, because it
removes what it takes for stale under it: the home carries the marker
.tehas-home, which a run leaves and nothing removes, and a home that exists,
is not empty and holds no marker is refused with exit 78 and one line naming the
path (--check says the same and exits 1).
Instance settings
Everything that differs between instances is in the instance directory:
<instance dir>/
instance.env settings, shell KEY=value lines, no secrets
models.json Pi provider and model list, installed to ~/.pi/agent/
with the keys a model leaves out filled
settings.json optional: Pi's own settings, installed to ~/.pi/agent/
with the session model filled in from instance.env
sandbox.Dockerfile optional: a layer the sandbox image is built on top of,
by sandbox/build.sh. See
[the sandbox image](/new-project#5-the-sandbox-image)
The directory is found in this order: TEHAS_INSTANCE_DIR in the environment,
the one-line file ~/.config/tehas/instance-dir, then ~/.config/tehas itself.
The tehas-tehas host keeps its instance beside the secrets:
cat ~/.config/tehas/instance-dir
/home/boss/.config/tehas/instance
Rules that hold for every command:
instance.envwins. A setting of the same name in the environment is dropped. OnlyTEHAS_HOME,TEHAS_INSTANCE_DIR, the energy switchesTEHAS_ENERGYandTEHAS_ENERGY_URL, and the hooks the tests use are taken from the environment.- A missing or malformed setting stops the command with exit 78 and one line naming the setting, before it calls GitHub, Docker or git.
- Loading settings runs no git command, makes no network call and writes
nothing. The rules are the console's (
console settings load): with no console that can run, a command stops with 78 and a line that says so, and a login shell prints that line and goes on. instance.envis shell, sourced as written, in a shell of its own with the environment left after the sweep. What it exports is what the command gets. Acdin it moves no command, anexitin it is a refusal, and what it prints goes to standard error. Keep it writable by the tehas user only../install.sh --checkreports it if it is not, and reads the file no further once it has a finding: the owner and mode of~/.config/tehas/env, of~/.config/tehas/instance-dir, of the instance directory, ofinstance.envand ofsandbox.Dockerfileare checked before the settings are read. The last is not sourced, but it is built into the image every cycle runs, so its bytes carry the same trust.
The settings and their defaults are listed on the commands page and,
with comments, in instances/example/instance.env.
Configuration comes from git
The platform repository is the source. Change it there, merge, then on the host:
tehas update --check # report what would change; changes no file of the
# checkout or of the host (origin/ refs do move)
tehas update # pull, install, run the follow-ups that apply
tehas update --pending # run only the follow-ups the record lists: no git
You do not have to remember to look. tehas status has a platform line
that says how many commits the checkout is behind origin's default branch,
which tehasbot status fetches at most once an hour, and /health says
warn once it has been behind for more than a day.
tehas update is the three steps that took hand work before: fast-forward
~/tehas/platform from its remote, run install.sh, then run each follow-up it
asks for by name (units, sandbox, docs, edge, labels: see
Commands).
One line per step, and it stops at the first failure. It checks the instance
settings against the one required list, tehas-core's, which tehas_load hands
lib/config.sh and tehas_require_instance_settings checks: the same install.sh
checks, before it calls git. It changes nothing when the checkout has local
changes or cannot be fast-forwarded, and it never enables a unit or starts a
container the host was not already running: a changed unit is reloaded and
restarted when it was active, and a docs or edge router container is recreated when
it is up. Caddy reads its config when the process starts, so a changed Caddyfile
needs the container brought back up. Asking Docker or systemd whether one runs and
getting no answer stops the update; only a real answer counts, not an exit status
on its own, and a systemd that did not reload the unit files stops the run rather
than report a changed unit as applied. A step that fails leaves the ones before it
applied, and what is still owed is kept in ~/tehas/state/ (update-pending)
until it has run, so the next update finishes it instead of calling the host
current.
The third form is for the host that cannot do the first two: --pending runs the
steps update-pending lists and calls no git command and no install.sh. A
checkout at a release tag, or a remote that is a local path which stopped
answering, stops a plain update at its first step and leaves the follow-ups of
the install it did run owed; --pending finishes them. install.sh and then
tehas update --pending is what a program runs to bring a host current without
moving the checkout. See tehas update.
One update runs at a time. tehas update and a real run of install.sh hold
~/tehas/state/update.lock; a second one started meanwhile waits
TEHAS_UPDATE_LOCK_WAIT seconds for it (10 by default, 0 to refuse at once,
at most 300, anything else 78), and if it is still held prints another update is running and
exits 1 before it changes anything. The update hands its lock to the
install.sh it runs. --check takes no lock.
From a checkout of tehas on another machine, two scripts release and deploy.
Both fetch the remote's tags with --force, so a tag the remote re-points
follows the remote instead of stopping the script.
scripts/tag-release.sh gates the head of the remote's default branch, with
a green run of the release gate on that commit on the speed lane, or with
--local-gate in a temporary worktree here
(The speed lane), tags that commit as the next vX.Y.Z with an
annotated tag, and pushes the tag. It refuses a commit whose CHANGELOG.md
has no "Adopter action" for the release (Releases).
The pushed tag starts the release workflow, which publishes the signed tarball.
When the head carries a polyfill that the newest pi-rukas no longer needs, it
opens a pull request that removes it and tags nothing until that is merged
(Polyfills). Before it tags, it moves
every pinned tool to the newest minor and patch of its major version, and when
anything moved it opens a pull request for that and tags nothing until it is
merged (Pinned tools). The
script is a short exec of xtask tag-release (console/xtask/src/tag.rs),
which cargo builds from the checkout, so a checkout that releases needs cargo,
or a build named in TEHAS_XTASK.
scripts/tag-deploy.sh tehas-tehas refuses
unless the newest tag is the head of that branch, runs
. ~/tehas/env.sh && tehas update on the host over ssh, then checks that the
host's checkout is at the tag. With --check it runs tehas update --check
instead. The ssh destination has to log in as the tehas user. Put the user and
key in ~/.ssh/config, or give the ssh command in TEHAS_SSH:
Host tehas-tehas
User boss
IdentityFile ~/.ssh/<key>
Logged in as another account, the remote command fails with
~/tehas/env.sh: No such file or directory.
The steps are still there on their own. install.sh is what puts tehas on a host
the first time, before tehas update exists there:
cd ~/tehas/platform && git pull
./install.sh --check # change nothing, report up to nine results
./install.sh --check --tests # the same, and run the shell tests
./install.sh # copy changed files into place, keep <name>.prev
A version that adds labels needs tehas labels run again after the install.
The labels tehas:plan, tehas:planning and tehas:question, for planning on
an issue and the retry tick, are not in a repository until it has been.
--check prints one line each for the home itself, the instance settings, the
host's tools, the
slice, whether the sandbox image reads a cycle's images (Images:), the
installed files, the command the other accounts type where root installed one,
the follow-ups an earlier run left undone, and the tests. The tests run only
with --tests; otherwise the line says not run. Three of the nine
appear only where there is something to say, so a current host prints five
lines, each OK. The sample below is a host with a follow-up owed and no
root-installed copy:
Instance: /home/boss/tehas/platform/instances/tehas-tehas OK
Dependencies: OK
Slice: MISSING (sudo ./bootstrap.sh slice)
Installed: DRIFT (1 files)
differs: /home/boss/tehas/libexec/update
Follow-ups: NOT DONE (2 from an earlier run, see /home/boss/tehas/state/update-pending)
Tests: not run (./install.sh --check --tests runs them)
The installed files are compared by content and by mode: a command that matches
the checkout byte for byte but is mode 644 where the file list says 755 is not
installed. --check says mode: <path> is 644, wants 755 and exits 1; a real
run sets the mode with chmod and copies the file again only when its content
differs too.
Pi rewrites ~/.pi/agent/settings.json itself when a person picks another
model: it sets defaultProvider and defaultModel and writes the file in its
own key order. --check compares that file by its keys, not its bytes, and
does not count those two as drift unless the instance's settings.json names
them. Any other key that differs is drift. A real run writes the file again,
with the instance's session model. ~/.pi/agent/mcp.json is installed at mode
600, as Pi keeps its own files.
A home the script cannot prove is tehas's answers with a Home: REFUSED line,
the reason under it, and not checked for the three lines that would have read
the home; it exits 1 and looks at nothing else. tehas update --check reports
that as something an update does not fix: a person fixes the home or the setting
that named it.
The Follow-ups: line appears only while ~/tehas/state/update-pending still
holds steps that were asked for and never ran. While it does, --check
exits 1, because a host with files matching and a step unapplied is not current.
Running tehas update runs them and clears the record
(Troubleshooting has the case in full).
The record is also the way to finish an install on a host that cannot run an
update. A checkout at a release tag has no branch to fast-forward, and a remote
that is a local path can stop answering, while the copies install.sh made are
already in place. tehas update --pending reads that record, runs the steps it
lists in the order they run, and calls no git command and
no install.sh, so it needs no checkout and no remote and no hold to be removed.
A program finishes an install with install.sh and then that command; see
tehas update.
One file of a host is not tehas's to install. sudo ./bootstrap.sh dev puts
host/login/tehas at /usr/local/bin/tehas as root, and an update can change
that source while the copy on the host stays as it was. When the two differ,
--check adds a Login: line naming the command that installs this checkout's
copy, and exits 1; a real install prints the same finding as a later: line.
install.sh writes nothing under /usr/local/bin or /etc/tehas and asks
sudo for nothing, so the difference is reported rather than repaired. A host
where bootstrap.sh dev never ran says nothing about it. See
Other accounts.
The Slice: line compares /etc/systemd/system/tehas.slice with
host/slice/tehas.slice in the checkout: OK, MISSING or DIFFERS. The
last two make --check exit 1, and so tehas update --check stays red, until
root has run sudo ./bootstrap.sh slice: every sandbox
container runs in the slice and none starts without it. A real run prints a
note: line for the last two, installs everything else and installs no slice,
which is root's step. The step installs two files beside the slice, the udev
rule and the unit that reloads systemd when memory comes online, and this line
compares the slice file only: ./bootstrap.sh check reports
those two as well, by file.
install.sh validates the settings first and installs nothing if they are
invalid. It prints one next: line per follow-up its changed files call for, and
restarts nothing itself; tehas update is what runs them. install.sh records
each of them as owed while it copies the file that calls for it. That is why a run
that dies partway does not leave the host looking current. It asks systemd for nothing,
but for the one case below:
a copied unit file is not in effect until systemd has reloaded it, and that reload
belongs to the step that restarts the units. A file edited directly on the host
shows up as drift in --check.
A run that copies a changed versions.env also prints
later: <checkout>/bootstrap.sh user (versions.env changed; until it runs, --check says Dependencies: NOT OK).
tehas update rebuilds the sandbox image for that change but does not run
bootstrap.sh user: it fetches from the network and replaces the tools under
the tehas user's home and the pi-rukas checkout. Run it yourself, as the tehas
user, once the update has finished and no cycle is running:
cd ~/tehas/platform && ./bootstrap.sh user
The line is printed only by the run that copied the file. After that only
--check says it, as Dependencies: NOT OK, and only for a tool at another
version: a changed npm lockfile with the same version is not reported there
(see Bootstrap).
On a host installed from a checkout pi-rukas is followed, not pinned, so its
commit can move with no versions.env to copy; a release pins one commit,
which moves only with the next release. tehas update prints the same line, once per run, when
the commit the sandbox image was built on is not the commit the host's clone in
~/tehas/repos/pi-rukas is on: the image moves to what is followed, the clone
moves only when you run the line. Both follow the same PI_RUKAS_FOLLOW, the
instance's when it sets one, so once bootstrap.sh user has run the clone is on
the image's commit and the line is not printed again. It reads the image's
tehas.rukas label and the clone's HEAD, and says nothing where either has no
answer, so a host with no clone or an image with no label is left as it was.
Each file is copied to <name>.new beside the installed one and renamed over
it. A cycle that starts during an install runs the old file or the new one,
never part of one, and an install that is stopped or fails partway leaves the
file it was copying as it was.
How the dashboard's files are named and cached
The manual and the front page are not copied from host/ as they stand.
install.sh first asks the console to stage them (console update assets,
console/ops/src/update/assets.rs), which copies host/fun and host/docs to a
scratch directory and, for each <script src="/fun/X.js"> and each
<link rel="stylesheet" href="/fun/X.css"> of fun/index.html,
fun/business.html and docs/dashboard.frag, puts a copy of that file beside
it under the name X.<hash>.<ext>, where <hash> is the first 12 hex digits
of the sha256 of its bytes, and rewrites the tag to name it. A file in a
subfolder is copied and named in that subfolder: /fun/factory/X.js becomes
/fun/factory/X.<hash>.js. The two syncs then
install the stage, so ~/tehas/fun and ~/tehas/docs hold exactly what the
stage holds and a hashed name of older content is removed as stale with any page
that went away. The pages keep their own names, and they are copied after every
other file, with the stale files removed last: an install that fails partway
leaves the old pages, which still name files the home has.
Every file in ~/tehas/fun and ~/tehas/docs belongs to tehas: a file the
checkout does not have is removed, in a folder the checkout has too, such as
fun/kit/. Keep your own files elsewhere. A directory there that the checkout
does not have is kept, and the install says tehas: kept <dir> each time,
since tehas keeps no record of the directories it made. When a release drops a
folder, the install names it so; remove it by hand.
A symbolic link in ~/tehas/fun or ~/tehas/docs, in the checkout's
host/fun or host/docs, or either of those itself a link, stops the install
before it installs anything, and so does a name that is a directory in the home
where the checkout has a file, or the other way round. The install says which
path it is, and nothing is written through it or removed behind it. Move it
away, or replace the link with a directory or file of its own, and run the
install again.
The docs server caches the two kinds differently (host/edge/docs.Caddyfile):
a script or stylesheet whose name has 12 hex digits of its own in it, in
/fun/ or in a folder under it, is served
public, max-age=31536000, immutable, because such a name can only ever hold
the bytes it was named for, and every page is served no-cache, so a browser
asks about the page each time and reuses what it already has of the files it
names. install.sh gives a changed file a new name, so a new install is seen at
once and nothing has to be waited out or forced.
Three things keep the name they have and are served no-cache, so a browser
revalidates them on each load and never runs a cached old copy beside a new
page. The theme stylesheet,
which a page's template names at the request as
/fun/theme-<design>.css, so no file of the checkout can be hashed for it. Any
file that is not a script or a stylesheet: a font, a logo, a share card. And a
module that another module imports by a relative address, such as
import "./x.js": only the module a tag names is hashed, and the files it
imports keep the names it asks for.
The kit in fun/kit/ is of the last kind: its modules and its Solid,
fun/kit/vendor/solid.js, are imported by a relative address and keep their
names. A module a tag names, such as an island's element file in
fun/factory/, is hashed in its own folder and the tag names it there,
/fun/factory/<name>.<hash>.js, so the relative addresses it imports, such as
../kit/island.js, still find the kit.
/favicon.ico, which browsers and crawlers ask for whatever a page links, is
answered with the icon the pages link, fun/favicon.svg, sent as SVG and
cached for a day.
Everything the server sends is compressed, zstd where the browser speaks it and
gzip otherwise. The files under /live/ and the two health addresses are left
alone, because the dashboard's console reads them with Range requests whose
offsets count the file's own bytes, and an encoded body holds none of those.
One file is written, not copied: version.txt, beside the pages in
~/tehas/docs and ~/tehas/fun. It holds the newest tag of the checkout and
the commit it was at when install.sh last ran, as v0.1.1+11b669d, and the
footer of every manual page shows it. --check does not look at it. The
footers of the two front pages read their versions from the factory's health
instead (/live/health.json, by fun/versions.js): tehas from
checks.platform, the pi-rukas the sandbox image runs from checks.rukas, and
the program that manages the factory from checks.manager when there is
one, as tehas v0.24.6 · pi-rukas v0.14.54 · manager v0.9.0. The same
module shows a banner at the top of both pages while a host message is set
(checks.hostMessages, from tehas host-message):
each message's level as a word (Alert, Warning or Notice), its text, when it
was set and its link. With no message there is no banner. A
rukas-version.txt an older image build left in ~/tehas/fun is no longer
read; install.sh leaves it where it is.
Seven installed files are compiled, not copied: the console of a running cycle,
the analytics program, the MCP server, the state store, the attachment checker,
the dispatcher and the cycle's supervisor, Rust programs in the Cargo workspace
console/ (the others are in console/analytics/, console/mcp/,
console/store/, console/attach/, console/dispatch/ and console/cycle/,
and the library all but the attachment checker share is in console/core/,
which holds the one probe of a lock file that the store, the dispatcher, the
health page and the cleaner ask).
A real run builds each with cargo in the checkout and installs them as
~/tehas/libexec/console, ~/tehas/libexec/analytics,
~/tehas/libexec/tehas-mcp, ~/tehas/libexec/store,
~/tehas/libexec/attach, ~/tehas/libexec/tehas-dispatch,
and ~/tehas/libexec/tehas-cycle. While outsource is on,
two more are built and installed: the model proxy, console/proxy/, as
~/tehas/libexec/tehas-proxy, with its unit tehas-outsource-proxy.service,
and the contractor program, console/contractor/, as
~/tehas/libexec/tehas-contractor. With it off none of the three is built,
copied or compared. The attachment checker fetches the files of an issue
and of a planning reply, judges who may attach them and how much is given,
reads their bytes, unpacks their zips, and composes what a cycle is told it was
given (see Tools). It holds GH_TOKEN only to pass it to gh and to
curl, on curl's standard input; what was fetched is read by the same program
run as a child with no environment but PATH. Without it a start or a planning
reply that links a file stops, with a reason that names no host path, one that
links nothing goes on with a manifest that gives nothing, a cycle given none says
it could not read the record, and the Protolab leaves a zip out. A host installed from a release tarball has neither
cargo nor console/: its programs are the ones the release packed
(Releases), and a release without a store installs only on a
host that has one. On a host with none, --check says so on a Store: REFUSED
line rather than as drift. Beside each, <name>.stamp holds two checksums:
of the source it was built from and of the program. A program is built again
only when its source has changed or the program on the host is not the one
that was installed. The console is the one exception: a real run asks cargo
for it first of all, because it reads the settings, and cargo answers at once
when nothing changed. That build comes after the proof of the home and before
the update lock, whose directory is a write to the home and waits for the
settings. It removes no earlier build, so a run the lock will refuse takes
nothing from the run that holds it. A console that does not build stops the run
with exit 1 before the settings are read. A program's source is read from the workspace's manifests by
console update sources: its own directory, the workspace's Cargo.toml and
Cargo.lock, and the directory of every crate it takes by path, without
target/, tests/ and src/tests.rs. The console's own directory is
console/ without the members' directories. So a change to one program alone
builds that program alone, a change to console/cycle/ builds the cycle's
supervisor and the console, which links it, and a change to console/core/
builds all seven. Each build asks cargo for
--offline first, so a host that has fetched once installs with no network.
The build that fetches is the slow one and takes a minute or two: analytics
compiles SQLite. When cargo says a crate is missing from its cache the build
is run once more without --offline, with a line that says so; a build that
fails again is reported from both attempts. A build that fails for any other
reason, a compile error among it, is reported as it is and not tried again.
One build that outlives TEHAS_BUILD_TIMEOUT is cut off and named as cut off;
the remedy is ./bootstrap.sh user, which installs cargo and its crate cache,
or a longer TEHAS_BUILD_TIMEOUT. --check compares the checksums and builds
nothing, so a program replaced on the host shows up as drift like any other
file. Every program that is due is built before any is installed, so one that
does not build stops the install before it has changed anything, and so does a
host without cargo. The build is
given no environment variable whose name holds TOKEN, SECRET, PASSWORD or
API_KEY. The cycle and the dispatcher call ~/tehas/libexec/analytics
(tehasbot cycle, tehas dispatch). The Deno
script the console replaced, ~/tehas/libexec/console.ts, is removed the way
the old commands below are.
Before there was a tehas command, ~/tehas/bin held one file for each
command (tehas-dispatch, tehas-work and so on). install.sh removes those
and --check lists them as stale. A cycle that was running before the install
still calls them by name. So the install removes them only while it holds the
dispatcher's lock itself. When a cycle or a poll holds it, they are left in
place and the install prints later: ./install.sh again when the running cycle has ended. The units systemd holds name them too, so this is the one case
where the install asks systemd to reload, and it leaves the files and prints a
later: line when the reload did not happen. A later: line is for a person
and is not a step: tehas update prints it and finds the files again on its
next run. Removing the old energy sampler asks for the units step, which
restarts a running one from the new file. An old command that cannot be
removed fails the install.
One thing it does besides copying, on a real run only: the product checkout's
origin/HEAD is refreshed, so the commands know the default branch without
asking the network. To pin another branch, set TEHAS_BRANCH. If the
repository's default branch changes later, run install.sh again.
Updating tehas
A host installed from a release updates from releases: tehas update --check
says which version is installed, which is newest and what each release between
asks the adopter to do, and tehas update moves to the newest. Each version is
unpacked beside the others in ~/tehas/versions/<version>, and
~/tehas/current points at the one in use. A host that develops tehas sets
TEHAS_UPDATE_FROM=git and updates from its platform checkout. See
tehas update.
A host on 0.30.x edits its renamed and removed settings and drains before it updates to 1.0: see Updating from 0.30.x to 1.0.
An update does not wait for the running cycles. Each cycle and planning turn
runs from its own copy of the code in ~/tehas/run, made when it started, and
install.sh replaces each file by renaming a new one over it, so what runs
ends on the version it began on while the next cycle starts on the new one. An
update restarts the services and timers of tehas that were running, never a
cycle's or a planning turn's unit. The one part a running cycle shares with the
new version is the state store and the analytics program, which are called
where they are installed: a store verb a released version calls stays for a
release after the one that stops calling it.
Move a checkout host to releases
A host installed before releases has a platform checkout at ~/tehas/platform
and no ~/tehas/current, so tehas update keeps pulling the checkout. To move
it to releases, once a signed release is published:
- Install minisign, which checks the signature:
sudo apt-get install minisign. The key it checks with is built into tehas. - Set
TEHAS_UPDATE_FROM=releaseininstance.env. - Run
tehas update --check, read the Adopter action of each release it lists, then runtehas update.
A checkout whose tag is newer than the newest release, such as a prerelease,
moves to the release of its own tag rather than back to the newest. When that
tag is not published, tehas update changes nothing and says so; name a
release with --to.
The checkout stays where it is and is no longer read. To go back to it, set
TEHAS_UPDATE_FROM=git and run ./install.sh from the checkout.
Rolling back tehas
On a host that updates from releases, go back with
tehas update --to <version>. A version still in ~/tehas/versions is not
downloaded again, and its sandbox image is put back if it still has its tag and
was built from the instance's sandbox.Dockerfile as it is now. To
stay there, hold the host, or the next tehas update moves it to the newest
again:
touch ~/tehas/state/update-hold # tehas update refuses while this exists
tehas update --to v0.8.0 # --to runs with the hold there
tehas update needs a console that starts. A release whose console does not
cannot update itself; the way back is the install.sh of a version still on the
host, see tehas update says the console does not answer.
install.sh keeps one <name>.prev beside each file it replaces, and only
one: a second install that changes the file replaces it. Copying a .prev
back shows as drift, and the next install undoes it. On a host that updates
from its checkout, the way back is the checkout. Hold it first, or the next
tehas update fast-forwards it to the release you left:
touch ~/tehas/state/update-hold # tehas update refuses while this exists
cd ~/tehas/platform
git log --oneline # the release to go back to
git reset --hard <commit>
./install.sh
git checkout <tag> does not do: tehas update refuses a detached checkout.
While ~/tehas/state/update-hold exists, tehas update exits 1 naming the
file and changes nothing, and tehas update --check says the hold is there.
tehas update --pending runs with the hold there and from a detached checkout,
because it moves nothing: the next: lines install.sh printed are its, not
steps you have to work through yourself. Run by hand, they are:
| Step | By hand |
|---|---|
units |
systemctl --user daemon-reload, then systemctl --user restart the units named |
sandbox |
~/tehas/sandbox/build.sh, or put an older image back by its date tag, as in Rolling back pi-rukas |
docs |
. ~/tehas/env.sh && docker compose -f ~/tehas/edge/docs.compose.yaml up -d --force-recreate |
edge |
. ~/tehas/env.sh && docker compose -f ~/tehas/edge/router.compose.yaml up -d --force-recreate |
labels |
~/tehas/bin/tehas labels |
They stay recorded in ~/tehas/state/update-pending, and install.sh --check
reports them, until tehas update --pending or a tehas update runs them. When a fixed release is out,
remove the hold and run tehas update.
The state store
~/tehas/state/tehas.db is the state store's database: an SQLite file, mode
600, in state/, which is kept mode 700. With WAL on, its -wal and -shm
files beside it hold rows too, so a readable state/ would be a readable copy.
No container is given it. Only one program writes it: the store,
~/tehas/libexec/store, which install.sh builds and installs with the
console, or takes from the release.
What is in it today: the schema, version 23 (PRAGMA user_version); meta,
which says when the database was made, by which version and commit of tehas,
and for which instance and repository; and the cycles' records: the approval
each start rests on (the dispatcher's), each cycle's start and end with its
image, settings, branch, result and progress (tehasbot cycle, tehas work,
tehas stop), and the last 50 lines of history of each issue; each park and
its question (tehasbot cycle, the dispatcher); and each planning session,
with its brief, its answers, the issues it filed, its open question and the
last 50 lines of history of its turns (the dispatcher); and the records
plugins keep, such as a prototype and the issue it was filed in (the store's
record-put, record-file, record-close and records; no plugin writes them
yet). What a planning turn
carries between turns is a directory beside its workspace,
~/tehas/work/<name>-plan-<issue>.keep. The scripts, tehas dispatch and
tehasbot cycle run the store, ~/tehas/libexec/store. The commands of the
console (tehas stop, tehas history, tehas export, tehas status,
tehas api, tehas state, tehasbot health, tehasbot clean's upkeep and a
cycle's review) call the store in their own process, with the same code, and
do not start the program; they still need it installed. tehas dispatch, tehasbot cycle, tehas work,
tehas stop, tehas history, tehas export and tehasbot health stop with
exit 78 before anything else when it is not installed.
install.sh makes and migrates it on every real run, under
state/update.lock. It passes --say, so the store prints the line you read
(store: made ..., or store: ... at schema <n>, backup ...) in place of its
JSON answer:
- When there is no
state/tehas.db, it runsstore init. - Otherwise it runs
store migrate --backup ~/tehas/state/backup. The store first copies the database intostate/backup/tehas-<schema>-<time>.db, mode 600, with SQLite'sVACUUM INTO, and then brings the schema forward. It never replaces a file: when that name is taken, as by an install in the same second, the copy istehas-<schema>-<time>-1.db, and so on to-99. A copy that cannot be made changes nothing. A database already at the version the store writes is still copied, so every install leaves one copy. Nothing removes old copies yet; remove them by hand when there are too many. A store at an older version is brought forward one step at a time, each step a transaction of its own, and the install keeps the database as it was under the name of the version it came with, such astehas-12-<time>.db, beside the copy the answer names,tehas-17-<time>.db. A run that stopped between two steps leaves the store at the last one with its rows; the next install goes on from there. - The oldest store it brings forward is the one v0.30.0 wrote, at schema 12.
v0.30.1 wrote 13, v0.30.2 to v0.30.6 wrote 14, v0.31.0 wrote 16 and
v0.32.0 wrote 17. The step to 13 keeps on
each approval what its start was, the step to 14 rebuilds
cyclesso itshowmay sayhost, a starttehas startapproved, the step to 15 adds the five outsource tables, empty, the step to 16 lets the action journal keep a write asunknownand writesmillwrightin every row that still saidfixer, and the step to 17 adds to the outsource tables, empty, the hash of a job's token and a contractor's last report. Every step keeps every row. - A store older than that, from a release before v0.30, is refused and left
as it was, with no backup written:
store: unreadable ... is at schema <n>, older than v0.30.0 wrote: update to a v0.30 release first, then to this one.install.shasks the store it installs first, withstore migrate --dry-run, so such a host stops with exit 78 before any file is copied and keeps the release it runs. Install any v0.30 release on the host first, then this one. - The same dry run, given
--backup ~/tehas/state/backup, writes the copies the migration writes and removes them again. Astate/backupthat is a link out of the home, or a disk with no room for the copies, stops the install with exit 78 before any file is copied, andtehas updateputscurrentback. The records an older tehas kept as files understate/are no longer imported: v0.30 imported them.
The store is told the version and commit of the tree install.sh runs from,
the instance directory's name and TEHAS_REPO. A checkout gives the commit from
git; a release carries it in its COMMIT file. install.sh --check does not
run the store and writes nothing.
A store that fails stops the install with exit 1 and its own line, which starts with one of these words:
| Word | What it means |
|---|---|
corrupt |
The file is not an SQLite database, or fails its check |
unreadable |
The file or its directory cannot be read or written, or a backup cannot be made |
future |
The database has a newer schema than this store knows, as after going back to an older release |
busy |
Another program held the database for more than five seconds |
The store never moves a damaged file aside. Read what the database holds with:
tehas state check
It prints the schema version, SQLite's integrity check and the rows in each
table, and writes nothing. A database that fails the integrity check exits 78
with corrupt and what failed, as any database the store cannot use does.
Backing it up. Copy the file with SQLite, not with cp, while tehas runs:
cp of a WAL database can take the file without the rows still in its -wal.
The copies in state/backup/ are made that way. For one more, run
./install.sh (~/tehas/current/install.sh on a host on releases), or, with
sqlite3 installed:
sqlite3 ~/tehas/state/tehas.db "VACUUM INTO '/path/to/tehas-copy.db'"
Keep the copy mode 600: it holds what the database holds.
Restoring it. This page has no restore steps of its own: use
Backups and restore. It drains the factory,
stops every unit that reads or writes the store, puts the copy in place, runs
tehas state check and starts the units again. The units are stopped rather
than the factory paused: a paused poll still writes the store, and one unit
left running keeps the old file open and goes on writing to it. The copy is a
daily one, tehas-<YYYYMMDD>.db, or one of the migration copies named above:
a migration that changes the schema leaves the database as it was under the
schema it came with and the one it went to, tehas-<old>-<time>.db and
tehas-<new>-<time>.db, and a restore after going back to an older release
needs one of those first, or the install stops with future.
Models
Three files name a model and they do different things:
| Where | Controls |
|---|---|
PI_ENSEMBLE_SUBAGENT_MODEL, _PROVIDER in instance.env |
The session, the agent driving the cycle, and every subagent role that has no model of its own |
.pi/settings.json in the product repository, optional |
Provider and model of the session, over the instance's |
PI_ENSEMBLE_MODEL_<ROLE>, PI_ENSEMBLE_PROVIDER_<ROLE> in instance.env |
One role |
models.json in the instance directory |
What the provider is and which models it offers |
Child agents do not inherit the session's model. Without the instance setting
they fall back to the first model in models.json, which may be a small one.
Changing the instance setting does not change the session's model.
./install.sh --check verifies that both named models are listed in
models.json.
In the example every role and the session use qwen3.8-flash-next on the
provider fleet.
What the endpoint serves right now:
curl -s "$(jq -r '.providers.fleet.baseUrl' ~/.pi/agent/models.json)/models" | jq -r '.data[].id'
An endpoint that needs a token (see below) answers 401 to this. Add
-H "Authorization: Bearer $TEHAS_MODEL_KEY_MAIN", from a login shell, which
has the tokens.
A backup model endpoint
A provider in models.json may name a second endpoint that serves the same
models, and a token for each:
"fleet": {
"api": "openai-completions",
"baseUrl": "https://llm.example/v1",
"apiKey": "$TEHAS_MODEL_KEY_MAIN",
"backupBaseUrl": "https://fleet.example/v1",
"backupApiKey": "$TEHAS_MODEL_KEY_FLEET",
"models": [ ... ]
}
- An
apiKeyis a word, such asunusedfor an endpoint that takes no key, or$TEHAS_MODEL_KEY_<NAME>. The token itself goes in~/.config/tehas/env, mode 600, asTEHAS_MODEL_KEY_MAIN=.... Never inmodels.jsonorinstance.env: both are in a repository.instance.envthat sets aTEHAS_MODEL_KEY_stops every command with exit 78. - Any other
$or!in anapiKeystops every command that starts a container, and the dispatcher, with exit 78, and so does a name that is not set../install.sh --checkreports both. It reads the tokens from~/.config/tehas/envitself, so a first install, or an update from a version that did not know them, finds them there. - A running service keeps the tokens it started with. After you change one
in
~/.config/tehas/env, runsystemctl --user restart tehas-energy; the dispatcher and each cycle read the file afresh. An update that changesenv.shrestarts the running units itself. backupApiKeydefaults toapiKey.- Either endpoint can be any OpenAI-compatible endpoint, a
viiwork mesh or not. Both are asked the
same way:
GET /models, with the token.
At each poll the dispatcher asks the main endpoint whether it offers the models the agents use on that provider. When it does not answer or does not offer one, it asks the backup. The poll holds only when both fail:
holding: no resources: the model endpoint does not answer, and its backup offers no models
While the backup is in use, each poll logs
model endpoint: provider fleet is on its backup, the main endpoint does not answer.
tehas work, tehas plan and tehas dev ask again when they start a
container. They give it a models.json of its own,
<state directory>/models.json, on the endpoint that answered and without
the backup keys, and the tokens it names as variables, by name. A contractor's container of outsource gets the same file
with every provider on the model proxy and its key named as
${PI_ENSEMBLE_API_KEY_<PROVIDER>}; no endpoint is asked for it. tehas work
prints tehas work: model endpoint: provider fleet is on its backup and writes
it to the preflight log. A container stays on its endpoint: when the main one
fails mid-cycle, Pi retries it as Provider retry says, and
the next cycle starts on the backup. The image descriptions pick the same
way.
The energy sampler asks the endpoint the dispatcher settled on for the
subagent provider, the one word in ~/tehas/live/dispatch.json, and samples
it only when it is a viiwork mesh. The cycles and the meter are then the same
endpoint. With no word in that file, because the dispatcher has not settled
one yet, it asks the main endpoint and then the backup as before, so an update
of the dispatcher never blanks the floor. An endpoint that is not viiwork gives
no meter, even when the backup is one: the section hides.
Provider retry
Pi retries a failed model request only as its settings.json says. The sandbox
image has no settings.json, so every container is given the one install.sh
put in ~/.pi/agent, read-only: the instance's, or the generic one in
host/pi/settings.json, with defaultProvider and defaultModel from
PI_ENSEMBLE_SUBAGENT_PROVIDER and _MODEL when the file does not name them.
The generic one sets:
| Key | Value | Without it (Pi 1.0) |
|---|---|---|
retry.provider.timeoutMs |
600000 | the HTTP idle timeout, 300000 |
retry.provider.maxRetries |
8 | 0: a failed request is not retried |
retry.provider.maxRetryDelayMs |
60000 | 60000 |
retry.maxRetries |
10 | 3 |
retry.baseDelayMs |
5000 | 2000 |
retry.maxAgentDelayMs |
120000 | 60000 |
httpIdleTimeoutMs |
120000 | 300000 |
Pi 1.5 reads httpIdleTimeoutMs at the top level only. An instance's
settings.json written for Pi 1.4 nests it under retry.provider; install.sh
moves it to the top level, and the log line below reads either place.
The retry.provider keys retry one HTTP request. The other three are Pi's
second layer: when a turn still ends in a retryable error, such as 429 no free slot, the agent waits and runs the turn again, doubling the wait up to
maxAgentDelayMs. Against a gateway that holds each request 20 s for a slot,
Pi's defaults give up after about 80 s. These values keep trying for at least
16 minutes. A busy model is a reason to wait, not to end the cycle. The
dispatcher does not count model slots before it starts a cycle: how busy the
model is changes faster than a poll.
A product's own .pi/settings.json is merged over it, so a product can change
these for its cycles. tehas work writes the values in effect to the cycle's
preflight log and prints them:
tehas work: provider retry: timeoutMs=600000 maxRetries=8 maxRetryDelayMs=60000 httpIdleTimeoutMs=120000 agentMaxRetries=10 agentBaseDelayMs=5000 agentMaxDelayMs=120000
unset means Pi's default. Without ~/.pi/agent/settings.json, tehas work,
tehas plan and tehas dev stop with exit 78 before they call Docker or git
or write anything: run install.sh.
A host name that only resolves on a private network is not known inside the
sandbox. Give the sandbox its address with PI_ENSEMBLE_HOST_ALIASES
(name:address, comma separated).
A model per role
Every agent of every cycle asks for the same model by default. Several cycles
at once, each with six lens reviewers, can take every slot that model has, and
then calls are refused with 429 no free slot. Give a role a model of its own
to spread the calls. In instance.env, where second-model is another model
models.json lists under fleet:
PI_ENSEMBLE_MODEL_CODE_REVIEW_SPECIALIST=second-model
PI_ENSEMBLE_PROVIDER_CODE_REVIEW_SPECIALIST=fleet
Role (<ROLE>) |
What it does in a cycle |
|---|---|
EXPLORE |
Reads the code before the plan |
DEVELOPER |
Writes the change, one per workstream |
ADVERSARIAL_DEVELOPER |
Reviews the change and argues against it |
CODE_REVIEW_SPECIALIST |
The lens review: all six lenses are this role |
OPS |
Makes the branch, writes the handoff |
These are the roles the pinned pi-rukas reads a model for. The session (the
project manager, which plans) is not among them: its model is the product's
.pi/settings.json. The six lenses are one role, so they share one model;
the pinned pi-rukas cannot give one lens a model of its own.
- A role that is not set uses
PI_ENSEMBLE_SUBAGENT_MODEL. With none set, nothing changes. _PROVIDER_<ROLE>defaults toPI_ENSEMBLE_SUBAGENT_PROVIDER.- Any other role name, a provider without its model, or a value of more than one word stops every command with exit 78 before it does anything. A misspelt role would otherwise run on the default model without a word.
./install.sh --checkreports a role's model thatmodels.jsondoes not list under its provider. The dispatcher holds starts while an endpoint does not offer one of the models, as it does for the default model.- The settings reach the cycle's container by name, as every
PI_ENSEMBLE_*setting does.
A role's model is still a model that can be busy. Nothing counts the slots a model has; spread the roles over models that different machines serve.
Limits and concurrency
Every sandbox container tehas starts runs in one systemd slice,
tehas.slice: a cycle, a planning turn, a tehas dev session,
the indexer and the containers of tehas check-product --sandbox. The slice's MemoryMax bounds
them all together. No setting describes the machine.
A cycle, a planning turn, a dev session, the indexer and the install and
gates containers of tehas check-product --sandbox each get the same seven
limits, fourteen words on the docker run line:
| Option | Value | What it does |
|---|---|---|
--cgroup-parent |
tehas.slice |
Puts the container in the slice |
--memory |
the slice's MemoryMax over TEHAS_SLICE_CONTAINERS, a quarter unless set |
A hard ceiling. At it the kernel kills the largest process in the container. The dispatcher starts no cycle while TEHAS_SLICE_CONTAINERS containers are in the slice, so their ceilings never sum to more than the slice |
--memory-swap |
the same value | No swap for the container |
--memory-reservation |
TEHAS_CYCLE_RESERVE, 2g unless set |
The container's floor. When the slice is full the kernel frees memory above the floors first |
--cpus |
the host's CPUs less one, never below 1. The host's CPUs are what nproc counts, or what the Docker daemon counts (docker info, NCPU) when that is fewer |
A CPU quota. The container may use no more CPU time than that many CPUs |
--pids-limit |
1024 for each CPU of the container's share, rounded up, from 2048 to 4096. The share is the quota divided by TEHAS_MAX_CYCLES, counted at most TEHAS_SLICE_CONTAINERS |
The most processes and threads in the container |
--cpu-shares |
1024 |
A CPU weight, the same on every container |
On a host with 16 CPUs and TEHAS_MAX_CYCLES=4 a container gets
--cpus 15.00 --pids-limit 4096; with 8 CPUs and the default ceiling of 7,
--cpus 7.00 --pids-limit 2048.
The Docker daemon counts the CPUs once, when it starts, and refuses a
--cpus above that count. A host given more CPUs while Docker runs, by a
resize or a raised container limit, has nproc count more than Docker
does. tehas then sizes the containers for Docker's count and says so in the
log of the command that starts them, for example tehas work: the host has 48 CPUs and its Docker daemon counts 16, so containers get --cpus of 15; restart the Docker daemon to give them the host's CPUs. Restart Docker when
no cycle runs (sudo systemctl restart docker). When Docker gives no count,
nproc's is used.
Every sandbox container also runs with --init: a cycle, a planning turn, a
dev session and the indexer. Docker's init is the first process
of the container, and it collects every process whose parent has gone. Pi is
the command of the container and collects only its own children. A process that
outlives its parent, as git's background housekeeping does, is handed to the
first process of the container, and without an init it is never collected and
counts against --pids-limit until the container ends. One pass of this
repository's shell tests leaves about 950 that way, so a cycle reached the
limit at its fifth pass and could start no process after that.
The quota is a ceiling, not CPUs held for the container: a container may use every CPU of the host but one, and several busy ones share by weight, about equally. A gate that runs while the other cycles wait for the model gets the whole host; four gates at once get about a quarter each. The weight is also what makes the kernel share CPU inside the slice at all, so every container carries it. The quota leaves one CPU to the host, its own services and the model backends among them. Every container has the same quota, so a cycle that starts first gets no more than one that starts later.
The pids limit follows the share, the quota divided by the cycles side by
side, because a container's processes are mostly what its gate runs side by
side, and on a busy host a gate gets its share of the CPUs, not the quota. At
most TEHAS_SLICE_CONTAINERS containers are in the slice at once (see
Limits that hold work back), which is
why the share counts at most that many. Measured on this repository's shell tests with an init: at most 108
processes at once with 16 test files side by side, 38 with 4. The floor of
2048 is for the agents, their tools and git around the gate.
Inside the container nproc still says how many CPUs the host has: a quota
does not change it. A gate that runs its tests side by side should size
itself from /sys/fs/cgroup/cpu.max, as this repository's scripts/test.sh
does, or it starts more than the quota can run. /sys/fs/cgroup/memory.max is
the same for memory: nproc knows nothing of the ceiling, and a pool sized to
48 CPUs in 12 GiB has its processes killed.
The share also sets how many runs of the gate pi-rukas makes at once inside the
cycle: tehas work passes PI_ENSEMBLE_VERIFY_CONCURRENCY, one for each two
whole CPUs of the share and each 2 GiB of the memory ceiling, the lower, at
least 1. That is pi-rukas's own rule for a host, applied to the container. A
run that waits for another does not count its wait against
TEHAS_VERIFY_TIMEOUT.
The gate under load
How long a gate takes depends on what else the host runs, so
TEHAS_VERIFY_TIMEOUT is sized against the gate measured with the cycles the
instance lets run at once (see The gate's bound and the cycles at
once). This repository's
scripts/test.sh also holds its next test file while the host's load average
is at its CPUs or above, so on a busy host its tests run one file at a time
and the whole gate gets slower than its share of the CPUs alone would make it.
This repository's whole gate, scripts/verify.sh, measured on 6 Nov 2026 on
a host of 16 CPUs (8 cores) with runs of the gate in other checkouts beside
it, the load average between 15 and 36 throughout:
| Run | Wall time | Result |
|---|---|---|
| A fresh checkout: the workspace built first | 55 minutes (3313 s) | passed |
| A second run beside it, started 22 minutes later, the workspace mostly built | 36 minutes (2143 s) | passed |
Both are above the default bound of 30 minutes. On 26 Oct 2026, with three
cycles at once on the tehas-tehas host, the gate ran 26 and 47 minutes in a
cycle. On a host that runs four cycles of this repository at once, a bound of
3600 seconds, with TEHAS_WORK_STALL above it, fits both runs above, the
first with little margin; a bound of 1800 fits only with fewer cycles at once.
The floor is a priority when the slice frees memory, not a guarantee against
the whole host: when the host itself runs short, the host comes first. With
the default reserve the host needs about 11 GiB of memory, because the reserve
may not be more than a container's ceiling. A smaller host sets
TEHAS_CYCLE_RESERVE lower.
The check that the sandbox can push, which tehas work runs for a few seconds before a cycle, is not in the slice and has no
limits. It is given the security options below. Previews, image builds and the
edge router are outside the slice too.
What a container may not do
A cycle, a planning turn, a tehas dev session, and the push check and the
product's install before a cycle all get the options below, from security in
console/core/src/sandbox.rs, beside the mounts and the variables. The list is
capability-shaped options and this round's bounded /tmp. The indexer is not
given them yet (issue #54 leaves it to a follow-up), so the bounded /tmp below
is not in that container either: when that follow-up calls the function, it
must say what the indexer gains, and not take the --tmpfs as a whole bundle by
default.
Each of these containers also starts as the tehas user, with
--user "$(id -u):$(id -g)", not as root. The image's entrypoint drops from
root to its own user with setpriv, which needs SETUID and SETGID; started
as that user it skips the drop. The image is built with the tehas user's uid
(tehas/pi-rukas:uid<uid>), so the uid has a name and a home inside it.
Every container tehas starts from the sandbox image or its base has
--pull=never: a cycle and its capabilities check, push check and install, a
planning turn, a review, a tehas dev session, the indexer, the memory's
vipune, the product check, the build's smoke runs and the questions the
dispatcher and tehasbot status ask the image. The image is built on the
host, and its name is also a name on Docker Hub. When the local image is gone, for example after
docker system prune -a, docker run ends 125 with No such image and the
command stops, instead of pulling an image of that name from the registry and
giving it the cycle's token and model keys. Build the image again with
~/tehas/sandbox/build.sh. tehas update does not: it rebuilds the image
only when its pins or its Dockerfile changed, not when the image is missing.
| Option | Value | What it does |
|---|---|---|
--cap-drop |
ALL |
Takes away every capability Docker grants by default: CHOWN, DAC_OVERRIDE, FOWNER, FSETID, KILL, NET_BIND_SERVICE, SETFCAP, SETGID, SETPCAP, SETUID, SYS_CHROOT, MKNOD, AUDIT_WRITE, NET_RAW |
--cap-add |
CHOWN |
npm install drops a package to its owner with chown(2), and Playwright's install of Chromium copies a cache tree that way. Both run in a gate of the product. Without it the gate fails with EPERM |
--cap-add |
FOWNER |
npm moves its staging directory onto its destination with rename, which is refused for a file one does not own even when the directory is writable. tar's unpack, cargo install of a built crate and a gate's own mv do the same |
--security-opt |
no-new-privileges:true |
No process in the container gains rights through its mode bits or file capabilities, whatever it runs |
--tmpfs |
/tmp:rw,exec,nosuid,nodev,size=<half of --memory>m,mode=1777 |
A /tmp that counts against the container's memory instead of the host's disk, where the writable layer it replaces sits on the host's root disk with no limit. The host keeps its own scratch under $TEHAS_HOME/tmp and sets TMPDIR there for its own commands, and TMPDIR is not among the variables given to a container, so a tool inside one that honours TMPDIR writes to this bounded tmpfs. The size is half the container's ceiling (--memory, from tehas-cycle sandbox limits), in MiB: about 2.7 GiB on tehas-tehas. Its pages count against --memory and cannot be reclaimed, so a tmpfs as large as the ceiling fills memory first and the kernel kills the agents, which frees nothing (cycle #353 on 2026-10-24, issue #761). At half, a full /tmp gives its writer ENOSPC and leaves the other half to the processes. A command with no usable ceiling gets no options and starts no container. Nothing prunes it during a cycle, and tehasbot clean reclaims the host's scratch and nothing of a running container's, so what a long cycle leaves there is what it runs out of. It stays exec because Docker's own default for a tmpfs is noexec and a product's gate is expected to write and run helpers there through npm, cargo and Playwright; no host of ours has been seen to need the bit, so that reason is an expectation, not an observation. With TEHAS_SCRATCH_DIR set, a cycle gets <dir>/tehas-<issue> bind-mounted at /tmp in place of this tmpfs: the tools write to the same path, the data is on disk and takes no memory, and the cycle removes it when it ends (the hourly cleaner takes what a killed cycle left). The host decides what is behind the path, normally a file system of its own at /mnt/scratch, mounted nosuid,nodev. tehas work measures the cycle's scratch every 10 seconds and stops the cycle when it holds more than TEHAS_SCRATCH_MAX (20g by default), or when the scratch's file system has less than TEHAS_CYCLE_STOP_FREE free (5g by default) and this cycle's scratch is the largest there (issue #1547: one cycle wrote 34.7 GB in two minutes and filled the host's disk). A scratch of more than 500,000 files and directories counts as over the cap and as the largest, since the measure stops reading there. Between two looks a runaway writer still gets up to 10 seconds, so a file system of its own is still the safer place. A planning turn and a tehas dev session keep the tmpfs |
What is left off the list on purpose: SETUID and SETGID, because nothing a
cycle runs becomes another user (the image has no sudo, the container runs as
one uid, and tehas gives it no setuid program to reach another); SYS_ADMIN,
the one capability that would let a container mount anything, which Chromium's
own sandbox would want, and Playwright's Chromium is run with --no-sandbox
instead; and NET_RAW, which nothing needs: the agents reach GitHub and the
models over HTTP with curl, git, npm and cargo, none of which opens a
raw socket. no-new-privileges:true breaks sudo inside the image, and
nothing in host/sandbox/Dockerfile installs it or relies on it.
The root filesystem stays writable, unlike a preview's: a cycle's gate installs
into its own tree and its caches, and a read-only root would need one --tmpfs
for every directory a tool writes in. The one --tmpfs above is given all the
same, so that the directory a tool writes the most into is the bounded one;
the rest of the writable layer stays unbounded. The process table is bounded by
--pids-limit, in the table above.
console/cycle/tests/work_container.rs, test/plan_test.sh and test/dev_test.sh pin each of
these words on the docker run line of their own container, and
console/cycle/tests/work_caps.rs pins the function that prints them. Whether a whole
cycle still builds, tests and drives a headless browser with them is not yet
seen on a host: see the sandbox row of the features page.
Nothing starts outside the slice. tehas work, tehas plan, tehas dev,
and tehas index ask once whether the slice is usable:
the slice is loaded from its file and has a MemoryMax, Docker uses the
systemd cgroup driver on cgroup v2, the cpu, memory and pids controllers
are there, and the reserve fits under the ceiling. If not, the command stops
with exit 78 and one line that says what is missing, before it clones
anything, calls GitHub or starts a container:
tehas work: no slice file on this host (sudo ./bootstrap.sh slice)
A cycle's container has its id written to ~/tehas/state/cycles/<issue>.cid
while it runs. That is how the cycle's container is told from the others in
the slice.
tehas dev prints how many more cycles the slice has room for before it
starts its session. The session's memory counts in the slice like any other
container's, so a session that uses a lot leaves room for fewer cycles.
A container that is killed
Memory is the one thing a container is killed for. A container that grows
reaches its own ceiling first, and the kernel kills the largest process in it.
When several grow and the slice reaches MemoryMax, the kernel frees file
cache, the floors last, and then kills the largest process in the slice. If
the process killed is a build step, the cycle goes on with a failed step. If
it is Pi itself, the container ends with status 137.
tehas work reads the container's own count of such kills while the cycle
runs. The cgroup goes with the container, so the kills that end a cycle often
come after the last look. When the container has ended, tehas work counts
the kernel log's oom-kill: lines that name the container's cgroup since the
cycle started (journalctl -k), and keeps the larger of the two counts. The
kernel rate-limits those lines, and reading them needs a user in the
systemd-journal group; without it the count is the last one the cgroup
showed. A count above 0 is in its output and in the comment that reports the
cycle:
tehas work: 2 processes in this cycle's container were killed for memory
The starts of a process that --pids-limit refused are counted the same way,
from the container's pids.events:
tehas work: this cycle's container reached its limit of processes, 41 starts were refused
A cycle whose container is at that limit can run no command, so its gate does
not run and its handoff may not be posted. The comment that reports the cycle
says the count, and the dispatcher's done line has it as forks_refused.
When the run named no cap of its own and no person stopped it, the cycle goes
on record with the cap process-limit:<step> (process-limit when no step
is known) and a reason that carries the count, so tehas history, the park
comment and the analytics row name it. A cap the run named stays. The comment
and the reason also say the limit the container had, from its pids.max, and
name the settings it follows, TEHAS_MAX_CYCLES and
TEHAS_SLICE_CONTAINERS; both are among the settings on the cycle's record.
A container that ends with 137 while the cycle was still running is reported
as killed: tehas work exits 137, and the issue is parked with
needs-human-attention and status killed in the comment. That is a
container that ran out of memory, or one that was stopped from outside, for
example with docker kill. It is not killed when tehas work stopped the
container itself, at the time limit or on a signal, nor when the runner had
already written its result. The cycle's record in the state store carries the
count as oom_kills.
Time limits
TEHAS_WORK_TIMEOUT bounds the cycle itself, TEHAS_WORK_STALL a cycle
that writes nothing, and TEHAS_CHILD_TIMEOUT one child of a cycle: pi-rukas
ends a child that runs past it, the backstop for a child nothing else stopped.
It is given to the container as PI_ENSEMBLE_SPAWN_TIMEOUT_MS, in milliseconds,
and is tehas' to set; pi-rukas alone allows two hours. It may be at most
TEHAS_WORK_TIMEOUT, so no child outlives the cycle that spawned it: a longer
one is refused with 78, because tehas would only see such a child when the
cycle itself ended. Before the limit comes the cycle's deadline,
PI_ENSEMBLE_CYCLE_DEADLINE: TEHAS_WORK_TIMEOUT less the handoff allowance.
The allowance is 8 minutes, and pi-rukas is given it as
PI_ENSEMBLE_HANDOFF_TIMEOUT_MS, so both sides count the same time for the
handoff. pi-rukas bounds every step by the deadline. After it pi-rukas starts
no new step and parks the cycle with the cap deadline and a handoff, so a
cycle that runs long ends at a step boundary with its branch and pull request
said, not in the middle of a step. The runner is
given TEHAS_WORK_TIMEOUT in whole minutes and ends the cycle itself, with
exit 30; tehas work stops a runner that is still there 300 seconds later.
Either way the cycle is timeout and goes on record with the cap
wall-clock and the step it was in. A cycle that
tehas freeze holds still is not
checked against the stall or the time limit while its container is paused,
and its time limit is moved forward by the time it was frozen; the runner's
deadline is not, so a long freeze can bring the cycle to it sooner. The steps around it are bounded too, so
a dockerd that stops answering or a network that swallows packets does not
hold a slot for ever:
| Step | Bound | After it |
|---|---|---|
| GitHub's answer for the issue before a cycle starts | 60 s a try, then a kill 10 s later; three tries | The cycle refuses its number and exits 65, with GitHub could not be asked what the number is (3 tries, the last: no answer within 60s) |
The image's --capabilities answer before a cycle |
120 s | tehas work exits 78, with gave no --capabilities answer |
| The push check before a cycle | 300 s | tehas work exits 3, with the push check did not end within 300s |
| The product's install before a cycle | 1800 s | tehas work exits 78, with the install did not end within 1800s in the .preflight file |
| The clone of the cycle's workspace, and each fetch that deepens a refresh's | 300 s | tehas work exits 78 |
docker stop at the end of a cycle, and on a signal |
60 s | docker kill, bounded the same way, and the line docker stop of tehas-work-N did not end within 60s, killing it |
| The console at the end of a cycle | 3 s, then 30 s after it is asked to stop (TEHAS_CONSOLE_WAIT) |
The console is killed, with the console did not stop within 30s, killing it |
| A call to GitHub in the report of a cycle that was stopped | 20 s, tried once | The call counts as refused. A label change that never happened leaves the issue tehas:running for the next poll |
A call of ~/tehas/libexec/analytics from a cycle or a poll |
5 s, then a kill 1 s later | WARN analytics <subcommand>: exit N, and the cycle or the poll goes on as without it |
| The stop of a cycle, its container and its report | 300 s (TimeoutStopSec of [email protected]) |
systemd kills the unit. The worst stop within the bounds above is about 277 s |
| The dispatcher's fetch of the product checkout | 120 s | WARN: could not fast-forward, and the poll goes on |
| The status, tidy or health run by a poll | 120 s, then a kill 5 s later | The poll goes on. A health cut off leaves the health file as the last poll wrote it, and the poll says WARN: the health file could not be written: <command> .... A status that did not end 0 leaves its files as they were, and the poll says WARN: the status command <command> exited <n>: the status files may be stale (or was killed at its bound or did not start) |
| A poll of the dispatcher | 1 hour (TimeoutStartSec of tehas-dispatch.service) |
systemd stops it. A poll runs no planning turn and no index run, so it has none to cut off |
| A planning turn | TEHAS_PLAN_TIMEOUT, then a quarter of an hour (RuntimeMaxSec of tehas-plan-<issue>.service) |
The next poll reports the turn as cut off |
| One child of a cycle | TEHAS_CHILD_TIMEOUT, given as PI_ENSEMBLE_SPAWN_TIMEOUT_MS |
pi-rukas ends the child and the cycle goes on without it |
| The code index | 30 minutes for the indexer, then 40 minutes for the unit (RuntimeMaxSec of tehas-index.service) |
The index stays as it was. The next poll starts the cycles |
[email protected] stops a cycle after 8 hours (RuntimeMaxSec), as the
last bound for a hang that none of these reaches. The stop is a TERM, and the
cycle is reported as one that stopped. A unit cannot read the instance's
settings, so TEHAS_WORK_TIMEOUT may be at most 25200, 7 hours: a longer one
is refused with exit 78. The hour between is for the stop and the report.
The 8 hours are wall-clock time from the unit's start, and time a cycle spends
frozen counts toward them.
TEHAS_PLAN_TIMEOUT may be at most 7200, 2 hours: the unit of a turn runs to
the limit plus a quarter of an hour, and one turn runs at a time. A planning
turn and the index run each run as their own unit, not inside a poll, so they
hold no poll and not its lock. A poll that finds the dispatcher's lock held
for longer than half an hour says so once in the log, as
troubleshooting shows.
TEHAS_MAX_CYCLES sets the most issues worked on side by side, each
in a cycle, a container and a workspace of its own. It defaults to the host's
CPUs minus one, at least 1, and a value above the host's CPUs is accepted. It
is a ceiling: the dispatcher starts fewer while the slice has no room. A
container's pids limit and its runs of the gate at once follow it (see
above); its CPU quota and its memory do not. There is no CPU or memory budget to set; an instance that still sets
TEHAS_WORK_CPUS or TEHAS_WORK_MEMORY is refused with 78 and one line naming
the slice file.
There is no auto for either count: tehas 1.0 removed the sizing that took
it from the host. auto is refused with 78 and one line that says
auto sizing is removed; set a number, which is also what an instance needs
when it wants workstreams (see the axis below).
TEHAS_WORKSTREAMS sets how many workstreams one cycle may run side by side,
inside that one container. It defaults to 1, and pi-rukas is always told it as
PI_ENSEMBLE_MAX_WORKSTREAMS.
A workstream is one developer agent and its review loop in their own worktree. pi-rukas plans up to that many per issue and folds anything beyond the limit into the last one, so no work is dropped at a low setting; it is done in sequence by fewer agents. pi-rukas plans parts that touch the same files as one workstream, but not parts that only share a symbol one of them adds: each part starts from the same commit without the others' new types and exports, so each fails its type check alone.
The factory has one axis of parallelism: issues side by side, one workstream
each. The two settings would otherwise multiply, and with them the agents
calling the model backends and the gates on the same CPUs: 4 issues of 4
workstreams are 16 developer agents and up to 16 full gates at once, in four
containers' quotas. So an instance may set TEHAS_WORKSTREAMS above 1 only
with TEHAS_MAX_CYCLES=1, one issue at a time. With both above 1
every command stops with exit 78 and one line that names both:
tehas: TEHAS_WORKSTREAMS (4) and TEHAS_MAX_CYCLES (7) are both above 1: choose one, ...
The default ceiling is the host's CPUs minus one, so on most hosts an instance that wants several workstreams also sets the ticket ceiling:
# in the instance's instance.env, then pull and ./install.sh on the host
TEHAS_MAX_CYCLES=1
TEHAS_WORKSTREAMS=4
It is read when a cycle starts; a running cycle keeps the value it began with. Two things it does not change:
- the six review passes on the finished pull request still run together
(pi-rukas's
PI_ENSEMBLE_SPAWN_CAP, default 64, is the ceiling there), - how many issues are worked on at once. That is
TEHAS_MAX_CYCLES.
Cycles that run side by side know nothing of each other:
- Two issues that touch the same files give two pull requests that conflict. Label such issues one after the other.
- The code index is refreshed only when no cycle is running. On a host that is never idle it falls behind the branch; the dispatcher's log says so each time.
- Each cycle writes only in its own workspace and in
~/tehas/work/<name>-<issue>.state, the directory made for it: its copy of the code index, its memory, Pi's sessions. What it caches under its home otherwise lives in its container's own layer and goes with the container. A cycle reads nothing another cycle wrote. - The cost is a cold start. Every cycle copies the index again (a second or two for this repository: the databases, not the indexer's logs or the staging files of a run that was stopped), and a product whose gates install packages downloads them again: minutes once per cycle for a large dependency tree, nothing after the first install within the cycle.
- A host upgraded from the version that mounted two Docker cache volumes,
pi-ensemble-cacheandpi-ensemble-bun-cache, still has them on the disk with what those containers wrote. Nothing mounts them now, andtehas indexwrites the code index into~/tehas/state/indexinstead. Removing the two volumes is a person's call:docker volume rmnames them. - The same change stopped mounting
~/.vipuneand Pi's~/.pi/agent/sessions. What earlier cycles and planning turns wrote there is still on the host and nothing mounts it now; a cycle keeps its memory and sessions in~/tehas/work/<name>-<issue>.state. Removing those two directories is a person's call too, and nothing moves what is in them: a manual session starts a new history in~/tehas/dev/<name>.state/sessions, and so does a cycle.
Where a container may connect
By default a container is on Docker's default bridge and can connect to any
address: the host's own ports, the local network and the internet. With
TEHAS_EGRESS=on in instance.env, a cycle, a planning turn, a review and a
tehas dev session are put on tehas-egress instead, and so are the two
containers before a cycle, the push check and the install of the product's
dependencies, an internal Docker
network with no way out and no address on the host. Each is given
HTTPS_PROXY and HTTP_PROXY (and the lower-case spellings, and
NODE_USE_ENV_PROXY=1 for node) naming the proxy, http://tehas-egress:3128.
The proxy is the container tehas-egress, on that network and on
tehas-egress-out, a plain bridge. It is ~/tehas/libexec/tehas-mcp egress,
the static MCP binary, in the Caddy image the docs server is pinned to: no
other image is trusted. It runs as the tehas user with a read-only root, every
capability dropped, 128m of memory and 512 processes. It connects only to:
github.com,api.github.com,codeload.github.comandobjects.githubusercontent.comon 443, for git, gh and downloads;registry.npmjs.org,crates.io,static.crates.ioandindex.crates.ioon 443, for npm and cargo;- the host and port of every
baseUrlandbackupBaseUrlin models.json; - the hosts of
TEHAS_EGRESS_HOSTS, a name on 443 orname:port, each word read by the one rule the settings load checks it with.
Anything else is answered 403 and the proxy logs one line naming it:
docker logs tehas-egress. A tool that ignores the proxy variables reaches
nothing, so a failure is closed, not open. Names are compared, not addresses:
the proxy resolves a name itself, through the names of
PI_ENSEMBLE_HOST_ALIASES first, which it is given too. A plain http://
request goes on with the Host of its allowed target, never the one the
client sent.
The first container that needs the proxy makes both networks and starts it,
under ~/tehas/state/egress.lock. Each Docker call of that step ends within
60 seconds, and a start waits for the lock 15 minutes at most, so a dockerd
that does not answer stops the start with the reason instead of holding the
issue's lock. It is started again when its list, the
binary or the image changed, which cuts the connections of the containers
running then. The network is held to what the previews' network is held to
(console preview network check): Docker 27.1 or later, which knows
gateway_mode_ipv4, and a network that is internal, of the bridge driver,
without IPv6 and with gateway_mode_ipv4 isolated, so the host has no
address on it. An older Docker, or a tehas-egress network that falls short of
any of these, stops the container with 78 instead of starting it open, and an
older Docker is not asked to make anything. For a network, remove it and start
again.
Checked on 2026-11-06 with the pi-rukas image on a development machine: curl,
git, gh, npm, cargo and bun went through the proxy, node 22 only with
NODE_USE_ENV_PROXY=1, and a direct connection or a name not on the list
failed. Not yet: a whole cycle on a host. An install that fetches from a
host not on the list fails with the cycle not started: add the host to
TEHAS_EGRESS_HOSTS.
The slice
tehas.slice is one systemd slice for every sandbox container tehas starts.
Root installs it once with sudo ./bootstrap.sh slice,
from host/slice/tehas.slice to /etc/systemd/system/tehas.slice.
Every sandbox container is started in it, with the limits above. Without it no container starts.
Its one limit is MemoryMax=75%: everything in the slice together may use
three quarters of the host's memory. It is a share, not a number, so the file
is the same on every host and no setting describes the machine. The other
quarter is for the host: Docker itself, the edge router, the previews, image
builds and the tehas user's own units. CPUWeight=100 is systemd's default,
written out, so the slice competes for CPU with the rest of the system on
equal terms. There is no CPU quota on the slice; each container has its own
(see above).
What the file leaves out, on purpose:
- No
MemoryHigh. Over that limit the kernel slows every process in the slice and kills nothing, so a full slice would stall. AtMemoryMaxthe kernel frees file cache and then kills the largest process in the slice. - No
MemoryLow. When the whole host is short of memory, the host wins. - No
ManagedOOMlines. tehas neither uses nor needs systemd-oomd. Where Ubuntu's systemd-oomd package is installed, it ships a setting that lets oomd kill a user's own service manager under pressure, the tehas user's among them. That is the package's doing, not this slice's.
To read what is in force:
systemctl show tehas.slice -p FragmentPath -p ActiveState -p MemoryMax -p CPUWeight
FragmentPath is the file it was loaded from and MemoryMax is a number of
bytes. A slice with an empty FragmentPath and MemoryMax=infinity is one
systemd made up for a name in use: the root step has not been run. An inactive
slice still answers from its file.
Another limit for one host goes in
/etc/systemd/system/tehas.slice.d/override.conf, by root, followed by
systemctl start tehas-slice-reload.service, the same one-shot reload the udev
rule asks for. tehas never writes that file.
The host's own size follows the machine: MemoryMax is a percentage, so a
virtual machine given more memory by its hypervisor needs no change here, and
the next container reads the new ceiling for itself. That is on
Resize or restart the host.
Sandbox image
tehas/pi-rukas:uid<uid>: the lean pi-rukas base below plus shellcheck,
tehas's jq (ahead of the base image's, the version the host runs), tsc at
TSC_VERSION (the kit's type check runs it), Rust at
RUST_VERSION with rustfmt and clippy, Playwright's headless Chromium with
fonts, file, and a Python image library. The last two are in the container only: bootstrap.sh installs
neither and its check does not look for them.
cargo's registry belongs to that user, so a gate that builds Rust can fetch its
crates; they go with the container. The Playwright install runs npm as root with the
cycle user's home, so its npm cache goes to /tmp and is removed in the same
step; the build stops when root owns anything in /home/vscode/.npm, where a
cycle's own npm would fail with EACCES. Near the end of the build, after every
step that runs npm as root, /home/vscode/.npm is made the cycle user's, and
the tool check, as that user, writes a file to the cache npm config get cache
names and stops the build when it cannot. The base is pinned by digest in
sandbox/Dockerfile, shellcheck, jq and tsc by checksum, codebase-memory-mcp by the
checksum of its installer plus a version read back from the binary
(CBM_INSTALLER_SHA256 and CBM_VERSION), and Playwright by the npm tree
beside it (sandbox/npm/playwright, whose package-lock.json fixes every
package in that tree by hash). versions.env holds the versions and the
checksums, and the build stops when a pin there does not match the file beside
the Dockerfile. A product whose gates need another toolchain adds it to the
instance's own sandbox.Dockerfile, which build.sh builds on top of this
image and gives the tag cycles run: see
the sandbox image. tehas's Node is in
/opt/tehas-node, linked into /usr/local/bin, and pi and the npm tools run
it by its path, so a layer can put the product's own Node first on PATH
(The product's Node). The platform's file stays
as this checkout has it, because a changed one makes tehas update refuse.
Three things the base carries are changed on purpose.
-
Rust is put at
RUST_VERSION, the versionbootstrap.shinstalls on the host and CI builds with. The base carries the stable toolchain of the day upstream built it, so the compiler a cycle's gate ran moved between builds. The build installs the pinned toolchain with rustup, with rustfmt and clippy, and makes it the default; the base's own toolchain stays beside it. rustup checks what it downloads against the channel's checksums. The build stops whenrustcdoes not answerRUST_VERSION, and the tool gate asks it again as the cycle's user. -
codebase-memory-mcp is put back at the version
versions.envnames, the onebootstrap.shinstalls on the host. The base installs it from upstream's main, unpinned, so its tool schemas moved under a host between builds and a code search call that worked in one cycle was refused in the next. The index a cycle searches is built by the same program in the same image, bytehas index, so pinning it fixes both halves at once. Whattehas indexrecords beside the commit is the id of the image that ran, not the pin it was told to use, because a host that pulled a new pin has not necessarily rebuilt the image. A run that finds a different id there, or none, sets aside what the other image wrote and builds from scratch, and puts it back unless this run wrote an index of its own, so rebuilding the sandbox image is enough on its own and no indexer ever updates an index it did not build. -
wigolo comes off PATH. The base installs it with npm's scripts off, which skips the native build of its better-sqlite3, so every call died on a missing bindings file and cost a cycle a call each time an agent reached for it. pi-rukas's own recipe preflights
command -v wigoloand says when it is not installed, so its absence is an answer and not a gap.
The image also carries the embedding model vipune searches with,
BAAI/bge-small-en-v1.5. vipune downloads it on its first search, and a cycle
cannot reach the publisher: the download failed and every search after it
answered an empty store. The build fetches the model's two files,
onnx/model.onnx and tokenizer.json, from huggingface.co at the revision
vipune asks for, and checks each against its sha256. versions.env holds the
model (VIPUNE_MODEL), the revision (VIPUNE_MODEL_REVISION) and the two
checksums. The files go where vipune reads them, ~/.cache/huggingface/hub of
the user a container runs as. The build then checks that the model works: as
that user, with the network shut off, it adds a memory to a scratch store and
searches it back. It stops when either step errors, writes anything to stderr,
or the search finds nothing, and when the base's vipune is not
VIPUNE_VERSION, because the version picks the revision. The image sets
ORT_INTRA_OP_NUM_THREADS=1: vipune sets no onnxruntime thread count, so
onnxruntime pinned a thread to each host core and, under a cpuset, wrote an
affinity error to stderr on every vipune call. With an explicit count it pins
nothing. It is an ENV of the image, not a variable a cycle passes, so every
container of the image has it. A build step has no cpuset, so the step above
cannot see a lost count; the smoke run below checks for it. When vipune is
bumped, bump the model pins with it: a vipune that
cannot find its model names the revision it wants.
To check an image by hand, with an empty store mounted where a cycle mounts its own:
mem=$(mktemp -d)
docker run --rm --network none --user "$(id -u):$(id -g)" -e HOME=/home/vscode \
-v "$mem:/home/vscode/.vipune" tehas/pi-rukas:uid$(id -u) \
sh -c 'vipune add "tehas dispatch reads label events" && vipune search "tehas dispatch" --json'
A step near the end of the build checks that every command a cycle's
instructions name, and the commands libexec/ gives a container (the one after
--entrypoint, or the one directly after the image), answers in the image, and
it stops when one is missing. Those commands are pi, pi-rukas's headless
runner at /opt/pi-rukas/bin/pi-rukas-headless, git, and
codebase-memory-mcp: they are how a cycle, a planning turn, tehas dev and
tehas index start. A base image that moved or dropped one of them would fail
every cycle at container start, which is what this step is for.
test/sandbox_test.sh reads those commands out of the docker run lines in
libexec/ and fails when the Dockerfile does not check one of them; a unit
that starts a container some other way is outside what it reads.
~/tehas/sandbox/build.sh
Each build is also tagged with its date, so
docker tag tehas/pi-rukas:<date> tehas/pi-rukas:uid$(id -u) rolls back (an
instance with its own sandbox.Dockerfile tags back <date>-product, the layer
the cycles run: see Rolling back pi-rukas).
Each image is several gigabytes, with Chromium and Rust in it. After a build
build.sh keeps the dated tags of the newest two builds, the new one and the one
before it (a build's <date>-product counted with its <date>), and removes
older ones (console clean dated). It keeps an older tag whose image a
container, running or stopped, was made from, or that a uid tag names. The
bases of the same uid other than this build's lose their tags too (console clean bases); their layers stay while a kept image stands on them. tehasbot clean keeps the same two builds, and takes the old sha- tags of upstream's
base repository that a host built before the base was tehas's own, each
removed by its own name (see tehasbot clean).
A build first asks the base image's runner what it supports,
pi-rukas-headless --capabilities. A base that does not speak the contract
versions tehas work reads (exit codes 1, result schema 5, stable NDJSON 1),
or whose work verb does not take --timeout, --json and --restart, is
not built on: the build exits 1 and names each gap. Whether the answer lists
PI_ENSEMBLE_ISSUE_IMAGES for manifest format 1, the manifest tehas writes
beside a cycle's images, is recorded as the label tehas.rukas.images. The
Dockerfile asks the base it stands on again and stops when the two disagree. tehas work, tehas plan, the
dispatcher and install.sh read the label; an image built without build.sh
carries unknown, which tehas reads as "not said" rather than as an answer.
A base that answers --capabilities can still start no run, which is what a
build cannot see from an answer alone: pi-rukas v0.14.30 to v0.14.40 passed the
check above and every work run on it ended at once, three cycles on
one host before anyone saw it. So before the uid tag moves onto an image this
build made, or onto the instance's layer above it, the build smoke-runs that
image: one work turn started inside it, in a container with no network
(--network none), no token and no model, small memory and pids bounds of its
own, and at most 40 seconds. A good image prints a step-started line within a
few seconds, the run ends there, and the tag moves; an image that prints no
such line, or a result that says its runner crashed, is refused and the build
exits 1. A refused platform image leaves the uid tag where it was. A refused
instance layer, like a layer that does not build, leaves it on this build's
platform image, without the layer, and the build's last line says so. After a started turn the smoke run adds a memory with vipune and
searches it back, in a second container with no network, as the build's uid,
on one CPU of a cpuset (--cpuset-cpus, the highest CPU the build may run
on). dockerd checks that CPU against the list it read when it started, so in
a container whose cpuset has moved since (Incus with limits.cpu) it can
refuse it; the check then runs once more on the highest CPU both the build
and dockerd name, and when they share none it says to restart docker.
Anything vipune writes to stderr there refuses the image the same way
and is printed in the build's log: it is how a lost onnxruntime thread count
shows, since only a cpuset refuses onnxruntime's pins (taskset does not). A
build with an instance layer smoke-runs both images. The run and the
decision on its output are tehas-cycle sandbox smoke-run, in
console/cycle/src/sandbox.rs. A smoke run starts no
cycle and reaches no model, so it costs the build
a few seconds, and it is not one of the containers a cycle is given.
An image that says its pi-rukas does not read them holds every issue whose
text links an attachment while TEHAS_WORK_IMAGES=on stands; other issues
start. A host with that setting that puts back an image from before upstream
merged the reader sets TEHAS_WORK_IMAGES=off first: putting it back is the
moment the hold becomes real. install.sh reports the answer it read from
the image, and the dispatch log names each issue it holds.
The build takes pi-rukas at the commit PI_RUKAS_FOLLOW names, as described
under pi-rukas comes from upstream.
build.sh --if-moved builds only when that is not the commit the current
image was built on, or when the instance's layer is not the one the image was
built from, and build.sh --check only says whether either moved. Both
first print which commit the current image is on, and the two sums when the
layer differs. The layer of an instance's sandbox.Dockerfile carries the
label tehas.layer: the SHA-256 of that file and of the files of the instance
directory its COPY and ADD lines name. A file changed, added or taken away
makes the sum differ, and so the next --if-moved builds. The
factory's health reports the same comparison of the commit and the layer
(checks.rukas.behind and checks.rukas.layerMoved), and the footers
of the front pages show the version the image runs from there. The
contract test proves the product's gates run inside the image, as the unprivileged user,
with nothing mounted but a clone:
T=~/tehas/tmp/contract-test
git clone -q ~/tehas/repos/tehas "$T"
docker run --rm --cgroup-parent tehas.slice --memory 4g --memory-swap 4g --user "$(id -u):$(id -g)" \
-e HOME=/home/vscode -v "$T:$T" -w "$T" --entrypoint bash \
"$PI_ENSEMBLE_IMAGE" -c '
sh .pi/worktree-setup &&
sh -c "$(grep -v -e "^#" -e "^$" .pi/verify-cmd-full | head -n 1)" &&
sh -c "$(grep -v -e "^#" -e "^$" .pi/smoke-cmd | head -n 1)"'
rm -rf "$T"
The container runs in the slice like the factory's own, so the dispatcher counts its memory while it is there.
What two instance users of one host share
The image is named per uid (tehas/pi-rukas:uid<uid>), and Docker shares an
image's layers by their content. A layer whose build read the uid can only ever
belong to that uid, so what decides how much of the image two instance users
share is where the uid enters the build.
It enters late. sandbox/Dockerfile does everything the uid does not decide
first - the base image, the Rust toolchain, cargo's registry, the distribution
packages, the code indexer, shellcheck, jq, tsc and the embedding model - and the
file ends where the uid enters: a stage that takes the one above it as its base. sandbox/build.sh builds
from those lines as they stand, with the uid's own argument carried to the stage
that reads it, so the remap, the read of the model as the cycle's own user, the
browser install and the tool gate are the only steps built for one uid. The remap
cannot go higher: each step between writes files, as root or as the user, and
remapping above them would leave what they wrote owned by the id that has just
moved. The step that remaps fixes the ownership afterwards, over the image's own
filesystem, so the image ends the same either way.
One file of the image is tracked, and the copy the build hands docker is written
from it at the moment it builds and taken back when the run ends, so the two cannot
drift and nothing is installed. Two names of the recipe are the contract between the
two stages: the build cuts at a line that reads exactly FROM shared, and the one
argument below it reads exactly ARG TEHAS_UID=. Both are read out of the tracked
file, and a recipe that holds either as anything else than a whole line is refused
before docker is asked. A link under the copy's name is written through and a
directory stops the build, so both are refused; a plain file is taken to be the
leftover of a build killed before its cleanup ran, and the build names the time it
was written and replaces it. tehasbot clean takes a copy of the age with the rest
of the host scratch, and install.sh reports one it finds in the directory it
owns as stale and takes it back when it installs. The name is ~/tehas/sandbox/sandbox-uid.Dockerfile, and the
repository gitignores it, so tehas update sees no local change in it and the build
is the only thing that decides what stands there. test/build_test.sh reads the
recipe docker was handed and says which step is shared and which belongs to one
uid. The console writes the copy owner-only (console sandbox stage,
console/ops/src/sandbox.rs, which also checks the recipe), and a link or a directory under the name
of one of the two is refused rather than removed: the cleaner takes a copy of that
name and shape and no other.
Since the base became tehas's own lean base, it is built
per uid too: its first layer makes the user at that uid, which is what saves the
remap's copy. So the layers below hold for two instance users of one host only
where their uids agree. Before that, a second instance user's build on a host
that already had the first reused the base and every layer above the remap, and
built only the steps after it: where much
of the image is shared, the cost of the second user is the last steps and not the
whole image. The sharing has not been measured on a host yet, and
features records the two measurements that would prove it - the layer
ids of docker history of the two images, and the time of the second uid's build.
A step added above the boundary is a step every instance user shares, so a step
that reads the uid, or holds it in its words, would silently give each uid its own
copy of every layer after it; the test/build_test.sh case that reads the recipe
docker was handed fails when one appears. That case also compares the two halves of
the copy with the two halves of the tracked file, in the order the build runs them,
so a staged copy that moved a step across the cut is caught too.
A second instance user needs what the first was given: its own instance
directory and its own settings, a checkout of the platform to build from, and a
place on the Docker daemon - bootstrap.sh root <user> is what puts an account
in the docker group, so a user that was never given it builds nothing. Its
tehas/pi-rukas:uid<uid> tag is its own, and so is the image it points at.
Two things are worth knowing about the sharing. The cache belongs to the daemon: on the usual host, where the instance users are all on one rootful daemon, the second build hits the layers the first built. To see it, build both images and compare the whole layer listings down to the remap:
docker history -q tehas/pi-rukas:uid<a>
docker history -q tehas/pi-rukas:uid<b>
What you should see, if the sharing holds, is the ids matching from the base up to
the remap and differing for the steps below it; the same ids are what docker
shares, so the second build is quick where the first was not. That comparison is
one of the two measurements features still records as owed, so read
it as the check to make and not as a result already seen. On a host that gives
each instance its own rootless daemon there is no
cache to share, and each user builds and keeps its own copy of everything; the
same is true when the first user's build has since been pruned, since tehasbot clean takes the dated tags past TEHAS_CLEAN_AFTER hours and the layers go with
the last image that needed them. See the cleaner.
The lean base
The base is tehas's own recipe, sandbox/base.Dockerfile, built by
build.sh from the host's pi-rukas clone at the commit followed. It follows
pi-rukas's .devcontainer/Dockerfile step by step on ubuntu:24.04 instead of
the VS Code devcontainer base, and leaves out what a cycle never runs or what
the sandbox layer installs again at pinned versions: glab, wigolo, Rust stable
(rustup only, the layer installs RUST_VERSION), codebase-memory-mcp from
upstream's main, huggingface_hub and its model download. vipune and oo are
built in a stage of their own at VIPUNE_VERSION and OO_VERSION, on
ubuntu:24.04 too: vipune's embeddings link the onnxruntime that ort-sys
downloads, which needs glibc 2.38 or newer and did not link on Debian bookworm.
That stage runs vipune and oo, so a binary that does
not start stops the base build.
The base is built from pinned inputs only. Both stages start from ubuntu:24.04
by digest. node, gh, bun and rustup are the versions versions.env names, each
download checked against its _SHA256 there before it runs; the first stage
builds with RUST_VERSION. pi, ctx7 and parallel-cli are installed from their
npm trees in npm/ beside versions.env, as bootstrap.sh installs them on
the host: build.sh hands that directory to the build as a context named npm,
and the build stops when a lockfile is not the one whose _LOCK_SHA256 is
recorded. pi is PI_VERSION, and the build stops when that is older than the
version pi-rukas's own recipe pins. To move the ubuntu digest, take the index
digest from docker buildx imagetools inspect ubuntu:24.04 and change both
FROM lines. Each apt step, of the base and of the sandbox layer, has apt
retry its fetches and, when the step still fails, runs it once more after 30
seconds: a mirror caught mid-sync answers with a hash mismatch that a quick
retry does not fix. The
user vscode is made at the tehas user's uid in the first layer, so the remap
of the sandbox layer finds nothing to copy: it used to store every file twice.
Playwright brings only its headless shell, since a container has no display.
On pi-rukas 686ed28 the base was 2.39G against upstream's 6.7G, and the sandbox image 5.57G against 11.5G; on v0.14.54, built for uid 1000, the base was 1.66G and the sandbox image 3.83G, and its smoke run started a step. The base is per uid, so two instance users of one host no longer share its layers.
pi-rukas comes from upstream
tehas takes pi-rukas from upstream.
PI_RUKAS_REPO in versions.env names the repository and PI_RUKAS_FOLLOW the
commit a host follows:
release:<line>, the default: the commit of the newestvX.Y.Ztag of that line, by version.release:0takes the newestv0.Y.Z,release:2the newestv2.Y.Z,release:0.14the newestv0.14.Z.versions.envnames the major version this tehas works with,release:0while pi-rukas is before 1.0, so a new pi-rukas reaches a host installed from a checkout at its nexttehas update. A new major version waits for a tehas release that moves the line. A release archive pins: itsversions.envends withPI_RUKAS_FOLLOW=commit:<sha>, the commit the line resolved to when the release was packed, so a host installed from releases gets a new pi-rukas with the next release of tehas (the pins).release: the newestvX.Y.Ztag of any line. A tag with a suffix, such asv1.0.0-rc1, does not count. Upstream marks its releases as pre-releases; tehas reads the tags, not that mark.branch:<name>: the head of that branch, for examplebranch:main.commit:<40 hex>: that commit, asked of no one, for a host that must keep one pi-rukas. A commit that is not 40 lower-case hex digits is refused with 78.
Any of these may go in the instance's instance.env, where it wins over the
line in versions.env for the sandbox build and for the host's clone, which
bootstrap.sh user moves.
An instance that sets none follows the line its tehas was shipped with. A load checks PI_RUKAS_FOLLOW when the
settings load and stops the command with 78 naming it.
One reading of these values serves the sandbox build, bootstrap.sh,
tehasbot clean and the release script: the console's, console rukas target <follow> <repo>, console rukas image <repo> <commit> and console rukas fetch <clone> <commit>
(console/core/src/rukas.rs).
What follows from it:
tehas updatemoves the sandbox image to that commit whenever it is not the commit the image was built on, also when no file of tehas changed. The base is built on the host fromsandbox/base.Dockerfileand the clone in~/tehas/repos/pi-rukasat that commit (git archive), taggedtehas/pi-rukas-base:sha-<first 12 characters>-uid<uid>: see the lean base. A clone that lacks the commit fetches upstream's tags, then the commit by its id (console rukas fetch <clone> <commit>): a release pins a commit, and once upstream re-points the tag it came from, no tag or branch may hold it. GitHub still serves it by id. A clone that still lacks it fails the update with a message that says so. A release'sPI_RUKAS_IMAGE_DIGESTno longer picks the base.tehas update --checksays whether the commit moved../bootstrap.sh usermoves the host's clone in~/tehas/repos/pi-rukasto that commit and runs its installer, once a console is there to name the commit: a release's own, or the oneinstall.shputs in~/tehas/libexec. That clone is whattehas devand an interactive Pi session on the host load. Cycles run the pi-rukas inside the sandbox image, so on an installed host it then runssandbox/build.sh --if-moved, which builds only when the image is not on that commit. A failed build stops it with the command to run again.- The health of the factory (
checks.rukas) names the commit the image runs, the one the host follows and the clone's, and sayswarnwhile the image is behind, or while its instance layer is not the onesandbox.Dockerfilesums to now. WithPI_RUKAS_FOLLOW=release:0the line ofversions.envstays the same from one pi-rukas release to the next, so noinstall.showes a build;tehas updaterunsbuild.sh --if-movedon every update, and health is what says a host that has not run one is behind.
The shell tests check that every argument the Dockerfile reads comes from
versions.env, except the ones sandbox/build.sh works out: the base, the
commit, the uid and whether the base reads images.
Nothing checks a new commit before a cycle runs on it, beyond the image's
--capabilities answer, and the dispatcher does not hold cycles back for one:
see Limits that hold work back.
Rolling back pi-rukas
Cycles run pi-rukas from the sandbox image, so putting the previous image back is the rollback, and it takes effect at the next cycle's start:
docker image ls tehas/pi-rukas # the builds, tagged by date
docker tag tehas/pi-rukas:<date> tehas/pi-rukas:uid$(id -u)
An instance with its own sandbox.Dockerfile has two tags per build, <date>
for the platform image and <date>-product for the layer on top of it, and
those are what cycles run. Tag back the -product one, or the rollback puts
back an image without the product's toolchain.
Each image carries the pi-rukas commit it was built with, as its label
tehas.rukas, and the dispatcher reads the commit from there. The cycle's
record in the state store has the commit and the image's id as the cycle's
container started.
On a host installed from a checkout, that holds until the next tehas update, which builds the followed commit again: hold off updates until
upstream tags a fix. A host installed from a release stays on the commit the
release pinned. On either, PI_RUKAS_FOLLOW in instance.env wins for the
sandbox image and the host's clone: branch:<name> for a branch whose head is the commit you want,
or commit:<sha> for one commit.
No cycle on the product fixes pi-rukas. A fix is made in pi-rukas and reaches
a host installed from a checkout with the next tehas update after upstream
tags a release with it, and a host installed from releases with the next
release of tehas.
Services
| Service | How it runs | Check |
|---|---|---|
| This site | . ~/tehas/env.sh && docker compose -f ~/tehas/edge/docs.compose.yaml up -d |
curl -i http://tehas-tehas:8080/health |
| Dispatcher | systemd user timer tehas-dispatch.timer, every 2 minutes, and tehas-dispatch.path, a poll as soon as a cycle, a planning turn or an index run ends |
tail ~/tehas/logs/dispatch.log |
| Planning turn | a unit the poll starts, tehas-plan-<issue>.service, one at a time. systemd stops it a quarter of an hour after TEHAS_PLAN_TIMEOUT |
tail ~/tehas/logs/dispatch-plan-<issue>.log |
| Code index | a unit the poll starts, tehas-index.service, before cycles start on an idle host. systemd stops it after 40 minutes |
tail ~/tehas/logs/dispatch-index.log |
| Energy use sampler, optional | systemd user service tehas-energy.service, every 15 s. It asks the endpoint the dispatcher settled on, the word in ~/tehas/live/dispatch.json. Enable it only when the model backend is a viiwork mesh |
jq .generatedAt ~/tehas/live/energy.json |
| Host snapshot publisher, optional | systemd user service tehas-top.service, every 5 s. It writes nothing unless TEHAS_TOP=on |
jq '.host.cpus, .host.load' ~/tehas/live/top.json |
| Protolab pages | systemd user timer tehas-protolab.timer, every 5 minutes |
tail ~/tehas/logs/protolab.log |
| Cleaner | systemd user timer tehas-clean.timer, every hour, the first time 15 minutes after boot. It removes build output, Docker's build cache, host scratch, the sandbox image's old dated tags and the old sha- tags of the base repository, each removed by its own name. install.sh copies the unit; a person enables it. The unit prints; tehasbot clean writes clean.log |
tail ~/tehas/logs/clean.log, and journalctl --user -u tehas-clean for a run that wrote nothing there |
| Edge router | . ~/tehas/env.sh && docker compose -f ~/tehas/edge/router.compose.yaml up -d |
curl -i http://tehas-tehas:8081/ |
| Previews | systemd user timer tehas-preview.timer, every 5 minutes |
tail ~/tehas/logs/preview.log, jq . ~/tehas/live/previews.json |
| Preview sweep | systemd user timer tehas-preview-sweep.timer, every 3 hours |
jq .lastSweep ~/tehas/live/previews.json |
| One preview | a container tehas-preview-<pr> |
docker ps --filter label=tehas.preview |
Every service in host/systemd sets NoNewPrivileges=yes: nothing a unit
runs gains rights through a setuid program. The three that never end,
tehas-mcp, tehas-top and tehas-energy, also have MemoryMax=256M. The
ceiling holds where the user's systemd is given the memory controller, as
current systemd does by default.
The docs server binds to TEHAS_HOST_ADDR, port 8080. Without the setting it
stays on 127.0.0.1. docker compose reads the address from the environment,
so each line above sources ~/tehas/env.sh first: run from a shell that has
not, the container is made from the defaults below.
Both containers have a read-only root with /config and /data in memory,
every capability dropped but NET_BIND_SERVICE, which the image's caddy is
marked with, and no-new-privileges.
Both compose files name Caddy by digest rather than by tag, with the version in
the comment above the image. versions.env records the version and the digest
together; preview/Dockerfile names the same digest, and test/edge_test.sh
checks the three agree.
The edge router binds to the same address, port 8081, and picks by the first label of the name it is asked for:
| Name asked for | Answer |
|---|---|
uat-<pr>. and anything after it |
The preview of that pull request, the container tehas-preview-<pr>. With no such container, a 404 that says no preview is running |
lab-<issue>. and anything after it |
That ticket's page in the Protolab, from ~/tehas/protolab/<issue>/ |
| Any other name | The Protolab by path: the list at /, a ticket at /<issue>/ |
The number is one to nine digits and does not start with a zero. Another uat- or
lab- name is a 404. Every answer of the router says noindex. Its
configuration is a fixed file and holds no domain: nothing writes it when a
preview comes or goes. It is on two Docker networks: one of its own for the
published port, and tehas-previews, an internal one that the previews are
on and the host has no address on. install.sh makes that network when
Docker is 27.1 or later, and says so when it is not: an older Docker does
not know the option that keeps the host out, and what it would make was not
tried. Where the network is there already
and does not keep the host out, install.sh leaves it and says why and that
it has to be remade. Troubleshooting has the lines.
Every unit and both containers are started by the operator. tehas update
restarts a unit that is already active and recreates a container that already
runs, and adds nothing. So a host installed before previews existed has the
units tehas-preview.timer and tehas-preview-sweep.timer installed and not
running until they are enabled. Previews has the steps.
The same is true of a restart of the machine itself, which is nobody's job but
the operator's: after a hypervisor restart the timers come back with the user's
session where lingering is on, and the two containers have to be brought up by
hand with the docker compose lines above. Where the machine is a virtual
machine, libvirt-guests is what brings the host itself back with its cycles
still running: Resize or restart the host.
Search engines are told to stay out: every page carries noindex and
/robots.txt disallows everything. TEHAS_SITE_INDEXING=on in instance.env turns
that off for an instance that is published and meant to be found, and adds
/sitemap.xml with the front page and the manual, each page dated by when its
file last changed on this host (an update leaves a page with the same bytes as
it was) and the front page by the last update that brought a new version; the
live data
under /live/ stays unlisted either way. The server reads the setting when its
container is created, so run the docker compose ... up -d line again after
changing it.
Every page carries structured data (JSON-LD) for search and answer engines,
whatever TEHAS_SITE_INDEXING says: the front page describes tehas as software,
with its licence, author and source repository; each manual page is an article
under the front page; and a page whose front matter names a section in faq:
has the ### questions of that section as an FAQ, read from the text.
Visitor analytics are optional and off by default. With TEHAS_SITE_ANALYTICS_SRC
(the https address of a script) and TEHAS_SITE_ANALYTICS_NAME (the name it reports
under) in instance.env, every page of the dashboard and the manual loads that
script, asynchronously. TEHAS_SITE_ANALYTICS_COOKIE=on adds data-cookie="true"
to the tag; a script that then sets a persistent cookie usually needs the
visitor's consent. The example instance uses this for its public pages. The
same docker compose ... up -d applies after a change.
The live console on the site
The live console of a running cycle shows what its agents did, the commands
they ran and the start of each result. It is masked, but it is still the
factory's logs, and the docs server has no sign-in. So by default the server
does not serve it: /live/console-<n>.txt and /live/console-<n>.txt.now
answer 404, and the console panels of the dashboard, the business page and
the factory floor stay empty; the dashboard and the floor still mark the
cycle live or ended. Everything else under /live/ is served as before.
TEHAS_SITE_CONSOLE=on in instance.env serves the console to anyone who can
reach the site, for an instance whose site is also its demo. A full key of
the MCP server reads the console either way, with
factory_console; a dashboard key does not. The same docker compose ... up -d
applies after a change.
Designs
The site has two designs, and the instance picks one for all of it with
TEHAS_DESIGN. A page's colours, typefaces, sizes, outlines and shadows come
from the design's theme file, and the design also picks the page at /:
TEHAS_DESIGN |
The front page, / |
Every page names | Logo and share card |
|---|---|---|---|
beesknees26, the default |
The business page | theme-beesknees26.css |
favicon.svg, tehas-logotype.svg, share-logo.png |
pixel |
The factory floor | theme-pixel.css |
factory.svg, share.png |
beesknees26 is ink and one muted green on a near-white ground, white panels
with soft shadows, IBM Plex, and no motion: light, with a dark set only where
the viewer picks it with the business page's mode button, kept in their browser.
pixel is the factory as a 16-bit game, in the Topaz bitmap typeface. It is
meant for a factory whose site is also its demo; a factory that sets nothing is
drawn in beesknees26 everywhere, / included.
The design draws every page: /, /floor, /business, /dashboard, every
manual page and the Protolab. The docs server reads TEHAS_DESIGN when its
container is created, so run its docker compose ... up -d line again after a
change. tehasbot protolab writes the Protolab's pages in the design, and
builds every page again at its next pass when the design changes. The edge
router is given no setting about looks: it serves the files the pages name.
Any value but beesknees26 or pixel stops every tehas command with 78.
TEHAS_THEME and TEHAS_LAYOUT are retired. A line that asks for the default
design, TEHAS_THEME=beesknees26, TEHAS_LAYOUT=business or an empty value,
loads and is dropped. Any other value, TEHAS_THEME=pixel and
TEHAS_LAYOUT=floor among them, stops every command with 78 and names the line
to take out of instance.env: set TEHAS_DESIGN=pixel instead.
Both pages are always there, at /floor and /business. The business page
reads the
same files as the floor: live/status.json, live/running.json and the
cycles' consoles, live/protolab.json, live/analytics.json,
live/epics.json and live/energy.json. Its console follows the running cycle's output, with a tab
for each cycle when there are several, as on the floor. Its live strip shows
only where the host publishes power, and its 10 days only once there is a
report. With no queue file it shows the floor's sample tickets and says so.
Both pages list the open epics from live/epics.json, one row each with a
block per sub-issue, filled when it is closed; a row opens to list the
sub-issues, open or closed, each linked, and a link to the epic. The panel
shows only where the file is there.
Its live charts cover the last 30 minutes, which is what energy.json holds.
A page asks for its theme by name, ~/tehas/fun/theme-<name>.css, and the docs
server and the edge router answer with that file: nothing is rewritten. The
docs server's pages are templates that read TEHAS_DESIGN for the name.
A theme is one file in host/fun/, theme-<name>.css, that sets every token
theme-pixel.css sets. test/theme_test.sh fails when a theme leaves a token
out, when a page names a colour or a typeface of its own, and when a page names
a theme other than the instance's design.
How the pages themselves are built, what they may use, how their parts are named and how big they may grow is on The front end.
Secrets and trust
~/.config/tehas/github-app.pem: the key of the factory's GitHub App, mode 600. Never given to a container: it is given a token narrowed to the product repository, from~/tehas/state/github-cycleor~/tehas/state/github-session, read-only.~/.config/tehas/env: no GitHub token.GH_TOKENandGH_CYCLE_TOKENin it stop every command with 78, since the factory acts as a GitHub App. It holds the model endpoints' tokens (TEHAS_MODEL_KEY_*, see A backup model endpoint), mode 600. The energy switchesTEHAS_ENERGYandTEHAS_ENERGY_URLgo here too (seetehasbot energyin Commands); loading the instance keeps them.~/.config/tehas/deploy_key: the read-only deploy key the platform checkout is pulled with.
Both are outside the repository and the tehas tree.
| Question | Answer |
|---|---|
| Who can start a cycle | Only an account in TEHAS_ALLOWED_LABELERS. The dispatcher checks who most recently applied tehas:ready, not just that it is there |
| What the label approves | The title and body as they were when it was applied. An issue whose text was changed afterwards by any other account, or by one GitHub no longer names, is skipped until the label is applied again. GitHub's times count whole seconds, so a change by another account in the second the label went on counts as afterwards. An approval of tehas start is by no account, so every change in its second counts as afterwards, even one by an account called host |
| What else starts a cycle | The retry box of a parked issue, ticked by one of those accounts. It counts once, and only in the question whose comment id the host has on record for that issue. Like the label, the tick approves the text as it was at that moment |
| Who can start or continue planning | The same accounts. A session starts when one of them applied tehas:plan. A turn runs on a tick or a reply from one of them to the question the session is waiting on |
| Who can put a ticket in the Protolab | The same accounts. tehasbot protolab checks who most recently applied tehas:prototype, and that the label is the pinned one, as the dispatcher checks tehas:ready. A title changed since by anyone else is not published. A label from anyone else counts as no label, and a page it had is removed. The pass stops with an error when TEHAS_ALLOWED_LABELERS names the bot's own login. The files beside a ticket are taken only from an owner, member or collaborator |
| What a planning container is given | A token narrowed to the product repository, with Contents and Pull requests write and Issues read, from ~/tehas/state/github-session (read-only), renewed every 5 minutes while the turn runs. Otherwise the same mounts and the same approve-everything mode as a work cycle's. The agent is asked to plan and file issues. Nothing in the container holds it to that |
| What an agent can do as the bot | With the narrowed token: push the branch, open and edit pull requests, and read issues. Its gh issue create, edit and comment go through the host's relay, which comments only on the cycle's own issue and on issues the cycle created, edits only issues it created during that cycle, never sets labels, assignees or state, refuses any text with <!-- tehas: in it, and allows 50 writes a cycle. The relay is a host channel under the rule that a container's mounts and variables are not widened (the relay). So a comment is the factory's question only if the host has its id on record in ~/tehas/state, which no cycle or planning container is given, and an answer counts only by who gave it |
| Where an agent's conversation is kept | In the container's own sessions directory: ~/tehas/work/<name>-<issue>.state/sessions for a cycle, ~/tehas/dev/<name>.state/sessions for a manual session. No other container reads or writes it, and a cycle's goes with its workspace |
| Does the token enter the cycle | The cycle token does, never the host's own. Every agent in a cycle's container, and the push check before it, has the cycle token as its GH_TOKEN, for the product repository only, with Contents and Pull requests write, Issues read and Metadata read. It is a second installation token of the app narrowed to that (#1814), kept fresh in ~/tehas/state/github-cycle, which the container is given read-only; the cycle acts as the app's <slug>[bot]. Without it a cycle does not start. Neither the app's own installation token nor its ~/tehas/state/github reaches a cycle. Issues are read-only for it, so a cycle cannot label an issue or comment on one with this token. A planning turn and a manual session are given a token of the same body from ~/tehas/state/github-session (read-only). pi-rukas pushes the branch and opens the pull request from inside, as the app's <slug>[bot]. Agent code can do anything the token can. So do the model endpoints' tokens that models.json names, as TEHAS_MODEL_KEY_*: Pi sends them. Agent code can read them and call the endpoints with them |
| What else enters the container | PI_ENSEMBLE_* settings, the bot's git name and email, the host aliases. Not the rest of the host environment |
| Host paths mounted | The cycle's own workspace, ~/tehas/work/<name>-<issue>, at the same path in every container; its own transcripts, ~/.pi/agent/ensemble-runs/issue-<issue>; its own state directory, ~/tehas/work/<name>-<issue>.state (read-write); its own models.json from that directory, mcp.json, Pi's settings.json (read-only). Only the last two are the same host file in every container; nothing one container writes is mounted for another |
| Not reachable from the container | The Docker socket, SSH keys, ~/.config/tehas, the platform checkout, the product checkout, the instance directory |
| What the host runs from the workspace | Nothing but the cleaner's one bounded git rev-parse of a worktree's gitdir, which reads no config of the tree and takes nothing from it. Every other git the host runs is in the product checkout, which no container has written. It reads three files of the workspace, as data: the product's .pi/settings.json, for the retry line of the cycle's log, and the runner's record of the attempt, .pi/work-state/<issue>.json or .pi/lean-state/<issue>.json. Each only as a plain file with no link on the way, and only up to a size bound. A cycle's outcome is the runner's result, from its standard output |
| The indexing container | tehas index runs the indexer, not an agent: a clone of the product read-only, and ~/tehas/state/index to write, which no other container is given; no network, no token, no capabilities and no-new-privileges |
| The network | Not restricted by default: the container reaches GitHub, the model endpoint and whatever else the host can route to. With TEHAS_EGRESS=on, only the hosts of the egress proxy's list, through the proxy. See Where a container may connect |
| Merging | The token could merge where the repository lets it. Nothing does, because AGENTS.md forbids it and the dispatcher never merges |
Two recommendations follow from that table:
- Give each instance its own GitHub App, installed on its product only. An app or a bot account shared by two instances means a cycle on one product holds a token that can write to the other.
- Put a branch protection rule on the product's default branch that requires a
person's review. That is what enforces "nothing merges on its own" on
GitHub's side. Requiring one approval is not enough: the bot has write
access, and its approval of somebody else's pull request counts. Require
review from code owners and name people, not the bot, in
CODEOWNERS. - Apply
tehas:readyonly to an issue whose text you have read. The label is the approval of that text.
console/cycle/tests/work_container.rs in the platform repository pins what the container is
given: the mounts, the variables and every other option of both docker run
calls, the security options of What a container may not
do among them.
A session by hand
tehas dev starts the same container for a person, and the table above holds
for it with these differences:
| Question | Answer |
|---|---|
| Who can start one | The tehas user, and the accounts in the group tehas, through one sudo rule. See below |
| The tree it works in | ~/tehas/dev/<name>, kept between sessions, where a cycle gets a fresh clone |
| git identity | The stored author of that clone, else the bot's. A label: it is not checked against anything |
| What else enters | A terminal, and TERM and COLORTERM from the shell. Nothing else of the host environment, and not ~/.config/gh |
| Where its build output goes | ~/tehas/dev/<name>.state/target, mounted read-write and named by CARGO_TARGET_DIR. A session's build output is kept with its clone, and the cleaner takes it only low on disk and untouched for TEHAS_CLEAN_AFTER hours - of a clone no session holds, never anything else under <name>.state; tehas dev says who clears it by hand |
| What the host runs from the clone | Nothing. The host runs git there once, to make it, and never again |
test/dev_test.sh pins the session's docker run the same way. Both commands
take the mounts and variables from console/core/src/sandbox.rs, so they cannot differ by
accident.
Other accounts
sudo ./bootstrap.sh dev boss alice lets the account alice start a session.
It puts three things on the host, outside any home:
| Path | Content |
|---|---|
/etc/sudoers.d/tehas-dev |
The group tehas may run ~boss/tehas/libexec/dev-login as boss, without a password. Nothing else |
/etc/tehas/manager |
One line: the tehas user's name |
/usr/local/bin/tehas |
The command those accounts type. It holds no setting and no secret |
What a member of the group gets, and does not:
| Question | Answer |
|---|---|
| The bot token | Yes, inside the session, as in any session. A member can push to the product and open pull requests as the bot. Add an account only if you would give it that |
| Docker, or a shell as the tehas user | No. The rule names one script, and the account is not put in the docker group |
| Which clone | The one named after the account. sudo sets that name; the caller cannot. Nobody enters another account's clone |
| The author | What the account's git configuration says. Not checked against anything |
| The arguments | An author, checked for its shape, and arguments for pi, which run inside the container |
| The environment | sudo clears it. dev-login loads the tehas user's own, as the timers do. TERM and COLORTERM are kept |
gpasswd -d alice tehas takes an account out. test/login_test.sh and
test/bootstrap_test.sh hold the rule and the two scripts to this.
/usr/local/bin/tehas is a copy of host/login/tehas, so an update of the
platform can leave the accounts typing an older command. No tehas command runs as
root, so none replaces it: install.sh --check reports it as Login: NOT CURRENT
and a real install prints later: sudo <root-owned copy>/bootstrap.sh dev boss.
Run that command again after an update that changed host/login/tehas, from
root's own copy at the new version: see
Root runs its own copy.
A host that ran cycles before the workspace existed gave its containers the product checkout itself. Replace that checkout once with a fresh clone, so nothing an earlier cycle could have left in it remains:
mv ~/tehas/repos/tehas ~/tehas/repos/tehas.old
git clone https://github.com/tehas-app/tehas.git ~/tehas/repos/tehas
./install.sh