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
1 change: 1 addition & 0 deletions changelog.d/added-18490-owner-prompt-source-repos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Owners can approve their own managed repos as prompt and definition sources.** Settings → Security → Prompt sources and the owner-only `GET /api/config/prompt-sources` / `PUT /api/config/prompt-sources/owner-repos` let the hive owner allow one of the hive's `project.repos` for `agents.<n>.prompt_source` and `definition_source` without editing the config volume, behind a confirm naming the trust implication (whoever can merge there can steer the agents). Approvals cover that repo only, are audit-logged as `config_prompt_source_repo`, persist to `variables.security.owner_github_prompt_repos` in the PVC runtime config, and lapse if the repo leaves `project.repos`. Non-owners get 403, repos outside the hive are refused, and the seed `github_prompt_allowlist` path is unchanged ([#18490](https://github.com/hivecommons/hive/issues/18490)).
167 changes: 167 additions & 0 deletions dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6103,6 +6103,173 @@
}
}
},
"/api/config/prompt-sources": {
"get": {
"tags": [
"System"
],
"summary": "Get prompt and definition source repos",
"description": "Lists the hive's managed repos and whether agents' prompt_source / definition_source may read from each, via the config-volume allowlist or an owner approval (#18490). Requires owner role.",
"responses": {
"200": {
"description": "Prompt source gate state",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"repos": {
"type": "array",
"items": {
"type": "object",
"properties": {
"repo": {
"type": "string"
},
"managed": {
"type": "boolean"
},
"owner_approved": {
"type": "boolean"
},
"seed_allowed": {
"type": "boolean"
},
"allowed": {
"type": "boolean"
},
"approved_by": {
"type": "string"
},
"approved_at": {
"type": "string",
"description": "RFC 3339 time of the owner approval."
}
}
},
"description": "One row per managed repo (project.repos), then any owner approval whose repo is no longer managed (inert)."
},
"seed_enabled": {
"type": "boolean",
"description": "variables.security.allow_github_prompt from the config volume."
},
"seed_allowlist": {
"type": "array",
"items": {
"type": "string"
}
},
"trust_notice": {
"type": "string"
},
"seed_only_note": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/api/config/prompt-sources/owner-repos": {
"put": {
"tags": [
"System"
],
"summary": "Approve or revoke a managed repo as a prompt source",
"description": "Approves (allowed: true, with acknowledge_trust: true) or revokes (allowed: false) one of the hive's managed repos as a prompt_source / definition_source repo. A repo outside project.repos, a malformed slug, or an approval without acknowledge_trust is refused with 400 and nothing changes. Persisted to variables.security.owner_github_prompt_repos in the running config and audit-logged. Requires owner role.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"repo",
"allowed"
],
"properties": {
"repo": {
"type": "string",
"description": "owner/repo slug of a managed repo."
},
"allowed": {
"type": "boolean"
},
"acknowledge_trust": {
"type": "boolean",
"description": "Must be true to approve: anyone who can merge to the repo can steer the hive's agents."
}
}
}
}
}
},
"responses": {
"200": {
"description": "Updated prompt source gate state",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"repos": {
"type": "array",
"items": {
"type": "object",
"properties": {
"repo": {
"type": "string"
},
"managed": {
"type": "boolean"
},
"owner_approved": {
"type": "boolean"
},
"seed_allowed": {
"type": "boolean"
},
"allowed": {
"type": "boolean"
},
"approved_by": {
"type": "string"
},
"approved_at": {
"type": "string",
"description": "RFC 3339 time of the owner approval."
}
}
},
"description": "One row per managed repo (project.repos), then any owner approval whose repo is no longer managed (inert)."
},
"seed_enabled": {
"type": "boolean",
"description": "variables.security.allow_github_prompt from the config volume."
},
"seed_allowlist": {
"type": "array",
"items": {
"type": "string"
}
},
"trust_notice": {
"type": "string"
},
"seed_only_note": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/api/config/reference-repos": {
"get": {
"tags": [
Expand Down
15 changes: 14 additions & 1 deletion src/docs/agent-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ Two merge rules to know before you rely on this:

### The trust boundary: allowlisted repos are seed-only

`definition_source` is gated by `Config.GitHubDefinitionAllowed(slug)` (`config.go:4731`), which simply delegates to `Config.GitHubPromptAllowed(slug)` (`config.go:4711`) — the **same** seed-only gate used by `prompt_source`. Fetching requires both:
`definition_source` is gated by `Config.GitHubDefinitionAllowed(slug)` (`config.go:4731`), which simply delegates to `Config.GitHubPromptAllowed(slug)` (`config.go:4711`) — the **same** seed-only gate used by `prompt_source`. On the seed path, fetching requires both (the owner approval for managed repos is [below](#owner-approval-for-the-hives-own-managed-repos)):

```yaml
variables:
Expand All @@ -1085,6 +1085,19 @@ This is the property operators most need to understand before enabling the featu

An empty allowlist denies every repo even with `allow_github_prompt: true` — the allowlist is required, not merely advisory.

### Owner approval for the hive's own managed repos

The seed edit is still the only way to allow a repo outside the hive. For one of the hive's **own managed repos** (an entry of `project.repos`, qualified with `project.org`), the hive owner can approve it from the dashboard instead of editing the volume ([#18490](https://github.com/hivecommons/hive/issues/18490)):

- **Settings → Security → Prompt sources** lists each managed repo and whether `prompt_source` / `definition_source` may read from it. **Approve…** opens a confirm that names the trust implication: anyone who can merge to that repo can change what the hive's agents are told to do and how they are defined. **Revoke** removes the approval.
- The API is `GET /api/config/prompt-sources` and `PUT /api/config/prompt-sources/owner-repos` with `{"repo": "org/name", "allowed": true, "acknowledge_trust": true}` (`"allowed": false` revokes). Both are owner-only: read, read-write and merger sessions get 403. A repo outside `project.repos` is refused with a 400, and an approval without `acknowledge_trust: true` is refused.
- Each approval covers that one repo only. It does not need `allow_github_prompt` and does not turn it on, so nothing on `github_prompt_allowlist` starts loading because of it.
- Approvals are stored in the running config as `variables.security.owner_github_prompt_repos` (`repo`, `approved_by`, `approved_at`), written by the dashboard Save to the PVC runtime config, so they survive a restart. Every change is audit-logged as `config_prompt_source_repo`.
- The dashboard overlay still cannot approve a repo: its `variables` block is never merged, so only the owner endpoint (or a seed edit) writes the list.
- An approval counts only while its repo is still in `project.repos`. Removing the repo from the hive lapses the approval; the Prompt sources panel shows it as inert until it is revoked.

`Config.GitHubPromptAllowed(slug)` (and `GitHubDefinitionAllowed`, which delegates to it) admits a repo when either the seed gate or an owner approval allows it, so every caller (prompt, definition and review-perspective resolvers) honors both paths without change.

`review.perspectives_source` (the live-linked review perspective set; see [review-swarm.md](review-swarm.md#live-linked-perspectives-reviewperspectives_source)) uses the same seed-only gate: the resolver is allowed to read a repo only when `GitHubPromptAllowed` permits it, it resolves at the same resolve points (startup and every reload), and it follows the same fallback shape as `Resolve` above (last-known-good, then the inline config).

### Fetch failures never blank an agent
Expand Down
2 changes: 2 additions & 0 deletions src/docs/api-reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f
| `PUT` | `/api/config/write-surface` | Owner only | Replace the lane write allowlist; `{"allowlist": {}}` clears it; unknown operation or bad lane name is a 400 with nothing changed | `pkg/dashboard/api.go:525` |
| `GET` | `/api/config/reference-repos` | Owner only | `project.reference_repos` ([#18136](https://github.com/hivecommons/hive/issues/18136)): `reference_repos` (`{repo, write, write_token_file}` plus `derived_from` on a derived entry and, on every write entry, `credential_state`, `credential_reason` and `credential_login`, the GitHub account the writes appear under ([#18197](https://github.com/hivecommons/hive/issues/18197)); always an array) and `write_kinds` | `pkg/dashboard/api.go:551` |
| `PUT` | `/api/config/reference-repos` | Owner only | Replace `project.reference_repos`; `{"reference_repos": []}` clears it. Refused with a 400 and nothing changed when the config loader would reject the list (bare name, repo also in `project.repos`, duplicate, unknown write kind, token file without write) or when a write entry has no credential boot would accept — the same message boot exits 22 with — or when an entry carries a `write_token_file` the config file does not already hold for that repo (the path is operator-only; a dashboard write opt-in writes as the hive owner's connected GitHub account). Entries with `derived_from` ([#18139](https://github.com/hivecommons/hive/issues/18139)) are the request issue's grant: echo them back as served; changing one's write set, leaving one out, sending one the hive did not derive or adding a hand-written entry for the same repo is a 409 naming the issue to change instead ([#18161](https://github.com/hivecommons/hive/issues/18161)). They are never stored: the saved list holds the hand-written entries and the derived set is merged back in memory after the save. 500 when the file could not be written (proxy restored, nothing changed). On success the GitHub proxy's reference policies are replaced without a restart; audited as `config_reference_repos` | `pkg/dashboard/api.go:552` |
| `GET` | `/api/config/prompt-sources` | Owner only | Repo-sourced prompt and definition gate ([#18490](https://github.com/hivecommons/hive/issues/18490)): `repos` (one row per managed repo, then any owner approval whose repo is no longer managed, each `{repo, managed, owner_approved, seed_allowed, allowed, approved_by, approved_at}`), `seed_enabled`, `seed_allowlist`, `trust_notice`, `seed_only_note` | `pkg/dashboard/api.go:561` |
| `PUT` | `/api/config/prompt-sources/owner-repos` | Owner only | `{"repo": "org/name", "allowed": true, "acknowledge_trust": true}` approves one of the hive's managed repos as a `prompt_source` / `definition_source` repo; `"allowed": false` revokes. 400 with nothing changed for a repo outside `project.repos` (still needs the seed edit), a malformed slug, or an approval without `acknowledge_trust: true`. Persisted to `variables.security.owner_github_prompt_repos` in the running config; audited as `config_prompt_source_repo`. Responds with the GET body | `pkg/dashboard/api.go:562` |
| `GET` | `/api/config/review` | Dashboard auth/session | Review Config Get | `pkg/dashboard/api.go:218` |
| `PUT` | `/api/config/review` | Owner only | Review Config Set | `pkg/dashboard/api.go:221` |
| `PUT` | `/api/config/governor/features` | Owner only | Governor Features | `pkg/dashboard/api.go:227` |
Expand Down
3 changes: 3 additions & 0 deletions src/hive.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,9 @@ dashboard:
# http_allowlist: []
# allow_github_prompt: false
# github_prompt_allowlist: []
# # Owner-approved managed repos, written by Settings -> Security -> Prompt
# # sources (owner-only). Not needed in a hand-written seed.
# owner_github_prompt_repos: []
# defs:
# EXAMPLE_TOKEN:
# type: env
Expand Down
28 changes: 19 additions & 9 deletions src/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,14 @@ type VarSecurityConfig struct {
// bounds the blast radius to repos the operator explicitly trusts, so the
// feature cannot be used to read every repo the App happens to be installed on.
GitHubPromptAllowlist []string `yaml:"github_prompt_allowlist,omitempty"`
// OwnerGitHubPromptRepos is the owner-approved subset of the hive's own
// managed repos that prompt_source and definition_source may read from,
// each approved on its own from the dashboard (hivecommons/hive#18490).
// Unlike GitHubPromptAllowlist it needs no AllowGitHubPrompt, and an entry
// counts only while the repo is still in project.repos. Written only by the
// owner-only dashboard endpoint through Save; the overlay cannot set it.
// See owner_prompt_repos.go.
OwnerGitHubPromptRepos []OwnerPromptRepo `yaml:"owner_github_prompt_repos,omitempty"`
}

type ProjectConfig struct {
Expand Down Expand Up @@ -6562,19 +6570,21 @@ func (c *Config) ResolveRegistryForAgent(agentName string, logger *slog.Logger)
// given "owner/repo" slug is permitted to be fetched. This mirrors the seed-only
// gating used for exec/http resolvers: it consults c.Variables.Security, which
// LoadWithDashboardOverlay guarantees comes ONLY from the trusted config seed
// (the dashboard overlay's Variables block is never merged). It returns false
// unless the feature is explicitly enabled AND the slug is on the seed-declared
// (the dashboard overlay's Variables block is never merged). The seed path
// needs the feature explicitly enabled AND the slug on the seed-declared
// allowlist, so a user-writable overlay can never widen the set of readable repos.
//
// It also admits a repo the hive owner approved from the dashboard
// (OwnerPromptRepoAllowed, hivecommons/hive#18490): one of the hive's own
// managed repos, approved individually and persisted through Save. That path
// is bounded to project.repos, so it cannot widen the set beyond repos the
// hive already manages. Callers (the prompt, definition and perspectives
// resolvers, and repo-discovered agents) should keep using this function.
func (c *Config) GitHubPromptAllowed(slug string) bool {
if slug == "" || !c.Variables.Security.AllowGitHubPrompt {
if slug == "" {
return false
}
for _, allowed := range c.Variables.Security.GitHubPromptAllowlist {
if strings.EqualFold(strings.TrimSpace(allowed), slug) {
return true
}
}
return false
return c.SeedGitHubPromptAllowed(slug) || c.OwnerPromptRepoAllowed(slug)
}

// GitHubDefinitionAllowed reports whether an agent's definition_source pointing
Expand Down
Loading
Loading