haematite-cli 0.21.0

The haematite command: serve a store, its door and Studio, answer MCP, query with jq, and host the store's assistant seat
use super::config::Harness;
use serde_json::json;

#[test]
fn r1_rows_13_14_catalogue_and_executable_boundary() -> anyhow::Result<()> {
    for id in ["claude-code", "codex", "gemini-cli", "opencode", "pi"] {
        super::catalogue::validate(id)?;
    }
    assert!(super::catalogue::validate("cdx").is_err());
    assert!(super::catalogue::executable(std::path::Path::new("./relative")).is_err());
    assert!(super::catalogue::executable(std::path::Path::new("/tmp")).is_err());
    let executable = std::env::current_exe()?;
    assert_eq!(super::catalogue::executable(&executable)?, executable);
    Ok(())
}

#[test]
fn r1_bounds_are_positive_and_no_policy_key_is_accepted() -> anyhow::Result<()> {
    let base = json!({"id":"codex","program":"/bin/true","args":[]});
    let harness: Harness = serde_json::from_value(base.clone())?;
    harness.validate()?;
    assert_eq!(harness.prompt_queue, 32);
    assert_eq!(harness.pending_permissions, 1024);
    for key in [
        "prompt_queue",
        "content_bytes",
        "acp_frame_bytes",
        "pending_permissions",
        "write_queue",
        "stream_queue",
        "issuer_response_bytes",
        "session_list",
        "title_chars",
    ] {
        let mut invalid = base.clone();
        invalid[key] = json!(0);
        let harness: Harness = serde_json::from_value(invalid)?;
        assert!(harness.validate().is_err(), "zero {key} accepted");
    }
    for key in ["permission", "permission_policy", "auto_approve"] {
        let mut invalid = base.clone();
        invalid[key] = json!("allow-once");
        assert!(serde_json::from_value::<Harness>(invalid).is_err());
    }
    Ok(())
}

#[test]
fn r4_channel_bounds_are_rejected_before_the_runtime_can_panic() -> anyhow::Result<()> {
    for field in ["write_queue", "stream_queue"] {
        let mut value = json!({"id":"codex","program":"/bin/true","args":[]});
        value[field] = json!(usize::MAX);
        let harness: Harness = serde_json::from_value(value)?;
        assert!(
            harness.validate().is_err(),
            "oversized {field} reached the runtime"
        );
    }
    Ok(())
}