Skip to main content

Module framework

Module framework 

Source
Expand description

Framework primitives bundled into every RuntimeResourceRef. Framework primitives bundled into every RuntimeResourceRef. 9 framework primitives the engine bundles into the RuntimeResourceRef for every dispatch_atomic call per docs/ENGINE.md §10 + docs/internal/IMPLEMENTATION_PLAN.md //! lines 770-779.

ships real impls for Scheduler / PeerGate / RequestTracker + adds 3 new primitives (serialize_queue / hold_table / record_buffer). Other primitives stay minimal until

Modules§

address_book
AddressBook - global PeerId → (Vec<Address>, ref_count) registry per ENGINE.md §10.5 + docs/ADDRESSING.md.
backoff_table
BackoffTable - per-peer exponential backoff state used by wire syscalls + transport adapters per ENGINE.md §10.2.
backpressure_notice
BackoffNoticePayload - typed wire payload for the backpressure protocol per docs/internal/superpowers/specs/2026-06-23-backpressure-runtime.md §2.
backpressure_tracker
BackpressureTracker - per-peer receiver-side state for the typed-overload-signal protocol per docs/internal/superpowers/specs/2026-06-23-backpressure-runtime.md.
event_source
EventSource - registered event_kind → ComponentTag subscription table consulted by the engine’s Phase 3 bus event routing per ENGINE.md §10.7.
hold_table
HoldTable - slot-named value buffer for Hold.Stash / Hold.Flush syscalls.
inbound_dedup
InboundDedup - sliding-window seen-message tracker per ENGINE.md §10.4.
outbound_queue
OutboundQueue - FIFO of wire envelopes ready to ship.
peer_gate
PeerGate - per-name concurrency limiter used by Limit.Acquire / Limit.Release syscalls.
peer_governor
PeerGovernor - the single source of truth for peer policy and health tracking per .
peer_state
PeerState — the framework’s consolidated per-peer state.
record_buffer
RecordBuffer - bounded per-name ring buffer used by the Record syscall.
request_tracker
RequestTracker - mint correlation tokens for CorrelateTag and track in-flight wire requests.
rng
RngU64Source - pluggable u64 RNG used by the RngU64 syscall op. Default impl wraps getrandom.
rtt_tracker
for adaptive deadlines on every wire round-trip.
scheduler
Scheduler - sorted timer heap.
serialize_queue
SerializeQueue - named-FIFO map for Serialize.Enqueue / Serialize.Dequeue syscalls.

Structs§

Address
Multiaddr - a sequence of typed Protocol segments describing a delivery path. Per docs/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.
AddressBook
Ref-counted PeerId → Vec<Address> registry. Single source of truth for “where can I reach this peer.”
BackoffNoticePayload
Wire-encoded BackoffNotice payload.
BackoffTable
Per-peer exponential backoff table.
BackpressureEntry
Per-peer back-pressure bookkeeping.
BackpressureTracker
Per-peer receiver-side back-pressure state.
CounterRng
Deterministic counter RNG for tests.
EventSource
event_kind → Vec<ComponentTag> subscription table.
FrameworkComponents
docs/ENGINE.md §3 bundle of framework primitives. Split-borrowed into each dispatch_atomic call’s RuntimeResourceRef.
GetrandomU64
Default getrandom-backed RNG.
HoldTable
Named-slot value buffer with bounded distinct-slot count.
InboundContext
Per-ExecId context captured at inbound envelope delivery. Replaces the four parallel envelope_* HashMaps with one struct of optional fields. Components access this through RuntimeResourceRef::inbound.
InboundDedup
Sliding-window seen-message tracker.
OutboundQueue
FIFO of wire envelopes ready to ship.
PeerGate
Per-name concurrency limiter.
PeerGovernor
Per-peer policy + health state owner.
PeerHealth
Per-peer health snapshot. Read by Node::peer_health() for operator introspection.
PeerState
Consolidated per-peer state.
RecordBuffer
Per-name ring buffer with two bounds.
RequestTracker
Monotonically-increasing token minter + in-flight tracker.
Scheduler
Sorted timer heap.
SerializeQueue
Named-FIFO map with per-queue bounded capacity.

Enums§

AddressBookError
Errors surfaced by AddressBook mutation methods.
AddressError
Decode errors surfaced by Address::from_bytes and Address::parse_str.
BackoffCause
Why the receiver is requesting a back-off.
BackoffCauseWire
Wire-stable encoding of BackoffCause. Serialized as a u8 so the on-wire representation never bit-shifts when the framework enum evolves. Always derived from the framework enum at the send site + mapped back at the receive site.
BackpressureDecision
Decision returned by BackpressureTracker::observe_overload.
BlockReason
Why a peer can’t receive an envelope, surfaced both inbound (drop) and outbound (gate failure).
Decision
Outcome of a check_inbound / check_outbound consultation.
LifecycleTransition
Side-effect of recording a failure or success - the engine translates these into EngineStep variants in Phase 8.
Protocol
One typed protocol segment in an Address multiaddr. Each variant maps to a stable BB-specific multiaddr code in the 0xE1-0xEF range (P2p reuses the libp2p code 0x55 since it carries the BB PeerId identity that crosses transport adapters). The binary encoding is code (u8) || payload where the payload’s length is fixed for every variant except Op (which is length-prefixed).
TimerKind
What a matured timer signals covers Sleep / Interval / After / Completion.

Constants§

BACKPRESSURE_DOMAIN
Domain string the framework uses to namespace the backpressure protocol per bb-runtime/src/bus.rs:155 reserved framework prefix. Surfaced for cross-referencing in docs + tests; the actual routing key is the per-fill type_hash from backoff_notice_type_hash.
DEFAULT_FAILURE_THRESHOLD
Default number of consecutive wire::Send failures before a peer is marked as down. PeerGovernor::record_failure emits the lifecycle transition; the engine’s Phase 8 surfaces it as EngineStep::PeerDown.
DEFAULT_HIGH_WATER_PCT
Default high-water mark percentage. Matches the spec default in §6: ingress queue depth >= 75% of capacity triggers a BackoffCause::QueueFull notice.
DEFAULT_K_BEFORE_SILENT
Default K (notices-without-slowdown before silent-drop). Matches RttEma::is_warm’s “evidence sufficient to act” threshold of 3 samples per bb-runtime/src/framework/rtt_tracker.rs:126-128.
DEFAULT_MIN_NOTICE_INTERVAL_NS
Default minimum interval between successive notices to the same peer (1 second). Acts as a hard lower bound on the duplicate-suppression window so a flood of inbound envelopes from one peer produces at most one notice per second even when the receiver lacks a tighter per-cause min_backoff_ns hint.

Traits§

RngU64Source
Source of u64 random values. Trait so tests can supply a deterministic counter via a different impl.

Functions§

backoff_notice_type_hash
Stable u64 discriminator for BackoffNoticePayload. Matches the canonical SlotFill.type_hash the framework stamps at send time and consults at receive time per bb-ir/src/slot_value.rs:203-210.
build_backoff_notice_envelope
Build a BackoffNotice wire envelope addressed to sender.

Type Aliases§

Multiaddress
Public DSL alias - the chosen name for Address on the graph surface. The internal type is framework::Address; the alias keeps user-facing code (Output<Multiaddress>, Multiaddress constants) reading naturally without introducing a second type.