test(cog-pose): cross-language adapter integration (Python producer -> Rust engine)

Closes the last verification gap in the calibration feature: previously the
Python producer and Rust consumer were proven compatible only by format
matching. Now a real ~11KB adapter fitted by cog_calibrate.py on the in-repo
pose_v1.safetensors is committed as a fixture, and a Rust test loads it via
the engine and asserts is_calibrated() + that it changes inference output.
The full Python->Rust calibration contract is verified with a real artifact.
7/7 cog-pose tests pass.

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
ruv
2026-05-31 05:22:54 -04:00
parent e94f4d8f73
commit 0fede72ec4
2 changed files with 31 additions and 0 deletions
@@ -133,6 +133,37 @@ fn per_room_adapter_changes_inference_output() {
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn python_produced_adapter_loads_in_engine() {
// Cross-language contract: an adapter fitted by `aether-arena/calibration/cog_calibrate.py`
// (real LoRA on the cog conv+MLP head) must load + activate in this Rust engine.
let base = std::path::Path::new("cog/artifacts/pose_v1.safetensors");
if !base.exists() {
eprintln!("(skipping — cog/artifacts/pose_v1.safetensors not present in cwd)");
return;
}
let adapter = std::path::Path::new("tests/fixtures/sample_room.adapter.safetensors");
assert!(adapter.exists(), "committed producer-generated adapter fixture is missing");
let base_eng = InferenceEngine::with_weights(Some(base)).expect("base load");
let cal_eng =
InferenceEngine::with_weights_and_adapter(Some(base), Some(adapter)).expect("calibrated load");
assert!(!base_eng.is_calibrated());
assert!(cal_eng.is_calibrated(), "engine should report calibrated with the producer adapter");
// Non-zero input so the LoRA delta is exercised.
let win = cog_pose_estimation::inference::CsiWindow {
data: (0..INPUT_SUBCARRIERS * INPUT_TIMESTEPS)
.map(|i| ((i % 7) as f32 - 3.0) * 0.2)
.collect(),
};
let a = base_eng.infer(&win).expect("base infer");
let b = cal_eng.infer(&win).expect("calibrated infer");
assert!(a.is_finite() && b.is_finite());
let diff: f32 = a.keypoints.iter().zip(&b.keypoints).map(|(x, y)| (x - y).abs()).sum();
assert!(diff > 1e-4, "python-produced adapter must change engine output (sum|Δ| = {diff})");
}
#[test]
fn manifest_roundtrips() {
let spec = ManifestSpec::embedded("pose-estimation", "0.0.1");