liminal-cli 0.3.21

The liminal command: serve the network, maintain its stores, or serve its discovery MCP over stdio
Documentation
//! Two real ticket children talk through one real Lys-gated exchange.

use super::channel_test_support::{
    Exchange, Host, TestResult, child_result, finish_results, require,
};
use serde_json::json;

#[test]
fn agt001_two_seats_wake_each_other_through_the_exchange() -> TestResult {
    let exchange = Exchange::start()?;
    let alpha_config = exchange.seat("alpha", Some(&["agents.alpha.inbox"]))?;
    let beta_config = exchange.seat("beta", Some(&["agents.beta.inbox"]))?;
    let mut alpha = Host::start(&alpha_config, None)?;
    let mut beta = Host::start(&beta_config, None)?;
    let outcome = (|| {
        alpha.initialize()?;
        beta.initialize()?;
        require(
            exchange.supervisor.active_connection_count() == 4,
            "each seat must already own its tap and payload subscriptions before sending",
        )?;
        let first = "{\"text\":\"alpha to beta\"}";
        let sent = alpha.tool(
            "send",
            &json!({"subject":"agents.beta.inbox","text":first,"key":"alpha-first"}),
        )?;
        require(
            sent["isError"] == false,
            "alpha's granted send must be acknowledged",
        )?;
        exchange.pump()?;
        let received = beta.read()?;
        require(
            received["method"] == "notifications/claude/channel",
            "beta must receive a channel wake",
        )?;
        require(
            received["params"]["content"] == first,
            "beta must receive the exact sent bytes",
        )?;
        require(
            received["params"]["meta"]["subject"] == "agents.beta.inbox",
            "beta's wake must name its inbox",
        )?;
        require(
            received["params"]["meta"]["from"] == "alpha",
            "beta's wake must name alpha as the sender",
        )?;
        require(
            received["params"]["meta"]["device"] == exchange.address,
            "beta's wake must name this exchange",
        )?;
        let reply = "{\"text\":\"beta to alpha\"}";
        let sent = beta.tool(
            "send",
            &json!({"subject":"agents.alpha.inbox","text":reply,"key":"beta-reply"}),
        )?;
        require(
            sent["isError"] == false,
            "beta's granted reply must be acknowledged",
        )?;
        exchange.pump()?;
        let received = alpha.read()?;
        require(
            received["method"] == "notifications/claude/channel",
            "alpha must receive a channel wake",
        )?;
        require(
            received["params"]["content"] == reply,
            "alpha must receive the exact reply bytes",
        )?;
        require(
            received["params"]["meta"]["subject"] == "agents.alpha.inbox",
            "alpha's wake must name its inbox",
        )?;
        require(
            received["params"]["meta"]["from"] == "beta",
            "alpha's wake must name beta as the sender",
        )?;
        require(
            received["params"]["meta"]["device"] == exchange.address,
            "alpha's wake must name this exchange",
        )
    })();
    let alpha_closed = alpha.close();
    let beta_closed = beta.close();
    let finished = exchange.finish();
    finish_results([
        outcome,
        child_result(alpha_closed),
        child_result(beta_closed),
        finished,
    ])
}