Conversation
Greptile SummaryThis PR introduces a Rust native module SDK (
Confidence Score: 4/5Safe to merge after fixing the unconditional stdin pipe change, which silently breaks existing non-stdin-config native modules. One confirmed P1 defect: dimos/core/native_module.py — the subprocess stdin pipe handling Important Files Changed
Sequence DiagramsequenceDiagram
participant PY as Python NativeModule
participant PROC as Native Process (Rust)
participant LCM as LCM Multicast Bus
PY->>PROC: Popen(stdin=PIPE, stdout=PIPE, stderr=PIPE)
alt stdin_config=True
PY->>PROC: write JSON {"topics":{...},"config":{...}}\n
end
PY->>PROC: stdin.close() [EOF]
PROC->>PROC: from_stdin() reads line, parses JSON
PROC->>PROC: module.input("data", decode) / module.output("confirm", encode)
PROC->>PROC: module.spawn() → background tokio task
loop publish loop
PROC->>LCM: transport.publish(topic, data)
end
loop recv loop
LCM-->>PROC: transport.recv() → (channel, data)
PROC->>PROC: route.try_dispatch(data) → Input mpsc channel
end
Reviews (2): Last reviewed commit: "Merge branch 'dev' into andrew/feat/rust..." | Re-trigger Greptile |
Problem
We need support for Rust native modules to offload performance critical modules.
Closes DIM-XXX
Solution
See native/rust/examples for a Rust native ping pong example
Added NativeModule struct to allow easy publishing and subscribing to topics. NativeModules can use any transport that implements the Transport trait (currently only LCM).
Rust NativeModules also support configuration through stdin instead of cli args. Cli args are kept for backwards compatibility.
Breaking Changes
None
How to Test
For unit tests
cd dimos/native/rust
cargo test
For end to end test with two Rust modules talking over LCM
python3 rust_ping_pong.py
Contributor License Agreement