Conversation
Greptile SummaryThis PR adds a Rust native module SDK (
Confidence Score: 4/5Safe to merge after fixing the empty-dict-to-null coercion in native_module.py; remaining findings are P2 style/hardening suggestions. One P1 logic bug: the dimos/core/native_module.py — the config serialization logic at line 181 needs the falsy-dict guard removed. Important Files Changed
Sequence DiagramsequenceDiagram
participant Py as NativeModule (Python)
participant Proc as Rust Process
participant BG as Background Task (tokio)
participant LCM as LCM Bus
Py->>Proc: spawn(executable + CLI args)
Py->>Proc: stdin: {"topics": {...}, "config": {...}}
Proc->>Proc: from_stdin() — parse topics & config
Proc->>Proc: module.input() / module.output() — register routes
Proc->>BG: module.spawn() — start select! loop
loop message loop
LCM-->>BG: transport.recv() -> (channel, data)
BG->>BG: match route.topic() -> try_dispatch(data)
BG-->>Proc: mpsc channel delivers typed message
Proc->>BG: Output::publish(msg) -> mpsc send
BG->>LCM: transport.publish(topic, data)
end
Py->>Proc: SIGTERM (on stop())
Proc-->>Py: exit
|
| @@ -0,0 +1,15 @@ | |||
| [package] | |||
| name = "dimos-native-module" | |||
| version = "0.1.0" | |||
There was a problem hiding this comment.
I don't actually know if this should be in our main repo and how rust manages packages, but you can own these decisions
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