Skip to content

Quick start

Steven Enamakel edited this page Oct 3, 2026 · 6 revisions

Quick start

Pin the repository as a submodule and take the crates as path dependencies. Host integration covers what your application has to implement; the Glossary covers the vocabulary.

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

One dependency exposes the algebra, session ports, routing, and deliberation modules. The host only implements the ports it uses.

Resolving a mention

use tinyhivemind_core::{
    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

Core's hive module reads typed markers from attributed transcript rows. This example has two proposals and two grounded supporters for stage.

use tinyhivemind_core::{aside::Audience, runtime::{SessionAuthor, SessionMessage, Sequence}};
use tinyhivemind_core::hive::{
    quorum::{consensus, standings, ConsensusState, QuorumPolicy},
    trace::read,
};

fn said(sequence: u64, author: &str, content: &str) -> SessionMessage {
    SessionMessage {
        sequence: Sequence(sequence),
        author: SessionAuthor::Agent { id: author.into(), label: author.into() },
        content: content.into(),
        audience: Audience::Desk,
        elided: None,
    }
}

let transcript = [
    said(1, "planner", "!propose #stage Stage the rollout."),
    said(2, "scout", "!propose #ship Ship it now."),
    said(3, "critic", "!support #stage ^1 The flag limits exposure."),
    said(4, "planner", "!support #stage ^1 We can reverse it."),
];
let policy = QuorumPolicy { window: 100, ..QuorumPolicy::DEFAULT };
let standing = standings(&read(&transcript), Sequence(4), &policy)?;
assert_eq!(
    consensus(&standing, &policy),
    ConsensusState::Quorum { topic: "stage".into() },
);

This is a read of the medium, not an episode scheduler. For the latter, step returns either a bounded round of turns or a named terminal outcome. The hive example shows the host loop.

Running the examples

cargo run -p tinyhivemind-core --example basic
cargo run -p tinyhivemind-core --example hive
cargo run --release -p tinyhivemind-core --example bench
cargo run --release -p tinyhivemind-core --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. The examples are tinyhivemind-core/examples/ .

Next

Host integration covers the ports and what your application owes the library. Responder ladder covers how one message finds one agent. Hive episodes covers the mechanics, and Further reading covers where they came from.

Clone this wiki locally