-
Notifications
You must be signed in to change notification settings - Fork 2
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 = { 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.
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.
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.
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 -- --traceThe 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/
and
tinyhivemind-hive/examples/.
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.
tinyhivemind is GPL-3.0-only. Built by @senamakel.
Start here
The algebra
- Shared medium
- Desks and rosters
- Mentions
- Cross-desk referral
- Transcript projection
- Threads
- Recall
- Responder ladder
Hive mechanics
Working on it
Reference