open-standards/wai/wai-rs/tests/int_world2.rs
Transaction Science 75ecf83f7a
Some checks failed
joule-moq-http live HTTP egress / joule-moq-http · does this change touch it (push) Successful in 28s
joule-moq-room room service / joule-moq-room · does this change touch it (push) Successful in 34s
joule-moq-remote host agent / joule-moq-remote · does this change touch it (push) Successful in 36s
wai-app and Create / wai-app · does this change touch it (push) Successful in 21s
wai-fleet service / does this change touch it (push) Successful in 22s
wai-ops-gpu integer operators on GPUs / does this change touch it (push) Successful in 17s
wai-quantum for JavaScript / does this change touch it (push) Successful in 14s
wai-quantum studio and desktop / does this change touch it (push) Successful in 16s
WAI breaking changes and the conformance runner / WAI breaking · does this change touch WAI (push) Successful in 15s
WAI examples / WAI examples · does this change touch them (push) Successful in 8s
wai-app and Create / wai-app · tests, clippy, the line language's verifier (linux) (push) Successful in 1m44s
WAI operation catalogue / does this change touch it (push) Successful in 3m36s
wai-pack / wai-pack · does this change touch it (push) Successful in 3m15s
wai-fleet service / service · linux (push) Successful in 2m56s
joule-moq-web browser client / joule-moq-web · does this change touch it (push) Successful in 4m14s
wai-sink-swift native sink package / does this change touch it (push) Successful in 3m21s
wai-audit collector and player integration / does this change touch it (push) Successful in 3m48s
wai-ledger service / does this change touch it (push) Successful in 3m34s
wai-sink-android native sink library / does this change touch it (push) Successful in 3m22s
WAI Studio / does this change touch it (push) Successful in 3m20s
WAI breaking changes and the conformance runner / WAI breaking · wire, record and API against main · linux (push) Successful in 2m9s
WAI Studio / the catalogue's actions, the unit tests and the core · linux (push) Successful in 1m13s
wai-quantum studio and desktop / studio · browser (push) Successful in 6m57s
wai-ops-gpu integer operators on GPUs / Vulkan GPUs (framework-128gb) (push) Successful in 8m32s
wai-ops-gpu integer operators on GPUs / Vulkan GPUs (jetson-hub) (push) Successful in 10m3s
wai-quantum for JavaScript / javascript · linux (push) Successful in 8m58s
wai-quantum studio and desktop / desktop app · linux (push) Successful in 8m43s
wai-ledger service / service · linux (push) Successful in 3m56s
wai-audit collector and player integration / collector · linux (push) Successful in 4m36s
wai-pack / wai-pack · linux (push) Successful in 6m27s
WAI breaking changes and the conformance runner / WAI breaking and conform · their tests, and the independent verifiers through wai conform · linux (push) Successful in 10m41s
wai-ops-gpu integer operators on GPUs / builds · no adapter is not a pass (linux) (push) Successful in 16m6s
WAI Studio / Studio in WebKit · linux (push) Successful in 17m52s
WAI operation catalogue / the catalogue and every door · linux (push) Successful in 20m17s
joule-moq-remote host agent / joule-moq-remote, every target (macos) (push) Successful in 49s
WAI examples / WAI examples · portable · linux (push) Successful in 27m28s
wai-fleet service / service · macos (push) Successful in 52s
wai-app and Create / wai-app · Create, browser end-to-end (macos) (push) Successful in 6m33s
wai-quantum studio and desktop / desktop app · macos (push) Successful in 6m20s
joule-moq-remote host agent / joule-moq-remote, every target (linux-arm64) (push) Successful in 2m39s
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (push) Successful in 9m3s
wai-ops-gpu integer operators on GPUs / Metal GPU and browser WebGPU (macos) (push) Failing after 10m47s
joule-moq-http live HTTP egress / joule-moq-http, every target (push) Successful in 9m20s
joule-moq-room room service / joule-moq-room, every target (push) Successful in 8m54s
wai-pack / wai-pack · macos (push) Successful in 4m43s
wai-ledger service / service · macos (push) Successful in 1m4s
wai-audit collector and player integration / collector, player integration and the browser end to end · macos (push) Successful in 2m30s
WAI examples / WAI examples · android-app · linux-arm64 (push) Successful in 13m7s
wai-pack / wai-pack · linux-arm64 (push) Successful in 7m17s
wai-pack / wai-pack · the floor through a media prober (push) Successful in 3m59s
wai-pack / wai-pack · dependency licences (push) Successful in 4m14s
joule-moq-web browser client / joule-moq-web · browser end-to-end (macos) (push) Successful in 13m34s
wai-sink-android native sink library / every ABI, the AAR, and the instrumented tests in a headless emulator · macos (push) Successful in 5m56s
WAI examples / WAI examples · the archive, the readiness check, the browser and Apple · macos (push) Successful in 25m59s
WAI Studio / Studio in Chromium and Firefox · macos (push) Successful in 13m40s
wai-sink-android native sink library / the JNI layer and the platform-free half on the host JVM · linux-arm64 (push) Successful in 9m23s
wai-sink-swift native sink package / libwai slices, desktop tests, simulator tests · macos (push) Successful in 22m8s
wai-pack / wai-pack · independent verifier (Python) (push) Successful in 27m17s
wai-quantum studio and desktop / desktop app · windows (push) Successful in 14m53s
wai-ops-gpu runs on main; wai-rs's world renderer build is clippy-clean and held to it
wai-ops-gpu.yml gains a push trigger on main over its pull-request paths (the repo's
concurrency form puts each push in a group of its own), so the Metal and Vulkan legs run on
every commit that changes the kernels, the decoders whose graphs run on the device, or their
vectors. tests/int_world.rs and int_world2.rs drop the indexed loops clippy refused under
world_int (int_world2 now also requires one committed hash per frame), and the catalogue
workflow's clippy step adds the world_int build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 16:19:09 -05:00

56 lines
2.7 KiB
Rust

// wai-conformance: int-kernels
//! `wai.world.model` TWO-AGENT co-control — both agents' actions drive one frame.
//! The committed transition + synthesis (A=4 input planes: dxA,dyA,dxB,dyB), an
//! initial latent, and a sequence of combined (agent-A, agent-B) actions regenerate a
//! frame sequence whose per-frame + clip hashes reproduce on every machine. Two
//! participants co-render one byte-exact world — true simultaneous multiplayer, not
//! serialized. Committed tiny vector under `tests/vectors/int_world2/`; never skips.
#![cfg(feature = "world_int")]
use std::path::PathBuf;
use wai::int_hyper_synth::IntModel;
use wai::int_world::{decode_planes, ACTIONS};
fn dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/vectors/int_world2")
}
#[test]
fn two_agent_world_regenerates_byte_for_byte() {
let t = IntModel::from_bytes(&std::fs::read(dir().join("world2_T.bin")).unwrap()).expect("transition WHM1");
let gs = IntModel::from_bytes(&std::fs::read(dir().join("world2_gs.bin")).unwrap()).expect("synthesis WHM1");
let j: serde_json::Value = serde_json::from_slice(&std::fs::read(dir().join("world2.json")).unwrap()).unwrap();
let c = j["c"].as_u64().unwrap() as usize;
let lat = j["lat"].as_u64().unwrap() as usize;
let one = 1i64 << j["afrac"].as_u64().unwrap();
let z0: Vec<i64> = j["z0"].as_array().unwrap().iter().map(|v| v.as_i64().unwrap()).collect();
// Each step's action PLANE row combines both agents: [dxA, dyA, dxB, dyB] at
// 2^afrac — the A=4 input the two-agent transition consumes.
let rows: Vec<Vec<i64>> = j["pairs"]
.as_array()
.unwrap()
.iter()
.map(|p| {
let aa = p[0].as_u64().unwrap() as usize;
let ab = p[1].as_u64().unwrap() as usize;
let (axa, aya) = ACTIONS[aa];
let (axb, ayb) = ACTIONS[ab];
vec![axa * one, aya * one, axb * one, ayb * one]
})
.collect();
let clip = decode_planes(&t, &gs, &z0, &rows, c, lat).expect("the committed clip renders");
let want = j["frame_hashes"].as_array().unwrap();
assert_eq!(clip.frames.len(), rows.len() + 1, "initial + one frame per combined action");
assert_eq!(want.len(), clip.frames.len(), "one committed hash per frame");
for (i, w) in want.iter().enumerate() {
let got = format!("{:016x}", clip.frame_hash(i));
assert_eq!(got, w.as_str().unwrap(), "two-agent frame {i} must reproduce its committed hash");
}
let clip_hash = format!("{:016x}", clip.clip_hash());
assert_eq!(clip_hash, j["clip_hash"].as_str().unwrap(), "clip hash");
println!("int_world2: {} frames {}px, two agents co-rendered byte-exact, clip {clip_hash}", clip.frames.len(), clip.frame_px);
}