Repository navigation
✨ Discover agents declared in a managed repo's .hive/agents/ behind owner approval - #18505
Conversation
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. @clubanderson this PR is held at Failing checks:
Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path. Review findings from Security delta re-review @ d38e09d (prior head 4f16836) Prior findings
Requested fix (concrete)
var body struct {
ID string `json:"id"`
+ SHA string `json:"content_sha"`
...
+ if body.SHA == "" || body.SHA != entry.ContentSHA {
+ jsonError(w, "definition changed since it was listed; refresh and review again", http.StatusConflict)
+ return
+ }
def, _, err := d.FetchDefinition(r.Context(), body.ID)
+ // and compare the fetched hash to entry.ContentSHA before registering
Limits of this review: the delta is 234 files / 15k lines, mostly main merged in (inference key resolver, sandbox relays, recordings, etc.). I reviewed only the repo-agent discovery files ( Review findings from Correctness review at head 4f16836. I read the diff plus Advisory (low, in-scope): a failed orphan pause is never retried. hive/awaiting-ci: rebased onto v5 (one docs-citation conflict resolved to the base side); CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.325 |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
cc @joerunde: this is part of the hive changes for the spyre-inference deps agent and sandboxed reviewer setup. |
There was a problem hiding this comment.
Style review at 4f16836 (diff read in full for pkg/repoagents, dashboard/api_repo_agents.go, api_agents.go, boot_repo_agents.go). No in-scope blockers; two advisory notes:
src/pkg/dashboard/api_agents.go:~400—handleAgentImportstill inlinesstrings.ToLower(strings.ReplaceAll(def.Metadata.Name, " ", "-")), whilerepoagents.AgentName(repoagents.go) is documented as "the same normalization the dashboard import uses". Two copies can drift. Since you already refactored this tail, reuse it:
name := repoagents.AgentName(def.Metadata.Name)
src/pkg/dashboard/api_repo_agents.go:16—discoveredAgentModeshard-codes the mode set ("same set the agent config editor accepts"). I could not find the shared source from the diff; if the config package already exposes a validator, use it so a new mode doesn't need two edits. Also the "only a pending definition can be approved" message is duplicated in the handler andDiscoverer.Approve.
— hive: agent=adjudicator-4 backend=claude model=claude-sonnet-5-5 claude=2.1.325
Review follow-ups (below
|
4f16836 to
d38e09d
Compare
Mutation testing⏱️ The 900s mutation budget ran out, so 2 package(s) were not fully mutated and the results below do not cover them:
1 mutant(s) in changed files are not reached by any test (NOT COVERED). A maintainer may apply the
ℹ️ 1 mutant(s) on added lines were SKIPPED because gremlins v0.6.0 only honours the first
Verdict: |
There was a problem hiding this comment.
Docs-currency (delta 4f16836 → d38e09d)
Docs for #18491 are otherwise current: the agent-configuration section, the four API rows (the api_repo_agents.go:23-26 citations match the route lines), the changelog fragment and openapi are all present.
Finding (in-scope, low): the two new env vars are missing from src/docs/env-vars.md.
HIVE_REPO_AGENTS_INTERVALandHIVE_REPO_AGENTS_STATEare defined atsrc/cmd/hive/boot_repo_agents.go:15-18. They are documented only insrc/docs/agent-configuration.mdand the changelog.env-vars.mdis the operator reference for everyHIVE_*variable. It already lists sibling knobs such asHIVE_REFERENCE_REPOS_DERIVE_INTERVAL(line 129) andHIVE_WORKSPACE_CLEANUP_INTERVAL(line 130).grep REPO_AGENTSover the file at head returns nothing.- Fix: add two rows next to line 129:
+| `HIVE_REPO_AGENTS_INTERVAL` | No | `15m` | Go duration between rescans of each allowlisted managed repo's `.hive/agents/` (#18491). Values under `1m` are raised to `1m`. See [agent configuration](agent-configuration.md#agents-declared-in-a-managed-repo-hiveagents). |
+| `HIVE_REPO_AGENTS_STATE` | No | `/data/repo-agents.json` | Path where discovered-agent entries (pending/approved/orphaned…) persist. |Previous findings:
- Docs-currency: none open before, none new beyond the above.
- I did not re-verify the correctness, intent-alignment, security and style findings, which are outside this perspective. I took no position on them.
— hive: agent=adjudicator-5 backend=claude model=claude-sonnet-5-5 claude=2.1.325
d38e09d to
983cfea
Compare
…wner approval Scan every allowlisted managed repo's .hive/agents/*.yaml at startup, on a timer and on default-branch pushes touching the directory. Each definition appears as pending in the dashboard's Import tab; nothing runs until an owner approves it. Approval registers the agent with definition_source (marked discovered) and, with a sibling <name>.md, prompt_source. Backend, model, mode and tools stay owner-controlled on every later re-apply. A removed file pauses the agent (orphaned), never deletes it. Fixes #18491 Signed-off-by: Andy Anderson <andy@clubanderson.com>
…tion Signed-off-by: Andy Anderson <andy@clubanderson.com>
…h testutil.Eventually Signed-off-by: Andy Anderson <andy@clubanderson.com>
Signed-off-by: Andy Anderson <andy@clubanderson.com>
Signed-off-by: Andy Anderson <andy@clubanderson.com>
…itation after rebase Signed-off-by: Andy Anderson <andy@clubanderson.com>
983cfea to
0e515e0
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Checks in the hive `deps` agent's prompt, definition and dependency targets under `.hive/`, where hive's repo agent discovery looks for them. The flow is unchanged: bump one dependency group, compile it, open an issue if that fails, open one PR on success, fix our side when CI is red, file dependency bugs upstream, recommend a refresh only when a newer release may fix the bug, never run the test suite and never wait for CI. Hive features this now uses, all merged in hive v5: - `hive-topic claim` from the sandbox, so each group keeps its one-PR claim (hivecommons/hive#18586). - `hive-open-issue` from the sandbox for dependency bugs (on torch-spyre) and compile failures (here). This replaces the `known_bad` ledger PR. `known_bad` stays in `targets.yaml` as a cap maintainers can set by hand (hivecommons/hive#18586). - Fix kicks on the agent's own red bump PR commit on top of it, and sandbox PRs are credited to `deps`, so red CI kicks `deps` and not `scanner` (hivecommons/hive#18587). PRs opened before that fix still get the fix as a patch in the report. - `${NEW_RELEASES}` from the release-feed watcher (hivecommons/hive#18507). - `.hive/agents/` discovery (hivecommons/hive#18505). Files: - `.hive/agents/deps.md`: the kick template (`prompt_source`). - `.hive/agents/deps.yaml`: optional presentation-only definition. - `.hive/deps/targets.yaml`: dependency groups. Only `deps-torch-spyre` is enabled. - `.gitignore`: keeps hive's per-run scratch under `.hive/` ignored and tracks only `.hive/agents/` and `.hive/deps/`. This overlaps torch-spyre#1626, which puts the prompt at `.github/hive/prompts/deps.md` and ignores all of `.hive/`. Its prompt content is merged into `.hive/agents/deps.md` here. If this lands first, torch-spyre#1626 can drop its prompt and `.gitignore` hunks. ## Setup after merge (hive owner) 1. **Approve the prompt source.** Settings, Security, Prompt sources. On the `torch-spyre/spyre-inference` row, click **Approve…** and confirm. Leave `allow_github_prompt` and `github_prompt_allowlist` alone. 2. **Point the agent at the prompt.** Agents, `deps`, General tab, **Prompt from GitHub repo**: Owner `torch-spyre`, Repo `spyre-inference`, File path `.hive/agents/deps.md`, Ref `main`. Save. Keep the current kick template as the cold-start fallback, and replace its text with this file so the fallback runs the same flow. 3. **Variables tab** (static, template scope): - `DEPS_LOCAL_CHECK`: `uv sync --frozen --inexact && uv run --no-sync python -c 'import torch_spyre, spyre_inference; print(torch_spyre.__version__)'` - `DEPS_MAX_REFRESHES`: `2` - `DEPS_UPSTREAM_REPO`: `torch-spyre/torch-spyre` 4. **Cadences tab.** idle, quiet and busy `24h`, surge `pause`. 5. **Optional, release-feed kicks** (YAML only, no Settings control yet): `governor.release_feeds.agents.deps.sources: [{kind: github_tag, repo: torch-spyre/torch-spyre}]`, with `cooldown_s: 21600`. Keep the daily cadence for CI follow-up. 6. **Import tab.** `deps.yaml` will show under "Declared in your repos". Leave it pending or reject it, because approving it would create a second `deps` agent. 7. Unpause `deps`. cc @joerunde 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Andy Anderson <andy@clubanderson.com>
Summary
A managed repo can now declare agents itself. Each
.hive/agents/<name>.yamlon the default branch of a managed repo that passes the existing repo-sourced prompt allowlist (Config.GitHubDefinitionAllowed, which delegates toGitHubPromptAllowed) is discovered and held for owner approval. Nothing runs until an owner approves.pkg/repoagents: a discoverer that lists.hive/agents/through the hive's GitHub App client (newgithub.Client.ListDirectoryFiles), parses each file withdefsrc.ParseDefinition, and tracks entries aspending/invalid/approved/rejected/orphaned. State persists in/data/repo-agents.json(HIVE_REPO_AGENTS_STATE).HIVE_REPO_AGENTS_INTERVAL), and on push webhooks to the default branch that touch.hive/agents/(routed through the existingWebhookDeliveryhook).POST /api/agents/discovered/approve, owner only): re-reads the file through the allowlist gate and registers the agent withdefinition_source(newdiscovered: truemarker) and, if a sibling<name>.mdexists,prompt_source. Backend, model and mode come from the owner's request, never the file. Tools start unset. The import handler's registration tail is moved into a sharedregisterDefinedAgenthelper so both paths create agents the same way.defsrc.ApplyToConfigkeeps backend, model, mode and tools fordiscoveredsources (KeepOwnerControlledFields). Keep-linked imports are unchanged.orphanedand its agent is paused (PauseBy, triggerrepo-agent-discovery), never deleted. A failed listing never orphans anything, and a repo off the allowlist is never read.GET /api/agents/discovered,/rejectand/refresh, plus openapi entries, the api-reference rows, docs inagent-configuration.md, and a changelog fragment.Trust gate: this only calls the existing allowlist check, so the owner-allowlist work in #18490 applies here automatically once it lands.
Fixes #18491
Test plan
pkg/repoagents: lifecycle (pending, approve, orphan, re-add), invalid/rejected transitions, read/list failures, allowlist gate, persistence, push filter, Run/Triggerpkg/dashboard: list/approve/reject/refresh handlers, including the owner-controlled fields, prompt_source wiring and every refusal pathpkg/defsrc: discovered sources keep backend/model/mode/tools on re-applypkg/github:ListDirectoryFilescmd/hive: wiring, orphan pause guard, push hook, interval env🤖 Generated with Claude Code