swarm-controller: move bulk config-PR read off /api/agents to avoid a name clash

This commit is contained in:
damocles 2026-08-19 22:23:45 +02:00
commit baac3ef023

View file

@ -810,19 +810,27 @@ async fn get_agent_config_pr(
/// scale and isn't how the rest of swarm-ui's single-fetch pages (jobq, /// scale and isn't how the rest of swarm-ui's single-fetch pages (jobq,
/// hives status) work. /// hives status) work.
/// ///
/// Deliberately **not** `/api/agents/config-prs`: agent names are
/// user-specified (any string `hive_types::Ident` accepts), so a literal
/// path segment sitting where a `{name}` capture could plausibly also want
/// to live is a real, not theoretical, clash risk the moment someone names
/// an agent `config-prs` — per mara's review call, closed off by
/// construction rather than relying on axum's static-route-priority
/// tiebreak to paper over it.
///
/// Only agents with a currently-open PR are present — same "absence is the /// Only agents with a currently-open PR are present — same "absence is the
/// answer" shape [`get_agent_config_pr`]'s `null` uses, just at map-entry /// answer" shape [`get_agent_config_pr`]'s `null` uses, just at map-entry
/// granularity instead of per-request. /// granularity instead of per-request.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/agents/config-prs", path = "/api/config-prs",
responses( responses(
(status = 200, description = "agent name -> open config PR, only agents with one present", body = std::collections::HashMap<String, forge::ConfigPrStatus>), (status = 200, description = "agent name -> open config PR, only agents with one present", body = std::collections::HashMap<String, forge::ConfigPrStatus>),
(status = 503, description = "no forge is configured on this host", body = String), (status = 503, description = "no forge is configured on this host", body = String),
), ),
tag = "agents" tag = "agents"
)] )]
async fn get_agent_config_prs( async fn get_config_prs(
State(state): State<AppState>, State(state): State<AppState>,
) -> Result<Json<std::collections::HashMap<String, forge::ConfigPrStatus>>, StatusUnavailable> { ) -> Result<Json<std::collections::HashMap<String, forge::ConfigPrStatus>>, StatusUnavailable> {
let Some(cache) = state.config_prs.as_ref() else { let Some(cache) = state.config_prs.as_ref() else {
@ -1034,7 +1042,7 @@ async fn main() -> Result<()> {
.routes(routes!(get_jobq_graph)) .routes(routes!(get_jobq_graph))
.routes(routes!(get_jobq_rollup)) .routes(routes!(get_jobq_rollup))
.routes(routes!(get_agent_config_pr)) .routes(routes!(get_agent_config_pr))
.routes(routes!(get_agent_config_prs)) .routes(routes!(get_config_prs))
.routes(routes!(create_agent)) .routes(routes!(create_agent))
.routes(routes!(webhook::post_webhook_forge)) .routes(routes!(webhook::post_webhook_forge))
.split_for_parts(); .split_for_parts();