Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 93 additions & 10 deletions docs/content/hive/adr/0026-sandbox-runtime-selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,31 +268,114 @@ Decision by the hive owner on #17695, option A:
egress is governed only by Substrate's `EgressPolicy`.
- Hive brokers pushes **post-kick**: it performs git pushes and GitHub writes
itself, from the workspace the bridge returns.
- **Phase 3 (future)**: SVID-authenticated broker delegation over the atenet
mTLS channel, so hive can delegate scoped GitHub writes to the actor without
a credential entering it. It is gated on hosted clusters serving the podcert
feature gates (`PodCertificateRequest` / `ClusterTrustBundle`,
`certificates.k8s.io/v1beta1`) and is tracked as a child issue of #17695.
- **Phase 3**: broker delegation, so hive can do scoped GitHub writes for the
actor during the kick without a credential entering it. It is gated on the
cluster serving the podcert APIs (`PodCertificateRequest` /
`ClusterTrustBundle`; `certificates.k8s.io/v1` on Kubernetes ≥ 1.37,
`v1beta1` behind feature gates on 1.35 to 1.36). It was planned as SVID
authentication and was built with gateway-injected actor JWTs instead; see
the 2026-12-01 amendment below (#17933, a child of #17695).

This supersedes the earlier statement that hive's credential brokering is
unchanged for Substrate. The podman, `job` and `openshell` runtimes keep
their proxy model (ADR-0002).

### Amendment (2026-12-01, #17933): phase 3, actor-JWT broker delegation

Decision by the hive owner on #17933. Substrate never gives an actor its own
X.509 SVID: the actor's client certificate is generated and held by `atunnel`
outside the workload and is accepted only by the egress gateway, and
`PodCertificateRequest` issues per pod, not per actor. Phase 3 therefore uses
Substrate's documented way for an actor to prove who it is to an outside
service, an actor JWT that `atenet-egress` injects, instead of an actor SVID.
It is **opt-in per agent and off by default**; phase 2 stays the fallback.

- **Egress.** A broker-enabled actor's `EgressPolicy` gets one `https`
(intercepting) rule for exactly hive's broker host and port. Its effect
replaces the `Authorization` header with `Bearer <actor JWT>` for this
hive's audience and a lifetime of 300 to 3600 seconds (default 600). The
broker host must be dedicated to the broker, because the token goes to
every request to that host and port. `network_mode: none` drops this rule
along with every other. The actor sends a placeholder value and never sees the token. The template
mounts the `egress-mitm.ate.dev` and `system-roots.ate.dev` trust bundles so
the actor trusts the gateway's interception certificate. The GitHub hosts
stay TLS passthrough. The broker host may not be a GitHub host or a wildcard.
- **Verification** (`crux/sandbox/substratebroker`). The issuer is pinned
(default `https://idp.ate-system.svc`). Its discovery document and key set
are fetched only over TLS that chains to the servicedns ClusterTrustBundle
projection, with no system roots, no proxy, no redirects, and `jwks_uri` on
the issuer's host. The audience must be this hive's
(`https://<host>/substrate-broker/<hive_id>` by default; without a
`hive_id` an explicit audience is required). The subject must
be `actor/<atespace>/<name>`; a `worker-for-actor` token is refused. The
atespace must be the one hive creates actors in, and the atespace, name and
UID must equal a kick hive is running now. The token's lifetime is capped
and clock skew is bounded (30s). A cached key set expires after 5 minutes,
so removing a key from Substrate's pool (its only revocation) takes effect.
- **The write.** Hive performs it with its own minter. The actor sends a git
bundle. Hive takes only the kick's branch from it, as a fast-forward of the
kick's start point, in a scratch clone with hooks off and object checks on.
It then runs the same pushbroker gates the post-kick push uses (hostile
config, sign-off, protected paths, secret scan, fast-forward and lease). A
kick on an existing PR re-checks before every push that the PR is still the
agent's own open PR at the expected head (the person's-PR rule). A PR is
opened through the same PR client and gates, and only from a branch the
broker published. Writes are accepted only while the kick's command runs:
the actor is registered under the UID Substrate gave it after it is
created, and released, with writes in flight cancelled and awaited, before
the workspace is pulled back. No token leaves hive. Writer errors reach the
actor only as hive-written reasons. The pushed body must be a git bundle.
Broker writes happen before the post-kick report-status and exit-code
gates, which the actor's own request stands in for. An agent with
`publish.verify` never gets the broker, because that gate can only run
after the kick.
- **Post-kick.** The post-kick push and PR reuse what the broker published.
If the workspace has nothing new, nothing is pushed again. Otherwise the
push is leased on what the broker pushed. If the push broker rewrote the
commits it published and the actor kept committing on the originals, the
push is withheld with that reason.
- **Fail closed.** Every one of these refuses: no token, a bad signature, the
wrong issuer, the wrong audience, a `worker-for-actor` subject, another
atespace, actor or UID, an expired or too-long token, a kick that is not
live, another repository or branch, and a cluster without the
ClusterTrustBundle projection (the broker does not start). If the broker
is not running or the agent's atespace is not the broker's, the kick runs
phase 2.
- **Gateway hop (optional, flagged).** `require_gateway_svid` makes the broker
require that the TLS client certificate is atenet-egress's pod SVID
(`spiffe://cluster.local/ns/ate-system/sa/atenet-egress`, verified against
the podidentity ClusterTrustBundle). Substrate v1.0's gateway re-originates
the upstream leg with no client certificate and trusts only the public
WebPKI roots. So the flag is off by default, and turning it on refuses
every request until a Substrate release originates with the SVID. For the
same reason the broker host needs a publicly trusted certificate.

Configuration and the operator runbook are in
[deploy/substrate.md](https://github.com/hivecommons/hive/blob/v5/src/deploy/substrate.md#phase-3-the-broker-opt-in-per-agent).

### Cluster prerequisites and which hive clusters qualify

Substrate's real requirement is **not** a kernel floor: the gVisor class runs
`runsc` inside the worker pod on any standard Linux node with cgroup v2; the
microVM class needs `/dev/kvm` (nested virtualisation on cloud shapes). Both
need the operator (`ate-setup deploy ate-system`: Control API, `atelet`
DaemonSet, `atenet-router`, podcert controller, PostgreSQL, snapshot object
storage) and Kubernetes with the `ClusterTrustBundle`,
`ClusterTrustBundleProjection` and `PodCertificateRequest` feature gates — still
off by default as of 1.36 — because actor identities are pod certificates.
Survey on 2026-11-11:
storage) and Kubernetes serving the `PodCertificateRequest` and
`ClusterTrustBundle` APIs, because the identities of hive, the router and the
workers are pod certificates. They are GA under `certificates.k8s.io/v1` and
on by default from Kubernetes 1.37; on 1.35 to 1.36 they are beta and need the
`ClusterTrustBundle`, `ClusterTrustBundleProjection` and
`PodCertificateRequest` feature gates plus `certificates.k8s.io/v1beta1`, which
managed control planes typically enable only through a provider support
request. On 1.34 `PodCertificateRequest` is alpha (`v1alpha1`) only, which is
not enough. The pinned Substrate release must support the served API version
and the Kubernetes minor version. The preflight accepts either version.
Survey on 2026-11-11 (since then one hosted cluster has moved to 1.37 and
serves the `v1` APIs; #17933):

| cluster | kernel / Kubernetes | `gvisor` class | `microvm` class |
|---|---|---|---|
| hive-oke | OL9, UEK8 6.12, k8s 1.34.10 | yes once the feature gates are on (OKE control plane: needs a support request or a self-managed control plane) | needs KVM-capable (bare-metal or nested-virt) shapes |
| hive-oke | OL9, UEK8 6.12, k8s 1.34.10 | yes once on Kubernetes ≥ 1.37, or ≥ 1.35 with the feature gates on (OKE control plane: needs a support request or a self-managed control plane) | needs KVM-capable (bare-metal or nested-virt) shapes |
| lke648397, hive-ci | Debian 13, 6.12 | yes; LKE exposes no control-plane flags, so the podcert gates are the blocker — check with `kubectl get --raw /metrics \| grep kubernetes_feature_enabled` | KVM to confirm per plan |
| vllm-d, a-ks-wec2 | RHCOS 9.x, 5.14 | possible: the kernel is fine, but the worker's `SYS_ADMIN`/`NET_ADMIN` needs an SCC and the gates a `FeatureGate` CR (TechPreviewNoUpgrade) | only on KVM-capable nodes |

Expand Down
12 changes: 12 additions & 0 deletions docs/content/hive/agent-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,18 @@ Names compare case-insensitively; an empty `backend:` (the hive default) is alwa
When reconciliation changes a gateway-routed agent's model, the log identifies the previous value as `old_model` and the replacement as `gateway_model`.
- **`PUT /api/config/agent/{name}/models`** rejects a placement onto a disallowed backend with `400` and a message naming it.

### Switching many agents at once (Governor bulk switch)

To move several agents to another provider or model — for example claude ↔ copilot and back — open **Settings → Governor → Agents**, tick the agents (the header checkbox selects every agent matching the filter box), and use the action bar: **Switch backend…**, **Switch model…** or **Undo last switch**. The dialog lists each agent's current backend/model → new backend/model with a per-agent verdict before anything is written; **Apply** changes only the valid rows, and rejected rows (disallowed or unauthenticated backend, a model the target backend does not offer) are listed with the reason rather than skipped silently. When the target backend has an equivalent of the agent's current model (Claude ids are rewritten between the claude and copilot spellings), it is kept; otherwise pick a model, or leave it empty to keep the model where valid.

```text
POST /api/config/agents/bulk-models {"agents": ["scanner","architect"], "backend": "copilot", "model": "", "dry_run": true}
POST /api/config/agents/bulk-models {"undo": true}
GET /api/config/agents/bulk-models/last
```

The endpoint is owner-only and runs every agent through the same validation as `PUT /api/config/agent/{name}/models`, including the `backends.allow`/`deny` list, so results match a single edit. The config is saved once and each changed agent is applied live without a restart of the hive; as with the single endpoint, an agent whose backend or model changed is restarted, so a kick in flight is interrupted rather than finished on the old backend. Each changed agent gets an `agent_models_bulk` audit entry with before and after. The previous assignment of the last switch is stored in `/data/bulk-models-last.json`; **Undo last switch** restores exactly those agents and is itself recorded, so pressing it again switches forward again.

### Changing backend and model together: use the atomic endpoint

Three API routes can change an agent's method or model. If you are changing **both**, use the single atomic one:
Expand Down
113 changes: 113 additions & 0 deletions docs/content/hive/ai-contribution-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
> **Synced from Hive.** This page is pulled from [hivecommons/hive@v5](https://github.com/hivecommons/hive/blob/v5/src/docs/ai-contribution-policy.md) during the docs build. Edit the canonical source in the Hive repository.

# AI contribution policy template

Last reviewed: 2026-11-30

Hive ships a template that any project can use to write its own AI
contribution policy, whether or not it runs a hive. Hive Commons uses the
same structure for its own
[org-wide policy](https://github.com/hivecommons/.github/blob/main/AI_POLICY.md).

## Why have one

The Linux Foundation's 2026 report *Navigating Open Source Software
Development in the Generative AI Era* found that only about a third of open
source projects have a formal policy permitting AI-assisted contributions.
Where projects do have policies, most cover disclosure and contributor review
responsibility (76% each). Far fewer cover licensing and copyright (39%), and
almost none cover required tooling (6%). The report recommends that projects:

- write the policy down rather than rely on informal norms;
- require disclosure, and make it consistent rather than left to each
contributor;
- make contributors review and test AI output before they submit it.

The template covers all of these and adds a section on agent autonomy. Agent
autonomy is what changes most between a project that only accepts
AI-assisted human PRs and a project that runs agents itself.

## What is in the template

The template is at
[`src/docs/templates/AI_POLICY.template.md`](https://github.com/hivecommons/hive/blob/v5/src/docs/templates/AI_POLICY.template.md).
Its eleven short sections are:

1. Scope
2. What is allowed
3. Disclosure: a note in the PR description, with an optional commit
trailer
4. Human responsibility
5. DCO and sign-off
6. Licensing and copyright, stated as facts and pointing to the LF guidance
7. Security reports
8. Quality expectations
9. Handling non-compliant PRs
10. Agent autonomy: choose one ACMM block
11. Review cadence

## How to use it

1. Copy the template. Save it as `AI_POLICY.md` in your repository root, or
in your organization's `.github` repository so it applies to every
repository.
2. Replace each placeholder written in double curly braces, such as the
project name, license and security policy link.
3. In section 10, keep the one block that matches how you run agents and
delete the others:
- **Option A:** you run no agents of your own.
- **Option B:** ACMM L1 or L2. Agents only observe, advise and post
comment-only reviews.
- **Option C:** ACMM L3 to L5. Agents open PRs, every agent PR is held, and
a person releases the hold and merges.
- **Option D:** ACMM L6. Eligible agent PRs merge on green CI in the
repositories you list.

See the [ACMM policy matrix](/docs/hive/acmm-policy-matrix) for what each level
enables in Hive.
4. In section 5, choose how agents sign off. Either agents sign only their
own commits under a bot identity, as Hive does, or a person reviews and
signs every agent commit.
5. Link the policy from `CONTRIBUTING.md`.
6. Revisit it when you change your hive's ACMM level. Moving from option C to
option D changes who is accountable for merges.

## Disclosure in Hive

Both the Hive Commons policy and the template put disclosure in the PR
description. A hive's agents open PRs through the hive's GitHub App (see
[hive-open-pr](https://github.com/hivecommons/hive/blob/v5/src/docs/hive-open-pr.md)), so agent authorship is visible on every
PR. The PR description ends with a footer naming the agent, backend and
model, for example `-- hive: agent=quality backend=claude model=MODEL`.
The `governor.attribution_trailer` setting controls the footer, and it is on
by default. PRs sent through the contributor relay carry the same footer.
Comments and review replies an agent posts (`gh pr comment`, a reply in a
review thread, a review body) end with the same trailer, applied by the GitHub
proxy from the calling agent's identity. A trailer the agent wrote itself is
replaced, and the trailer sits above the identity footer when there is one.
Each agent signs off only the commits it authored, and credits issue authors with
`Co-authored-by`, never with a sign-off.

A project may also choose a commit trailer. The template's disclosure
section has an optional line for one. For context: in 2026 the Linux kernel
documented an `Assisted-by:` commit trailer, later dropped the model name
from it, and then removed it in favor of disclosure in the cover letter or
PR description. Kubernetes asks for disclosure in the PR description and
does not use AI trailers.

## Sources

- Linux Foundation,
[Guidance Regarding Use of Generative AI Tools for Open Source Software Development](https://www.linuxfoundation.org/legal/generative-ai).
- Linux kernel,
[AI Coding Assistants](https://docs.kernel.org/process/coding-assistants.html)
and [tool-generated content](https://docs.kernel.org/process/generated-content.html).
- Project policies used for structure:
[curl](https://curl.se/dev/contribute.html),
[Kubernetes](https://www.kubernetes.dev/docs/guide/pull-requests/), and
[QEMU](https://www.qemu.org/docs/master/devel/code-provenance.html) and
[Gentoo](https://wiki.gentoo.org/wiki/Project:Council/AI_policy), which
ban AI-generated contributions.
- CNCF has no separate foundation-wide AI policy at the time of writing
([cncf/foundation#1285](https://github.com/cncf/foundation/issues/1285)).
- The ACMM paper: [arXiv 2604.09388](https://arxiv.org/abs/2604.09388).
Loading
Loading