swactor/crates/iroh-driver
Zachery Aaron Shores-Chmielewski c257dde02f refactor: fold driver pumps into iroh-driver and codecs into transport
Consolidate the duplicated JSON codec into `transport` and relocate the iroh edge-transport pieces into `iroh-driver`, dissolving the `mvp-system` transport shim.

- `transport`: add a canonical `json_codec::JsonCodec<M>` (re-exported from the crate root) as the single JSON codec for serde message types
- `distribution`/`datastream`: drop the per-crate `JsonCodec` copies and the `impl_json_codec!` macro; register SWIM/gossip and publisher messages against the shared `swactor_transport::JsonCodec`
- `iroh-driver`: move `driver_pumps` and `endpoint_advertisement` out of `mvp-system/src/transport/`, re-exporting `EndpointAddrMask`/`advertised_endpoint`/`MVP_IROH_ENDPOINT_ADDR_MASK_ENV`, and relocate the endpoint guarantee test to `iroh-driver/tests/endpoint_advertisement.rs`
- `mvp-system`: delete the `transport/` module and keep codec aggregation in a new `codecs.rs` (`register_mvp_actor_codecs`)
- `mvp-system/node`: shrink `worker_node_runtime.rs` (~260 lines) by adopting the relocated modules and collapsing verbose `emit_stdio_node_event` calls into local `boot()`/`worker_evt()` closures

Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-07-30 12:18:02 +04:00
..
src refactor: fold driver pumps into iroh-driver and codecs into transport 2026-07-30 12:18:02 +04:00
tests refactor: fold driver pumps into iroh-driver and codecs into transport 2026-07-30 12:18:02 +04:00
Cargo.toml docs(iroh-driver): add spec, slim mvp-system specs 2026-07-21 10:25:52 +04:00
IROH_DRIVER_SPEC.md docs(iroh-driver): add spec, slim mvp-system specs 2026-07-21 10:25:52 +04:00
README.md refactor: extract iroh-driver crate, drop node example 2026-06-24 00:10:41 +04:00

iroh-driver

iroh-driver is the iroh-backed transport bridge for the actorized distribution stack. It owns the concrete iroh endpoint, QUIC connections, relay configuration, peer authorization, and frame shuttling between iroh and swactor actor mailboxes.

Tokio runtime ownership

The driver needs Tokio because iroh's endpoint, accepts, dials, stream reads/writes, retry timers, and shutdown APIs are async. New call sites should make that engine explicit by constructing the driver with:

let driver = IrohDriver::with_handle(tokio_handle, config)?;

with_handle does not own the Tokio runtime. The caller must keep the runtime alive for as long as the driver exists.

Legacy implicit constructor

IrohDriver::new(config) is still present as a compatibility convenience, but it hides runtime ownership:

  • If called inside an existing Tokio runtime, it uses Handle::try_current() and shares that ambient engine.
  • If called outside Tokio, it silently builds and owns a multi-threaded Tokio runtime with enable_all().

Avoid IrohDriver::new in new production code. Use with_handle or an explicit engine wrapper at the application boundary so every Tokio engine in the process is visible in construction code.

Sync facade caveat

The synchronous facade methods that bridge to async with block_on must run from a non-async thread. Do not call those methods from inside tasks running on the same Tokio runtime; Tokio will panic on nested block_on.