Skip to main content

Crate bb_compiler

Crate bb_compiler 

Source
Expand description

The compilation pipeline. Each pass is a pure function over GraphProto / FunctionProto. Composition flattens at authoring time, so no compiler-side sub-Module inlining pass exists. partition_by_wire_ops slices at wire ops via reachability + names partitions by longest common module_instance prefix.

Re-exports§

pub use analyze_wire_edges::analyze_wire_edges;
pub use derive_wire_deadlines::derive_wire_deadlines;
pub use driver::Compiler;
pub use driver::CompilerStage;
pub use driver::PassError;
pub use error::CompileError;
pub use error::SlotSource;
pub use error::ValidationError;
pub use expand_ops::expand_ops;
pub use inline_for_partition::inline_for_partition;
pub use insert_async_deadlines::insert_async_deadlines;
pub use insert_backoff_gate_rx::insert_backoff_gate_rx;
pub use insert_backoff_gate_tx::insert_backoff_gate_tx;
pub use insert_dedup_gate_rx::insert_dedup_gate_rx;
pub use insert_peer_health_gate_rx::insert_peer_health_gate_rx;
pub use insert_peer_health_gate_tx::insert_peer_health_gate_tx;
pub use partition_by_wire_ops::partition_by_wire_ops;
pub use partition_by_wire_ops::NetworkAnalysis;
pub use partition_by_wire_ops::WireEdge;
pub use resolve_slots::resolve_slots;
pub use runner::CANONICAL_PASS_NAMES;
pub use stamp_compilation_metadata::stamp_for_test;
pub use synthesize_wire_recvs::synthesize_wire_recvs;
pub use type_solver::TypeError;
pub use type_solver::TypeSolution;
pub use type_solver::TypeSolver;
pub use validate::validate;
pub use validate_bootstrap_composition::validate_bootstrap_composition;
pub use validate_runtime_complete::validate_runtime_complete;
pub use verify_no_dangling_calls::verify_no_dangling_calls;

Modules§

analyze_wire_edges
analyze_wire_edges — classify each cross-Node edge as data or trigger_only and group sends in the same cycle scope for batching.
derive_wire_deadlines
Stamps each wire.Send’s static deadline from the (per_hop_budget_ns × chain_depth) formula, defaulting to chain_depth = 1 when no chain_depth on every target-boundary wire.Send. For each such Send, computes the static deadline as chain_depth * per_hop_budget_ns and stamps it as a deadline_ns: i64 attribute on the NodeProto. The existing super::insert_async_deadlines pass then inserts a DeadlineCheck gate upstream so the deadline is enforced at runtime.
driver
Compiler — single compile entry point. Canonical pipeline runs once per compile target; user stages fire after, once per emitted partition.
error
Compiler error taxonomies. ValidationError is exclusive to validate; CompileError covers everything else and wraps ValidationError via From.
expand_ops
expand_ops — materialize op-variant choices.
gate_contract
Open GateContract inventory consumed by [crate::validate_runtime_complete].
infer_peer_classes
infer_peer_classes - stamp every NodeProto with the class of Node it runs on.
inline_for_partition
Selective function inlining for the partition stage.
insert_async_deadlines
Pair every NodeProto carrying a deadline_ns attribute with an upstream DeadlineCheck syscall gate. The check writes to a new sibling <node>#__trigger_deadline slot so the protected node fires only after both its original payload AND the deadline gate.
insert_backoff_gate_rx
Compiler pass - pair every synthesized wire::Recv op with a downstream BackoffGateRx. Runs after insert_peer_health_gate_rx so the RX chain order is Recv → DedupGateRx → PeerHealthGateRx → BackoffGateRx.
insert_backoff_gate_tx
Compiler pass - pair every wire::Send op with an upstream BackoffGateTx syscall. The gate consults [crate::framework::BackoffTable] and drops sends to peers currently in cooldown.
insert_dedup_gate_rx
Compiler pass - pair every synthesized wire::Recv op with a downstream DedupGateRx. First in the RX gate chain (cheap drops for replays).
insert_peer_health_gate_rx
Compiler pass - pair every synthesized wire::Recv op with a downstream PeerHealthGateRx. Runs after insert_dedup_gate_rx so the RX chain order is Recv → DedupGateRx → PeerHealthGateRx.
insert_peer_health_gate_tx
Compiler pass - pair every wire::Send op with an upstream PeerHealthGateTx syscall. The gate consults [crate::framework::PeerGovernor] before the Send fires; blocked / cooldowned peers fail the send through the existing OpFailed path without the Send queueing an envelope.
partition_by_wire_ops
Slice the recorded function into per-BB-Node sub-graphs by wire-op reachability.
refine_polymorphic_value_info
refine_polymorphic_value_info — narrows the placeholder TYPE_TENSOR denotation stamped by the DSL recorder on every Contract-method NodeProto to each bound concrete’s actual Storage::TYPE.
resolve_component_dependencies
resolve_component_dependencies pass.
resolve_slots
resolve_slots + pre-flight. Final check before a ModelProto is emitted: rejects a Module where the same role domain hosts BOTH a concrete-type provider AND a generic (required_trait, slot_id) provider — that combination is AmbiguousRole.
runner
Pipeline orchestrator. Runs canonical passes in order and emits one ModelProto per partition; functions[0] is the partition main, functions[1..] are hoisted sub-Module bodies. Driven from crate::driver::Compiler::compile.
rx_chain
RX-chain head bookkeeping shared by the RX gate-insertion passes.
stamp_compilation_metadata
stamp_compilation_metadata — the final pass that turns each per-partition ModelProto into a complete artifact by writing the compilation passport + slot binding table into metadata_props. Install reads these stamps; the typed BindingSpec Rust struct never crosses the compile boundary after this pass runs.
synthesize_wire_recvs
synthesize_wire_recvs - synthesize a wire.Recv NodeProto on each receiver partition for every wire.Send’s cross-partition data consumer.
type_solver
Type-resolution pass — bipartite worklist solver following TVM Relay’s type_solver.h design, adapted to Rust.
validate
Structural sanity check. Reject malformed input before any other pass mutates it. Pure function over GraphProto.
validate_all_slots_bound
validate_all_slots_bound — surfaces a typed CompileError::UnboundSlot when the compiler hasn’t been given enough information to construct every component the runtime needs. Walks the artifact’s BindingSpec + IR + every bound concrete’s DEPENDENCIES.
validate_bootstrap_composition
Structural check for the bootstrap-as-function composition tree.
validate_runtime_complete
Final structural completeness check.
verify_no_dangling_calls
Structural verifier: every entry in model.functions[1..] must be reachable from model.functions[0] via the CALL chain. Errors when a CALL chases a function name absent from model.functions. Orphan entries (no CALL referencing them) are tolerated today; a later reachability-pruning pass may tighten this.