Skip to content

Reusable crates for remote hives: carve hum-identity/hum-thrum/hum-mcp leaf libs - #56

Open
adiled wants to merge 7 commits into
mainfrom
crates/reusable-hive-libs
Open

Reusable crates for remote hives: carve hum-identity/hum-thrum/hum-mcp leaf libs#56
adiled wants to merge 7 commits into
mainfrom
crates/reusable-hive-libs

Conversation

@adiled

@adiled adiled commented Aug 30, 2026

Copy link
Copy Markdown
Owner

What

Lands the "reusable crates for remote hives" boundary proposed in
hives/common/REUSABLE_CRATES.md. A remote hive (source in a foreign
repo, shallow-cloned by hum hive install) should depend on small leaf
crates for the wire, not the daemon's whole dependency tree.

Today every Rust hive that wants identity minting, the serve loop, or an
MCP bridge pulls nest-common, which transitively drags ensemble
(iroh/rustls), nest (command-group/portable-pty/sysinfo), drone, mcp,
hum-paths. The carve reduces that to tokio + serde + ed25519 + sha2 + hex
(+ axum for MCP).

Commits (c3cd7a6..a39c878)

  1. ids — move Hid/HidPrefix/HidParseError out of ensemble;
    ensemble re-exports ids::{...} for back-compat.
  2. hum-identity (new) — load_or_mint_bee_key / BeeKey /
    bee_key_path as a leaf crate (ids + hum-paths + ed25519-dalek +
    rand). hives/common::identity is a thin re-export shim.
  3. hum-thrum (new) — the wire client (connect / send_json /
    read_tones / serve_forever). serve_forager and serve_worker
    now use it; chi semantics stay in nest-common.
  4. hum-mcp (new) — the axum JSON-RPC bridge (spawn_local_mcp /
    McpBridge). hives/common::mcp_bridge is a thin shim; the mcp
    crate stays a pure library (no server).
  5. Tool surface — unify ToolDef/ToolResult on mcp::protocol
    (dropped the forager.rs duplicates; nest-common re-exports from
    mcp).

What stays in the daemon tree

nest's cell pool / WorkerBee / Egg, drone + suspicion_regex
(sentinel), and ensemble itself (the mesh is humd-to-humd; a bee
reaches a remote humd through that humd's transport, never opening the
mesh). Each new crate is independently publishable so an Orchfile can
point a hive at hum-thrum + hum-identity instead of the whole repo.

Verification

  • cargo build --workspace --exclude grpc-forager clean
  • Tests green: ids, hum-identity, hum-thrum (wire round-trip), hum-mcp
    (MCP bridge), nest-common, mcp, humfs (39) — 68 tests, 0 failed
  • grpc-forager excluded: needs protoc (environment prerequisite,
    unrelated to this change)

Docs

hives/common/REUSABLE_CRATES.md updated to mark the carve as landed and
list what's done.

adiled added 7 commits August 30, 2026 23:58
Move the content-addressable identity primitive (Hid, HidPrefix,
HidParseError) from ensemble into ids so light bee/identity crates can
mint Hids without dragging the whole mesh (iroh/rustls/etc). ensemble
re-exports ids::{Hid,HidPrefix,HidParseError} for back-compat, so
existing ensemble::Hid call sites keep compiling.

ids gains a hex dep for the wire-form encoding.
Extract load_or_mint_bee_key / BeeKey / bee_key_path from nest-common
into a standalone hum-identity crate so remote hives can depend on it
without pulling the daemon tree (ensemble/iroh, nest, mcp, etc).

- New crate hum-identity: ids (Hid) + hum-paths + ed25519-dalek + rand.
- hives/common/src/identity.rs becomes a thin re-export shim for
  back-compat; existing nest_common::load_or_mint_bee_key call sites
  keep resolving.
- Registered in workspace members; added to hives/common deps.
…r serve_forager

Factor the thrum wire loop (dial Unix socket, split, send NDJSON,
read tones, reconnect with jittered backoff) out of nest-common into a
standalone hum-thrum crate so remote hives can dial humd without
pulling the daemon tree.

- New crate hum-thrum: connect / send_json / read_tones / serve_forever.
  Deps: ids + hum-paths + hum-identity + thrum-core + tokio + serde_json.
- serve_forager (forager.rs) now uses hum-thrum for the wire; the
  ToolDispatcher / ToolDef / ToolResult semantics stay in nest-common.
- hum-identity re-exports ids::{Hid,HidPrefix} so consumers get the
  role type through hum_identity::HidPrefix.
- Wire round-trip test: real Unix socket, NDJSON hello contract.

Registered in workspace members; added to hives/common deps.
Swap the worker's manual Unix-socket connect/split/hello-write/read
loop for hum_thrum::connect / send_json / read_tones, keeping the
nest-specific dispatch (cells, MCP bridge, handle_prompt) in the
closure. The cancel / tool-result arms now spawn per-tone to fit the
sync read_tones closure, matching the forager's all-spawn pattern.

Behavior preserved: hello envelope, MCP bridge, per-sid cell routing,
grace-window reconnect policy all unchanged.
Move the axum JSON-RPC bridge (spawn_local_mcp / McpBridge / handle)
from nest-common into a standalone hum-mcp crate so remote worker
hives can expose tools to their compute over MCP without pulling the
daemon tree.

- New crate hum-mcp: mcp (protocol/catalogue/translate) + thrum-core
  (rid) + axum + tokio + parking_lot. Keeps the mcp crate pure (no
  server) — the bridge is the axum layer on top.
- hives/common/src/mcp_bridge.rs becomes a thin re-export shim for
  back-compat; existing nest_common::{spawn_local_mcp, McpBridge}
  call sites keep resolving.
- Moved the bridge tests (tools/list + tools/call round-trip) along.

Registered in workspace members; added to hives/common deps.
forager.rs defined its own ToolDef/ToolResult with the same shape as
mcp::protocol's. Remove the duplicates and use mcp::protocol::{ToolDef,
ToolResult} everywhere; nest-common now re-exports them from mcp.
humfs and the forager dispatch construct both types identically, so the
unify is a no-op at call sites (mcp's ToolResult also derives
Serialize/Default + serde attrs).

No separate hum-tooldef crate — mcp is already a pure library, so the
shared tool-surface types re-export straight from it (per the doc's
'...or just from mcp' option).
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