Expand description
Re-exports§
pub use install::install;pub use install::Config;pub use install::InstallError;pub use bb_ir::bincode;pub use bb_ir::inventory;pub use bb_compiler as compiler;pub use bb_ops as ops;
Modules§
- aggregators
- Concrete
Aggregatorimplementations the framework ships (e.g.FedAvg). ConcreteAggregatorContract implementations the framework ships out of the box. Each impl bridges the user-facingbb_runtime::contracts::Aggregatortrait to the engine’sdispatch_atomicpath through thebb_derive::Aggregatormacro and self-registers viainventory::submit!. - atomic
- Atomic dispatch declaration types +
DispatchResult. Catalog declarations stay inbb-ir;DispatchResultcarriesCommandIdand so lives here.AtomicOpsetDecl,AtomicOpDecl,AtomicOpKind,DispatchResult. Engine-side atomic dispatch result. Catalog types (AtomicOpsetDecl,AtomicOpDecl,AtomicOpKind) live inbb_ir::atomic; re-exported here for one-import access. - backends
- Concrete
Backendimplementations the framework ships (CpuBackend+ theexecute_graphwalker that drives aGraphProtothrough it). Concrete backend implementations. Each backend (cpu, cuda, …) is one self-contained unit underbb_ops::backends::<name>. - bus
- Typed in-Node event bus.
Typed in-Node event bus.
Typed in-Node event bus. Cross-Component signaling per
docs/ENGINE.md§13.1. - completion
CompletionHandlefor async Contract methods.CompletionHandle,CompletionSink,ContractResponse.CompletionHandlefor async Contract methods. Implementations call [CompletionHandle::complete]; the handle routes through a [CompletionSink] (typicallyIngressQueue), which the engine drains on its next poll to unpark the suspended op.- component
ErasedComponent+AnyComponenttraits + foundation polymorphism plumbing (ComponentPackage,RestoreError,SerializeFn,RestoreFn). Foundation polymorphism plumbing shared bybb-dsl(authoring) andbb-runtime(dispatch).- concrete
ConcreteComponentpolymorphism contract + theComponentHandlefn-pointer-capture wrapper.ConcreteComponentpolymorphism contract — canonical home inbb-runtime::concrete. This module re-exports the type for authoring ergonomics sobb_dsl::concrete::ConcreteComponentkeeps resolving.- contracts
- User-facing Contract traits (
Index,Aggregator,Model,Codec,DataSource,PeerSelector,Backend,Protocol). User-facing Contract traits — canonical home isbb-runtime::contracts. This module re-exports the traits for authoring ergonomics sobb_dsl::contracts::Indexetc. keep resolving. - engine
- The sans-IO Engine state machine. The sans-IO Engine state machine. The sans-IO Engine state machine
- envelope
WireEnvelopecodec; per-type decoders register throughbb_ir::slot_value::register_type_node!.WireEnvelopecodec; per-type decoders register throughbb_ir::slot_value::register_type_node!.WireEnvelopecodec- errors
- Public error taxonomies. Public error taxonomies. Public error taxonomies surfaced by the user-facing API.
- exec_
state - Per-poll execution-state bundle owned by
Engine.exec.ExecState— per-poll execution-state bundle (frontier, slot table, pending state, scheduler, inbound contexts, monotonic ID allocator). Owned byEngineas one field.ExecState— the engine’s per-poll execution-state bundle. - fallible
- Test-only components, gated behind the
test-componentsfeature. Thread-localtry_reserve_exactfault-injection seam. Exposed undertest-componentsso integration tests intests/drive the same seam as crate-internal sibling tests.try_reserve_exactwrapper at ingress boundaries so allocator failures surface as typed events.fallible::testingis a stub-allocator seam undertest-components. FallibleVec::try_reserve_exactwrapper used at engine ingress boundaries perdocs/internal/superpowers/specs/2026-06-24-engine-boundary-fallibility-and-backend-owned-tensors.md§1 (Principle 1) + §2.1 sites S4 / S5. - framework
- Framework primitives bundled into every
RuntimeResourceRef. Framework primitives bundled into everyRuntimeResourceRef. 9 framework primitives the engine bundles into theRuntimeResourceReffor everydispatch_atomiccall perdocs/ENGINE.md§10 +docs/internal/IMPLEMENTATION_PLAN.md//! lines 770-779. - graph
Graphrecording context. Recording context wrapping the in-progressFunctionProto. The proto is the IR — semantic BB attributes ride on proto fields, not a parallel Rust shadow store. Seedocs/IR_AND_DSL.md§2.- ids
- Identity newtypes. Engine-internal IDs (
NodeSiteId,OpRef,ExecId,CommandId,ComponentRef) live here; wire/compiler IDs (PeerId,RequestId,OpsetId,ComponentTag) come frombb-irre-exported through this module. Engine identifier types —PeerId,NodeSiteId,OpRef,ComponentRef,ExecId,CommandId,RequestId,OpsetId,ComponentTag. Engine-internal IDs. Wire/IR IDs come frombb_ir::idsre-exported here for a single import surface. - ingress
- Lock-free MPMC ingress queue. Lock-free MPMC ingress queue. Lock-free MPMC ingress queue.
- install
bb::install— single Node construction entry point.- keys
- Framework attribute-key string constants (
BACKEND_SUBGRAPH_BODY_ATTR,WIRE_TRANSPORT_KEY, …). Re-exported so proc-macro emission reaches them without users depending onbb-irdirectly. Single source of truth for metadata-key string constants shared across DSL → Compiler → Runtime. Reference these constants rather than re-typing"ai.bytesandbrains.*"literals. - module
- The
Moduletrait.Module::build()returns a recordedModelProtothatCompilerconsumes. TheModuletrait.Module::build()produces one pre-compileModelProtowherefunctions[0]is the top-level body andfunctions[1..]are composed sub-Modules (deduped byname()). - node
- Public
Node+ lazy build chain. PublicNode+ lazy build chain.Node— the framework’s runtime construct, installed via [bytesandbrains::install] and driven throughNode::poll. - output
- Non-generic
Outputhandle threaded through DSL method chains. Non-genericOutputhandle threaded through DSL method chains. - peer_
class - Peer-class metadata stamps (
SELF_CLASS,PEER_CLASS_KEY,HOME_CLASS_KEY). Peer-class metadata for partitioning by “what kind of Node does this op run on.”PEER_CLASS_KEYtagsOutput<PeerId>producers;HOME_CLASS_KEYtags each NodeProto with the class of Node it runs on (stamped byinfer_peer_classes). - placeholders
- Role-method dispatch slot placeholders (
BackendSlot,IndexSlot,ModelSlot, …). Module fields are typed against these; the compiler binds them to concrete implementations. Role-method dispatch slot placeholders. Each*Slotunit struct is a generic slot bound at compile time viaCompiler::new().bind_<role>::<T>("slot"). DSL methods record NodeProtos stamped with(required_trait, slot_id)for binding-resolution routing. - prelude
- Canonical authoring surface in a single import.
- proto
- Prost-generated proto bindings (ONNX +
bb.core). Prost-generated proto bindings. - protocols
- Concrete
Protocolimplementations the framework ships (e.g.GlobalRegistryClient,GlobalRegistryServer). Protocol implementations -<Role>Runtimebridges for concrete coordination protocols. Each lives in a sub-directory and self-registers viainventory::submit!per the standard component-authoring contract. - recorded
RecordedModule— the DSL → Compiler hand-off produced byGraph::finish().RecordedModule- the compiler’s input type.- registry
- Global inventory-collected registry for custom ops + concrete
components. Proc-macros emit
::bytesandbrains::registry::*paths into this namespace. Global inventory-collected registry for custom ops. Global registries collected viainventory. - roles
- The
<Role>Runtimerole traits. The<Role>Runtimerole traits. Framework-internal engine-side<Role>Runtimetraits. - runtime
- Runtime resource handle +
ComponentTimerKind. Runtime resource handle +ComponentTimerKind. Runtime resource handle threaded into everydispatch_atomiccall. - slot_
value - Universal slot value trait. Re-exports
bb_ir::slot_valueplus engine-side carriers (BackendTensorCarrier) that bypass the serde-driven blanket impl. The universalSlotValuetrait. The universalSlotValuetrait — every value flowing through slot sites (DSL outputs, wire payloads, syscall returns, role-method returns) implements it via the blanketimpl<T: Tensor> SlotValueand per-primitive impls. - snapshot
NodeSnapshot.NodeSnapshot.NodeSnapshot- syscall
ai.bytesandbrains.syscall v1opset (runtime-side dispatch + DSL-side helpers). FoundationSlotValueimpls -PeerIdValue,WireReqIdValue,TriggerValue,BytesValue,CommandIdValue. FoundationSlotValueimpls -PeerIdValue,WireReqIdValue,TriggerValue,BytesValue,CommandIdValue. The polymorphism layer every syscall component consumes; kept in bb-runtime so components in bb-ops link against a single canonical source.- syscall_
ids - Stable
(domain, op_type)+ attribute-name string constants for every framework syscall - the IR contract between bb-compiler + bb-runtime. Syscall identifier string constants — the IR-level contract between compiler (gate emission) and runtime (dispatch). - telemetry
- Optional OpenTelemetry layer constructors for the engine’s
tracing::spans. Optional OpenTelemetry layer constructors for the engine’stracing::spans. Optional OpenTelemetry layer constructors for the engine’stracing::spans. - tensor
- Tensor and Scalar abstractions. Backends implement. Tensor + Scalar abstractions. The framework crate ships no concrete tensor type; backends implement these traits over their own storage of choice.
- types
- Polymorphic type system — hierarchical
TypeNodetree resolved at compile time by the bb-compiler’s TypeSolver. Hierarchical type system resolved at compile time by the compiler’s TypeSolver. The tree is open via inventory: backends and DSL authors register new leaves viainventory::submit!. TheLatticeis built once at startup;is_subtype_ofwalks the parent chain with caching. The runtime never sees abstract types. - wire
- Wire codec contract + canonical
TypeNodestatics (TYPE_TENSOR_F32,TYPE_TRIGGER,TYPE_PEER_ID, …). Wire codec hash helper.
Macros§
- register_
op register_op!{}proc-macro re-exported frombb-derive. Register a custom op with the global inventory.- register_
protocol register_protocol!{}proc-macro re-exported frombb-derive. Declarative macro emitting a completeProtocolRuntimeimpl from a struct + opset + ops block.
Structs§
- Address
- Multiaddr - a sequence of typed
Protocolsegments describing a delivery path. Perdocs/ADDRESSING.md, this is BB’s canonical address type: the suffix segments tell the receiver where to route inside its own node, so no per-message-type or per-endpoint-id lookup tables are needed. - Bootstrap
Input - Host-supplied bootstrap input staging request — borrowed shape.
The host hands the engine a
targetname plus an ordered(input_name, value_bytes)slice; the engine validates against the target’s declared formal input ports and runs the Principle 1a copy (cap-check →try_reserve_exact→extend_from_slice) so the caller’s borrowed buffers can drop the momentcrate::node::Node::run_bootstrapreturns. - Compiler
- The single compile entry point.
- Engine
Stats - Point-in-time hot-path counters for dashboards + saturation detection. Not synchronized against an in-flight poll cycle.
- Generic
Slot Spec - Description of a generic placeholder slot the user must bind at
Node construction via
with_<role>(impl). - Graph
- Recording context every DSL method writes into.
- Ingress
Queue - Lock-free MPMC ingress queue + waker. Multiple external
producers may
pushconcurrently; the engine’s single consumer drains viadrain_allon each poll cycle. - Ingress
Queue Ref - Cheap-clone handle to the shared
IngressQueuesurfaced bycrate::node::Node::ingress_handle. Behaves identically toArc<IngressQueue>viaDerefso callers can.push(IngressEvent::...)directly. The newtype wrapper isolates the public API from the underlying smart-pointer choice. - Node
- Constructed BB Node ready to drive ML work. Produced by
[
bytesandbrains::install] — by the time the host holds one, the engine has resolved its dispatch table, registered every bound concrete, and installed the target function as the root graph. - Node
Config - Construction-time configuration for a
Node. - Node
Snapshot - Top-level snapshot per ENGINE.md §15.1.
- Output
- Handle passed between DSL methods. Carries the recorded ONNX
value name plus a
&'staticpointer to the canonicalTypeNodeof the value’s type. - PeerId
- Peer identity. Wraps a fixed-capacity
Multihash<64>so overlays pick their own digest algorithm. Same wire shape aslibp2p_identity::PeerId; bytes round-trip without translation. - Transient
Snapshot - Runtime ephemeral state per ENGINE.md §15.1.
- Type
Node - Static type-identity carrier. Identity is pointer equality;
subtype queries route through
Lattice.
Enums§
- Build
Error - Recording-time errors. Compile-time errors come from the compiler.
- Delivery
Error - Errors surfaced by host-facing delivery methods on
Node. - Engine
Step - One step of work the engine performed during a poll cycle.
Engine::pollreturnsVec<EngineStep>capturing every event the host can observe. - Ingress
Event - External-event variants pushed to the ingress queue per
docs/ENGINE.md§6 entry points. - Restore
Error - Errors surfaced by
Node::restore(the public surface arrives in the commit that landssrc/node.rs).
Statics§
- TYPE_
PEER_ ID - Concrete
PeerId- canonical peer identifier (multihash). - TYPE_
TENSOR_ F32 - Concrete
Tensor<F32>- dense f32 tensor.
Traits§
- Aggregator
- User-facing Contract trait for a federated/decentralized
aggregator. The derive bridges these methods to the engine’s
crate::roles::AggregatorRuntimetrait. - Backend
- User-facing Contract trait for a tensor compute backend.
- Codec
- User-facing Contract trait for a typed in/out storage codec.
- Data
Source - User-facing Contract trait for a data source / data loader.
- Index
- User-facing Contract trait for a vector index.
- Model
- User-facing Contract trait for an ML model.
- Module
- Unit of composition. Implement
name()+body(); framework suppliesop()andbuild(). Body declares inputs viag.input("name")and emits viag.output("name", value)(local) org.net_out("name", peers, value)(network). - Peer
Selector - User-facing Contract trait for a peer-selection protocol.
Functions§
- address_
book_ insert_ many - Record an
AddressBook::InsertMany(peer, addresses)custom-op NodeProto into aGraph. New peer creates an entry withref_count = 1; known peer dedupe-appends every address without touchingref_count. Emptyaddressesvec surfaces as a dispatch-timeOpError. - address_
book_ lookup - Record an
AddressBook::Lookup(peer)custom-op NodeProto into aGraph. Output carries the full orderedTYPE_ADDRESS_VEC; callers that need a single address pick one downstream. Unknown or empty-address peer surfaces as a dispatch-timeOpError. - announce
- Record a
GlobalRegistryClient::AnnounceNodeProto. The client readsctx.local_addresses()automatically, throttles sub-interval calls to the server’s last advertised heartbeat interval, and merges the server’s address bag from the Handshake reply. - constant
- Record a typed
Constantsyscall NodeProto. Bootstrap-stage constants seed the AddressBook + GlobalRegistry ops with the server’s PeerId and dial bag at install time. The compiler’sexpand_constantpass requiresvalue: TensorProto; this helper satisfies that contract with an empty tensor sized for the declared scalar kind. - gate_
dispatch - Record a
GateDispatchsyscall NodeProto into aGraph- a multi-edge synchronization barrier. - pass_
through - Record a
PassThroughsyscall NodeProto into aGraph.
Derive Macros§
- Aggregator
#[derive(bb::Aggregator)]— bridges a Contract impl toAggregatorRuntime. Derivebb::Aggregatorbridge.- Backend
#[derive(bb::Backend)]— bridges a Contract impl toBackendRuntimeand emits theai.onnx v1opset declaration. Derivebb::Backendbridge - emits the ai.onnx v1 51-op opset declaration;dispatch_atomicforwards intoBackend::execute.- Codec
#[derive(bb::Codec)]— bridges a Contract impl toCodecRuntime. Derivebb::Codecbridge - emits ConcreteComponent + CodecRuntime.- Concrete
#[derive(bb::Concrete)]— emits theConcreteComponent- Data
Source #[derive(bb::DataSource)]— bridges a Contract impl toDataSourceRuntime. Derivebb::DataSourcebridge.- Index
#[derive(bb::Index)]— bridges a Contract impl toIndexRuntime. Derivebb::Indexbridge - emitsConcreteComponent,AnyComponent,IndexRuntime, andinventory::submit!.- Model
#[derive(bb::Model)]— bridges a Contract impl toModelRuntime. Derivebb::Modelbridge.- Peer
Selector #[derive(bb::PeerSelector)]— bridges a Contract impl toPeerSelectorRuntime. Derivebb::PeerSelectorbridge.