Skip to content

Require a restrict-updates ruleset, pin AGENTS.override.md, and rewrite the security docs - #1367

Merged
max-sixty merged 5 commits into
mainfrom
drop-sandbox-env
Sep 21, 2026
Merged

max-sixty merged 5 commits into
mainfrom
drop-sandbox-env

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The site's security section still described tend before the environment gate and the systemd sandbox. Checking every security claim in the docs against the code turned up two that didn't hold, and this PR fixes both along with the docs.

Behavior changes

  • The merge check now requires a restrict-updates ruleset. Branch protection that only requires reviews used to pass both the preflight and tend check. That setup doesn't stop the bot: it has write access, so its own approval counts on a PR someone else opened, and it can then merge that PR. security_preflight.py and checks.py now require a ruleset with an update rule that GitHub reports the bot can never bypass. The preflight aborts when the rules listing is readable and has no such ruleset, and falls back to "the branch is protected at all" only when GitHub won't answer. Both read the rules listing across every page, via gh api --paginate --slurp. All 8 consumers already have an update rule, so none of them will be refused.
  • tend check --fix creates that ruleset for an unprotected or reviews-only branch. It now replaces an existing ruleset with the same name instead of failing with GitHub's duplicate-name error; the same applies to the tag ruleset.
  • AGENTS.override.md is pinned alongside AGENTS.md. Codex reads it in place of AGENTS.md (checked with codex-cli 0.155.1), so a fork PR could otherwise swap in its own instructions under the Codex harness.

Docs

  • Site: the security section is cut to the two guarantees the design rests on. A hijacked session can't land code (the ruleset), and can't take the bot's credentials past the end of the run (the sandbox, the proxy and the environment gate). It also says what a hijacked session can still do while the run lasts.
  • README: the Security section's lead names the same two guarantees, and its layers are reordered to match.
  • docs/security-model.md: the merge-restriction section is rewritten. The exfiltration section now names the remaining channels (the proxy connects to any host; the logs; the job summary; the uploaded session logs), and it no longer lists DNS, which the sandbox blocks.
  • CLAUDE.md, TODO.md and the install-tend security reference are updated to the ruleset model.

Integration fixture

tend-agent/tend-integration still uses classic branch protection, which the new check rejects. The weekly recipe (.claude/skills/running-tend/references/integration-test.md) now ensures a "Merge access" ruleset with no bypass actors on every run, and asserts it reads active never before §2 regenerates. §2 disables the ruleset for its own push to main and re-enables it afterwards. The old preflight passes with the ruleset in place too, so the migration is safe on either release.

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

🤖 Generated with Claude Code

max-sixty and others added 4 commits September 21, 2026 13:53
…ibe the systemd sandbox

The docs describe tend's security from before 0.2.14, and checking their
claims against the code turned up two gaps.

- Merge restriction: the preflight and `tend check` accepted branch protection
  with required reviews. The bot holds write, so its own approval counts on a
  PR someone else opened, and it can then merge it. Both now require a
  restrict-updates ruleset the bot cannot bypass; the preflight falls back to
  "protected at all" only when GitHub won't answer. Both read the rules listing
  paginated. `tend check --fix` sets the ruleset for any branch-protection
  failure, replacing an existing "Merge access" or "Tag operations" ruleset
  rather than POSTing a duplicate name. All eight consumers already have the
  ruleset. The weekly integration fixture, owned by the bot, moves to a
  no-bypass ruleset that §2 lifts around its push.
- Config pinning: Codex reads AGENTS.override.md in place of AGENTS.md, so a
  fork PR could replace the pinned instructions under the Codex harness. The
  pin list now covers it.

Docs: the site's security section (unchanged since before the environment
gate and the sandbox) now covers the merge ruleset, credential isolation, the
systemd sandbox, the environment gate and config pinning. The README orders
its layers by what a reviewer asks first, and the threat model's exfiltration
paragraph names the channels the unit leaves open.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A hijacked session can't land code, and can't take the bot's credentials
past the end of the run. The sandbox, proxy, and environment gate are the
mechanisms of the second, so they share one block; config pinning and rate
limits move to the threat model. The README's lead names the same two.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.

Two notes on the new gate, both in shared/steps/security_preflight.py.

A ruleset body that parses but isn't a ruleset is read as "bypassable". The listing now falls back to the .protected floor when GitHub answers with anything but an array of pages: gh_paginated raises UnexpectedShape and GH_READ_FAILED catches it. The per-ruleset read in the loop below has the same failure mode and takes the opposite branch — {"message": ...} under a 200 is a dict, so it clears the isinstance(ruleset, dict) guard, current_user_can_bypass comes back None, nothing matches "never", and bypassable = True. The run aborts with BYPASS_ERROR ("the bot can bypass every restrict-updates ruleset") against a repo whose ruleset is fine, and the outage issue records that as the cause. The loop is pre-existing; what's new is the premise this PR added to _common.py — a blip can answer "with an HTML error page, or an error object, under a 200" — which is now handled for the listing and not for the ruleset beside it. Treating a body with no current_user_can_bypass as unread (continue, the arm GH_READ_FAILED already takes) puts it on the floor path the listing uses. I can push that if you want it here rather than separately.

NO_RULESET_ERROR is what a repo with no protection at all now sees, and it describes a setup they don't have. Such a repo reads its rules listing cleanly as [], so the new check fires before .protected is ever consulted, and explains the failure as "Required reviews don't stop the bot" — reviews they never configured. UNPROTECTED_ERROR, which names what is actually wrong, is now reachable only when the listing is unreadable and the branch is unprotected, since an update rule implies protected: true on its own. The remedy line is right either way, so this is diagnosis rather than behavior — but the unprotected repo is the one a new install meets first.

Unrelated to the diff: the red review check on this head is a run that exited before reading it — claude -p exited non-zero (exit=1): You've hit your session limit, ~90s in. This review is tend-notifications picking the head up as unreviewed.

… no-ruleset error for unprotected repos

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 5fc17f5 into main Sep 21, 2026
14 checks passed
@max-sixty
max-sixty deleted the drop-sandbox-env branch September 21, 2026 22:36
@max-sixty max-sixty mentioned this pull request Sep 22, 2026
max-sixty added a commit that referenced this pull request Sep 22, 2026
Bumps the generator to 0.2.15, syncs `uv.lock`, and adds the 0.2.15
changelog section. The release ships the restrict-updates ruleset
requirement and the `AGENTS.override.md` pin (#1367), the follow-up
review that focuses on the pushed commits (#1368), a rising bar for
further fix rounds on PRs with no human author (#1366), #1365, #1362,
and the setup-uv v10.2.0 bump (#1359, #1360).

`uv run pytest` (1216 passed), the worker's vitest suite and typecheck,
and every pre-commit hook pass on this commit.

> _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/leaf that referenced this pull request Sep 22, 2026
Regenerates the nine `tend-*` workflows on tend 0.2.15, up from 0.2.14.
Every job now pins `max-sixty/tend/[email protected]`, so merging adopts
that release's agent behaviour as well as the YAML below.

## What changes for this repo

**`tend check` holds branch protection to a ruleset the bot cannot
bypass.** Required reviews alone no longer pass the
`branch-protection:main` check: the bot holds write, so its own approval
satisfies a review requirement on a pull request someone else opened,
and it can then merge. A read it cannot decode is now a failed read
rather than a pass — previously an unreadable protection response
reported the check green without having verified anything. Leaf already
carries the `Merge access` restrict-updates ruleset, so this check stays
`PASS`; `tend check --fix` now offers to create that ruleset for any
failing branch, not only for the specific "bot can still merge" message.

**`tend-mention` measures its queue delay before checkout and
`setup:`.** The delay step moved ahead of both, so the number it reports
is the wait for the job to start rather than that wait plus however long
this repo's `setup:` takes. Leaf's mention runs will report a smaller
delay than before for the same actual queue time.

**Reviews open with a finding.** A review body no longer spends its
first lines restating where GitHub shows the verdict, a follow-up review
focuses on what was pushed while keeping the whole PR in view, and each
further fix round on a PR with no human author has to clear a higher bar
before the bot pushes again.

**Action pins.** `astral-sh/setup-uv` moves from v10.1.0 to v10.2.0 in
the two workflows that set it up directly (`tend-mention`,
`tend-notifications`).

[Compare
0.2.14...0.2.15](max-sixty/tend@0.2.14...0.2.15)

<details><summary>Upstream commits in this range</summary>

- `chore: regenerate workflows with tend 0.2.14` (max-sixty/tend#1358)
- `fix(review): say where GitHub shows a review's verdict, so the body
opens with a finding` (max-sixty/tend#1362)
- `fix(mention): compute the queue delay before checkout and setup`
(max-sixty/tend#1365)
- `fix(review): raise the bar for each further fix round on a PR with no
human author` (max-sixty/tend#1366)
- `Require a restrict-updates ruleset, pin AGENTS.override.md, and
rewrite the security docs` (max-sixty/tend#1367)
- `chore: bump setup-uv to v10.2.0` (max-sixty/tend#1359)
- `chore: bump repo-local setup-uv and wrangler pins`
(max-sixty/tend#1360)
- `chore(token-usage): drop the stream-json artifact copy its own
comment marked for removal` (max-sixty/tend#1361)
- `fix(review): focus a follow-up review on what was pushed, with the
whole PR in view` (max-sixty/tend#1368)
- `chore: release 0.2.15` (max-sixty/tend#1369)

The `AGENTS.override.md` pin in max-sixty/tend#1367 and the dropped
stream-json artifact copy in max-sixty/tend#1361 have no effect here —
the first applies to the Codex harness and the second to tend's own
repository.

</details>

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Sep 22, 2026
Regenerates the nine `tend-*.yaml` workflows with tend 0.2.15 (from
0.2.14). The version bump and the `astral-sh/setup-uv` pin (v10.1.0 →
v10.2.0, in the `tend-mention` and `tend-notifications` preflight jobs)
are mechanical; one step actually moves, in `tend-mention.yaml`.

**`tend-mention` measures its queue delay before checkout and setup.**
The "Compute queue delay" step used to run after `actions/checkout` and
`./.github/actions/tend-setup`, so the number it recorded was the wait
for the job to start *plus* the several minutes this repo's setup action
takes to install the Rust toolchain and sandbox tools. It now runs
first, and the delay reports the queue wait alone
([max-sixty/tend#1365](max-sixty/tend#1365)).

Behavior that arrives inside the action rather than in these files, and
that shows up in what the bot posts here:

- **PR reviews lead with a finding.** A review body now opens with
something actionable instead of restating the verdict GitHub already
renders in its own header
([max-sixty/tend#1362](max-sixty/tend#1362)),
and a follow-up review scopes itself to what the latest push changed
while still reading the whole PR
([max-sixty/tend#1368](max-sixty/tend#1368)).
- **Fewer self-directed fix rounds on bot PRs.** On a PR with no human
author the review session applies its own findings; each further round
now has to clear a higher bar, so a bot PR stops accumulating marginal
follow-up commits
([max-sixty/tend#1366](max-sixty/tend#1366)).
- **`AGENTS.override.md` joins the pinned instruction paths.** Codex
reads it in preference to `AGENTS.md`, so on a PR-derived checkout it is
now restored from the base commit alongside `CLAUDE.md`, `AGENTS.md`,
`.claude/`, and `.agents/` — a fork can no longer reach the session
through that filename. The same release makes a restrict-updates ruleset
a `tend check` requirement; this repo already satisfies it (`tend check`
passes every line today)
([max-sixty/tend#1367](max-sixty/tend#1367)).

Full comparison:
[0.2.14...0.2.15](max-sixty/tend@0.2.14...0.2.15).

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