liminal-cli 0.3.21

The liminal command: serve the network, maintain its stores, or serve its discovery MCP over stdio
Documentation
//! A full silent window ends on an external signal, never a test timer.

use super::channel_test_support::{
    Exchange, Host, TestResult, child_result, finish_results, require,
};
use super::idle_test_proxy::Proxy;
use std::io::Read;

#[cfg(unix)]
#[test]
fn agt001_two_listened_subjects_send_no_bytes_or_frames_over_sixty_seconds() -> TestResult {
    use std::os::unix::fs::FileTypeExt as _;
    let signal = std::env::var_os("AGT001_IDLE_FIFO")
        .ok_or("AGT001_IDLE_FIFO must name the external observation FIFO")?;
    require(
        std::path::Path::new(&signal).is_absolute(),
        "the idle signal path must be absolute",
    )?;
    require(
        std::fs::metadata(&signal)?.file_type().is_fifo(),
        "the idle observation signal must be a FIFO",
    )?;
    let exchange = Exchange::start()?;
    let proxy = Proxy::start(exchange.address.clone(), 1_048_576)?;
    let config = exchange.seat("alpha", Some(&["agents.alpha.inbox", "messages.s0"]))?;
    let mut table: toml::Table = toml::from_str(&std::fs::read_to_string(&config)?)?;
    table.insert(
        "server".to_owned(),
        toml::Value::String(proxy.address.clone()),
    );
    std::fs::write(&config, toml::to_string(&table)?)?;
    let mut host = Host::start(&config, None)?;
    let outcome = (|| {
        host.initialize()?;
        let before = proxy.counts()?;
        require(
            before.subscribes == 4,
            "the two subjects must open two tap and two payload subscriptions",
        )?;
        let start = std::time::Instant::now();
        eprintln!(
            "AGT-001 IDLE READY: four subscriptions; release the FIFO after the full observation"
        );
        // The operator releases a FIFO after measuring the complete observation
        // window. The test records elapsed time but never arms a waiting timer.
        let mut input = std::fs::File::open(&signal)?;
        let mut released = [0];
        input.read_exact(&mut released)?;
        let elapsed = start.elapsed();
        require(
            elapsed.as_secs() >= 60,
            "the silent observation must span at least sixty seconds",
        )?;
        let after = proxy.counts()?;
        require(
            after.bytes == before.bytes,
            "the idle ticket sent wire bytes",
        )?;
        require(
            after.frames == before.frames,
            "the idle ticket sent wire frames",
        )?;
        require(
            after.subscribes == before.subscribes,
            "the idle ticket opened another subscription",
        )?;
        require(
            host.request("ping", &serde_json::json!({}))?
                .get("result")
                .is_some(),
            "the ticket must remain alive through the silent interval",
        )
    })();
    let closed = host.close();
    let proxy_closed = proxy.finish().map_err(Into::into);
    let finished = exchange.finish();
    finish_results([outcome, child_result(closed), proxy_closed, finished])
}