From f8f4356c17e27877a78437f8c049f04eb6349224 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sun, 1 Nov 2026 11:39:08 -0600 Subject: [PATCH 1/2] test(id): review-gated chat-frame PoC harness on /id-envelope/1 (#2808) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test-only two-endpoint harness (envelope_net tests): a CaptureFrames receiver on the existing ENVELOPE_ALPN exchanges the proposed v1 chat frame byte-for-byte in both directions and resolves a linked blob from the recipients local store with BLAKE3 hash verification. It deliberately does NOT use the production EnvelopeProtocol (which parses directory envelopes and refuses chat-frame JSON) or the CLI (which has no arbitrary-frame command) — that harness-vs-CLI gap is the review question on #2808. Frame sig field is a test-only placeholder; no signature verification is claimed. Harness authored across queue task 5792 attempts (openchamber lane + lane B compile fixes: Debug derive for CaptureFrames, Hash::new for content hashing). --- pkgs/id/src/envelope_net.rs | 150 ++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/pkgs/id/src/envelope_net.rs b/pkgs/id/src/envelope_net.rs index 62398ac52a..99b8ef90f2 100644 --- a/pkgs/id/src/envelope_net.rs +++ b/pkgs/id/src/envelope_net.rs @@ -206,6 +206,7 @@ mod tests { }; use super::*; + use crate::commands::put::add_raw; use crate::connectivity::silent::{ endpoint_with_silent_lookup, unanswered_addr, unanswered_id, }; @@ -213,6 +214,8 @@ mod tests { use crate::envelope_outbox::{Finish, Outbox, flush}; use crate::world::{WorldCore, WorldHandle, WorldLimits}; use crate::world_session::WorldService; + use iroh_blobs::{Hash, store::mem::MemStore}; + use std::sync::Arc; use std::time::Instant; use tokio::sync::Mutex; @@ -235,6 +238,40 @@ mod tests { .unwrap() } + fn loopback_addr(ep: &Endpoint) -> EndpointAddr { + EndpointAddr::from_parts( + ep.id(), + ep.bound_sockets().iter().map(|addr| { + let ip = if addr.ip().is_unspecified() { + std::net::Ipv4Addr::LOCALHOST.into() + } else { + addr.ip() + }; + iroh::TransportAddr::Ip(std::net::SocketAddr::new(ip, addr.port())) + }), + ) + } + + /// Test-only receiver for exercising the raw frame transport. This is not + /// the production [`EnvelopeProtocol`], which accepts directory envelopes + /// and deliberately refuses chat-frame JSON. + #[derive(Clone, Debug)] + struct CaptureFrames(Arc>>>); + + impl ProtocolHandler for CaptureFrames { + async fn accept(&self, conn: Connection) -> Result<(), AcceptError> { + let frames = self.0.clone(); + answer_frames(&conn, move |body| { + let frames = frames.clone(); + async move { + frames.lock().await.push(body); + Reply::Applied + } + }) + .await + } + } + /// A lobby on a node that is reachable only over loopback. async fn lobby(ep: &Endpoint) -> (Router, EndpointAddr, String) { let world = WorldHandle::spawn(WorldCore::new("lobby", WorldLimits::default()).unwrap()); @@ -316,6 +353,119 @@ mod tests { )); } + /// A throwaway transport fixture for the proposed chat frame. It proves + /// byte-preserving exchange on the existing ALPN and a local content-hash + /// hit; it does not test CLI routing, production envelope acceptance, or + /// chat signature verification. + #[tokio::test] + async fn review_gated_chat_frame_round_trips_and_resolves_local_blob() { + let alice = endpoint().await; + let bob = endpoint().await; + let alice_frames = Arc::new(Mutex::new(Vec::new())); + let bob_frames = Arc::new(Mutex::new(Vec::new())); + let alice_router = Router::builder(alice.clone()) + .accept(ENVELOPE_ALPN, CaptureFrames(alice_frames.clone())) + .spawn(); + let bob_router = Router::builder(bob.clone()) + .accept(ENVELOPE_ALPN, CaptureFrames(bob_frames.clone())) + .spawn(); + + let receiver_store: iroh_blobs::api::Store = MemStore::new().into(); + let blob_bytes = b"review-gated chat PoC local blob"; + let (blob_hash, _keep) = add_raw(&receiver_store, blob_bytes.to_vec()).await.unwrap(); + + let frame_alice_to_bob = serde_json::to_vec(&serde_json::json!({ + "v": 1, + "channel": "group:local-poc", + "author": alice.id().to_string(), + "seq": 1, + "after": [], + "text": "blob link fixture", + "links": [{ + "kind": "blob", + "hash": blob_hash.to_string(), + "author": alice.id().to_string() + }], + "sig": "test-only; no signature verification" + })) + .unwrap(); + let frame_bob_to_alice = serde_json::to_vec(&serde_json::json!({ + "v": 1, + "channel": "group:local-poc", + "author": bob.id().to_string(), + "seq": 1, + "after": [], + "text": "acknowledged", + "links": [], + "sig": "test-only; no signature verification" + })) + .unwrap(); + + println!( + "Alice -> Bob /id-envelope/1 frame bytes (UTF-8): {}", + String::from_utf8(frame_alice_to_bob.clone()).unwrap() + ); + println!( + "Bob -> Alice /id-envelope/1 frame bytes (UTF-8): {}", + String::from_utf8(frame_bob_to_alice.clone()).unwrap() + ); + + assert_eq!( + send_within( + &alice, + ENVELOPE_ALPN, + loopback_addr(&bob), + &frame_alice_to_bob, + Duration::from_secs(5), + ) + .await, + Outcome::Delivered + ); + assert_eq!( + send_within( + &bob, + ENVELOPE_ALPN, + loopback_addr(&alice), + &frame_bob_to_alice, + Duration::from_secs(5), + ) + .await, + Outcome::Delivered + ); + + assert_eq!( + bob_frames.lock().await.as_slice(), + &[frame_alice_to_bob.clone()] + ); + assert_eq!( + alice_frames.lock().await.as_slice(), + &[frame_bob_to_alice.clone()] + ); + + let received_alice_to_bob = bob_frames.lock().await[0].clone(); + let received_frame: serde_json::Value = + serde_json::from_slice(&received_alice_to_bob).unwrap(); + let linked_hash: Hash = received_frame["links"][0]["hash"] + .as_str() + .unwrap() + .parse() + .unwrap(); + assert_eq!(linked_hash, blob_hash); + assert!(receiver_store.blobs().has(linked_hash).await.unwrap()); + let resolved = receiver_store.blobs().get_bytes(linked_hash).await.unwrap(); + assert_eq!(&*resolved, blob_bytes); + assert_eq!(Hash::new(&*resolved), blob_hash); + println!( + "Bob local blob resolution: hash={blob_hash} bytes={} hash_verified=true", + resolved.len() + ); + + alice.close().await; + bob.close().await; + alice_router.shutdown().await.unwrap(); + bob_router.shutdown().await.unwrap(); + } + #[tokio::test] async fn an_unreachable_recipient_is_retried() { let client = endpoint().await; From 3b7869685a8a7706b8ae652882435ccab8e162aa Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sun, 1 Nov 2026 13:11:01 -0600 Subject: [PATCH 2/2] =?UTF-8?q?test(id):=20address=20Codex=20review=20on?= =?UTF-8?q?=20#3887=20=E2=80=94=20test=5F=20prefix=20+=20import=20groups?= =?UTF-8?q?=20(#2808)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/id/src/envelope_net.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkgs/id/src/envelope_net.rs b/pkgs/id/src/envelope_net.rs index 99b8ef90f2..007d949080 100644 --- a/pkgs/id/src/envelope_net.rs +++ b/pkgs/id/src/envelope_net.rs @@ -199,11 +199,16 @@ async fn receive(hub: &WorldHub, body: &[u8]) -> Reply { #[cfg(test)] #[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] mod tests { + use std::sync::Arc; + use std::time::Instant; + use iroh::{ address_lookup::MemoryLookup, endpoint::{RelayMode, presets}, protocol::Router, }; + use iroh_blobs::{Hash, store::mem::MemStore}; + use tokio::sync::Mutex; use super::*; use crate::commands::put::add_raw; @@ -214,10 +219,6 @@ mod tests { use crate::envelope_outbox::{Finish, Outbox, flush}; use crate::world::{WorldCore, WorldHandle, WorldLimits}; use crate::world_session::WorldService; - use iroh_blobs::{Hash, store::mem::MemStore}; - use std::sync::Arc; - use std::time::Instant; - use tokio::sync::Mutex; const NOW: u64 = 1_000_000_000; @@ -358,7 +359,7 @@ mod tests { /// hit; it does not test CLI routing, production envelope acceptance, or /// chat signature verification. #[tokio::test] - async fn review_gated_chat_frame_round_trips_and_resolves_local_blob() { + async fn test_review_gated_chat_frame_round_trips_and_resolves_local_blob() { let alice = endpoint().await; let bob = endpoint().await; let alice_frames = Arc::new(Mutex::new(Vec::new()));