hive-sh4re + docs: extract AgentMeta wire-shape prose (#717 batch 8)

This commit is contained in:
iris 2026-05-31 16:21:14 +02:00 committed by mara
commit 777d26812a
2 changed files with 43 additions and 44 deletions

View file

@ -389,15 +389,9 @@ pub enum AgentRequest {
/// to `{state_dir}/hyperhive-status` so it survives harness restarts.
/// Pass an empty string to clear the status.
SetStatus { text: String },
/// Fetch metadata for an agent: identity (name + role + hyperhive
/// rev) and current status. When `name` is `None` the caller's own
/// identity is returned (self-introspection — replaces the old
/// `Whoami` request). When `name` is `Some`, the target agent's
/// status fields are populated but `role`/`hyperhive_rev` reflect
/// the responding daemon's view (`role` is best-effort: `"manager"`
/// for the manager agent, `"agent"` for everyone else).
/// `status_text` / `status_set_at` are `None` when the target has
/// never set a status or the agent name is unknown.
/// Fetch identity + status for an agent. `name = None` =
/// self-introspection; `Some(<agent>)` = target query. See
/// `docs/conventions.md::Agent metadata`.
GetAgentMeta {
#[serde(default, skip_serializing_if = "Option::is_none")]
name: Option<String>,
@ -446,18 +440,8 @@ pub enum AgentResponse {
PendingRemindersCount { count: u64 },
/// `ReminderRollup` result: reminder activity stats for the agent.
ReminderRollup(ReminderStats),
/// `GetAgentMeta` result: identity + status metadata for an agent.
/// `role` is `"agent"` for sub-agents and `"manager"` for the
/// manager. `hyperhive_rev` is `None` only when the configured
/// flake URL has no canonical path. `running` reflects whether the
/// target's container is currently up (#432); when it's false,
/// `status_text` / `status_set_at` are intentionally cleared by the
/// host because the on-disk values are stale snapshots from before
/// the stop. `status_text` is the last value written via
/// `SetStatus`, or `None` when none has been set or the agent name
/// is unknown. `status_set_at` is a Unix timestamp (seconds since
/// epoch) of when the status was last written; `None` when no
/// status is set.
/// `GetAgentMeta` result. Per-field semantics + serde defaults
/// live in `docs/conventions.md::Agent metadata`.
AgentMeta {
name: String,
role: String,
@ -469,24 +453,16 @@ pub enum AgentResponse {
status_text: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
status_set_at: Option<i64>,
/// Hive display name (#701 / #710) — e.g. `"pr1ma"`. Host
/// reads from its own `HYPERHIVE_HIVE_NAME` env (set by
/// `services.hyperhive.hiveName`); `None` when the option
/// isn't configured.
#[serde(default, skip_serializing_if = "Option::is_none")]
hive_name: Option<String>,
/// Swarm display name (#701 / #710) — e.g. `"constellat1on"`.
/// Source mirrors `hive_name` (`HYPERHIVE_SWARM_NAME` env /
/// `services.hyperhive.swarmName`).
#[serde(default, skip_serializing_if = "Option::is_none")]
swarm_name: Option<String>,
},
}
/// Serde default for the `running` field on legacy wire payloads that
/// predate #432 — older harnesses never serialised it, and `true`
/// matches the historical assumption (the host only knew how to ask
/// about live containers).
/// Serde default for the `running` field; keeps wire backwards-compat
/// with pre-running-field payloads. See
/// `docs/conventions.md::Agent metadata`.
fn default_true() -> bool {
true
}
@ -744,8 +720,7 @@ pub enum ManagerRequest {
/// Mirror of `AgentRequest::SetStatus` on the manager surface.
SetStatus { text: String },
/// Mirror of `AgentRequest::GetAgentMeta` on the manager surface.
/// `None` returns the manager's own identity (replaces the old
/// `Whoami` request).
/// See `docs/conventions.md::Agent metadata`.
GetAgentMeta {
#[serde(default, skip_serializing_if = "Option::is_none")]
name: Option<String>,
@ -950,11 +925,7 @@ pub enum ManagerResponse {
/// `ReminderRollup` result: reminder activity stats for the manager.
ReminderRollup(ReminderStats),
/// Mirror of `AgentResponse::AgentMeta` on the manager surface.
/// `role` is `"manager"` for the manager and `"agent"` for any
/// sub-agent looked up by name. `running` is false when the
/// target's container is stopped (#432) — in that case
/// `status_text` / `status_set_at` are cleared by the host so
/// stale pre-stop values don't leak through.
/// See `docs/conventions.md::Agent metadata`.
AgentMeta {
name: String,
role: String,
@ -966,13 +937,8 @@ pub enum ManagerResponse {
status_text: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
status_set_at: Option<i64>,
/// Hive display name (#701 / #710), same source + semantics
/// as on `AgentResponse::AgentMeta`. Read from the host's
/// `HYPERHIVE_HIVE_NAME` env so manager + agent surfaces
/// return the same view.
#[serde(default, skip_serializing_if = "Option::is_none")]
hive_name: Option<String>,
/// Swarm display name (#701 / #710), mirror of `hive_name`.
#[serde(default, skip_serializing_if = "Option::is_none")]
swarm_name: Option<String>,
},