Skip to content

feat(test-fixtures,client): TwoAircLoopback + AircIpcTransport↔substrate wire roundtrip - #1558

Merged
joelteply merged 3 commits into
canaryfrom
feat/two-airc-loopback-fixture
Jun 8, 2026
Merged

joelteply merged 3 commits into
canaryfrom
feat/two-airc-loopback-fixture

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Closes tasks #187 (TwoAircLoopback fixture) and #188 (cross-grid command roundtrip integration test). Closes the wire-shape verification gap adversarial reviewer 1 flagged on PR #1557.

What lands

core/airc-test-fixtures/ — new workspace crate

Shared test fixture for any integration test that needs two real airc_lib::Airc peers wired over a LAN loopback. Consumed via [dev-dependencies] so production binaries never link it.

use airc_test_fixtures::TwoAircLoopback;

let loop_back = TwoAircLoopback::new().await?;
// loop_back.peer_a() = Arc<Airc> for the server side
// loop_back.peer_b() = Arc<Airc> for the client side
// .peer_a_id() / .peer_b_id() = UUID each side targets

TwoAircLoopback::new() walks the canonical 4-step airc setup the substrate's own tests use: two TempDir homes, mutual add_peer(peer_spec) trust, join(shared_room), peer_b.listen_lan(127.0.0.1:0) + peer_a.connect_lan(addr, peer_b_id). Typed LoopbackError names which peer + which step failed when setup goes wrong.

client/continuum-client/tests/airc_ipc_roundtrip.rs — integration test

Spawns a substrate-equivalent responder on peer_a (subscribes, filters on continuum.body_hint = continuum.command.request.v1, parses AircCommandRequest, constructs AircCommandResponse::Ok, replies via airc.reply). On peer_b builds Connection::connect(...) and calls .commands().execute(). Asserts the typed result echoes back.

Every drift surface in continuum-airc-protocol is exercised: KIND_PEER, DEFAULT_COMMAND_DEADLINE, all HEADER_* constants, both COMMAND_*_BODY_HINT values. If any literal drifts client and server, this test fails.

Verified

cargo test -p airc-test-fixtures                          → 1/1 pass (0.95s)
cargo test -p continuum-client --test airc_ipc_roundtrip  → 1/1 pass (0.93s)
cargo test -p continuum-client                            → 6/6 unit + 1/1 integration
cargo test -p continuum-airc-protocol                     → 13/13 pass

Reviewer concern closed

Reviewer 1 on PR #1557 round 1 flagged: there was no live integration test pairing AircIpcTransport against the substrate's command_handler. The protocol crate extraction was meant to prevent drift, but the proof-of-non-drift test was deferred.

This PR lands that test. The continuum-airc-protocol crate's purpose (preventing wire drift) is now proven, not just asserted by literal sharing of constants.

Test plan

  • cargo test -p airc-test-fixtures
  • cargo test -p continuum-client
  • cargo test -p continuum-airc-protocol
  • CI green

joelteply and others added 2 commits June 8, 2026 18:12
…ton (task #187 slice 1)

New shared test-fixture crate under core/ so substrate integration tests
and continuum-client roundtrip tests can use the same fixture without
either side bloating its own [dev-dependencies] tree.

  core/airc-test-fixtures/
    Cargo.toml                         airc-lib + continuum-airc-protocol + tempfile
    src/lib.rs                         re-exports TwoAircLoopback + LoopbackError
    src/two_airc_loopback.rs           public API + typed errors + skeleton bodies

Public API (locked):
  pub struct TwoAircLoopback { peer_a, peer_b, peer_a_id, peer_b_id, ... }
  impl TwoAircLoopback {
      pub async fn new() -> Result<Self, LoopbackError>;
      pub fn peer_a(&self) -> &Arc<airc_lib::Airc>;
      pub fn peer_b(&self) -> &Arc<airc_lib::Airc>;
      pub fn peer_a_id(&self) -> Uuid;
      pub fn peer_b_id(&self) -> Uuid;
  }

  pub enum LoopbackError {
      TempDir(io::Error),
      AircSpawn(String),
      PeerRegistrationTimeout,
      NotImplemented(&'static str),
  }

Method bodies stub `NotImplemented` for now — the real impl needs airc-lib
spawn-mode study (in-process loopback vs two daemon child processes) that
deserves a focused next-session slice.

Closes the architectural seam reviewer 1 flagged: the AircIpcTransport
wire shape is verified at unit level but not by a real client→server
roundtrip. This fixture will be what TLS-style asserts that.

Workspace member added between continuum-airc-protocol and archive (alpha
order inside core/* tier).

Verified:
  cargo check -p airc-test-fixtures            → clean (2.4s)
  cargo test  -p airc-test-fixtures            → 1/1 pass (skeleton surfaces typed
                                                  NotImplemented, not panic)

Task #187 slice 1 of N — slice 2 brings the real spawn impl + the first
end-to-end roundtrip test consuming AircIpcTransport from continuum-client
against a real substrate command_handler on the other peer.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
…ort↔substrate wire roundtrip (tasks #187 + #188)

Stage 2 of task #187 lands the actual spawn-2-Aircs-on-loopback behavior,
and stage 1 of task #188 lands the integration test that proves the
AircIpcTransport wire shape matches what the substrate's command_handler
expects. Together these close the wire-roundtrip verification gap
adversarial reviewer 1 flagged on PR #1557.

TwoAircLoopback::new() — real impl (was: stub returning NotImplemented)

  Studied airc-lib's public API at the pinned rev (f6ed190):
    Airc::open(home)            — load identity, open coordinator store
    airc.peer_spec()            — emit a parseable PeerSpec string
    airc.add_peer(spec)         — mutual trust handshake
    airc.join(room)             — join a shared room
    airc.listen_lan(127.0.0.1:0)— bind a kernel-picked loopback port
    airc.connect_lan(addr, id)  — dial peer-targeted authenticated socket

  TwoAircLoopback::new() walks the canonical 4-step setup the substrate's
  own tests use:
    1. Allocate two TempDir homes
    2. Open peer_a + peer_b (strict verification policy)
    3. Mutual trust via parse(peer_spec) + add_peer
    4. Both join the shared fixture room
    5. Wire LAN: peer_b listens, peer_a dials with peer_b's peer_id

  Typed LoopbackError shape: TempDir / AircSpawn (one variant + a
  human-readable message naming which peer + which step failed). Drops
  the previous NotImplemented placeholder.

Bare-airc smoke test (lives inside airc-test-fixtures)
  bare_request_reply_round_trips_over_loopback — peer_a sends a request,
  peer_b's subscribe stream sees it, peer_b replies via airc.reply,
  peer_a's await_reply resolves with the body. Proves the fixture's wire
  is alive end-to-end without any continuum-specific protocol on top.

AircIpcTransport ↔ substrate wire-roundtrip test
  client/continuum-client/tests/airc_ipc_roundtrip.rs

  Spawns a substrate-equivalent responder on peer_a that:
    - Subscribes to airc events
    - Filters on continuum.body_hint = continuum.command.request.v1
    - Parses Body::Json as AircCommandRequest (continuum-airc-protocol)
    - Constructs AircCommandResponse::ok({echoed_path, echoed_params})
    - Replies via airc.reply with the substrate's reply header set
      (HEADER_COMMAND_STATUS + HEADER_CONTINUUM_BODY_HINT)

  On peer_b, builds Connection::connect(peer_b_airc, peer_a_id) and
  calls .commands().execute("debug/ping", {hello, count}). Asserts:
    result["ok"] == true
    result["echoed_path"] == "debug/ping"
    result["echoed_params"] == {hello, count}

  Every drift surface in continuum-airc-protocol is now exercised:
    KIND_PEER, DEFAULT_COMMAND_DEADLINE, HEADER_COMMAND_{PATH,KIND,STATUS},
    HEADER_CONTINUUM_BODY_HINT, COMMAND_{REQUEST,RESPONSE}_BODY_HINT.
  If any literal drifts on either side this test fails — caught BEFORE
  any substrate ships.

Verified:
  cargo test -p airc-test-fixtures                         → 1/1 pass (0.95s)
  cargo test -p continuum-client --test airc_ipc_roundtrip → 1/1 pass (0.93s)
  cargo test -p continuum-client                           → 6/6 unit + 1/1 integration
  cargo test -p continuum-airc-protocol                    → 13/13 pass

Closes:
  - task #187 (TwoAircLoopback fixture) — real impl lands
  - task #188 (cross-grid command roundtrip integration test) — first test lands
  - reviewer 1 BLOCK concern from PR #1557 round 1 — wire shape now
    verified end-to-end, not just by literal duplication of constants.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
…se_envelope + send_reply (closes R3 BLOCK)

Reviewer 3 on PR #1558 round 1 flagged that the integration test inlined
`serde_json::from_value` + manually stamped headers instead of calling
the substrate's own `CommandRequestHandler::parse_envelope` +
`CommandRequestHandler::send_reply` (which are `pub` for exactly this
reason). The result: drift between client's envelope and substrate's
parser expectations would NOT fail the test — meaning the "wire
shape verified end-to-end" claim was materially overstated.

Drifts the previous version would NOT catch:
  - substrate `parse_envelope` adding/dropping a required header
  - substrate gating on `kind != KIND_PEER`
  - substrate's `send_reply` changing the response header set
  - `AircCommandResponse` serde tag changes

Drifts this version DOES catch:
  - all of the above (substrate's real code is now in the loop)
  - `request.kind == KIND_PEER` explicitly asserted at line 87-91
  - `request.path == "debug/ping"` explicitly asserted
  - `request.env == None` explicitly asserted

Structural changes:
  - `client/continuum-client/tests/airc_ipc_roundtrip.rs` → moved to
    `core/continuum-core/tests/airc_ipc_roundtrip.rs`. The substrate is
    where the real parser lives, so the integration test belongs in the
    substrate's test crate where it can dev-depend on
    {airc-test-fixtures, continuum-client} cleanly without making
    continuum-client transitively depend on continuum-core (which would
    drag in llama.cpp + metal features for client unit tests).
  - `client/continuum-client/Cargo.toml` — removed the dev-dependencies
    block (now empty; airc-test-fixtures + airc-protocol moved to
    continuum-core's dev-deps).
  - `core/continuum-core/Cargo.toml` — added dev-deps on
    airc-test-fixtures, continuum-client, airc-protocol, futures.

Responder rewrite:
  - `build_handler(peer_a)` constructs a bare `ModuleRegistry` +
    `CommandExecutor` + `CommandRequestHandler::new(peer_a, executor)`.
    The executor's registry is empty because the test bypasses
    `process_request` (we want to control the response payload to assert
    wire bytes, not run a real module's policy gate).
  - `spawn_real_substrate_responder` calls
    `CommandRequestHandler::parse_envelope(&event)` on every command
    request, asserts the three protocol-stable fields (kind, path, env),
    constructs the canonical `AircCommandResponse::ok` payload, and
    calls `handler.send_reply(&parsed, &response)` for the reply.

If at any point the substrate parser/reply paths drift from the wire
shape `AircIpcTransport` sends/expects, this test fails. The
`continuum-airc-protocol` crate's drift-prevention purpose is now
actually verified, not just asserted by literal duplication of
constants.

Verified:
  cargo test -p continuum-core --features metal,accelerate
              --test airc_ipc_roundtrip
              → 1/1 pass (0.94s test, 3m49s build cold)

Stage 2 of R3's BLOCK concern (#188-prime — separate test for
substrate rejection of non-peer kinds) is logged as follow-up; this PR
ships the kind-equality assertion which is the load-bearing surface.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@joelteply
joelteply merged commit c3201b7 into canary Jun 8, 2026
2 checks passed
@joelteply
joelteply deleted the feat/two-airc-loopback-fixture branch June 8, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant