feat(#3255): hives stop owning the knowledge webhook, and clean up their own
A webhook has exactly one target URL, so every hive registering one against the shared internal/knowledge repository was last-writer-wins rather than idempotent: all but the most recent silently stopped receiving deliveries. The swarm controller holds the single registration and now addresses an event to each hive over the queue instead. This is a migration, not a deletion. Not registering any more fixes nothing on a hive that has already run — the hook it created persists on the forge, so the contention would survive on exactly the deployments that have it while fresh installs looked fixed. The hive that created a hook removes it. It removes only its OWN, matched on the full URL rather than the /webhook/knowledge suffix. A hook with that suffix and a different base belongs to another hive, possibly one not yet upgraded, and deleting it would break that hive's knowledge sync until it caught up. Reaping a neighbour's registration is the behaviour being removed here; doing it while fixing it would only invert the direction. The predecessor did reap by suffix, to clear loopback hooks left by an older single-hive layout. That was safe when a hive was alone on its forge and is not safe now. The hive-side registrars also acted as reapers of hooks under their own path, which is why the swarm hook lives under /webhook/forge/; removing this registrar removes that reaper too. Intended, and stated because no reviewer would infer it from the diff. The receive endpoint goes with it. A live HMAC-verified /webhook/knowledge that nothing can legitimately reach would tell the next reader that this is how a hive learns about knowledge changes. Docs move in the same commit: docs/swarm/README.md said two hooks exist per swarm-wide repo and neither should be deleted, which is now true for agent-configs and wrong for internal/knowledge — a half-correct description being worse than an uncorrected one.
This commit is contained in:
parent
89050ef34b
commit
d2a550e685
6 changed files with 111 additions and 218 deletions
|
|
@ -179,10 +179,18 @@ async fn run_matrix_sweep() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Boot-time Forgejo webhook registration as a DAG node — see
|
||||
/// Boot-time Forgejo webhook management as a DAG node — see
|
||||
/// [`NodeKind::WebhookRegister`]. Mirrors the guard chain the
|
||||
/// `tokio::spawn` block it replaced used: no-op (not an error) when the
|
||||
/// HMAC secret, core token, or hive domain aren't available yet.
|
||||
///
|
||||
/// The node now does one of each: it still registers the config-PR hook,
|
||||
/// and it *removes* the knowledge one. A knowledge push is delivered to
|
||||
/// the swarm controller, which addresses an event to each hive over the
|
||||
/// queue — so a hive holding its own registration is holding a shared
|
||||
/// resource only one party can own. The removal runs every boot rather
|
||||
/// than behind a marker because it is already idempotent: it is a no-op
|
||||
/// the moment the hook is gone.
|
||||
async fn run_webhook_register() -> Result<()> {
|
||||
let Ok(webhook_secret) = crate::webhook_secret::load_or_generate() else {
|
||||
tracing::debug!("webhook secret unavailable; skipping hook registration");
|
||||
|
|
@ -198,10 +206,8 @@ async fn run_webhook_register() -> Result<()> {
|
|||
tracing::debug!("HYPERHIVE_HIVE_DOMAIN unset; skipping webhook registration");
|
||||
return Ok(());
|
||||
};
|
||||
if let Err(e) =
|
||||
crate::workers::knowledge::ensure_webhook(&token, &domain, &webhook_secret).await
|
||||
{
|
||||
tracing::warn!(error = ?e, "knowledge: ensure_webhook failed");
|
||||
if let Err(e) = crate::workers::knowledge::remove_webhook(&token, &domain).await {
|
||||
tracing::warn!(error = ?e, "knowledge: remove_webhook failed");
|
||||
}
|
||||
if let Err(e) = crate::forge::ensure_config_pr_webhook(&token, &domain, &webhook_secret).await {
|
||||
tracing::warn!(error = ?e, "forge: ensure_config_pr_webhook failed");
|
||||
|
|
|
|||
Loading…
Reference in a new issue