hive-c0re: split OpenAPI summary/description, move param docs to params

utoipa splits a handler's doc comment on the first blank `///` line:
everything before it becomes the OpenAPI `summary` (shown in Swagger
UI's collapsed endpoint-list row), everything after becomes the
`description` (only shown once that row is expanded). With no blank
line, the whole doc comment becomes the summary and the description is
empty — which is what every handler in hive-c0re/src/dashboard/ was
doing, so the all-endpoints list showed full multi-sentence prose next
to every route instead of a short one-liner.

For every `#[utoipa::path(...)]`-annotated handler across the 19 files
in that module:

- Inserted a blank `///` line after the first short sentence/clause so
  utoipa's split produces a real summary + description, where the doc
  comment had more to say. Left already-short single-clause docs alone
  (nothing to split).
- Where a query struct derives `IntoParams`, moved param prose that
  duplicated a field's own doc comment out of the handler doc (the
  field already documents itself in the generated spec), or added a
  field doc where the handler explained a param that had none.

No behavior changes — doc comments and `params()` description text
only. Verified `cargo build -p hive-c0re` (clean) and `nix fmt` (zero
changes) after.

Closes #2969
This commit is contained in:
iris 2026-08-02 20:50:07 +02:00 committed by mara
commit 071dbd774c
16 changed files with 193 additions and 133 deletions

View file

@ -30,7 +30,9 @@ pub(super) struct BuildLogsAllQuery {
} }
/// `GET /api/build-logs?limit=N` — most-recent build log headers across /// `GET /api/build-logs?limit=N` — most-recent build log headers across
/// all agents, newest first. Same JSON shape as the per-agent endpoint. /// all agents, newest first.
///
/// Same JSON shape as the per-agent endpoint.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/build-logs", path = "/api/build-logs",
@ -61,10 +63,10 @@ pub(super) struct BuildLogsQuery {
} }
/// `GET /api/build-logs/{agent}?limit=N` — most-recent build log /// `GET /api/build-logs/{agent}?limit=N` — most-recent build log
/// headers for one agent, newest first. Returns /// headers for one agent, newest first.
/// `Vec<BuildLogHeader>` (JSON). Limit defaults to 10, server-side ///
/// cap at 50. Backs the per-agent log chip in the agent card and /// Returns `Vec<BuildLogHeader>` (JSON). Backs the per-agent log chip
/// the side-panel header list. /// in the agent card and the side-panel header list.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/build-logs/{agent}", path = "/api/build-logs/{agent}",
@ -102,9 +104,11 @@ pub(super) async fn get_build_logs_agent(
} }
/// `GET /api/build-logs/id/{id}` — full build log row (stdout + /// `GET /api/build-logs/id/{id}` — full build log row (stdout +
/// stderr concatenated) by id. Returns `BuildLogFull` (JSON), or /// stderr concatenated) by id.
/// HTTP 404 when the id doesn't exist (vacuum-reaped, or the ///
/// operator passed a stale id from a refresh race). /// Returns `BuildLogFull` (JSON), or HTTP 404 when the id doesn't
/// exist (vacuum-reaped, or the operator passed a stale id from a
/// refresh race).
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/build-logs/id/{id}", path = "/api/build-logs/id/{id}",
@ -128,13 +132,15 @@ pub(super) async fn get_build_log_full(
} }
/// `GET /api/build-log/{node_id}` — the build log for a **queue node**, /// `GET /api/build-log/{node_id}` — the build log for a **queue node**,
/// resolved node id → log-row id → full log. Same `BuildLogFull` JSON /// resolved node id → log-row id → full log.
/// (`stdout` / `stderr` + header) as `get_build_log_full`; HTTP 404 when the ///
/// node has no linked log (the client gates the request on /// Same `BuildLogFull` JSON (`stdout` / `stderr` + header) as
/// `NodeView.build_log_id`, but a vacuum race can still 404). This is the /// `get_build_log_full`; HTTP 404 when the node has no linked log (the
/// on-demand live-log-panel fetch, distinct from the `build_log_id` on the /// client gates the request on `NodeView.build_log_id`, but a vacuum
/// wire — that id is for deep-linking to the BUILD L0GS tab's full history /// race can still 404). This is the on-demand live-log-panel fetch,
/// view, not for fetching the log content itself. /// distinct from the `build_log_id` on the wire — that id is for
/// deep-linking to the BUILD L0GS tab's full history view, not for
/// fetching the log content itself.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/build-log/{node_id}", path = "/api/build-log/{node_id}",
@ -201,14 +207,15 @@ struct BuildLogFrame {
} }
/// `GET /api/build-logs/id/{id}/stream` — SSE stream that delivers /// `GET /api/build-logs/id/{id}/stream` — SSE stream that delivers
/// incremental stdout/stderr as a build runs. The client connects when /// incremental stdout/stderr as a build runs.
/// it opens a running-build panel; the stream closes automatically once
/// the build finishes (or the row disappears due to a vacuum).
/// ///
/// Each frame is a JSON-serialised `BuildLogFrame`. The first frame /// The client connects when it opens a running-build panel; the
/// always carries the full accumulated log so far (cursors start at 0); /// stream closes automatically once the build finishes (or the row
/// subsequent frames carry only new bytes. `done: true` on the final /// disappears due to a vacuum). Each frame is a JSON-serialised
/// frame signals the browser to close the `EventSource`. /// `BuildLogFrame`. The first frame always carries the full
/// accumulated log so far (cursors start at 0); subsequent frames
/// carry only new bytes. `done: true` on the final frame signals the
/// browser to close the `EventSource`.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/build-logs/id/{id}/stream", path = "/api/build-logs/id/{id}/stream",
@ -308,7 +315,9 @@ pub(super) async fn get_build_log_stream(
} }
/// `GET /api/build-logs/id/{id}/raw` — full log as `text/plain` for /// `GET /api/build-logs/id/{id}/raw` — full log as `text/plain` for
/// download. Stdout and stderr are concatenated with a `--- stderr ---` /// download.
///
/// Stdout and stderr are concatenated with a `--- stderr ---`
/// separator (same layout the JS side-panel renders). The /// separator (same layout the JS side-panel renders). The
/// `Content-Disposition` header triggers a browser download with a /// `Content-Disposition` header triggers a browser download with a
/// descriptive filename so the operator can save and share the log. /// descriptive filename so the operator can save and share the log.

View file

@ -58,11 +58,13 @@ pub(super) struct ExtraForgesQuery {
agent: String, agent: String,
} }
/// `GET /api/extra-forges?agent=<name>` — list the external forge accounts /// `GET /api/extra-forges?agent=<name>` — list the external forge
/// currently provisioned for `agent`, derived from every `forge-<label>- /// accounts currently provisioned for `agent`.
/// token` file in its state dir (mirrors `matrix_accounts.rs`'s filename-scan ///
/// listing). `base_url` is backfilled from the matching `forge-<label>.json` /// Derived from every `forge-<label>-token` file in its state dir
/// sidecar when present. Never returns a token. /// (mirrors `matrix_accounts.rs`'s filename-scan listing). `base_url`
/// is backfilled from the matching `forge-<label>.json` sidecar when
/// present. Never returns a token.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/extra-forges", path = "/api/extra-forges",
@ -135,8 +137,10 @@ struct ExtraForgeAccountResult {
/// `POST /api/extra-forge-account` — add persists the operator-pasted /// `POST /api/extra-forge-account` — add persists the operator-pasted
/// label/base-URL/token to the agent's state dir via hive-priv; remove /// label/base-URL/token to the agent's state dir via hive-priv; remove
/// deletes both files. Purely local — no remote account creation or /// deletes both files.
/// revocation, there is no admin access assumed on the external forge. ///
/// Purely local — no remote account creation or revocation, there is
/// no admin access assumed on the external forge.
/// Operator-authenticated (dashboard). Never echoes the token back. /// Operator-authenticated (dashboard). Never echoes the token back.
#[utoipa::path( #[utoipa::path(
post, post,

View file

@ -49,12 +49,13 @@ struct ReadyBody {
warnings: Vec<ServerWarning>, warnings: Vec<ServerWarning>,
} }
/// `GET /health/ready` — readiness. `200` with `{"status":"ok", "warnings": /// `GET /health/ready` — readiness.
/// [...]}` unless a `crit`-level warning is currently set in ///
/// [`crate::warnings::snapshot`], in which case `503` with /// `200` with `{"status":"ok", "warnings": [...]}` unless a `crit`-level
/// `{"status":"degraded", ...}`. `warnings` always carries the full /// warning is currently set in [`crate::warnings::snapshot`], in which
/// current list (including `warn`-level entries not affecting the /// case `503` with `{"status":"degraded", ...}`. `warnings` always
/// status) so a poller gets detail either way. /// carries the full current list (including `warn`-level entries not
/// affecting the status) so a poller gets detail either way.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/health/ready", path = "/health/ready",

View file

@ -15,13 +15,14 @@ use hive_priv_sock::{InfraAction, InfraContainer};
use super::{AppState, error_response}; use super::{AppState, error_response};
/// `POST /api/infra-container/{name}/{action}` — start / stop / restart a /// `POST /api/infra-container/{name}/{action}` — start / stop / restart a
/// hive infrastructure container from the dashboard. `name` parses into /// hive infrastructure container from the dashboard.
/// [`InfraContainer`] (the allowlist; unrecognised names 400), `action` ///
/// into `start` / `stop` / `restart`. Every attempt lands in the audit log /// `name` parses into [`InfraContainer`] (the allowlist; unrecognised
/// (actor `"operator"`, action `start_infra` / `stop_infra` / /// names 400), `action` into `start` / `stop` / `restart`. Every attempt
/// `restart_infra`) and streams as an `AuditEntryAdded` event, so /// lands in the audit log (actor `"operator"`, action `start_infra` /
/// operator-driven and agent-driven (`infra_admin`) infra actions show up /// `stop_infra` / `restart_infra`) and streams as an `AuditEntryAdded`
/// in the same AUDIT view. /// event, so operator-driven and agent-driven (`infra_admin`) infra
/// actions show up in the same AUDIT view.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/infra-container/{name}/{action}", path = "/api/infra-container/{name}/{action}",

View file

@ -34,6 +34,7 @@ pub(super) struct JournalQuery {
} }
/// Read `journalctl -M <container> -b` and return its text output. /// Read `journalctl -M <container> -b` and return its text output.
///
/// Operator-only by virtue of the dashboard being host-bound. hive-c0re /// Operator-only by virtue of the dashboard being host-bound. hive-c0re
/// runs unprivileged (privsep), so the `-M` read — which enters the /// runs unprivileged (privsep), so the `-M` read — which enters the
/// container namespace and needs root — is delegated to hive-priv. /// container namespace and needs root — is delegated to hive-priv.
@ -160,9 +161,11 @@ pub(super) struct JournalHostQuery {
} }
/// `GET /api/journal-host?unit=<unit>&lines=N` — host-side journald (no /// `GET /api/journal-host?unit=<unit>&lines=N` — host-side journald (no
/// `-M` container flag). Restricted to an allow-list of known host services /// `-M` container flag).
/// so arbitrary unit names can't be probed. Operator-only by virtue of the ///
/// dashboard binding to a host-only port. /// Restricted to an allow-list of known host services so arbitrary unit
/// names can't be probed. Operator-only by virtue of the dashboard binding
/// to a host-only port.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/journal-host", path = "/api/journal-host",

View file

@ -60,7 +60,9 @@ pub(super) async fn post_rebuild(
} }
/// `POST /api/kill/{name}?graceful=1` — stop `name`, hard by default or /// `POST /api/kill/{name}?graceful=1` — stop `name`, hard by default or
/// gracefully (quiesce → drain → stop) when `graceful=1`. /// gracefully when `graceful=1`.
///
/// Graceful mode: quiesce → drain → stop.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/kill/{name}", path = "/api/kill/{name}",
@ -120,7 +122,9 @@ pub(super) async fn post_kill(
} }
/// `POST /api/restart/{name}?graceful=1` — restart `name`, hard by default /// `POST /api/restart/{name}?graceful=1` — restart `name`, hard by default
/// or gracefully (quiesce → drain → restart) when `graceful=1`. /// or gracefully when `graceful=1`.
///
/// Graceful mode: quiesce → drain → restart.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/restart/{name}", path = "/api/restart/{name}",
@ -423,9 +427,10 @@ pub(super) struct DestroyForm {
purge: Option<String>, purge: Option<String>,
} }
/// `POST /api/destroy/{name}` — destroy `name`'s container. Form field /// `POST /api/destroy/{name}` — destroy `name`'s container.
/// `purge` (any non-empty value, e.g. `"on"`) also wipes the retained ///
/// state dir instead of leaving a tombstone. /// Form field `purge` (any non-empty value, e.g. `"on"`) also wipes the
/// retained state dir instead of leaving a tombstone.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/destroy/{name}", path = "/api/destroy/{name}",

View file

@ -104,7 +104,9 @@ fn account_name_from_filename(fname: &str) -> Option<String> {
} }
/// `GET /api/matrix-accounts?agent=<name>` — matrix accounts provisioned /// `GET /api/matrix-accounts?agent=<name>` — matrix accounts provisioned
/// for `agent`, backfilled with `homeserver`/`live`/`user_id` from the daemon's /// for `agent`.
///
/// Backfilled with `homeserver`/`live`/`user_id` from the daemon's
/// snapshot. /// snapshot.
#[utoipa::path( #[utoipa::path(
get, get,
@ -188,6 +190,7 @@ struct MatrixLoginResult {
} }
/// Provision (or refresh) the token for an agent's extra matrix account. /// Provision (or refresh) the token for an agent's extra matrix account.
///
/// password mode → `m.login.password`; token mode → validate via `whoami`. /// password mode → `m.login.password`; token mode → validate via `whoami`.
/// On success writes the token to `matrix-token-<account>` via hive-priv and /// On success writes the token to `matrix-token-<account>` via hive-priv and
/// kicks the daemon. Operator-authenticated (dashboard). Never echoes the /// kicks the daemon. Operator-authenticated (dashboard). Never echoes the
@ -293,7 +296,9 @@ struct GithubAccountResult {
} }
/// Provision (or refresh) an agent's GitHub PAT from the dashboard /// Provision (or refresh) an agent's GitHub PAT from the dashboard
/// credentials tab. Validates the agent name, then writes the PAT to /// credentials tab.
///
/// Validates the agent name, then writes the PAT to
/// `<state>/github-token` (`0600`, agent-owned) via hive-priv. No account /// `<state>/github-token` (`0600`, agent-owned) via hive-priv. No account
/// creation and no daemon to kick — the agent's `gh` wrapper / git credential /// creation and no daemon to kick — the agent's `gh` wrapper / git credential
/// helper read the file live, so the new token takes effect immediately. /// helper read the file live, so the new token takes effect immediately.
@ -339,9 +344,10 @@ struct GithubAccountStatus {
} }
/// `GET /api/github-account?agent=<name>` — whether the agent has a GitHub /// `GET /api/github-account?agent=<name>` — whether the agent has a GitHub
/// PAT provisioned (its `github-token` file exists). Lets the credentials tab /// PAT provisioned (its `github-token` file exists).
/// show "token stored" vs "not set" instead of a black-hole paste field. ///
/// Never returns the token itself. /// Lets the credentials tab show "token stored" vs "not set" instead of a
/// black-hole paste field. Never returns the token itself.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/github-account", path = "/api/github-account",

View file

@ -179,11 +179,12 @@ pub(super) struct MetaUpdateForm {
} }
/// Bulk-update selected meta flake inputs, then rebuild the affected /// Bulk-update selected meta flake inputs, then rebuild the affected
/// agents in the background. Idempotent w.r.t. selection — choosing /// agents in the background.
/// an input that's already at the latest sha is a no-op (no commit, ///
/// no rebuild ripple). Returns immediately after queueing the work; /// Idempotent w.r.t. selection — choosing an input that's already at
/// dashboard polls for progress via container `pending` spinners + /// the latest sha is a no-op (no commit, no rebuild ripple). Returns
/// the meta-inputs row sha update. /// immediately after queueing the work; dashboard polls for progress
/// via container `pending` spinners + the meta-inputs row sha update.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/meta-update", path = "/api/meta-update",

View file

@ -16,6 +16,7 @@ use crate::container_stats::ContainerResource;
use crate::hive_stats::HiveStats; use crate::hive_stats::HiveStats;
/// Unread operator-directed messages for the dashboard's Y3R C4LL inbox. /// Unread operator-directed messages for the dashboard's Y3R C4LL inbox.
///
/// Returns messages addressed to `"operator"` that haven't been /// Returns messages addressed to `"operator"` that haven't been
/// acked yet (the operator clears them via the existing /// acked yet (the operator clears them via the existing
/// `POST /api/agent/operator/mark-all-read`). Newest-first; path-shaped /// `POST /api/agent/operator/mark-all-read`). Newest-first; path-shaped
@ -72,12 +73,14 @@ pub(super) async fn api_operator_inbox(State(state): State<AppState>) -> Respons
#[derive(Deserialize, IntoParams)] #[derive(Deserialize, IntoParams)]
pub(super) struct StatsHiveQuery { pub(super) struct StatsHiveQuery {
/// Stats window; defaults to `24h`.
window: Option<String>, window: Option<String>,
} }
/// Hive-wide turn-stats rollup for the dashboard swarm-stats view. /// Hive-wide turn-stats rollup for the dashboard swarm-stats view.
///
/// Aggregates every agent's `hyperhive-turn-stats.sqlite` read-only /// Aggregates every agent's `hyperhive-turn-stats.sqlite` read-only
/// (skips missing/unreadable ones). Window defaults to `24h`. /// (skips missing/unreadable ones).
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/stats-hive", path = "/api/stats-hive",
@ -97,8 +100,10 @@ pub(super) async fn api_stats_hive(
.into_response() .into_response()
} }
/// Live per-agent-container CPU + memory load from cgroup v2. Samples /// Live per-agent-container CPU + memory load from cgroup v2.
/// CPU over a short interval (~200 ms), so this call briefly awaits. ///
/// Samples CPU over a short interval (~200 ms), so this call briefly
/// awaits.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/container-resources", path = "/api/container-resources",
@ -110,8 +115,9 @@ pub(super) async fn api_container_resources() -> Response {
} }
/// `GET /api/audit-log` — most-recent agent-initiated privileged-action /// `GET /api/audit-log` — most-recent agent-initiated privileged-action
/// audit entries, newest first (server-clamped to 500). Backs the /// audit entries, newest first (server-clamped to 500).
/// operator dashboard's audit view. Returns ///
/// Backs the operator dashboard's audit view. Returns
/// `{ "entries": [AuditEntry…], "total": N }` so the UI can show /// `{ "entries": [AuditEntry…], "total": N }` so the UI can show
/// "latest 500 of N" rather than silently capping. `ts_unix` is in /// "latest 500 of N" rather than silently capping. `ts_unix` is in
/// **seconds**. /// **seconds**.
@ -138,11 +144,12 @@ pub(super) async fn api_audit_log(State(state): State<AppState>) -> Response {
} }
/// Operator-driven "clear this agent's inbox" — backs the side-panel /// Operator-driven "clear this agent's inbox" — backs the side-panel
/// "mark all read" button. Marks every message addressed to the /// "mark all read" button.
/// agent as acked (backfilling `delivered_at` for any still-pending ///
/// rows so vacuum can collect them). Returns `{ "marked": N }` so the /// Marks every message addressed to the agent as acked (backfilling
/// frontend can show "cleared N messages" feedback without an extra /// `delivered_at` for any still-pending rows so vacuum can collect
/// fetch. /// them). Returns `{ "marked": N }` so the frontend can show "cleared
/// N messages" feedback without an extra fetch.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/agent/{name}/mark-all-read", path = "/api/agent/{name}/mark-all-read",

View file

@ -299,13 +299,14 @@ pub(super) struct BatchPermsBody {
/// `(logical agent, new groups?, new caps?)`. /// `(logical agent, new groups?, new caps?)`.
type StagedPerm = (String, Option<Vec<String>>, Option<Vec<String>>); type StagedPerm = (String, Option<Vec<String>>, Option<Vec<String>>);
/// Batch permission apply — `POST /api/permissions`. The save-all /// Batch permission apply — `POST /api/permissions`.
/// permissions UI sends only the perm-types that actually changed per ///
/// agent; each affected agent gets ONE combined `PermChange`, so the /// The save-all permissions UI sends only the perm-types that actually
/// dedup key collapses to `(kind, agent)` and an agent whose caps AND /// changed per agent; each affected agent gets ONE combined
/// groups both changed rebuilds once, not twice. The whole batch is /// `PermChange`, so the dedup key collapses to `(kind, agent)` and an
/// atomic: every change is validated up front and on any validation /// agent whose caps AND groups both changed rebuilds once, not twice.
/// error nothing is written or enqueued. /// The whole batch is atomic: every change is validated up front and
/// on any validation error nothing is written or enqueued.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/permissions", path = "/api/permissions",
@ -428,11 +429,12 @@ pub(super) async fn get_stale_permissions(
} }
/// Clear all explicit permission entries for a named agent without /// Clear all explicit permission entries for a named agent without
/// requiring it to exist in the live roster. Used by the P3RM1SS10NS /// requiring it to exist in the live roster.
/// tab's "remove" button for agents that have stale explicit entries ///
/// in `tool-groups.json` / `capabilities.json` but are no longer /// Used by the P3RM1SS10NS tab's "remove" button for agents that have
/// running (e.g. an agent that was renamed or destroyed while its /// stale explicit entries in `tool-groups.json` / `capabilities.json`
/// JSON entries persisted). /// but are no longer running (e.g. an agent that was renamed or
/// destroyed while its JSON entries persisted).
/// ///
/// Bypasses `guard_agent_name`'s live-roster check intentionally — /// Bypasses `guard_agent_name`'s live-roster check intentionally —
/// the whole point is to remove entries for non-roster agents. Only /// the whole point is to remove entries for non-roster agents. Only

View file

@ -94,14 +94,14 @@ pub(super) async fn post_answer_question(
with_cors(resp) with_cors(resp)
} }
/// Resolve a pending operator question with a sentinel answer when
/// the operator decides not to / can't answer. The asker harness
/// receives a `QuestionAnswered` event with `answer = "[cancelled]"`
/// so it can fall back on whatever default it had. Same code path as
/// a real answer — just lets the operator close the loop instead of
/// letting the question dangle forever.
/// `POST /cancel-question/{id}` — resolve a pending question with the /// `POST /cancel-question/{id}` — resolve a pending question with the
/// `[cancelled]` sentinel answer. /// `[cancelled]` sentinel answer.
///
/// Used when the operator decides not to / can't answer. The asker
/// harness receives a `QuestionAnswered` event with
/// `answer = "[cancelled]"` so it can fall back on whatever default
/// it had. Same code path as a real answer — just lets the operator
/// close the loop instead of letting the question dangle forever.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/cancel-question/{id}", path = "/api/cancel-question/{id}",

View file

@ -19,8 +19,10 @@ use crate::scheduled_prompts_worker::FireNowReport;
use super::{AppState, error_problem, error_response}; use super::{AppState, error_problem, error_response};
/// `GET /api/schedules` — snapshot of every schedule for the /// `GET /api/schedules` — snapshot of every schedule for the
/// scheduled-prompts tab. Returns the wire shape directly /// scheduled-prompts tab.
/// so the frontend can render without an extra translation layer. ///
/// Returns the wire shape directly so the frontend can render
/// without an extra translation layer.
// `hive_sh4re::WireSchedule` (the actual body) has no `ToSchema` — adding // `hive_sh4re::WireSchedule` (the actual body) has no `ToSchema` — adding
// one would pull `utoipa` into the wire-types crate for a single dashboard // one would pull `utoipa` into the wire-types crate for a single dashboard
// endpoint. `serde_json::Value` placeholder; see the batch report. // endpoint. `serde_json::Value` placeholder; see the batch report.
@ -58,10 +60,11 @@ pub(super) async fn api_schedules(State(state): State<AppState>) -> Response {
} }
/// `POST /api/schedules` — operator-direct schedule creation /// `POST /api/schedules` — operator-direct schedule creation
/// (mara: "user can add them manually"). Accepts the same /// (mara: "user can add them manually").
/// `SchedulePromptPayload` shape as the manager request flow but ///
/// skips the approval gate — the operator click *is* the /// Accepts the same `SchedulePromptPayload` shape as the manager
/// approval. The schedule lands directly with /// request flow but skips the approval gate — the operator click
/// *is* the approval. The schedule lands directly with
/// `source = Operator` and the worker picks it up at fire time. /// `source = Operator` and the worker picks it up at fire time.
#[utoipa::path( #[utoipa::path(
post, post,
@ -120,13 +123,15 @@ pub(super) struct FireNowBody {
} }
/// `POST /api/schedules/{id}/fire-now` — operator-initiated /// `POST /api/schedules/{id}/fire-now` — operator-initiated
/// out-of-band fire of a scheduled prompt. Runs the per-target /// out-of-band fire of a scheduled prompt.
/// fan-out once immediately and reports per-target outcome counts. ///
/// One-shot schedules are consumed (cancelled) by a manual fire — /// Runs the per-target fan-out once immediately and reports
/// the operator's intent is "send this now, the scheduled time was /// per-target outcome counts. One-shot schedules are consumed
/// wrong." For recurring schedules the cadence stays intact unless /// (cancelled) by a manual fire — the operator's intent is "send
/// the body carries `{"reset_timer": true}`, in which case the /// this now, the scheduled time was wrong." For recurring schedules
/// countdown is re-armed from now (`next_fire_at = now + interval`). /// the cadence stays intact unless the body carries
/// `{"reset_timer": true}`, in which case the countdown is re-armed
/// from now (`next_fire_at = now + interval`).
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/schedules/{id}/fire-now", path = "/api/schedules/{id}/fire-now",
@ -244,17 +249,19 @@ where
} }
/// `PATCH /api/schedules/{id}` — partial update of an existing /// `PATCH /api/schedules/{id}` — partial update of an existing
/// schedule. Mutable fields: `body`, `description`, /// schedule.
/// `interval_seconds`, `next_fire_at_unix`, plus the target set ///
/// via `targets_add` / `targets_remove`. Both target lists /// Mutable fields: `body`, `description`, `interval_seconds`,
/// are applied in the same transaction as the scalar fields with /// `next_fire_at_unix`, plus the target set via `targets_add` /
/// removes-before-adds; re-adding a previously-removed target /// `targets_remove`. Both target lists are applied in the same
/// resets per-target history (fresh start); draining all targets /// transaction as the scalar fields with removes-before-adds;
/// auto-cancels the parent schedule. JSON body uses missing-key /// re-adding a previously-removed target resets per-target history
/// = "leave alone", explicit null = "clear" for `description` + /// (fresh start); draining all targets auto-cancels the parent
/// `interval_seconds`. Cancelled schedules are refused — submit /// schedule. JSON body uses missing-key = "leave alone", explicit
/// a new one instead. Returns the updated `WireSchedule` so the /// null = "clear" for `description` + `interval_seconds`. Cancelled
/// caller's post-edit refresh has the new state inline. /// schedules are refused — submit a new one instead. Returns the
/// updated `WireSchedule` so the caller's post-edit refresh has the
/// new state inline.
#[utoipa::path( #[utoipa::path(
patch, patch,
path = "/api/schedules/{id}", path = "/api/schedules/{id}",
@ -293,8 +300,10 @@ pub(super) async fn patch_schedule(
} }
/// `POST /api/schedules/{id}/pause` — pause a schedule so the worker /// `POST /api/schedules/{id}/pause` — pause a schedule so the worker
/// skips it until explicitly resumed. Idempotent; no-op on an already- /// skips it until explicitly resumed.
/// paused row. Returns 404 when the schedule is cancelled or not found. ///
/// Idempotent; no-op on an already-paused row. Returns 404 when the
/// schedule is cancelled or not found.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/schedules/{id}/pause", path = "/api/schedules/{id}/pause",
@ -326,6 +335,7 @@ pub(super) async fn post_schedule_pause(
} }
/// `POST /api/schedules/{id}/resume` — resume a paused schedule. /// `POST /api/schedules/{id}/resume` — resume a paused schedule.
///
/// Idempotent; no-op on an already-active row. Returns 404 when the /// Idempotent; no-op on an already-active row. Returns 404 when the
/// schedule is cancelled or not found. /// schedule is cancelled or not found.
#[utoipa::path( #[utoipa::path(
@ -360,8 +370,10 @@ pub(super) async fn post_schedule_resume(
/// `POST /api/schedules/{id}/cancel` — operator-side cancel /// `POST /api/schedules/{id}/cancel` — operator-side cancel
/// (whole schedule when no `targets` field, partial when one is /// (whole schedule when no `targets` field, partial when one is
/// provided). Operator bypasses the topology check; the manager /// provided).
/// surface enforces it for agent callers. ///
/// Operator bypasses the topology check; the manager surface
/// enforces it for agent callers.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/schedules/{id}/cancel", path = "/api/schedules/{id}/cancel",

View file

@ -18,6 +18,9 @@ use crate::paths::{AGENTS_ROOT, SHARED_ROOT};
#[derive(Deserialize, IntoParams)] #[derive(Deserialize, IntoParams)]
pub(super) struct StateFileQuery { pub(super) struct StateFileQuery {
/// Absolute path under an agent's `state/` dir or under `shared/`;
/// checked against the allow-list (`docs/security.md::State-file
/// endpoint`).
path: String, path: String,
} }
@ -164,10 +167,10 @@ pub fn scan_validated_paths(body: &str) -> Vec<String> {
out out
} }
/// `GET /api/state-file?path=…` — serve an allow-listed per-agent /// `GET /api/state-file?path=…` — serve an allow-listed file.
/// `state/` or `shared/` file. Raster images get their real ///
/// content-type; everything else is served as (possibly truncated) /// Raster images get their real content-type; everything else is
/// text. /// served as (possibly truncated) text.
#[utoipa::path( #[utoipa::path(
get, get,
path = "/api/state-file", path = "/api/state-file",

View file

@ -293,10 +293,12 @@ where
/// minutes. /// minutes.
const CRASH_WARNING_WINDOW: std::time::Duration = std::time::Duration::from_mins(10); const CRASH_WARNING_WINDOW: std::time::Duration = std::time::Duration::from_mins(10);
/// `GET /api/state` — cold-load snapshot of the whole dashboard: roster, /// `GET /api/state` — cold-load snapshot of the whole dashboard.
/// approvals (+ history), questions (+ history), tombstones, job queue, ///
/// meta inputs, and more. Live clients then follow `/api/dashboard/stream` /// Includes the roster, approvals (+ history), questions (+ history),
/// (SSE) for incremental updates keyed off `seq`. /// tombstones, job queue, meta inputs, and more. Live clients then
/// follow `/api/dashboard/stream` (SSE) for incremental updates keyed
/// off `seq`.
// `StateSnapshot` is a large tree of nested view types (`ContainerView`, // `StateSnapshot` is a large tree of nested view types (`ContainerView`,
// `ApprovalView`, `QuestionView`, ...) with no `ToSchema` anywhere in that // `ApprovalView`, `QuestionView`, ...) with no `ToSchema` anywhere in that
// graph; wiring it up is a schema-modelling project of its own, well past // graph; wiring it up is a schema-modelling project of its own, well past

View file

@ -48,6 +48,7 @@ pub(super) struct SetParentBulkEntry {
} }
/// `POST /api/topology/set-parent` — operator-driven parent move. /// `POST /api/topology/set-parent` — operator-driven parent move.
///
/// Form fields: `child` (required, agent name), `new_parent` /// Form fields: `child` (required, agent name), `new_parent`
/// (optional — empty / absent string ⇒ promote to root). Refuses /// (optional — empty / absent string ⇒ promote to root). Refuses
/// cycles and unknown agents (surfaced async on the job view — this /// cycles and unknown agents (surfaced async on the job view — this
@ -102,12 +103,13 @@ pub(super) async fn post_set_parent(
Ok((StatusCode::OK, "ok").into_response()) Ok((StatusCode::OK, "ok").into_response())
} }
/// `POST /api/topology/set-parent-bulk` — move multiple agents in a single /// `POST /api/topology/set-parent-bulk` — move multiple agents in a
/// request, producing **one** git commit. JSON body: `[{"child":"name", /// single request, producing **one** git commit.
/// "new_parent":"target-or-null"}, ...]`. Empty array is a no-op (200 OK). ///
/// First identifier that fails to parse aborts the whole batch before /// JSON body: `[{"child":"name", "new_parent":"target-or-null"}, ...]`.
/// anything is submitted — a partially-invalid bulk move never reaches /// Empty array is a no-op (200 OK). First identifier that fails to
/// the queue. /// parse aborts the whole batch before anything is submitted — a
/// partially-invalid bulk move never reaches the queue.
#[utoipa::path( #[utoipa::path(
post, post,
path = "/api/topology/set-parent-bulk", path = "/api/topology/set-parent-bulk",

View file

@ -58,8 +58,10 @@ pub(super) struct PushWebhookRepo {
} }
/// POST `/webhook/knowledge` — Forgejo push webhook for /// POST `/webhook/knowledge` — Forgejo push webhook for
/// `internal/knowledge`. Runs `git pull` on the local clone so /// `internal/knowledge`.
/// agents see up-to-date documents on their next turn. ///
/// Runs `git pull` on the local clone so agents see up-to-date documents
/// on their next turn.
/// ///
/// Expected Forgejo webhook configuration: /// Expected Forgejo webhook configuration:
/// - URL: `https://<HYPERHIVE_HIVE_DOMAIN>/webhook/knowledge` /// - URL: `https://<HYPERHIVE_HIVE_DOMAIN>/webhook/knowledge`