Adds the "carries whatever it can reconstruct, verifies whatever it
carries" surface on top of the existing neural/codec WAI. All builds
green against this base (wai-rs all-features tests + clippy, wai-web
wasm, wai-spz-gen, wai-relay).
Reconstruct half — each a spec + conformance corpus + in-tab browser
sink that re-derives the corpus hash, over one wai.det.fixed64 floor:
- interactive worlds replay-equivalence (3 sim registrants,
relay multiplayer, session receipts, glTF + real-SPZ assets)
- spatial audio mixdown-equivalence
- haptics sample-equivalence
- state-feeds replay-equivalence (non-physics sim)
- avatars / digital humans pose-equivalence (+ telepresence)
- volumetric / 4D splats frame-state-equivalence (WebGPU EWA render)
Verify half (lever 4):
- asset provenance — signed, energy-accounted lineage for opaque
captured content WAI does not reconstruct; tamper-evident in-tab.
Cross-cutting: per-class JWP receipt profiles; a native energy meter
(IOReport via macmon, no sudo) emitting receipts with real measured
joules. Codecs gated behind a `codecs` feature (default on) so the
world/wasm sinks build without the C codec chain.
Excludes the separately-evolving neural subsystem (semantic path, GLC
rANS, ONNX tooling) to avoid reverting newer origin work.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
48 lines
1.5 KiB
Rust
48 lines
1.5 KiB
Rust
//! Browser sink for `wai.haptic.signal` — reconstructs the per-channel
|
|
//! intensity/sharpness envelope in the deterministic floor and checks
|
|
//! its hash against the corpus (sample-equivalence). Playback drives the
|
|
//! Gamepad vibration actuator / Vibration API; the waveform view is the
|
|
//! always-available presentation a sink without actuators shows.
|
|
|
|
use wai::haptic::HapticSignal;
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
#[wasm_bindgen]
|
|
pub struct HapticSink {
|
|
sig: HapticSignal,
|
|
}
|
|
|
|
fn hex(b: &[u8]) -> String {
|
|
b.iter().map(|x| format!("{x:02x}")).collect()
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
impl HapticSink {
|
|
#[wasm_bindgen(constructor)]
|
|
pub fn new(whap: &[u8]) -> Result<HapticSink, JsError> {
|
|
Ok(HapticSink { sig: HapticSignal::from_bytes(whap).map_err(|e| JsError::new(&e.to_string()))? })
|
|
}
|
|
|
|
pub fn num_channels(&self) -> u32 {
|
|
self.sig.contract.channels
|
|
}
|
|
pub fn duration(&self) -> u64 {
|
|
self.sig.contract.duration
|
|
}
|
|
pub fn sample_rate(&self) -> u32 {
|
|
self.sig.contract.sample_rate
|
|
}
|
|
pub fn signal_hash_hex(&self) -> String {
|
|
hex(&self.sig.signal_hash())
|
|
}
|
|
|
|
/// Reconstructed channel `c`: interleaved `[intensity, sharpness]`
|
|
/// u8 per sample — the canonical buffer, for the waveform view and
|
|
/// to drive the actuator.
|
|
pub fn channel(&self, c: usize) -> Box<[u8]> {
|
|
if c >= self.sig.channels.len() {
|
|
return Box::new([]);
|
|
}
|
|
self.sig.reconstruct_channel(c).into_boxed_slice()
|
|
}
|
|
}
|