bb_ops/syscalls/structural/pass_through/mod.rs
1//! `PassThrough` - the framework's structural identity syscall.
2//!
3//! syscall component in bb-ops. The (domain, op_type) constants
4//! come from `bb_ir::syscall_ids`; the DSL recording helper, the
5//! runtime dispatch entry, and the `inventory::submit!`
6//! self-registration all live in one file alongside the sibling
7//! tests.
8
9use bb_ir::proto::onnx::NodeProto;
10use bb_runtime::atomic::DispatchResult;
11use bb_runtime::bus::OpError;
12use bb_runtime::registry::OpRegistration;
13use bb_runtime::runtime::RuntimeResourceRef;
14use bb_runtime::slot_value::SlotValue;
15
16// --- IR identity --------------------------------------------------
17
18pub use bb_ir::syscall_ids::OP_PASS_THROUGH as OP_TYPE;
19/// `(domain, op_type)` key. Re-exported from the foundation so
20/// every reference cites one declaration.
21pub use bb_ir::syscall_ids::SYSCALL_DOMAIN as DOMAIN;
22
23/// Engine dispatch-table marker - its sole purpose is to provide a
24/// unique `TypeId` for the syscall registry.
25pub struct PassThroughOp;
26
27// --- Runtime dispatch ---------------------------------------------
28
29/// Invoke fn - forwards the input value via polymorphic
30/// `SlotValue::clone_boxed`. The concrete type survives the hop;
31/// downstream consumers downcast to the type the graph contract
32/// guarantees at the consumer site.
33pub fn invoke(
34 _node: &NodeProto,
35 inputs: &[(&str, &dyn SlotValue)],
36 _ctx: &mut RuntimeResourceRef<'_>,
37) -> Result<DispatchResult, OpError> {
38 let Some((_, input)) = inputs.first() else {
39 return Err(OpError {
40 detail: "PassThrough requires one input".to_string(),
41 ..Default::default()
42 });
43 };
44 Ok(DispatchResult::Immediate(vec![(
45 "value".to_string(),
46 input.clone_boxed(),
47 )]))
48}
49
50// --- Inventory self-registration ----------------------------------
51
52inventory::submit! {
53 OpRegistration {
54 domain: DOMAIN,
55 op_type: OP_TYPE,
56 invoke,
57 kind: bb_runtime::registry::RegistrationKind::Syscall,
58 }
59}
60