Watch
0
0
Fork
You've already forked hyperhive
0

swarm-wire: take notices's wire types, fmt the moved imports

This commit is contained in:
atlas 2026-10-18 21:34:58 +02:00 • committed by mara
commit fc72bea151
12 changed files with 72 additions and 86 deletions

View file

@ -8,10 +8,11 @@
pub mod agent_icon;
pub mod agent_inference;
pub mod agent_limits;
pub mod agent_schedules;
pub mod agent_login;
pub mod agent_schedules;
pub mod agent_status;
pub mod builder;
pub mod claude_login;
pub mod notices;
pub mod review_classifier;
pub mod wanted;

37
swarm-wire/src/notices.rs Normal file
View file

@ -0,0 +1,37 @@
//! The hive-notices stream: its name and subject shape.
//!
//! A hive that publishes and a swarm-level reader that consumes live in
//! different crates, and a literal name repeated across both is an agreement
//! nothing checks.
//!
//! **This is a stream, not a bucket.** The hive-status snapshot has a current
//! value, so a KV bucket (last value per key) is the right shape. A lifecycle
//! notice ("container crashed at 04:12") has no such steady state: miss the
//! message and nothing left to read later says it happened. That needs durable
//! delivery (a `JetStream` stream a consumer acks against), which
//! `swarm_queue_client::notices::open_or_create` opens.
/// The stream a hive publishes lifecycle notices into.
///
/// A constant and not an option, like every bucket name here:
/// reader and writer must name the same stream, and letting either side
/// pick its own name is how two deployments end up disagreeing about
/// which stream a notice actually landed in.
pub const STREAM: &str = "hive-notices";
/// Build the subject a given hive's notices publish to.
///
/// Every hive's notices land under `STREAM`, one subject per hive:
/// `hive-notices.<hiveName>`.
///
/// Not one subject per notice *kind* — a consumer that wants a specific
/// hive's notices subscribes to `subject(hive)`; one that wants the whole
/// swarm's subscribes to `{STREAM}.>`. The kind travels inside the message
/// payload instead, so adding a new notice kind is never a subject-design
/// change. Deliberately reuses `STREAM` rather than a second `PREFIX`
/// constant with the same value — one name for one fact, same reasoning
/// the module doc above gives for a shared `const` over a repeated literal.
#[must_use]
pub fn subject(hive: &str) -> String {
format!("{STREAM}.{hive}")
}