feat(#2377): forge-webhook-triggered config-PR merge flow
Replace the request_merge_config_pr MCP tool with a Forgejo pull_request webhook on the agent-configs org. Agents now open a config PR normally; hive-c0re auto-queues the MergeConfigPr approval from the webhook event — no extra tool call needed. Changes: - dashboard/webhook.rs: add POST /webhook/config-pr handler - parses Forgejo pull_request payload (opened/synchronize) - strips agent-configs/<agent> prefix to extract agent name - calls submit_merge_config_pr → queues dashboard approval card - always 200 to prevent Forgejo retries; errors logged at warn - dashboard/mod.rs: wire /webhook/config-pr route - forge/mod.rs: add ensure_config_pr_webhook() — idempotent org-level hook registration on agent-configs at startup; CONFIG_ORG now pub(crate) for webhook handler - main.rs: call ensure_config_pr_webhook alongside knowledge webhook - socket_server/config_approvals.rs: drop handle_request_merge_config_pr; make submit_merge_config_pr pub(crate) for webhook handler - socket_server/mod.rs: re-export submit_merge_config_pr; drop dispatch arm - hive-sh4re/src/lib.rs: remove AgentRequest::RequestMergeConfigPr wire type; drop from ToolGroup::Approvals tool list - hive-ag3nt/src/mcp/: drop request_merge_config_pr tool + args struct - docs: update approvals.md (webhook trigger), conventions.md (tool group), agent-hierarchy.md, tools/lifecycle.md Hardening from #2375-merge-config-pr-hardening branch preserved: - pr_is_open check at queue time (rejects closed/merged PRs) - atomic fetched_sha INSERT via submit_kind(fetched_sha: Some(&sha)) Approve-handler machinery unchanged (run_merge_config_pr, ff_push_to_main, fetch_pr_head_into_applied, mark_pr_merged).
This commit is contained in:
parent
96eda4ed6b
commit
d5a81f9195
14 changed files with 255 additions and 163 deletions
|
|
@ -99,7 +99,6 @@ Once enforcement lands the rules collapse into:
|
|||
| `kill` / `start` / `restart` / `update` (any descendant) | any ancestor |
|
||||
| `request_init_config` (spawn a new child) | any agent, child added under self |
|
||||
| `request_apply_commit` (any descendant's config) | any ancestor |
|
||||
| `request_merge_config_pr` (any descendant's forge config PR) | any ancestor |
|
||||
| `get_logs` (any descendant) | any ancestor |
|
||||
| moderate questions / reminders (cancel any open thread of a descendant) | any ancestor |
|
||||
| `send` / `recv` routing | parent ↔ same-parent siblings ↔ self ↔ descendants; explicit allow-list for anyone else |
|
||||
|
|
|
|||
|
|
@ -111,15 +111,20 @@ kind-specific payload carrier.
|
|||
row (only `ApplyCommit` populates it). See the End-to-end flow
|
||||
above.
|
||||
- `MergeConfigPr` — the PR-based config flow's counterpart to
|
||||
`ApplyCommit`. `commit_ref` stores the **PR number** (decimal),
|
||||
and `fetched_sha` is the PR **head sha the operator reviewed**.
|
||||
On approve, `run_merge_config_pr` re-reads the live PR head and
|
||||
aborts if it drifted from `fetched_sha` (re-review), then fetches
|
||||
that head into the applied repo, eval-verifies it, fast-forwards
|
||||
the forge config repo's `main` to it (the merge), marks the PR
|
||||
merged (best-effort — `main` is already there), and runs the same
|
||||
shared deploy tail as `ApplyCommit` (`deploy_applied_target`).
|
||||
Never a first spawn.
|
||||
`ApplyCommit`. Triggered automatically: when an agent opens (or
|
||||
force-pushes) a PR on its `agent-configs/<agent>` forge repo,
|
||||
hive-c0re's `/webhook/config-pr` endpoint receives the Forgejo
|
||||
pull_request event and queues this approval row. No MCP tool call
|
||||
needed — the forge PR IS the request. `commit_ref` stores the
|
||||
**PR number** (decimal), and `fetched_sha` is the PR **head sha
|
||||
at queue time** (the "reviewed" sha). On approve,
|
||||
`run_merge_config_pr` re-reads the live PR head and aborts if it
|
||||
drifted from `fetched_sha` (submitter must push again to
|
||||
re-trigger), then fetches that head into the applied repo,
|
||||
eval-verifies it, fast-forwards the forge config repo's `main` to
|
||||
it (the merge), marks the PR merged (best-effort — `main` is
|
||||
already there), and runs the same shared deploy tail as
|
||||
`ApplyCommit` (`deploy_applied_target`). Never a first spawn.
|
||||
- `Spawn` — direct container creation under the default
|
||||
`agent.nix` template. `commit_ref` is empty. Submitted via
|
||||
`HostRequest::RequestSpawn` (operator-gated, the
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ binary flavor.
|
|||
| `inbox` | `get_loose_ends`, `cancel_loose_end`, `remind`, `request_next_turn` |
|
||||
| `execution` | vestigial — `mcp__bash__run` / `mcp__bash__status` are always available unconditionally via `extraMcpServers`; this group's entries expand to non-existent `mcp__hyperhive__run` / `mcp__hyperhive__status` and have no effect. See `docs/tools/bash.md`. |
|
||||
| `lifecycle` | `kill`, `start`, `restart`, `update` *(privileged)* |
|
||||
| `approvals` | `request_init_config`, `request_apply_commit`, `request_merge_config_pr`, `request_update_meta_inputs` *(privileged)* |
|
||||
| `approvals` | `request_init_config`, `request_apply_commit`, `request_update_meta_inputs` *(privileged)* |
|
||||
| `scheduling` | `request_schedule_prompt`, `fire_schedule_now`, `cancel_schedule`, `edit_schedule`, `list_schedules` *(privileged)* |
|
||||
| `diagnostics` | `get_logs` *(privileged)* |
|
||||
|
||||
|
|
|
|||
|
|
@ -64,24 +64,6 @@ pinned commit.
|
|||
rejected — the approval pins the exact commit). `agent` must be a
|
||||
direct child. Topology-enforced.
|
||||
|
||||
### `request_merge_config_pr(agent, pr_number, description?)`
|
||||
|
||||
Submit an open PR on the agent's `agent-configs/<agent>` forge repo for
|
||||
operator review and merge. The PR-based config flow's counterpart to
|
||||
`request_apply_commit`: instead of pinning a commit sha from the proposed
|
||||
repo, the submitter references an already-open forge PR.
|
||||
|
||||
hive-c0re fetches the PR head sha at submission time (the "reviewed" sha);
|
||||
on operator approval it re-checks for drift, eval-verifies the commit,
|
||||
fast-forwards the forge repo's `main` to the reviewed sha, marks the PR
|
||||
merged, and rebuilds the agent container. If the PR head moves between
|
||||
submission and approval the approve handler aborts — the submitter must
|
||||
re-submit.
|
||||
|
||||
`agent` must be in the caller's subtree. The agent must already be fully
|
||||
provisioned (applied repo present); this tool is not for first-spawn.
|
||||
Requires the `approvals` tool group.
|
||||
|
||||
### `request_update_meta_inputs(inputs?, description?)`
|
||||
|
||||
Queue an approval to run `nix flake update [inputs...]` on the meta
|
||||
|
|
@ -100,7 +82,6 @@ agents after the approval resolves.
|
|||
| `list_containers` | No | All descendants |
|
||||
| `request_init_config` | Yes (InitConfig) | New direct child only |
|
||||
| `request_apply_commit` | Yes (ApplyCommit) | Direct children |
|
||||
| `request_merge_config_pr` | Yes (MergeConfigPr) | Descendants |
|
||||
| `request_update_meta_inputs` | Yes (MetaUpdate) | Meta flake (global) |
|
||||
|
||||
## See also
|
||||
|
|
|
|||
Loading…
Reference in a new issue