Expand description
Canonical Send / Recv NodeProto shape — the contract every wire-IR-touching pass + runtime gate agrees on.
Wire ops carry a specific NodeProto shape. Centralizing the contract here keeps the DSL emitters, compiler passes, and runtime gates from drifting on string literals or attribute layouts.
This module is the single declarative description of that
shape. The DSL emits to it; the compiler passes mutate within
it; the runtime consumes it. [crate::verify::wire_shape]
checks a ModelProto against the contract.
§The shape
§Send
NodeProto {
op_type: "Send",
domain: "ai.bytesandbrains.wire",
input: [payload_0, payload_1, ..., payload_{N-1}, peer],
output: [handle],
attribute: [
(name: "peer", type: BYTES, t: <PeerId.to_bytes() multihash>),
(name: "dest_suffix.{name}", type: BYTES, t: <multiaddr-bytes>),
(name: "deadline_ns", type: INT, i: <i64-ns>), // optional
],
metadata_props: [
("ai.bytesandbrains.wire.wire_id", "<u64>"),
("ai.bytesandbrains.wire_transport", "data" | "trigger_only"),
("ai.bytesandbrains.batch_group_id", "<u32>"),
("ai.bytesandbrains.dest_site_name.{name}", "<recv-site-name>"),
],
}§Recv
NodeProto {
op_type: "Recv",
domain: "ai.bytesandbrains.wire",
input: [],
output: [received_0, received_1, ..., received_{N-1}, sender],
metadata_props: [
("ai.bytesandbrains.wire.wire_id", "<u64 matching paired Send>"),
("ai.bytesandbrains.wire_transport", "data" | "trigger_only"),
],
}wire_id pairs the Send/Recv halves across the cut.
wire_transport tells the runtime whether each fill carries a
payload (data) or is firing-signal-only (trigger_only).
§Key invariants the contract pins
-
ATTR_PEERis bytes, not i64. The peer attribute on a Send carries the PeerId’s canonical multihash byte form (PeerId::to_bytes()), NOT au64-collapsed identity hash. The runtime gates parse viaPeerId::from_bytes(&attr.t). -
wire_idis the pairing token. The DSLGraph::wiremints a monotonic u64 and stamps it on BOTH halves; the compiler’sdiscover_wire_edgespair Send/Recv by it. -
wire_transportlives on the NodeProto itself.analyze_wire_edgesstamps it ontopartition.functions[0].node[i].metadata_propsin place, so downstream passes and the runtime read a single source of truth. -
SlotFill.type_hashis populated from the sender side’sT::HASH. Receivers dispatch wire bytes viaif envelope.fill.type_hash == T::HASH { T::deserialize(&fill.payload) }.
Re-exports§
pub use crate::syscall_ids::ATTR_PEER;pub use crate::keys::DEST_SUFFIX_ATTR_PREFIX;pub use crate::syscall_ids::ATTR_DEADLINE_NS;pub use crate::keys::WIRE_ID_KEY;pub use crate::keys::WIRE_TRANSPORT_KEY;pub use crate::keys::WIRE_TRANSPORT_DATA;pub use crate::keys::WIRE_TRANSPORT_TRIGGER_ONLY;pub use crate::keys::DEST_SITE_NAME_PREFIX;
Constants§
- OP_RECV
- op_type for a Recv node.
- OP_SEND
- op_type for a Send node.
- WIRE_
DOMAIN - Wire-op domain. All Send / Recv NodeProtos live under here.
Functions§
- is_recv
- Return
trueif the NodeProto is awire.Recv. - is_send
- Return
trueif the NodeProto is awire.Send. - read_
peer_ bytes - Read the destination peer’s multihash bytes from a Send / gate
NodeProto. Returns
Noneif the attribute is absent or carries no byte content. The byte payload lives onattribute.sper the ONNX convention for raw bytes (paired withAttributeType::String); callers reconstruct the PeerId viaPeerId::from_bytes(read_peer_bytes(node)?). - read_
wire_ id - Read the wire_id metadata stamp from a Send or Recv node.
Returns
Noneif the key is absent or non-numeric. - stamp_
peer_ bytes - Stamp the destination peer onto a Send / gate NodeProto’s
attribute.s(bytes) using the canonical multihash form. Used by the compiler’s gate-insertion passes and any pass synthesizing new Send NodeProtos. - stamp_
wire_ transport - Stamp the
WIRE_TRANSPORT_KEYclassification onto a wire-op NodeProto’smetadata_props(idempotent: replaces an existing value).