Manifest captured from the clawdie-iso operator USB: - FreeBSD 15.0-RELEASE, Node v24.14.1, pi 0.78.0 - Validates the RuntimeInventory contract parses live USB data
198 lines
7.6 KiB
Rust
198 lines
7.6 KiB
Rust
//! Golden tests: the contract structs must accept the real committed manifests
|
|
//! (produced by different agents/hosts) and round-trip without data loss.
|
|
|
|
use colibri_contracts::*;
|
|
|
|
const OSA_INV: &str = include_str!("../../../manifests/2026-05-26-osa-runtime-inventory.json");
|
|
const DOMEDOG_INV: &str =
|
|
include_str!("../../../manifests/2026-05-26-domedog-runtime-inventory.json");
|
|
const OSA_RUN: &str = include_str!("../../../manifests/2026-05-26-osa-pi-bump-run-manifest.json");
|
|
const DOMEDOG_RUN: &str =
|
|
include_str!("../../../manifests/2026-05-26-domedog-linux-lane-run-manifest.json");
|
|
const DOMEDOG_CACHE: &str =
|
|
include_str!("../../../manifests/2026-05-26-domedog-deepseek-cache-result.json");
|
|
const OSA_CACHE: &str =
|
|
include_str!("../../../manifests/2026-05-26-osa-deepseek-cache-result.json");
|
|
const OSA_GATE4_RUN: &str =
|
|
include_str!("../../../manifests/2026-05-26-osa-freebsd-gate4-run-manifest.json");
|
|
const HOST_STATUS_MOCK: &str = include_str!("../../../manifests/2026-05-26-host-status-mock.json");
|
|
const OSA_WATCHDOG_STATUS: &str =
|
|
include_str!("../../../manifests/2026-05-26-osa-watchdog-host-status.json");
|
|
const OSA_WATCHDOG_RUN: &str =
|
|
include_str!("../../../manifests/2026-05-26-osa-watchdog-host-status-run-manifest.json");
|
|
const DEBBY_INV: &str = include_str!("../../../manifests/2026-05-26-debby-runtime-inventory.json");
|
|
const USB_INV: &str =
|
|
include_str!("../../../manifests/2026-06-04-usb-runtime-inventory.json");
|
|
|
|
fn roundtrip_eq<T>(value: &T)
|
|
where
|
|
T: serde::Serialize + serde::de::DeserializeOwned + PartialEq + std::fmt::Debug,
|
|
{
|
|
let json = serde_json::to_string(value).expect("serialize");
|
|
let again: T = serde_json::from_str(&json).expect("re-deserialize");
|
|
assert_eq!(value, &again, "round-trip mismatch");
|
|
}
|
|
|
|
#[test]
|
|
fn parses_osa_inventory() {
|
|
let inv: RuntimeInventory = serde_json::from_str(OSA_INV).expect("parse osa inventory");
|
|
assert_eq!(inv.schema, RUNTIME_INVENTORY_SCHEMA);
|
|
assert_eq!(inv.host, "osa.smilepowered.org");
|
|
assert_eq!(inv.pi.as_deref(), Some("0.75.5"));
|
|
assert_eq!(inv.package_manager.as_deref(), Some("pkg"));
|
|
roundtrip_eq(&inv);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_debby_inventory() {
|
|
let inv: RuntimeInventory = serde_json::from_str(DEBBY_INV).expect("parse debby inventory");
|
|
assert_eq!(inv.schema, RUNTIME_INVENTORY_SCHEMA);
|
|
assert_eq!(inv.host, "debby");
|
|
assert_eq!(inv.node.as_deref(), Some("v24.16.0"));
|
|
assert!(inv.pi.is_none(), "pi not installed on debby yet");
|
|
roundtrip_eq(&inv);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_usb_inventory() {
|
|
let inv: RuntimeInventory = serde_json::from_str(USB_INV).expect("parse usb inventory");
|
|
assert_eq!(inv.schema, RUNTIME_INVENTORY_SCHEMA);
|
|
assert_eq!(inv.host, "usb.clawdie.home.arpa");
|
|
assert_eq!(inv.os, "15.0-RELEASE");
|
|
assert_eq!(inv.node.as_deref(), Some("v24.14.1"));
|
|
assert_eq!(inv.pi.as_deref(), Some("0.78.0"));
|
|
roundtrip_eq(&inv);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_domedog_inventory() {
|
|
let inv: RuntimeInventory = serde_json::from_str(DOMEDOG_INV).expect("parse domedog inventory");
|
|
assert_eq!(inv.schema, RUNTIME_INVENTORY_SCHEMA);
|
|
assert_eq!(inv.host, "domedog");
|
|
assert_eq!(inv.pi.as_deref(), Some("0.75.5"));
|
|
assert_eq!(inv.node.as_deref(), Some("v24.16.0"));
|
|
roundtrip_eq(&inv);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_osa_run_manifest() {
|
|
let run: RunManifest = serde_json::from_str(OSA_RUN).expect("parse osa run manifest");
|
|
assert_eq!(run.schema, RUN_MANIFEST_SCHEMA);
|
|
assert_eq!(run.role, "freebsd-build");
|
|
assert_eq!(run.agent.as_deref(), Some("codex-osa"));
|
|
assert!(run.summary.contains_key("pi_after"));
|
|
roundtrip_eq(&run);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_domedog_run_manifest() {
|
|
let run: RunManifest = serde_json::from_str(DOMEDOG_RUN).expect("parse domedog run manifest");
|
|
assert_eq!(run.schema, RUN_MANIFEST_SCHEMA);
|
|
assert_eq!(run.role, "linux-build-smoke");
|
|
assert_eq!(
|
|
run.artifacts.get("runtime_inventory").map(String::as_str),
|
|
Some("manifests/2026-05-26-domedog-runtime-inventory.json")
|
|
);
|
|
roundtrip_eq(&run);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_domedog_live_cache_result() {
|
|
let res: ProviderSmokeResult =
|
|
serde_json::from_str(DOMEDOG_CACHE).expect("parse live cache result");
|
|
assert_eq!(res.schema, PROVIDER_SMOKE_SCHEMA);
|
|
assert_eq!(res.status, "ok");
|
|
assert!(res.cache_hit_observed, "expected a cache hit");
|
|
assert!(res.cache_hit_tokens > 0);
|
|
roundtrip_eq(&res);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_osa_live_cache_result() {
|
|
let res: ProviderSmokeResult = serde_json::from_str(OSA_CACHE).expect("parse osa cache result");
|
|
assert_eq!(res.schema, PROVIDER_SMOKE_SCHEMA);
|
|
assert_eq!(res.host, "osa");
|
|
assert_eq!(res.agent, "codex-osa");
|
|
assert_eq!(res.status, "ok");
|
|
assert!(res.cache_hit_observed, "expected a cache hit");
|
|
assert!(res.cache_hit_tokens > 0);
|
|
roundtrip_eq(&res);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_osa_gate4_run_manifest() {
|
|
let run: RunManifest = serde_json::from_str(OSA_GATE4_RUN).expect("parse osa gate4 run");
|
|
assert_eq!(run.schema, RUN_MANIFEST_SCHEMA);
|
|
assert_eq!(run.role, "freebsd-build-cache-smoke");
|
|
assert_eq!(run.agent.as_deref(), Some("codex-osa"));
|
|
assert_eq!(
|
|
run.artifacts
|
|
.get("deepseek_cache_result")
|
|
.map(String::as_str),
|
|
Some("manifests/2026-05-26-osa-deepseek-cache-result.json")
|
|
);
|
|
roundtrip_eq(&run);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_host_status_mock() {
|
|
let status: HostStatus = serde_json::from_str(HOST_STATUS_MOCK).expect("parse host status");
|
|
assert_eq!(status.source, "watchdog-socket");
|
|
assert_eq!(status.mode, "auto");
|
|
assert_eq!(status.free_memory_mb, 2048);
|
|
assert_eq!(status.controlplane_status.as_deref(), Some("ok"));
|
|
roundtrip_eq(&status);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_osa_watchdog_host_status() {
|
|
let wrapped: serde_json::Value =
|
|
serde_json::from_str(OSA_WATCHDOG_STATUS).expect("parse watchdog status wrapper");
|
|
assert_eq!(
|
|
wrapped.get("ok").and_then(|value| value.as_bool()),
|
|
Some(true)
|
|
);
|
|
let status: HostStatus =
|
|
serde_json::from_value(wrapped.get("status").expect("status").clone()).expect("status");
|
|
assert_eq!(status.source, "watchdog-socket");
|
|
assert_eq!(status.mode, "auto");
|
|
assert_eq!(status.controlplane_status.as_deref(), Some("ok"));
|
|
roundtrip_eq(&status);
|
|
}
|
|
|
|
#[test]
|
|
fn parses_osa_watchdog_run_manifest() {
|
|
let run: RunManifest = serde_json::from_str(OSA_WATCHDOG_RUN).expect("parse watchdog run");
|
|
assert_eq!(run.schema, RUN_MANIFEST_SCHEMA);
|
|
assert_eq!(run.role, "freebsd-watchdog-host-status-read");
|
|
assert_eq!(run.agent.as_deref(), Some("codex-osa"));
|
|
assert_eq!(
|
|
run.artifacts.get("host_status").map(String::as_str),
|
|
Some("manifests/2026-05-26-osa-watchdog-host-status.json")
|
|
);
|
|
roundtrip_eq(&run);
|
|
}
|
|
|
|
#[test]
|
|
fn provider_smoke_skipped_shape() {
|
|
// No live result committed yet; assert the struct accepts a skipped result.
|
|
let raw = r#"{
|
|
"schema": "clawdie.provider-smoke.result.v1",
|
|
"test_id": "colibri-probe-20260526T080805Z",
|
|
"host": "domedog",
|
|
"agent": "claude-domedog",
|
|
"provider": "deepseek",
|
|
"model": "deepseek-chat",
|
|
"started_at": "2026-05-26T08:08:05Z",
|
|
"ended_at": "2026-05-26T08:08:05Z",
|
|
"status": "skipped",
|
|
"cache_hit_tokens": 0,
|
|
"cache_hit_observed": false,
|
|
"notes": ["DEEPSEEK_API_KEY unset/empty — build verified, live cache probe skipped"]
|
|
}"#;
|
|
let res: ProviderSmokeResult = serde_json::from_str(raw).expect("parse provider smoke");
|
|
assert_eq!(res.schema, PROVIDER_SMOKE_SCHEMA);
|
|
assert_eq!(res.status, "skipped");
|
|
assert!(res.warm_usage.is_none());
|
|
roundtrip_eq(&res);
|
|
}
|