Skip to content

Run the agent in the job's own checkout and home, through a copy-on-write view - #1333

Merged
max-sixty merged 22 commits into
mainfrom
sandbox-setup-from-actions
Sep 21, 2026
Merged

max-sixty merged 22 commits into
mainfrom
sandbox-setup-from-actions

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

A consumer's setup: steps are ordinary GitHub Actions steps that run as the runner, and until now nothing they prepared was visible to the agent: the sandbox got a separate home and a separate checkout, so every project had to reimplement its own setup a second time inside sandbox_setup:. That is a real cost to adopt tend on any repo with a non-trivial toolchain, and it is the thing this branch removes.

The agent now runs in the job's own checkout and home, with the job's PATH and environment, seen through a copy-on-write view. What setup: prepared — a toolchain, a warm cargo or npm cache, a generated file — is there at the path it was left at, with no configuration. The agent writes wherever the runner itself could, and nothing it writes reaches the runner's disk or any later step in the job.

The view

shared/steps/enter_view.py runs as root inside unshare --mount --propagation private and ends in exec, so the mounts die with the process tree and need no cleanup. The view is an overlay mounted over $HOME itself:

  • the lower layer is a read-only bind of that home, idmapped so the runner's uid/gid and the sandbox's swap places, identity elsewhere;
  • the upper and work layers sit in the per-run runtime container under /var/tmp.

The idmap is what makes the view writable. Overlayfs checks the accessing task's credentials against the lower inode's owner, so a runner:runner lower would refuse every create by the sandbox uid. It is a swap rather than a one-way map because overlayfs gives a copied-up inode the mapped lower owner, and an unmapped one — a root-owned file setup: left behind — refuses the copy-up. The merged root takes the upper directory's owner and mode, so the upper is chowned to the sandbox account and chmodded to the home's mode; without that, $HOME itself is root-owned inside the view and git config --global fails on .gitconfig.lock.

bwrap resolves binds through the parent mount namespace, so SRT's allowWrite re-bind of the home picks up the overlay unchanged.

Paths inside the home that the agent must not see are masked — a directory by an empty read-only tmpfs, a file by /dev/null. The masks cover the Actions runner's own installation and GitHub's file-command directory ($GITHUB_ENV and friends), minus the workspace and RUNNER_TEMP. The runner install directory is found by walking this step's own ancestry for Runner.Worker rather than by a hardcoded path.

Leaving every id but those two alone is also what bounds the view: the agent writes wherever the runner could, and no further. A directory only root can write stays unwritable, and a root-owned file only root can read stays unreadable; mapping uid 0 as well would hand the agent both.

Floors: kernel 5.19 (idmapped overlayfs layers) and util-linux 2.39 (X-mount.idmap, a userspace option that an older mount(8) silently ignores). The ubuntu-24.04 image the generated workflows run on clears both, and install-sandbox-runtime.sh already refuses any hosted runner that isn't noble.

One check per guarantee

A deliberate slim-down pass leaves the branch a net −294 lines against main. Each guarantee has exactly one mechanism:

  • agent_lifecycle.probe_view is the only verification: from inside SRT, before any untrusted code runs, it writes to the workspace and checks that every mask took. A mask that silently didn't mount stops the run. enter_view no longer re-checks its own mounts — a failing mount already stops the run.
  • strip_checkout_credentials is the only credential-stripping mechanism; persist-credentials: false was a second one doing the same job and is gone.
  • Post-agent PATH pinning is gone with its two tests. Outside its own view the agent can now write only its own home, the memory directory and the runtime container, none of which is on the job PATH.
  • The .claude/settings.local.json gitignore rule now goes in the checkout's .git/info/exclude, written next to where the settings file itself is written, instead of a global core.excludesFile that had to be saved and restored.

What a consumer sees

sandbox_setup: keeps its job — it runs against the PR's tree, which setup: cannot see — but it no longer has to rebuild what setup: already built. No config key changes and no workflow regeneration is required; every generated-workflow snapshot on this branch is identical to main's.

The security posture moves in one visible way, and docs/tend.example.yaml now says so: because the agent reads the runner's home through the view, anything setup: leaves readable there (a registry login, a cloud credential file), and anything exported to $GITHUB_ENV or set in job-level env:, is readable by the agent and so by anyone who can open a pull request. Log in only in steps tend does not run.

Testing

1219 Python tests pass, and all thirteen pre-commit hooks. The unit suite cannot reach the mount plumbing itself: proxy/test-setup-sandbox.sh does, in the test-sandbox CI job on a real Ubuntu runner, and it is green on this PR. Its first three runs each stopped one step further into the lifecycle, on things no unit test could reach:

  • SRT masked the runner's ~/.gitconfig. SRT resolves its mandatory deny paths (.gitconfig, the shell rc files, .git/hooks, .claude/commands, …) against the launching process's own cwd, and enter_view.py chdirs to the home, so the runner's real ~/.gitconfig got a /dev/null mask and git config --global failed before the agent existed. The SRT process now chdirs to the checkout — where the cwd sat before this branch, and the tree those protections are written for.
  • The test named a base branch origin doesn't publish. On pull_request, GITHUB_REF_NAME is <number>/merge; the test now takes GITHUB_BASE_REF, and the job fetches the base branch the way the generated workflows' own checkout does.
  • The test asserted a write the design doesn't allow, inside a root-owned directory. That assertion now checks the bound above instead: the read succeeds and the write is refused.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 17 commits September 19, 2026 15:00
#1324 made /tmp writable by adding it to SRT's `allowWrite`, which binds
the host's /tmp into the sandbox read-write at the same path. That is a
channel out of the boundary: a consumer's cache action saving a path
under /tmp would carry whatever the sandbox wrote there into the base
branch's cache scope, which the default branch's CI restores and builds
from. `tend-review` runs on `pull_request_target`, so the writer is
anyone who can open a pull request. The dispose sweep #1324 added does
not cover it — it removes top-level entries the sandbox uid owns, while
the write that matters lands inside a directory the runner already owns,
and it declines to delete anything at all when the reap left a live
process, which does not stop GitHub running the POST steps.

Deny /tmp instead. SRT mounts a tmpfs over a read-denied directory, so
the sandbox gets an empty writable /tmp of its own that exists only in
its mount namespace and dies with the process tree, and the runner's
never appears inside. Tooling that hard-codes a path there — NuGet's
build mutex, zsh's here-documents — is served exactly as before, which
was the point of #1324. Nothing tend needs sits in the host's /tmp: both
containers are under /var/tmp, and SRT's own bridge sockets and scratch
follow TMPDIR into the sandbox home.

The sweep, its unit tests, and the sticky-bit reasoning go with it. The
integration probe now asserts the stronger property: a runner-owned file
in /tmp is absent inside the sandbox rather than merely unremovable, and
the file the sandbox writes to /tmp never appears on the host.

Unreleased, so no consumer ran the shared /tmp: 0.2.11 predates #1324.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Two preconditions for handing runner-prepared directories to the sandbox.

Every generated job that names the `tend` environment now carries
`ACTIONS_CACHE_MODE: read`. A save from a tend job lands in the scope the
default branch's CI restores from: every tend trigger runs with the default
branch or the PR base as `GITHUB_REF`, never an isolated PR ref. `@actions/cache`
6.2.0 reads the variable and skips the save; `actions/cache` and
`Swatinem/rust-cache` have taken that bump on their default branches but not in
a release, so this is the forward half of the guard. tend's own hand-maintained
`review-reviewers.yaml` carries it too.

"Compute artifact name" was the one post-agent step resolving a command
(`jq`) from the job PATH, which a consumer's `setup:` prepends to and
`sandbox_path` can point the sandbox at. The name moves into
`token_usage.py`, which already runs `if: always()`, reads the event, and
emits outputs; the upload step reads it with a static fallback so a token
step that died early cannot produce an empty name. `Token usage` and the two
memory-Gist teardown steps now pin `PATH` like the rest, and a test holds
every post-agent step to that.

Both harnesses now key the artifact on the thread where the event has one,
`token_usage.py`'s `subject_number()` answering that rather than a second
event read: Codex runs on an issue or PR become recallable by name, and a
review relayed as a `repository_dispatch` keys the same thread as a comment
on it instead of falling through to the per-job id.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A consumer's `setup:` runs as `runner` against the runner's checkout and home;
the agent runs as `tend-sandbox` in a disposable clone with `denyRead` on
both. Nothing `setup:` prepares reaches it, so every project reimplements its
setup inside `sandbox_setup:` and re-fetches a cache the runner already has.

`sandbox_import` names the directories that cross, and they cross as copies.
The host filesystem is byte-for-byte what `setup:` left it, before the agent
and after: nothing is chowned, moved, or deleted. An absolute or `~`-prefixed
entry — `~` being the runner's home, the opposite of `sandbox_path`'s — is
copied to `~/imports/<basename>` in the sandbox home; a relative entry is
resolved against the runner checkout and copied to the same relative path in
the clone. The destination is derived rather than configurable, so there is
one path rule and a second field can be added the day a caller needs one.

The copy runs as the sandbox uid, which is what makes the boundary exact
instead of enumerated: host permissions decide what crosses, so a 0600
credential is refused by the kernel rather than by a list here that would
always be behind whatever a consumer's `setup:` installed next. A read the
sandbox cannot make fails the run naming the path, rather than importing part
of a tree.

That leaves only the checks a copy cannot make for itself: the entry exists
and is a directory, two entries do not collide on a destination, nothing under
the checkout's `.git` is imported, and a relative entry's destination inside
the clone is canonical — a symlink a pull request planted at `target` must not
choose where the copy lands. There is no cleanup step, no self-hosted gate,
and no refusal set standing in for ownership, because nothing is handed over.

Both destinations already sit inside paths SRT binds at their own names
(`AGENT_HOME`, the clone), so `sandbox_runtime.mjs` is untouched.

What a consumer gets depends on where the copy lands, and the docs say so
outright rather than leaving it to be discovered: content-addressed caches
(Go, Maven, Gradle, npm, uv) are fully warm anywhere, pointed at with
`sandbox_env`; a relative `node_modules` is fully warm; cargo gets the
download and the index but no compiled artifacts, because registry
fingerprints record absolute paths under `CARGO_HOME`; a `.venv` should not be
imported at all. The copy costs real time and real disk — `cp -a` turns pnpm's
hardlinks into separate files.

The hosted probe asserts the invariant directly: it checksums both sources
before the lifecycle, has the sandbox write into each copy, and checks
afterwards that the runner's originals are unchanged and carry no such write.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Three things that hold whatever `sandbox_import` is eventually rebuilt on.

`actions/checkout` was writing the bot PAT into
`$GITHUB_WORKSPACE/.git/config` as `http.https://github.com/.extraheader` and
leaving it there for the whole job, which made that file the most valuable
thing SRT's `denyRead` on the runner checkout was hiding. Removing it beats
hiding it, and nothing tend runs reads it: every later step takes the PAT
through `env:`, `prepare_agent_workspace.py` clones from the remote under its
own token and touches the runner checkout only for a local `git rev-parse
HEAD`, and `restore-sensitive-config.sh` runs `git restore` inside the
disposable clone. The token input stays — the fetch itself still needs it on a
private repository. It is a behavior change for a consumer whose `setup:` does
its own authenticated git operation in that checkout, so
`docs/tend.example.yaml` shows the form for passing a token, where someone
configuring `setup:` meets it.

`unreact_eyes` was the one generated step running after the agent — `if:
always()`, the PAT in `env:` — that resolved `gh` and `head` through the job
PATH. It now takes what the harness actions' post-agent steps take: an
absolute shell, `BASH_ENV: ""`, and the pinned PATH ahead of its first
command. `react_eyes` runs before the agent and keeps the plain form.

The hygiene test read only the two `action.yaml` files, which is how that step
stayed unpinned through the commit that added the rule. The rule moves into
`unpinned_steps`, stated once, and a second test renders every generated
workflow and applies it to each step after the one that calls the tend action.

Three stale claims, corrected where the code moved out from under them: the
sandbox home goes with the VM on a hosted runner but persists under a shared
uid on a self-hosted one; the PATH translation infers nothing about the runner
home, while `sandbox_import`'s credential list does exactly that and is named
as the stopgap it is; and neither `macros.yaml.j2` nor `_common.py` should
still say mention reaches the PR head with `gh pr checkout`, which
`prepare_agent_workspace.py` has done for some time.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A consumer's `setup:` prepares the environment their own CI uses, and the
agent saw none of it: it ran as a second uid in a disposable clone under
/var/tmp with the runner's home and checkout denied, so every project had to
reimplement its setup inside `sandbox_setup:`, and a cache that did not carry
across failed as a silent rebuild rather than an error.

The agent now works in `$GITHUB_WORKSPACE` and `$HOME=/home/runner` at their
real paths, with the job's own PATH and environment, through a copy-on-write
view that `shared/steps/enter_view.py` builds before the drop to the sandbox
uid: a read-only idmapped bind of the runner's home as the lower layer of an
overlay mounted over that home, with the upper layer in the per-run /var/tmp
runtime container. It reads what `setup:` left and may write anywhere; every
write lands in an upper layer no trusted process reads, and the runner's
filesystem is byte-for-byte what `setup:` left it, before the agent and after.
The namespace dies with the process tree, so there is no cleanup step that
could fail open. A toolchain, a dependency cache or a build cache is warm at
its own path with nothing to configure.

The idmap is what makes the view writable — overlayfs checks the accessing
task's own credentials against an inode that mirrors the lower one's owner, so
a runner:runner lower is EACCES for the sandbox uid however it was mounted —
and it is also what sets the read policy: the agent is the runner account for
file permissions on this tree. `docs/tend.example.yaml` states that to
consumers. Two directories inside the home are masked with empty tmpfs mounts,
both derived from the running job rather than listed: the Actions runner's own
installation, found by walking this step's ppid chain, and GitHub's
file-command directory. Tend's own runner-side secrets move out of
`$RUNNER_TEMP`, which is inside the view, into a 0700 directory in the runtime
container.

What this deletes, because the view replaces it: `sandbox_import` and the copy
machinery it needed (added earlier on this branch), the disposable clone and
its ownership handoff, the runner-home PATH translation and its
blocked-command shim, and the `ACTIONS_CACHE_MODE: read` job variable, which
guarded a channel that no longer exists. `prepare_agent_workspace.py` becomes
`event_checkout.py` and runs inside SRT, so Git parses a contributor's
packfile as the sandbox uid rather than as the runner and authenticates
through the proxy holding no token of its own.

The hosted integration test asserts the properties no unit test can reach: the
agent writes throughout the job's home and checkout, nothing it wrote is on
the runner afterwards, both masks are empty inside, Tend's secrets are
unreadable, and — as a negative control against the kernel — the same overlay
without `X-mount.idmap` refuses every write.

Floors: kernel 5.19 for idmapped overlayfs layers, util-linux 2.39 for
`X-mount.idmap`. A runner below either fails the run naming the floor.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`run-tend`'s privileges rule still described the old boundary — a PATH that
never reaches the runner's home — which is now the opposite of what a session
finds, and it ships to every consumer.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`HOME` and the four `XDG_*` variables are the sandbox account's in the agent
environment file, because the runner-side install steps read that file and run
before the view exists. The launch has to say the job's home instead — that is
what the view is for — and it was still saying the file's, so `~/.cargo`,
`~/.config/gh` and `~/.cache/uv` would all have resolved to an empty sandbox
home while the warm ones sat one directory away.

The supervisor now overrides all five at the launch, beside the two paths it
already overrides for the same reason. The hosted integration test asserts
`HOME` in the environment the harness binary actually received.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The view's staging directory is root-owned 0700, so the unprivileged `rm -rf`
between the Claude and Codex runs would have failed the step under `set -e`,
and an upper layer carried over would have let the first run's writes answer
the second run's reads.

The bot's commit identity moved inside the view with `HOME`, so the assertion
follows it: the setup hook reads back what `git config --global` resolves to
where a clone the agent makes itself would read it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Three defects found by review of the view, all in how the boundary is derived
or verified rather than in its shape.

The runner-install mask took the whole installation. On the default
self-hosted layout that directory also holds `_work` — the checkout,
`RUNNER_TEMP` and the tool cache — so every run on such a runner would have
died at launch, with an error naming a mask rather than the layout. It now
masks that installation's entries one at a time and keeps any the job's own
paths live under: still derived from the running job, still unable to grow
into a list. A directory takes the tmpfs; a file takes a read-only bind of
`/dev/null`, which is what `.credentials` and `.runner` need.

`X-mount.idmap` failed open. `X-` options are userspace options, so a
`mount(8)` older than util-linux 2.39 records it and ignores it: the bind comes
up un-idmapped, the overlay mounts, `findmnt` reports exactly what the
verification expects, and the run dies much later as an unwritable view with
nothing naming the cause. One stat after the bind makes the floor announce
itself. The verification of the masks moved to the same footing — what each
mask now *is*, rather than the filesystem under it — so neither half can pass
while the thing it covers is still readable.

And the docs claimed the file-command mask keeps `$GITHUB_ENV` back. It does
not: an export is an environment variable by the time the agent launches, and
the agent gets the job's environment. What the mask holds is a `$GITHUB_OUTPUT`
or `$GITHUB_STATE` value that never became one. Both `docs/tend.example.yaml`
and the security model now say which is which, and the consumer-facing rule
gains the case it was missing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Three more from review, all assertions that passed whether or not the boundary
was there.

The host-unchanged digest covered names, sizes and modes. "Byte for byte" is
the claim in the test's own header and in the security model, and an in-place
overwrite at the same length would have passed it — which is exactly the
overlayfs copy-up path an idmapped lower is most likely to get wrong, and the
one the setup hook never exercised, because it only created files. The digest
now covers contents and ownership, and the hook rewrites a lower file in place.

The in-sandbox probe swallowed every `OSError` from a masked path, which is the
right pass condition for a mode-0 tmpfs and also passes for a path that is not
there at all. It now requires the path to exist first, so a mask that landed
somewhere else is a failure rather than a silence.

Nothing positively asserted the runner's own service identity was out of reach.
The hook now sweeps the home for a `.credentials*` or `.runner` that reads back
non-empty — a sweep rather than a path, so it also fails if GitHub ever moves
those files somewhere the derived mask does not follow. That was named in the
security model as the residual to keep watching; it is now a red run.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`ACTIONS_*` and `INPUT_*` are the two namespaces the environment pass-through
withholds by shape — the runner's service channel, whose RUNTIME_TOKEN is write
access to the Actions cache and so the one route a sandbox write could take
into a later run, and the channel an action's inputs reach a step by, some of
them this job's real secrets. Both had unit coverage and neither had any in the
real boundary. The integration test now plants a value in each and greps the
environment the stub harness binary actually received.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Three more from review.

Checking a mask by emptiness alone passes on a mask that never mounted: a
directory that happens to be empty — which `_runner_file_commands` often is at
that moment — lists nothing either way. `enter_view.verify()` now asks both
questions of every directory mask, before the drop to the sandbox uid, where
the previous round had left the emptiness check alone. A masked file still
needs only the one, since nothing the runner keeps is already a character
device.

`identity_map` refused two ids that were equal, telling the operator they were
"outside the mappable range" when they were well inside it and merely needed no
swap. That is the shape wherever `tend-sandbox` was created with `useradd -g`,
so a self-hosted runner would have failed at launch pointing at the wrong
thing. Equal ids now emit the identity map for that id type, which still has to
be complete: an id the mount leaves out reads back as the overflow id.

And two files disagreed about the Git environment the event checkout runs in.
`restore-sensitive-config.sh` still claimed its caller disables inherited Git
configuration; it does not, now that `HOME` is the job's home. What that
disabling bought was keeping a global `filter.lfs.smudge` or `core.hooksPath`
from executing against a contributor's `.gitattributes` *as the runner user* —
which is no longer where these commands run. `event_checkout.git_environment`
says so, and the shell script points at it instead of contradicting it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`core.excludesFile` is single-valued and now resolves in the job's own home, so
setting it took away whatever global ignore file the runner image or a `setup:`
step had established — for the session only, since the write lands in the view,
but for every command the session runs. Tend's one rule is appended to that
file where there is one, and only falls back to a file in the sandbox
account's own home where there is not.

Three comments still described the world before the view: the config restore's
claim that a copy here would run as the runner user and follow a fork-planted
symlink to the checkout credential (which `persist-credentials: false` removed
and which no longer runs as the runner), the same sentence in the security
model, and `run_claude`'s pointer at a gitignore that setup_sandbox.py no
longer writes.

And the bundle stager now says why it is exclusive rather than idempotent: one
lifecycle per runtime container, so a second stops rather than executing what
the first left behind.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`enter_view` asserts the mount is private with findmnt from inside the
namespace it just made, where a mount that propagated out would still look
private to it. The integration test covered the consequence — the host's files
are unchanged — but not the mechanism, so it now looks for an overlay at the
runner's home from the runner's own namespace after the reap.

The header also says plainly what the test cannot claim: a `$GITHUB_ENV` export
does reach the sandbox, and this file demonstrates it, since the hook reads two
variables `plant` exported exactly that way. The mask holds back an output or a
state value that never became an environment variable; the two facts were
sitting side by side for a reader to reconcile.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`enter_view.py` is the first file under `ACTION_PATH` that root executes;
before this branch the runner-side steps all ran as the runner. For a generated
workflow that path is an immutable tag checkout, so the pinning is what carries
the property — worth saying, since a workflow pointing the harness action at a
local path would make its own checkout root-executable, and the fallback
argument (every generated checkout takes the base tree) is an invariant the
templates document rather than enforce.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The view made several mechanisms redundant; this deletes them and trims the
prose that accumulated around it. Net across the branch: −379 lines against
the base, from +939.

- `enter_view.py` drops its findmnt verification and the post-bind idmap stat.
  Mount exit status covers the mounts, and `agent_lifecycle.probe_view` checks
  from inside SRT, before any untrusted code, that the view is writable and
  every mask took. A file mask is recognised by type, since bwrap's nodev
  remount makes the /dev/null bind unopenable; a directory mask is a 0555
  tmpfs so it can be listed empty.
- The overlay's upper directory is chowned to the sandbox and given the home's
  mode: the merged root takes the upper's owner, so a root-owned upper made
  `$HOME` itself unwritable and `git config --global` failed.
- `persist-credentials: false` goes; `strip_checkout_credentials` already
  removes the persisted checkout credential before launch.
- The post-agent PATH pinning and its tests go: with the view and a private
  /tmp, the sandbox persists writes only to its own home, the memory
  directory and the runtime container, none of them on the job PATH.
- The `.claude/settings.local.json` ignore moves to the checkout's
  `.git/info/exclude`, written where run_claude writes the file, so a
  consumer's global excludesFile is never touched.
- The idmap negative-control CI step, the dead TEND_BOT_* plumbing into the
  setup step, and review-reviewers' stale ACTIONS_CACHE_MODE go.
- Docstrings, comments, docs/security-model.md and docs/tend.example.yaml say
  what holds now and stop recounting the design that preceded it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
# Conflicts:
#	docs/tend.example.yaml
#	plugins/install-tend/skills/install-tend/references/tend.example.yaml

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is red on this head, and both failures sit in the mechanism the branch introduces. main at the merge base (b953f68) is green on the same workflow, so neither is pre-existing.

test — three failures from a stale launch fixture. sandbox_runtime.mjs now reads GITHUB_WORKSPACE, but run_sandbox_runtime() in shared/steps/test_launch_sandbox_runtime.py still passes TEND_AGENT_WORKSPACE and TEND_RUNNER_WORKSPACE, so each launch dies with tend sandbox runtime: GITHUB_WORKSPACE is unset. Swapping those two entries for "GITHUB_WORKSPACE": str(workspace) takes the module to 11 passed locally. Those lines fall outside the diff, so I can't leave it as an inline suggestion — say the word and I'll push it.

test-sandbox — the lifecycle dies before it reaches the view's own assertions. It fails in agent_lifecycle.configure_git(): warning: unable to access '/home/runner/.gitconfig': Permission denied, then fatal: unknown error occurred while reading the configuration files, and git config --global user.name exits 128. probe_view passed just before it, so the overlay mounted and $GITHUB_WORKSPACE was writable — what the sandbox uid couldn't reach was a path in the home's root. Since this is the first run of the job, none of verify-srt's in-view assertions have executed yet.

One candidate worth ruling out first, because it would explain that error and is visible from the code rather than the log: the swap map is identity outside the two accounts, so identity_map emits u:0:0:<runner uid> and uid 0 stays uid 0 inside the view. Anything in the home that setup: left root-owned is therefore still root-owned to the agent, with ordinary DAC deciding. That is also what the new verify-srt assertion exercises — plant() creates sudo install -d -m 755 -o root -g root "$TEND_WARM_CACHE/root-owned" and the sandbox side asserts printf "agent\n" > "$TEND_WARM_CACHE/root-owned/written-by-sandbox" under the comment "Writable everywhere, in place, under root-owned dirs". A non-root uid has no write bit on a 0755 root-owned directory whatever the idmap does, so that assertion looks like the next failure after configure_git is fixed. If root-owned paths are meant to be writable the map needs to cover uid 0 too; if they aren't, both the assertion and the enter_view docstring's "a root-owned directory setup: left behind" framing need to say so.

Separately, and independent of CI: consumer_env in proxy/setup_sandbox.py now rejects any GITHUB_* name in sandbox_env, but Config.load in generator/src/tend/config.py only checks RESERVED_SANDBOX_ENV, which has no prefix rule. docs/tend.example.yaml as changed here lists "the GitHub context — any GITHUB_* name" under "Reserved keys are rejected at init, and again inside the sandbox", so the init half of that sentence isn't true. A consumer who has sandbox_env: {GITHUB_ANYTHING: …} today gets a clean tend init, a stamped workflow, and then a mid-job failure on every workflow the next time the action runs — which is the silent-parse-then-fail-late shape CLAUDE.md's "No backward compatibility" section asks to avoid. Adding the same prefix check next to the RESERVED_SANDBOX_ENV test in config.py moves it back to init.

Two leftovers I can fold into the same push if you like: claude/action.yaml and codex/action.yaml still describe base_branch as "Base branch used to seed the disposable agent clone", and generator/tests/test_generate.py still names a test test_review_delegates_pr_topology_to_disposable_clone.

Comment thread codex/action.yaml Resolved
max-sixty and others added 2 commits September 20, 2026 18:18
The first real-runner run of this branch died before the agent existed:
`git config --global` failed with `unable to access
'/home/runner/.gitconfig': Permission denied`.

SRT resolves its mandatory deny paths against the launching process's own
cwd — `DANGEROUS_FILES` (`.gitconfig`, the shell rc files, `.mcp.json`)
and the dangerous directories (`.git/hooks`, `.claude/commands`,
`.claude/agents`) are all `path.resolve(cwd, name)`, and a file on that
list is masked with `--ro-bind /dev/null`, which bwrap's nodev remount
makes unopenable. `enter_view.py` chdirs to the home so no inherited cwd
names the host's inode through the overlay, so that cwd reached SRT and
the runner's own `~/.gitconfig` became the masked one.

The checkout is the tree those protections are written for, and it is
where the cwd sat before this branch. Moving it back also restores them:
against a home cwd, a consumer repo's `.claude/commands`, `.claude/agents`
and `.git/hooks` were left unprotected.

The three `sandbox_runtime.mjs` tests failed for an unrelated reason: they
are `linux_only`, so the local suite skips them, and their env dict still
named `TEND_AGENT_WORKSPACE` after the runtime moved to `GITHUB_WORKSPACE`.
It now names what the runtime reads, and drops three keys nothing reads.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`verify-srt` drives the whole lifecycle, `event_checkout` included, and
named the base branch `${GITHUB_REF_NAME:-main}`. On `pull_request` that
is `<number>/merge`, which origin publishes under `refs/pull/` and never
as a branch, so `checkout_base`'s `git branch --set-upstream-to
origin/<number>/merge` failed and took the step with it. Only the
pull_request runs were affected; a push to main resolves.

GITHUB_BASE_REF carries the base branch on `pull_request` and is empty on
the push, so the two together name it on both. The job's checkout now
fetches everything, because `origin/<base>` has to exist for the upstream
— the generated workflows' own checkout already does.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event_checkout gets through now — the log shows branch 'main' set up to track 'origin/main' and the base selected. test-sandbox stops one line later, in sandbox_setup, on printf "agent\n" > "$TEND_WARM_CACHE/root-owned/written-by-sandbox": Permission denied. That is the candidate I raised on the previous head, now the confirmed failure rather than a guess, so the choice it needs is live — either the idmap covers uid 0 and root-owned paths really are writable, or they aren't and both that assertion and enter_view's docstring framing need to say so.

A git failure inside the lifecycle escapes its handler. agent_lifecycle.main() now calls configure_git() (check=True) and event_checkout.main(), both of which raise subprocess.CalledProcessError, and event_checkout raises bare TypeError for its own topology diagnostics — neither is in the module's closing except (OSError, RuntimeError, ValueError). The prepare_agent_workspace.main() this branch deletes caught (OSError, subprocess.CalledProcessError, TypeError, ValueError) and reported through fail(); moving the work into the sandbox dropped two of the four. The run on the previous head walked that path and showed the cost: instead of one agent lifecycle: ... line, the log carried a traceback, then a second traceback from apport failing to write /var/crash on the read-only mount, then the original exception again. Restoring the two names to the tuple restores the old diagnostic. The line sits outside the diff, so I can't leave it as a suggestion — happy to push it alongside the other leftovers if you want them folded in.

The real-runner test asserted the agent could write inside a root-owned
0755 directory a consumer's `setup:` left. It cannot, and the design says
so: the idmap swaps the runner's and the sandbox's ids and leaves every
other id alone, so uid 0 is uid 0 on both sides. Mapping it as well would
also hand the agent every root-owned file only root can read — more than
the account whose home this is has.

So the bound is the honest claim: the agent writes wherever the runner
could, and no further. The test now plants a file in that directory and
asserts both halves, the read and the refused write; `enter_view`'s
docstring and the shipped `sandbox_setup:` docs say it rather than "can
write anywhere".

Three things the review raised, all from this branch:

- `agent_lifecycle`'s closing `except` missed `CalledProcessError` and
  `TypeError`, which `configure_git` and `event_checkout` both raise. A
  traceback is the job's only account of why the turn never started, and
  the `prepare_agent_workspace` this branch deletes caught all four.
- `init` accepted `sandbox_env: {GITHUB_*: …}` that `consumer_env` then
  refuses inside the sandbox, so the consumer met the rule as a failed
  job rather than a rejected config.
- Both actions still described `base_branch` as seeding "the disposable
  agent clone", and a generator test still carried that name.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both CI failures from the earlier rounds are closed — test and test-sandbox are green on this head — and init now rejects sandbox_env: {GITHUB_*: …} before the workflows are stamped. Three things this commit's own goal, saying what the view actually gives the agent, doesn't finish:

docs/security-model.md still says the agent "writes anywhere." The commit corrects that claim in enter_view's docstring, both tend.example.yaml copies and the test header, but the sentence under Agent execution boundary — "The agent reads what setup: left and writes anywhere" — is added by this PR and still carries it. It's the document a consumer reads to decide what the boundary gives away, so it's the copy most worth having right.

The except tuple is enumerated by hand and still misses KeyError. This module reads os.environ[...] unguarded five times — TEND_VIEW_MASKS, GITHUB_WORKSPACE, HTTP_PROXY, BOT_NAME, BOT_ID, plus TEND_CODEX_RUNNER on the Codex branch — so an unset variable from the new launch plumbing lands as the traceback-then-apport output the widened tuple exists to prevent. That's the failure shape the previous round hit, where sandbox_runtime.mjs started reading a variable the launch fixture wasn't passing. enter_view.py's own handler already catches (KeyError, OSError, ValueError).

2>/dev/null doesn't suppress the refused write in the new assertion. Bash applies redirections left to right, so > "$TEND_WARM_CACHE/root-owned/by-sandbox" fails and is reported before 2>/dev/null is installed: bash: …: Permission denied reaches the job log on every passing test-sandbox run. Wrapping the command in { …; } puts the redirect outside it and the message goes where it was meant to.

Checked
  • identity_map covers 0 … ID_CEILING-1 with no hole, and uid/gid 0 map to themselves, so the docstring's bound holds: the exit 95 assertion also fires if anyone later maps root, which covers the unreadable-file half of the same claim without a second fixture.
  • The GITHUB_* prefix rejection matches consumer_env's wording and sits after the RESERVED_SANDBOX_ENV check, so GITHUB_TOKEN and GITHUB_WORKSPACE keep their more specific messages. The parity pre-commit hook's `([A-Za-z_][A-Za-z0-9_]*)` regex doesn't match `GITHUB_*`, so the new docs bullet adds no phantom name to the documented set.
  • plant() computes TEND_HOST_SUM after the sudo tee, so root-owned/planted is inside the host checksum, and cleanup removes the directory under sudo.

Comment thread docs/security-model.md Resolved
Comment thread shared/steps/agent_lifecycle.py Resolved
Comment thread proxy/test-setup-sandbox.sh Resolved
max-sixty and others added 2 commits September 20, 2026 18:52
The review asked for `KeyError` in `agent_lifecycle`'s closing `except`,
which would have been the third name added to that list in as many
commits. The reads it would catch are the problem: `GITHUB_WORKSPACE`,
`BOT_NAME` and `BOT_ID` were each read deep inside whichever step first
needed them. `_common.require_env` is the helper written for exactly this
— "call this at the top of `main` so a missing input fails there, by
name" — and the lifecycle never used it. `main` now does, before the
probe runs, and passes the values down; the Codex runner path is read the
same way. An empty `BOT_ID`, which used to commit as `+tend-agent@…`, now
fails too.

`docs/security-model.md` still said the agent "writes anywhere" after the
last commit corrected every other copy of that claim.

The refused-write assertion in `test-setup-sandbox.sh` leaked
`Permission denied` into every passing run: bash applies redirections left
to right, so the failed `>` is reported before `2>/dev/null` exists. The
write is grouped so the redirect covers it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
sandbox_runtime.mjs was its only reader, and stopped reading it when the
allowRead list went. Left in, it only widened the job environment that
crosses into the sandbox.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit f968a1e into main Sep 21, 2026
16 checks passed
@max-sixty
max-sixty deleted the sandbox-setup-from-actions branch September 21, 2026 02:01
max-sixty added a commit that referenced this pull request Sep 21, 2026
…ut of the view (#1334)

Two gaps #1333 left in the sandbox launch chain, both in
`shared/steps/enter_view.py` and the supervisor that calls it.

**The job's environment was on `sudo`'s command line.** The launch
passed the agent's whole environment as `env -i NAME=VALUE …` arguments
to `sudo`, which logs its command line, and which any process on the
host can read from `/proc`. On a self-hosted runner, a secret a consumer
sets in job-level `env:` ended up in the system log. The supervisor now
writes the environment, NUL-separated, to a 0600 file in the private
directory. `enter_view.py` reads it without following links, removes it
before anything that can fail, and passes it to `execve`. Standard input
would have avoided the file entirely, but `sudo` can relay its input
through a pty in canonical mode, which mangles it.

**A host `/tmp/claude` could be written from inside.** SRT always allows
writes to `/tmp/claude` and binds the host's whenever one exists at
launch, and it resolves binds through the namespace it was launched
from. So a world-writable host `/tmp/claude` came back writable under
SRT's own private `/tmp`, and anything written there outlived the run.
`enter_view.py` now mounts an empty `/tmp` in the view's private
namespace, so SRT never finds the host's. The mount covers all of `/tmp`
rather than that one path: nothing SRT runs uses the host's `/tmp`,
because its sockets follow `TMPDIR`.

`plugins/tend-ci-runner/skills/run-tend/SKILL.md` loses one sentence
that told every session the `sudo env` launch carries its environment in
argv; the rule against printing a process's environment or command line
stands without it.

The unit tests cover the file handoff (last entry wins, the file is
removed, a symlink is refused, nothing from the job reaches the argv)
and hold `enter_view.py`, which root runs straight from the action
checkout, to the standard library. `proxy/test-setup-sandbox.sh` checks
both on a real runner in `test-sandbox`:

- the env file is gone after the launch;
- a job-only variable reaches the agent but not `sudo`'s journal, which
the test also requires to hold this launch's entry, so an absent marker
means something;
- a write to `/tmp/claude` from inside never reaches a world-writable
host one.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@max-sixty max-sixty mentioned this pull request Sep 21, 2026
max-sixty added a commit that referenced this pull request Sep 21, 2026
Version bump, lockfile, and the `## 0.2.12` section the release workflow
publishes verbatim as the GitHub Release notes.

17 commits since 0.2.11. The headline is the sandbox layout: the agent
runs in the job's own checkout and home through a copy-on-write view, so
what a consumer's `setup:` steps prepare reaches the agent without being
rebuilt in `sandbox_setup:`, and the job environment crosses into the
sandbox in a `0600` file rather than on `sudo`'s command line
([#1333](#1333),
[#1334](#1334)). Alongside it:
`/tmp` is writable inside the sandbox as scratch private to the run
([#1324](#1324)), CI sessions
ignore the bot's claude.ai skills, plugins and connectors
([#1328](#1328)), the SRT launch
retries a transient bridge-socket failure
([#1327](#1327)), and a cancelled
gating check polls as unverified rather than green
([#1323](#1323)).

Each bullet was written from the commit's diff rather than its subject.
No real agent session has run through the new view yet (CI's
`test-sandbox` lifecycle runs stub `claude`/`codex` binaries), so the
release's live check after tagging is the first one that does.

> _This was written by Claude Code on behalf of max-sixty_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 21, 2026
Deploys 0.2.12 to tend itself, the last step of the release before its
live check.

The pin moves from `@0.2.11` to `@0.2.12` across the nine generated
workflows. That brings in the agent running in the job's own checkout
and home through a copy-on-write view
([#1333](#1333),
[#1334](#1334)), plus the rest of
the [0.2.12
release](https://github.com/max-sixty/tend/releases/tag/0.2.12). The
generated files themselves change in three lines each at most: the
header's version, `setup-uv`'s uv 0.12.17, and the review workflow's
checkout comment.

`review-reviewers.yaml` is hand-maintained, so `init` doesn't touch its
ref; it's restamped onto the same version here, per **Nightly: restamp
the hand-maintained workflow refs** in the overlay. Every
`max-sixty/tend/...` ref in `.github/workflows/` now reads `0.2.12`.

> _This was written by Claude Code on behalf of max-sixty_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 21, 2026
Reverts [#1334](#1334) and
[#1333](#1333), which shipped in
0.2.12. The code under `shared/`, `proxy/`, `claude/`, `codex/`,
`generator/src/` and `docs/` is byte-identical to `b953f683`, the commit
before #1333. A 0.2.13 release follows.

The release's live check on tend found two regressions:

- **SRT's masks land as files in the checkout the agent commits from**
([#1338](#1338)). #1333 made the
SRT process `chdir` to `$GITHUB_WORKSPACE`, so SRT resolves its
mandatory deny list (`.bashrc`, `.gitconfig`, `.gitmodules`, `.vscode`,
…) there and binds `/dev/null` over each name. `git add -A` then fails
with `can only add regular files`, every session sees thirteen untracked
entries, and git warns `unable to access '.gitmodules': Permission
denied`. Under 0.2.11 the launcher sets no working directory, so SRT
resolved the list against the step's default, the runner's checkout,
while the agent committed from a separate disposable clone.
- **The experimental memory-gist save fails.** #1333 moved its key file
from `RUNNER_TEMP` into the runtime's private directory, which the
dispose step deletes before the save reads it.

> _This was written by Claude Code on behalf of max-sixty_

🤖 Generated with [Claude Code](https://claude.com/claude-code)
max-sixty added a commit that referenced this pull request Sep 21, 2026
…ite view, and deprecate sandbox_setup and sandbox_path (#1346)

Reapplies #1333 and #1334, which #1339 reverted after 0.2.12's live
check, fixes the defects that check and the weekly integration test
found, and deprecates `sandbox_setup:` and `sandbox_path:`, which the
view makes redundant. Ten commits:

- The first two revert the two reverts #1339 squashed, and leave the
code byte-identical to 6d74214, the 0.2.12 tree.
- The third, `Resolve SRT's write protections off the checkout, and keep
the memory key past dispose`, fixes the regressions.
- The fourth, `Remove sandbox_setup, and refuse a checkout outside the
runner's home by name`, and the fifth, `Remove sandbox_path: the agent
runs with the job's PATH`, remove both keys' machinery.
- The sixth, `Warn on sandbox_setup and sandbox_path, and carry them
over as setup: steps`, keeps configs that still set them working.
- The seventh added a `setup-uv` step to the migration, the eighth
reverts it, and the ninth, `Say that a setup: step installs the tools it
calls`, puts that in the warning and the example config.
- The tenth, `Run migrated sandbox_setup commands in one shell, and keep
sandbox_path's order`, makes the migration match how the keys ran.

Closes #1198: a cache `setup:` restores into the runner's checkout or
home now reaches the agent, at the path it was restored to.

## What 0.2.12's live check found

**SRT's write protections landed in the checkout the agent commits
from** (#1338). SRT 0.0.76 resolves its mandatory deny list (shell rc
files, `.gitconfig`, `.gitmodules`, `.mcp.json`, `.vscode`, `.idea`,
`.claude/commands`, `.claude/agents`, `.git/hooks`) against its own
process cwd, and binds only the entries inside `allowWrite`: one that
exists is re-bound read-only, one that doesn't gets a `/dev/null` bind,
or a read-only empty directory when an intermediate component is what's
missing (`dist/sandbox/linux-sandbox-utils.js`,
`linuxGetMandatoryDenyPaths` and the deny loop in
`generateFilesystemArgs`). #1333 put the runner's home in `allowWrite`
and chdir'd the launcher to the checkout, which sits under that home, so
every session's checkout held thirteen character devices: `git add -A`
failed with `can only add regular files`, and every git command reading
submodule config warned `unable to access '.gitmodules': Permission
denied`. Under 0.2.11 the launcher's cwd was the runner checkout,
outside `allowWrite`, so the list bound nothing at all.

**The experimental memory-gist save failed on every run.** #1333 moved
the baseline key out of `RUNNER_TEMP`, correctly: the view's idmap shows
the runner's 0600 files in the home to the agent as its own. It moved
the key into the private directory inside the runtime container, which
`Dispose sandbox resources` deletes right after the reap, before `Save
experimental memory Gist` reads it (`cat:
/var/tmp/tend-runtime.…/private/tend-auto-memory-key.…: No such file or
directory`). The save is `continue-on-error`, so the job stayed green.

## Three further defects the fix removes

- **A repository without `.claude/` could not start the agent.**
`.claude/commands` and `.claude/agents` sit two levels deep, so where
`.claude` itself is missing SRT mounted a read-only empty directory over
`.claude`, and `run_claude` failed writing `.claude/settings.local.json`
before the harness started (`tee: …/.claude/settings.local.json:
Read-only file system`). The weekly integration test hit this; tend's
own checkout tracks `.claude/`, so `test-sandbox` could not.
- **Tracked protected paths were read-only.** A repository that tracks
`.vscode/`, `.idea/`, `.gitmodules`, `.mcp.json`, `.claude/commands/` or
`.claude/agents/`, at the root or up to SRT's search depth of 3, got
each re-bound read-only, so the agent could not edit them.
- **A pull request touching one of those paths could not be checked
out.** The binds are computed once, at launch, against the reviewed base
tree; `event_checkout` then moves that same checkout to the PR's ref
inside the sandbox, and git cannot write a path that is a read-only bind
or create one beneath a `/dev/null` stub. This one is inferred from the
binds rather than reproduced.

## The fix

- **`shared/steps/sandbox_runtime.mjs`** chdirs the launcher to its own
staged directory, under the runtime container and outside every
`allowWrite` path, so SRT's list binds nothing. The list exists to stop
something unsandboxed from later running what a sandboxed process wrote,
and under the view nothing outside the process tree runs what the agent
writes in the home: every write lands in the overlay's upper layer,
which the dispose step deletes. It was never a boundary on the agent's
own config either — it leaves out `.claude/settings.json`, `CLAUDE.md`
and skills. SRT has no switch for this list alone (`filesystem.disabled`
drops all filesystem policy), so the cwd is the lever. The lifecycle's
own cwd comes from the `spawn`'s `cwd`, so the harness still starts in
the checkout. Resolving from the home instead is what #1333's first CI
run hit: `~/.gitconfig` masked and `git config --global` failing.
- **`claude/action.yaml`** creates the memory key beside the memory
directory in `/var/tmp`, a 0600 runner file outside both the home and
the runtime container. Moving the save ahead of dispose would also work,
but `test_sandbox_resources_are_removed_immediately_after_agent_reap`
pins dispose to the step after the reap.
- **`docs/security-model.md`** says where the key lives and that SRT's
built-in protections bind nothing, and why.

Running SRT 0.0.76's own `wrapCommandWithSandboxLinux` (argument
generation only, no bwrap) with `allowWrite` covering a runner home: a
launcher cwd in the checkout emits exactly #1338's thirteen `/dev/null`
binds plus read-only `.vscode` and `.git/hooks`; a cwd in the home emits
a read-only `~/.gitconfig` and twelve more; a cwd in the staged
directory emits none.

#1340 took the other route, excluding the stubs from git after
`event_checkout`; it would have left the read-only `.claude`, the
read-only tracked paths, the failing PR checkout and the `.gitmodules`
warning.

## `sandbox_setup:` and `sandbox_path:` are deprecated, and migrate
themselves

`sandbox_setup:` ran consumer commands inside the sandbox so the agent
could have what `setup:` built, which a separate home and checkout kept
from it. `sandbox_path:` prepended directories to the agent's PATH.
Under the view `setup:` output is at the path it was left at and the
agent's PATH is the job's, so both are redundant, and the view broke
`sandbox_path:` besides: its `~` still expanded to the sandbox account's
home rather than the runner home the agent now runs in. Their action
inputs, `shared/steps/sandbox_setup.py`, the lifecycle's call (with its
unused `probe` harness) and the `~` expansion in
`proxy/setup_sandbox.py` are gone, and the docs no longer mention either
key.

At the maintainer's call, and against CLAUDE.md's rule that an old
format fails, `init` does not refuse them yet, so that nothing breaks in
a consumer before it migrates. It warns, naming the key and its
migration, and performs that migration: each key becomes one `setup:`
step appended after the consumer's own, in every agent job.
`sandbox_path` comes first, since `sandbox_setup` ran with those
directories on PATH, and becomes `echo "<dir>" >> "$GITHUB_PATH"` lines,
with a leading `~` as `$HOME`. They are written last-first: the runner
adds each `$GITHUB_PATH` line to its prepend list in order and builds
PATH from that list reversed, so the first entry stays first.
`sandbox_setup`'s commands share one `shell: bash` step, the `-eo
pipefail` bash they were joined into before, so an `export`, `cd` or
`source` still reaches the entries after it. The setup renderer now
emits a multi-line string as a `|` block scalar rather than a
double-quoted line of `\n` escapes, which also covers a consumer's own
multi-line `run:`. A `TODO(2026-10-21)` in `config.py` marks turning the
warnings back into refusals once the consumers have migrated. `enabled`
keeps refusing.

A migrated command runs as an ordinary `setup:` step, with what the
consumer's `setup:` and the runner image provide. Inside the sandbox it
also had tend's `uv` fallback on PATH, which no `setup:` step gets:
tend's own `uv` stays off PATH, and the ubuntu-24.04 image ships none.
So a command that calls `uv` needs `astral-sh/setup-uv` earlier in
`setup:`, as in any workflow; the warning and `docs/tend.example.yaml`
say so. Of the five consumers only PRQL/prql is affected: its `uv tool
install pre-commit` needs `setup-uv` in its `tend-setup` composite
before it takes this release. leaf and numbagg list `setup-uv` in
`setup:`, and worktrunk's `tend-setup` composite runs it.

On ubuntu-24.04, `~/.local/bin` and `~/.cargo/bin` are both on the job
PATH the agent inherits: the `sandbox PATH:` line in this PR's
`test-sandbox` log carries `/home/runner/.local/bin` and
`/home/runner/.cargo/bin`.

`sandbox_env` stays: the job's environment already crosses, but it is
still the one way to give a value to the agent alone, which a consumer
uses for a secret on some events only.

## Self-hosted layouts

The view is an overlay of the runner account's home, so a self-hosted
runner whose work folder is elsewhere would give the agent a read-only
checkout and fail later, in the sandbox, on a probe that cannot say why.
`proxy/setup_sandbox.py` now refuses that layout in the "Set up
credential-isolation sandbox" step, naming both paths, and
`docs/tend.example.yaml` says it is not supported yet and how to avoid
it. #1348 tracks supporting it.

## Testing

- `proxy/test-setup-sandbox.sh` (the `test-sandbox` job) asserts from
inside the lifecycle that the checkout holds no character device, that
`git add -A --dry-run` succeeds, and that `.claude/commands/` and
`.mcp.json` are writable there. Those assertions ran through the
`sandbox_setup:` hook; the Claude stub now runs them, from where the
agent starts. The Claude launch moves `.claude/` out of the checkout
first, so it runs the case most consumers are in, and the stub sits
where the real Claude binary installs rather than on a `sandbox_path`
entry. At 6d74214 the test never ran `git add`, `git commit` or `git
status` in the checkout, which is why it stayed green.
- `shared/steps/test_launch_sandbox_runtime.py` drives the real launcher
against a stand-in SRT, with the workspace under the runner home as on a
hosted runner, and asserts the cwd SRT reads while wrapping is outside
every `allowWrite` path. It is Linux-only; run on macOS through a
`process.platform` shim, it passes, and it fails against the 0.2.12
launcher.
- `generator/tests/test_repo_pins.py` pins the memory directory and key
to `/var/tmp`; `test_config_edge_cases.py` asserts both deprecated keys
warn with their migration and turn into the expected `setup:` steps,
`test_migrated_sandbox_setup_commands_share_one_shell` runs the migrated
step under the bash GitHub uses and checks an `export` reaches a later
entry and a failure stops the rest, and a regtest snapshots them
rendered after the consumer's own step under the notifications
pre-check; `proxy/test_setup_sandbox.py` asserts the layout refusal
names both paths.
- `uv run pytest`: 1216 passed, 4 skipped. All thirteen pre-commit hooks
pass; the `sandbox_env` reserved-set parity hook now scopes to that
list's new paragraph, and still reads every reserved name from it.

Only a live run verifies the memory-gist save (no CI job runs the Gist
steps) and a review in PR mode.

## For the release notes

- 0.2.13 reverted the view, so this restores what 0.2.12 announced: what
`setup:` builds reaches the agent again.
- `sandbox_setup:` and `sandbox_path:` are deprecated. Their entries
move to `setup:` automatically, one step per key after the consumer's
own, and `tend init` warns with the migration; a later release will
refuse them. Five consumers set `sandbox_setup` (worktrunk, PRQL/prql,
numbagg, leaf, cargo-affected), none `sandbox_path`. A migrated command
now runs as an ordinary `setup:` step, without the `uv` the sandbox
provided, so a command that calls `uv` needs `astral-sh/setup-uv`
earlier in `setup:`; PRQL/prql is the one consumer that needs it.
- A self-hosted runner whose work folder is outside the runner account's
home is refused by name (#1348).

> _This was written by Claude Code on behalf of max-sixty_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Sep 21, 2026
Regenerates the `tend-*` workflows with tend 0.2.13 (from 0.2.11).
Mechanically the diff is the action pin `max-sixty/tend/[email protected]` →
`@0.2.13` in the eight workflows that run the agent, the
`astral-sh/setup-uv` pin `0.12.13` → `0.12.17` in the two that install
uv directly (`tend-mention`, `tend-notifications`), and a regenerated
header comment in all nine.

The upgrade that matters for this repo is in CI polling.
`poll_pr_checks.py` previously treated any gating check that settled
without a red conclusion as green — so a required check belonging to a
**cancelled** or **stale** run, or a `COMPLETED` check carrying no
conclusion at all, let the bot report a PR as green when nothing had
actually verified it. 0.2.13 splits those out as `unverified` and gives
`poll` a distinct exit code for them (max-sixty/tend#1323). Practically:
fewer "checks went green" claims on PRs whose required jobs were
cancelled, at the cost of some polls ending unverified rather than
green.

The rest, in rough order of how visible it is here:

- **Sandbox reliability** — the sandbox runtime now retries past a
transient bridge-socket failure at launch (max-sixty/tend#1327). That
failure is one of the shapes that produces a `tend-outage` issue, so it
should show up as fewer of those.
- **Sandbox environment** — root `/tmp` is writable inside the sandbox
(max-sixty/tend#1324); the `run-tend` skill's note that it was read-only
is gone. This repo's `running-tend` skill still restates that note, so
it goes stale when this merges — I'll follow up separately rather than
mix a skill edit into the generated-workflow diff.
- **Instruction-path pinning** — the `run-tend` skill's description of
which paths get restored from the PR base, and on which events, was
wrong in 0.2.11; `.agents/` is now named alongside `.claude/`, and the
event list is corrected (max-sixty/tend#1311). The restore behavior
itself is unchanged.
- **Auth hygiene** — the bot's claude.ai account is kept out of CI
sessions (max-sixty/tend#1328).
- **Harness pins** — claude-code 2.1.278 (max-sixty/tend#1330), uv
0.12.17 (max-sixty/tend#1331).

`.config/tend.yaml` pins no model, so the harness-default check found
nothing to adjust.

Full comparison:
max-sixty/tend@0.2.11...0.2.13

<details><summary>Copy-on-write sandbox view: landed and reverted within
this range</summary>

max-sixty/tend#1333 and max-sixty/tend#1334 moved the agent into the
job's own checkout and home through a copy-on-write view;
max-sixty/tend#1339 reverted both before 0.2.13. Nothing from that work
is in this diff — noted so a later reader doesn't chase it out of the
commit list.

</details>

Co-authored-by: worktrunk-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants