pub struct GraphSlot {
pub function: FunctionProto,
pub op_dispatch: Vec<OpDispatch>,
pub consumers: HashMap<NodeSiteId, Vec<OpRef>>,
pub site_names: HashMap<String, NodeSiteId>,
pub top_level_outputs: HashMap<NodeSiteId, String>,
pub recv_sender_sites: HashMap<NodeSiteId, NodeSiteId>,
pub recv_wire_type_hash: HashMap<NodeSiteId, u64>,
pub recv_site_to_slot_id: HashMap<NodeSiteId, u32>,
pub is_entry_point: bool,
}Expand description
Per-FunctionProto compiled data installed on the Engine. Keyed
in Engine.graphs by (domain, name, overload) - the canonical
symbol-table key the linker dedupes on. The map key IS the name,
so GraphSlot carries no separate name field.
Fields§
§function: FunctionProtoThe post-analysis FunctionProto body. Source of truth for
op_type / domain / input + output names. function.node[i]
is the NodeProto for OpRef pack(graph_idx, i).
op_dispatch: Vec<OpDispatch>Per-NodeProto dispatch decision, indexed parallel to
function.node[]. Populated by Engine::resolve_dispatch
after install; runtime invoke is op_dispatch[node_idx]
where node_idx = op_ref.split().1.
consumers: HashMap<NodeSiteId, Vec<OpRef>>Producer site → downstream consumer ops. Used by
write_outputs to push ready consumers onto the frontier.
site_names: HashMap<String, NodeSiteId>Site name → NodeSiteId allocation.
top_level_outputs: HashMap<NodeSiteId, String>Top-level function.output sites, mapped from NodeSiteId to
the declared output name. When a value lands at one of these
sites and consumers[site] is empty, the engine surfaces it
as EngineStep::AppEvent { module_name, topic: <output name> }
— the “function signature is the engine I/O contract” path.
Populated only for entry-point GraphSlots (is_entry_point).
recv_sender_sites: HashMap<NodeSiteId, NodeSiteId>wire.Recv payload site → sender site pairing. Recv NodeProtos
emit two outputs — (payload, sender). The inbound envelope
delivers its byte payload to the payload site; the engine
also writes PeerIdValue(src_peer) to the sender site on the
same execution so downstream user ops can read the
provenance of the received message and reply by sending back
to the same peer. Populated at install time by scanning
every ai.bytesandbrains.wire Recv NodeProto with two
outputs.
recv_wire_type_hash: HashMap<NodeSiteId, u64>wire.Recv payload site → expected wire-type hash. When the
compiler stamped ValueInfoProto.type_node on a Recv’s
payload output, the runtime carries the producer-side
type_hash here so the typed-receive path can fire a
WireReceiveError { kind: TypeMismatch } when an inbound
fill’s type_hash does not match the slot contract.
Slots without an entry are treated as dynamic / Any: the
decoder-registry lookup proceeds without the mismatch
check. Populated at install time alongside
Self::recv_sender_sites.
recv_site_to_slot_id: HashMap<NodeSiteId, u32>wire.Recv payload site → bound role slot id. Built at
install time by reading the compiler-stamped
RECV_SLOT_ID_KEY off each wire.Recv NodeProto and pairing
it with the Recv’s allocated NodeSiteId. Consumed by
decode_typed_fill to cross from data-plane identity
(NodeSiteId) to binding identity (slot_id) before
dispatching the backend-mediated tensor path. Recv sites whose
payload does not flow into a role-bound slot are absent.
is_entry_point: booltrue if this function is an entry point (a registered
Module’s main partition function). Entry-point GraphSlots
have top_level_outputs populated; sub-function bodies do not
(their outputs flow through CallContext.output_forwarding at
call time).
Implementations§
Source§impl GraphSlot
impl GraphSlot
Sourcepub fn from_function(
_name: String,
function: FunctionProto,
graph_idx: u32,
next_node_site_id: &mut u64,
) -> GraphSlot
pub fn from_function( _name: String, function: FunctionProto, graph_idx: u32, next_node_site_id: &mut u64, ) -> GraphSlot
Canonical install path: walks the FunctionProto’s
nodes assigning positional OpRefs + fresh NodeSiteIds,
populates op_index + site_names + consumers per
docs/ENGINE.md §3.
OpRefs pack as (graph_idx << 32) | node_idx so the engine
hot path resolves OpRef → NodeProto via two array accesses
(the op_index HashMap is retained only as a /// migration aide; C8 deletes it). graph_idx is the engine’s
number of already-installed graphs at the moment of install,
passed in by the caller (typically Engine::install_graph /
install_function_library). NodeSiteIds remain globally
monotonic via next_node_site_id since they cross graphs.