Skip to content

hive: a bee is a key its hive entered, and hum launches nothing - #86

Merged
adiled merged 6 commits into
mainfrom
hive/bee-decouple-standalone
Oct 24, 2026
Merged

adiled merged 6 commits into
mainfrom
hive/bee-decouple-standalone

Conversation

@adiled

@adiled adiled commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

What this is

The hive/bee model, settled. A hive is a kind, installed on a humd. A bee is a participant: a key its hive entered, and whatever signs a hello with that key. hum launches nothing; what runs is each hive's own business.

No C and no dwarfstar here. The dwarfstar hive (#85) lands on top and needs to follow this model (see the end).

The first commit's archetypes are gone: no archetype, no <kind>-<archetype> naming, no HUM_BEE_ARCHETYPE, and no HUM_BEE either.

The model

  • A hive is a directory with an Orchfile. hum recognises one unit in it, hive-install. hum hive <ref> install records the hive in ~/.config/hum/hives.d/<hive>.orch, then runs that unit in the foreground with HUM_SRC, HUM_HIVE, and hum on its PATH. If the unit fails, the record is removed. hum reads nothing else in the Orchfile.
  • Entering is signing a bee in, by label. hum bee enter --hive <hive> --as <label> mints an ed25519 key at ~/.local/state/hum/bees/<id>.key, records it under the hive and label in bees.d/<id>.json, and prints the id (bee_<sha256(pubkey)>). The same hive and label are always the same bee, so a process enters itself each time it starts (--as main), and a runtime holding many bees enters each by its own label. hum bee <id> exit signs a bee out and reenter signs it back in.
  • humd admits a hello only if the hive it names is installed, it is signed by an entered key (pubkey, signedAt, and a signature over hum-bee-socket-v1:<hid>:<signedAt>), and that key entered under that hive and hasn't exited. Unsigned, stale or forged hellos, and keys entered under another hive, are refused, so a process can no longer claim another bee's hid. The record is read at every hello, so an exit takes effect from the next one.
  • A bee's place in the nest is its socket. One runtime can hold many bees by opening a socket per bee.
  • Remote bees are gossiped as before, but a humd only routes to one whose hive it has installed itself.
  • hum launches nothing. Every call from hum into orchd is gone, and so is hum nest. The installer still installs orchd, for hives to use. Each bundled hive's hive-install runs its own install script, which builds and runs its process under orchd in its own hum-<hive> namespace; the process enters its own main bee when it starts.

openai-server: every requester is a bee

Each HTTP requester is fingerprinted by a hash of its bearer token, its X-Tenant and the request's user, and entered as an asker bee labelled requester-<fingerprint>. Its requests go to humd over its own socket, signed by its own key, so humd sees, logs and can exit or revoke each requester separately. The fingerprint is the only trace of the token on disk. Idle requester sockets close after ten minutes. The process's own main bee keeps the upstream OpenAI worker.

The spec is enforced

The per-chi body structs in thrum-core/src/views.rs are now machine-readable as the spec (thrum_core::spec, read from the structs' own serde shape, and a new chi does not compile without a view). A key that is neither an envelope key nor in its chi's view is undeclared; a bee's private data belongs under ext. humd checks every tone it hears and sends: in the field it logs each undeclared key once (thrum.tone.undeclared), and in the simulator any undeclared key fails the test. This found and removed toolNames on hello, toolName on tool results, the legacy bee roles field, and several stray keys in test fixtures. WIRE.md states the rule.

Wire (THRUM_VERSION 0.8.0)

  • A hello names its hive and roles and must carry hid, pubkey, signedAt and signature. The canonical HelloBody matches, and the TS/Python/Go clients are regenerated from it.
  • Bee hids are bee_. A role is a claim in the hello, never part of the identity. wbee_/fbee_ still parse, so older revocation entries keep working.
  • HiveManifest is BeeManifest (hive, roles; still reads an older humd's name/bee in gossip), and hive_advertise/discover are bee_*, on the same topic.
  • The comb counts per hive (hive:<name>:…); older bee:<name>:… keys are folded in on load.

Bees

Rust bees use hum_identity::enter_as(hive, "main") (or hum_nest::serve_worker/serve_forager, which do it). TS, Go and the paid-oracle buyer enter through hum bee enter … --as … and sign with the same key format and message. The Kotlin bee (wifi-p2p) reads a provisioned id and key and signs with BouncyCastle; the old code derived the wrong public key.

Code is speech

Every code file this PR touches keeps only its top-of-file header; other comments were removed, hives included. Generated client files keep their WIRE.md descriptions.

Verification

  • cargo test --workspace green, with the simulator in strict wire mode. New coverage: uninstalled hive, unsigned hello, never-entered key, key entered under another hive, exited bee, remote routing gated on a locally installed hive, labelled entering.
  • tools/speech.py clean; Go and Python client tests pass.
  • openai-server bun test green, including a new test that two requesters become two asker bees and one requester stays one bee.
  • All 9 Rust hives compile against this branch's crates (temporary path patch; lockfiles untouched). twilio-sms vets.

Not verified: the bundled install scripts against the real orchd (that writes launchd agents), the Kotlin build, and typechecking anthropic-server and vercel-ai (no node_modules; their identity.ts is identical to openai-server's).

Upgrading

Reinstall the hives you run (hum hive <name> install). Every bee is entered fresh. Bees started by an older hum in hum's own orchd namespace are not stopped by the upgrade; orchd --project-dir ~/.config/hum fell once clears them.

Relation to #85

#85's C bee was written for archetypes and per-archetype keys. On top of this it should enter itself with hum bee enter --hive dwarfstar --as main (or a label per bee it hosts), sign its hello as above, and leave process supervision to the dwarfstar hive's own hive-install.

A hive is a kind. A bee is a participant. An archetype is a shape a bee
of that kind can take. The Orchfile is the addressable target: point a
humd at one and it sets the hive up, with no knowledge of the hive
itself.

So the CLI stopped knowing how hives are built. cargo, pnpm and go are
gone from it; each hive carries a build script and the CLI runs that.
The Orchfile's RUN execs the artifact where the hive keeps it — nothing
is installed into the system's PATH, because a bee is a participant, not
an installed program.

The Orchfile may declare several SERVICE directives: those are the
archetypes of the kind, named <kind>-<archetype> for now while the
hives overlay the central Orchfile and share one hum namespace. The
first SERVICE is the kind's own bee; the rest are alternatives.

A bee tells which archetype it is with HUM_BEE_ARCHETYPE, and says so
in the hello: the hive it belongs to, and the nestler id that lets two
nestlers of one kind register without their manifests collapsing into
one. The identity key follows the archetype, so each is its own
participant with its own hid.

Paths come from the environment.

Standalone: this carries the hum-core refactor and the build-script
split for the existing hives; the dwarfstar hive (the C bee / the
engine linked in) is the exemplar and lands via its own PR.
The grow() function now reads the base Orchfile to inherit ARGs like HOME
for ${VAR} expansion in overlay ENV lines. This allows services like
dwarfstar-ds4flash-q2 to inherit HOME from the base Orchfile and have
DWARFSTAR_DIR populated from the env override.
decl_args superseded declared_args (it carries values, not just names);
this branch swapped the one caller over, which left declared_args and its
HashMap import dead. grow() was reading the base Orchfile twice — once for
the discarded 'base' binding, once fresh for base_args; read it once and
reuse. Both were dead code the refactor left behind; removing them leaves the
hum package warning-free.
A hive is a kind. A directory with an Orchfile is one, and hum asks a
single thing of it: a hive-install unit, which `hum hive <ref> install`
runs after recording the hive in hives.d. Everything else the hive runs,
and how it keeps it alive, is the hive's own business. The archetype
naming, the unit-as-bee reading of the Orchfile and every call from hum
into orchd are gone; `hum nest` with them. The installer still puts
orchd on the machine, for hives to use.

A bee is a participant, not an instance of its kind. It is a key: `hum
bee enter --hive <hive>` mints one at bees/<id>.key, records it under
the hive in bees.d, and prints the id. Whatever the hive runs as that
bee is told its id in HUM_BEE and signs its hello with the key. `hum bee
<id> exit` signs it out and `reenter` signs it back in.

humd admits a hello only when its hive is installed and it is signed by
a key entered under that hive and not exited. An unsigned hello, a stale
or forged signature, or a key from another hive is refused, so a process
can no longer claim another bee's hid. A remote bee of a kind this humd
never installed is never routed to.

The hello names its hive and its roles; roles replace the old `bee`
field, which is still read, and hids are bee_<sha256(pubkey)>. The comb
counts per hive (hive:<name>:…), folding older bee:<name>:… keys in.
HiveManifest is BeeManifest, and hive_advertise/discover are bee_*, on
the same announce topic. THRUM_VERSION is 0.8.0.

Each bundled hive's hive-install runs its own install script: build,
enter a bee (reused on reinstall), and run its process under orchd in
its own hum-<hive> namespace with HUM_BEE set. Every bee — Rust through
hum-nest or by hand, TS, Go, Kotlin, the paid-oracle buyer — loads its
key from HUM_BEE and signs.
@adiled adiled changed the title hive: the kind, the bee, and the archetype (hum-core, dwarfstar-free) hive: a bee is a key its hive entered, and hum launches nothing Oct 24, 2026
… the spec

Entering takes a label. `hum bee enter --hive <hive> --as <label>` is
the same bee every time for one hive and label, so a process enters
itself when it starts (`--as main`) and a runtime that holds many bees
enters each by a label of its own. HUM_BEE is gone: nothing hands a
process its id any more. The bundled hives' install scripts only build
and run; Rust bees call hum_identity::enter_as, the TS, Go and buyer
bees go through the hum CLI, so entering has one implementation.

openai-server treats every requester as a bee. A requester is
fingerprinted by a hash of its bearer token, X-Tenant and `user`, and
entered as an asker labelled requester-<fingerprint>. Its requests go to
humd over its own socket, signed by its own key, so humd sees, logs and
can exit or revoke each one apart. Idle requester sockets close after
ten minutes; the process's main bee keeps the upstream worker.

The views in thrum-core are the spec, read from their own serde shape
by thrum_core::spec, and a new chi does not compile without one. humd
checks every tone it hears and sends against it: in the field each
undeclared key is logged once, in the simulator it fails the test. That
removed toolNames from hello, toolName from tool results, the legacy
`bee` roles field and stray keys in test fixtures. WIRE.md states the
rule.

Code is speech: the code files this branch touches keep only their
top-of-file header, hives included. MIGRATING.md is gone, and the docs
carry no em dashes in what this branch wrote.
Read through runuz, the names that still argued with the model:

A role is never part of who a bee is, so the hid prefixes are humd and
bee alone. Wbee, Fbee and same_key are gone, and with them the
revocation list's and the manifest's readings of the older spellings;
no old-prefixed bee can enter, so nothing was left for them to keep.

nestler_id was a phase word used as an identity, and humd read
`nestlerId` from a hello that never declared it. Signed hids made it
dead; it is gone.

A worker is a role a bee plays, so the hum-nest trait is Worker, not
WorkerBee, and what a worker says about itself is WorkerAdvert, beside
ForagerAdvert. A hive's config is the hive's: hum_paths::hive_config at
hives/<hive>.json, and HiveConfig in the TS hives. anthropic-server's
registrar is its bee. bee_retract retracts a bee by its id, not a hive
by its name. VOCABULARY names the forager contract it has
(ToolDispatcher), and the hives guide points at hum-nest.
@adiled
adiled merged commit 6823427 into main Oct 24, 2026
4 checks passed
@adiled
adiled deleted the hive/bee-decouple-standalone branch October 31, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant