Skip to content

Quick start

Steven Enamakel edited this page Sep 1, 2026 · 4 revisions

Quick start

Pin the repository as a submodule and take the crates as path dependencies.

git submodule add https://github.com/tinyhumansai/tinyhivemind.git vendor/tinyhivemind
[dependencies]
tinyhivemind = { path = "vendor/tinyhivemind/crates/tinyhivemind" }

The runtime crate re-exports tinyhivemind-core, so one dependency gets you both. A host that only needs desk, roster, and mention decisions can depend on tinyhivemind-core directly and skip the ports entirely. A host that wants deliberation takes tinyhivemind-hive, which re-exports the other two.

Resolving a mention

use tinyhivemind::{
    desk::{Desk, DeskSet, ResponderMode},
    mention::{direct_responder, resolve, MentionAuthor, MentionTarget},
    roster::{Roster, RosterMember},
};

let desks = [Desk {
    id: "engineering".into(),
    name: "Engineering".into(),
    description: Some("Build the product".into()),
    members: vec!["alice".into(), "bob".into()],
    responder_mode: ResponderMode::Lead,
}];
let set = DeskSet::new(&desks, &[], &[], &[], &[]);

let members = [RosterMember { id: "alice".into(), name: Some("Alice".into()) }];
let roster = Roster::new(&members, &[], &[]);

let mentions = resolve("Could you take this, @Alice?", None, &MentionAuthor::Other, &roster, &set);
assert_eq!(direct_responder(&mentions, &roster), Some("alice"));
assert_eq!(mentions[0].target, MentionTarget::Agent { id: "alice".into() });

Both calls are folds over borrowed slices. You did the roster read; the library does not repeat it.

Reading a deliberation

use tinyhivemind::{SessionAuthor, SessionMessage, Sequence};
use tinyhivemind_hive::{
    quorum::{consensus, standings, ConsensusState, QuorumPolicy},
    trace::read,
};

let traces = read(&transcript);
let policy = QuorumPolicy { threshold: 2, window: 100, require_grounded: true };
let standings = standings(&traces, Sequence(4), &policy)?;

assert_eq!(consensus(&standings, &policy), ConsensusState::Quorum { topic: "stage".into() });

A transcript of ordinary conversation folds to an empty medium. Nothing is coerced into a vote because it happened to be typed in a room.

Running the examples

cargo run -p tinyhivemind-core --example basic
cargo run -p tinyhivemind-hive --example hive
cargo run --release -p tinyhivemind-hive --example bench
cargo run --release -p tinyhivemind-hive --example bench -- --trace

The last one prints a single episode turn by turn, which is the fastest way to see what the protocol actually does.

Next

Host integration covers the three ports and what your application owes the library. Responder ladder covers how one message finds one agent.

Clone this wiki locally