Files
ruflo/v3/crates
rUvandReuven e0a922eef9 feat(federation-peer): wire real midstreamer-quic@0.3.0 + aimds-core@0.2.0 (ADR-120 Step 3) (#2011)
Replaces the typed `not implemented` placeholders in
`native_transport` and `native_gate` with real implementations that
delegate to the embedding traits published in ruvnet/midstream PR #82.

**Cargo.toml**
- Bumped `midstreamer-quic` 0.2.1 → 0.3.0 (now exposes `QuicTransport`)
- Bumped `aimds-core` 0.1.1 → 0.2.0 (now exposes `SafetyGate` + `SafetyVerdict`)
- Dropped optional `aimds-detection` / `-analysis` / `-response` —
  the peer composes any `aimds_core::SafetyGate` so the concrete
  3-gate pipeline is supplied by the caller (e.g. AIMDS's
  `ComposedGate` or a custom composition)
- Added optional `uuid` + `chrono` (used by the gate adapter to
  build `PromptInput` values)

**lib.rs — `native_transport::MidstreamerTransport<T: QuicTransport>`**
- Generic over any embedder-supplied transport (defaults to `QuicConnection`)
- `connect(addr)`: opens a client connection via `QuicConnection::connect`
- `send(addr, msg)`: opens a bidirectional stream, writes one NDJSON
  line per `FederationMessage`, finishes the stream
- `recv()`: accepts an inbound bidirectional stream, reads to EOF
  (16 MiB cap), parses one JSON value
- `close()`: closes the connection with reason "peer shutdown"

**lib.rs — `native_gate::AimdsGate`**
- Adapter that holds `Arc<dyn aimds_core::SafetyGate>` so it composes
  any 3-gate pipeline (AIMDS's canonical `ComposedGate`, a custom
  composition, or a test stub)
- Converts `FederationMessage` ↔ `PromptInput` (payload-as-string +
  metadata-as-context)
- Converts `aimds_core::SafetyVerdict` ↔ peer-local `SafetyVerdict`,
  preserving routing metadata on `Redact`

**bin.rs**
- Under `--features native`, boots a real tokio runtime that wires
  `MidstreamerTransport::connect()` + `AimdsGate` (with a
  pass-through default gate so the smoke boot path works without
  AIMDS rules) + an NDJSON-stdout dispatcher
- Reads `RUFLO_FEDERATION_REMOTE_ADDR` for the connect target

**Tests**
- New `aimds_gate_adapter_forwards_pass_and_block_verdicts` test
  exercises the real `aimds_core::SafetyGate` trait surface
- 4/4 tests pass under `--features native`; 3/3 pass without

**audit-fix-invariants.mjs**
- Bumped Cargo.toml pin invariants to 0.3.0 / 0.2.0
- Added two new invariants checking the lib.rs imports actually
  reference upstream `QuicTransport` and `aimds_core::SafetyGate` —
  guards against silent reversion to a typed placeholder
- 34/34 invariants pass

Closes ADR-120 Step 3.

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
2026-05-14 23:35:32 -04:00
..