Watch
0
0
Fork
You've already forked hyperhive
0

agents get a per-agent repo limit in their permissions record, orgs are locked

max_repos (default 0, 0..=100) lives in the agent's agent-permissions record and is edited on its permissions panel. The controller applies each agent's own value as max_repo_creation at CreateForgeUser and to existing accounts on change, restart and every five minutes; agent accounts may not create organizations.
This commit is contained in:
atlas 2026-11-15 20:47:21 +01:00 • committed by mara
commit 1edeb5c55d
6 changed files with 763 additions and 58 deletions

View file

@ -119,7 +119,7 @@ checkpoints**, not about sandboxing the agent from its own tools:
- **Operator merges, not the agent** — an agent may _push_ branches, but a
**human (the operator) merges the PR**, keeping a person in the loop on the
highest-value action. On the **internal forge this is technically enforced,
not just convention**: agents can't create repos (`max_repo_creation = 0`),
not just convention**: agents can't create repos by default (next bullet),
and `main` on an `agent-configs/<name>` repo carries swarm-controller's
branch protection: merge and approval allowlisted to the `operators` team,
which swarm-controller converges on every config repo. An operator's merge
@ -129,6 +129,15 @@ checkpoints**, not about sandboxing the agent from its own tools:
settings nor merge its own PR. It's **not** set up for external VCS (GitHub
etc.), though — there, operator-merge is process + accepted risk, not a
technical control.
- **Repo creation is a per-agent setting, default 0** — the _repositories_ badge
in an agent's card sets how many repos that agent's forge account may create
(`max_repos` in its permissions record, Forgejo's `max_repo_creation`, 0 to
100). The operator must raise it for that agent before it may create any. Agents never create organizations: the
controller turns that off on every agent account. A repo an agent creates is
its own, so the operator-merge gate doesn't cover it, and the agent can add a
CI workflow to it. CI workflows run unsandboxed on the CI runner, which is
arbitrary code on the runner host. Allow repo creation only for agents you
would trust with that.
- **Operator sign-off** — config changes are config PRs an operator merges
on the forge (see
[`persistence.md`](persistence.md#config-changes)), and

View file

@ -26,7 +26,7 @@ by a test). swarm-controller mints every agent token with it:
| `write:repository` | Create, clone, push, delete repos; merge PRs. |
| `write:issue` | Open / comment / review issues **and** pull requests (Forgejo namespaces PR conversation under issues). |
| `write:user` | Edit own profile, create repos under own user. |
| `write:organization` | Create + manage orgs (lets agents share a forge namespace). |
| `write:organization` | Manage orgs the agent belongs to. The forge refuses to create one: agent accounts may not. |
| `read:user` | Token-owner endpoint used for self-identification at harness startup. |
| `write:misc` | Hooks, attachments, the rest of the long tail. |
| `read:notification` | Poll `GET /notifications` for unread events. |

View file

@ -102,7 +102,7 @@ Deadline: hive-forge stops after HIVE_FORGE_DEADLINE seconds (default 900), prin
* `comment-show` — Print the body (or full JSON) of a single comment by id
* `comment-edit` — Edit an existing comment by id
* `clone` — Clone a forge repo (default `-r`/`HIVE_FORGE_REPO`) with credentials autoinjected. Pairs with `pr create --agit`
* `repo-create` — Create a forge repo under the current user (or `--org`). Prints the repo URL. Agent accounts can't create repos (limit 0)
* `repo-create` — Create a forge repo under the current user (or `--org`). Prints the repo URL. Agent accounts create repos only up to their own limit (0 by default)
* `repo-add-collaborator` — Add a collaborator to the active repo (`-r`/`HIVE_FORGE_REPO`) with a permission level. Companion to `repo-create`
* `repo-labels` — List every label defined on the repo (name + description), optionally filtered by a name substring
* `repo-search` — Search the forge for repositories by keyword, topic, or description
@ -1008,7 +1008,7 @@ Clone a forge repo (default `-r`/`HIVE_FORGE_REPO`) with credentials autoinjecte
## `hive-forge repo-create`
Create a forge repo under the current user (or `--org`). Prints the repo URL. Agent accounts can't create repos (limit 0)
Create a forge repo under the current user (or `--org`). Prints the repo URL. Agent accounts create repos only up to their own limit (0 by default)
**Usage:** `hive-forge repo-create [OPTIONS] <NAME>`

View file

@ -224,9 +224,11 @@ plain comment show under `last comment`, not `reviews`.
### Repo management
Agent accounts can't create repos: swarm-controller sets their
repo-creation limit to 0 (see `docs/2-handbook/agents/security.md`), so
an operator merge stays the only path to main. Ask the operator to
Agent accounts can't create repos unless the operator allows it for that
agent: swarm-controller sets the account's repo-creation limit to the
agent's own `max_repos`, which is 0 until the operator raises it (see
`docs/2-handbook/agents/security.md`), so an operator merge stays the only
path to main. Ask the operator to
create the repo (for example `agents/<name>`) and add you as a
collaborator. Forgejo also disables push-to-create.

View file

@ -817,6 +817,21 @@ The agent's **internet** access is its own row beside it: a badge reading
restricted, log or unrestricted. Selecting it lists the three modes; picking one does a
`PUT` of the mode with the stored permissions beside it.
The **repositories** row is how many repositories the agent's forge account may
create: a badge reading none or `up to N`, in the warning tone above 0. Selecting
it opens a number box, 0 to 100, and **save** does a `PUT` of `max_repos` with the
stored permissions beside it. A `PUT` that leaves `max_repos` out, and the `DELETE`
of **use the default**, keep it. Nothing stored means 0, and the box warns that an
agent that may create repositories can add a CI workflow to them, CI workflows run
unsandboxed on the CI runner, and that makes it arbitrary code on the runner host.
The controller sets the value as Forgejo's `max_repo_creation` on that agent's
account: on a new one at creation, and on an existing one within seconds of a save
and again after every restart. It also turns off creating organizations on every
agent account, whatever the number. Forgejo never reports `max_repo_creation`
back, so the controller's log (`agent max repos`) is the record of what it applied
to each agent. The controller tries an agent whose account the forge refuses again
every five minutes.
A saved change isn't instant. The hive reads the grant about every 30 seconds
and the agent takes it at its next turn. A change to `manage_root_agent`
restarts the agent after its current turn. The card reads

View file

@ -340,6 +340,15 @@ explicit `unrestricted_internet: false`; read the pair with
`DELETE` keeps it. A hive that doesn't read the field sees `false` and enforces
the list. The proxy's handling is under _Log mode_ in [the egress proxy](../../4-implementation/networking/network.md#egress-proxy-squid).
**Repository limit** — the record also carries `max_repos`, how many repositories
the agent's forge account may create, 0 to 100. An absent value is 0. Only the
controller reads it: it sets the account's Forgejo `max_repo_creation` from it at
`CreateForgeUser`, and again for an existing account within seconds of a change,
at every start and every five minutes (`forge::agent_max_repos`). It also turns
off creating organizations on every agent account. A `PUT` that leaves the field
out, a `DELETE`, and a re-create keep the stored value; the route refuses more
than 100.
**How a change applies** —
- The agent's harness reads its own key every 10 seconds and builds every
turn's `--tools`, `--allowedTools` and MCP config from the last value, so a