hyperhive/hive-types
Repository files (latest commit first)
Filename Latest commit message Latest commit date
atlas 5202e5c5ba types: reserve the protocol names an agent must not be called
An agent's name was checked for shape and never for meaning:
`Ident::parse` is 1-63 chars of [a-z0-9-] and there was no reserved-name
list anywhere in the tree. So an agent could be called `operator`,
`forge` or `todo` -- names the message layer already produces as a
sender -- and a wake from that component became indistinguishable, at the
broker, from a message sent by the agent.

Adds `RESERVED_NAMES` + `is_reserved_name` to `hive-types`, the zero-dep
leaf both `hive-c0re` and `swarm-controller` already depend on, so
neither grows a dependency to use it.

Every entry is a value some component actually produces as a message
`from`/`to`, taken from `hive-sh4re`'s own sentinel constants rather than
guessed: operator, system, reminder, forge, scheduled, todo, compact,
graceful-stop. Two sentinels are deliberately absent -- `<parent>` and
`<children>` are unreachable as agent names because the charset rejects
them, and `ruth` is a real agent, so wanting that name is a name being
*taken*, which the roster answers.

Deliberately not enforced inside `Ident::parse`: parsing runs on every
read of an already-created name, so rejecting there would make existing
agents unreadable rather than un-creatable -- and it would be a refusal,
which is a stronger action than the warning this is used for today.

`create_agent` now warns on both halves -- a reserved name, and a name
that is also a hive in the roster -- and does not refuse. The warnings
ride on `CreateAgentResponse` rather than only the daemon's log, because
the person who can still fix the name in one keystroke is holding the
response, not reading the journal. `skip_serializing_if` keeps the
no-warning JSON byte-identical to before, so this is a non-breaking first
step toward refusing later.

`hive-sh4re` gains a drift test tying its sentinel constants to the list:
two crates that cannot import each other's intent now fail loudly if a
sentinel is added without being reserved. Mutation-verified -- forcing
the predicate false, forcing it true, and dropping a single entry each
turn a different test red.
2026-08-27 16:36:42 +02:00
..
src types: reserve the protocol names an agent must not be called 2026-08-27 16:36:42 +02:00
Cargo.toml docs(#2627): add READMEs for the remaining infra crates 2026-07-23 13:16:29 +02:00
README.md docs(#2627): add READMEs for the remaining infra crates 2026-07-23 13:16:29 +02:00

hive-types

Foundational shared newtypes for the hyperhive workspace. A zero-dependency (bar serde) leaf crate, so every wire-type crate (hive-sh4re, hive-host-sock, hive-core-agent-sock) and both binaries (hive-c0re, hivectl) can share them without cross-crate coupling and without growing hive-sh4re.

What's here

  • Ident — a validated agent-name newtype. Typing agent-name fields as Ident (rather than bare String) gets serde-validated parsing at the socket boundary for free: a malformed name is rejected at deserialize time instead of flowing into a handler that has to re-validate by hand.

The crate is deliberately a leaf with the smallest possible dependency footprint so anything in the workspace can depend on it. See docs/conventions.md ("identity = socket") for how agent identity is modelled across the sockets.