Every registered string now lives in one table (codecs/registry.rs) with its kind, status, media class, registering SPEC section, edition and registration date. `wai registry export` writes registry/capabilities.json, its JSON Schema, the generated table in REGISTRY.md and vocab v2; --check fails on drift. vocab v1 stays stable. A candidate capability (a registered string whose payload format no revision has pinned) must not be emitted. The C packers, the browser writers and `wai wrap` refuse one, and `codecs::is_dispatchable` is the single dispatch and selection predicate (SPEC §4): candidates, companion-only capabilities, records and derivations are not dispatchable, and an unregistered string is decoded only where the sink advertises it. The codec glossary is linked to the registry through a reviewed table and held to its schema by a library test; `org` becomes `body`, from a closed allowlist. The SPEC gains §5 sections on kinds and candidates, a §8 edition rule, corrected citations and rewritten appendices. The quantum-ops vectors are regenerated with neutral device ids. CI declares the feature-gated test targets with required-features, checks the registry export, builds wai-web for wasm32, and runs two public-text checks (comparative prose, and private name patterns) with a self-test. The specification, extensions, research notes, READMEs, glossary and source comments are rewritten to name no company or product and to make no comparisons. Co-Authored-By: Claude Opus 5.5 <[email protected]>
158 lines
7.6 KiB
Rust
158 lines
7.6 KiB
Rust
//! `wai wrap` writes an envelope that pins no prior, so SPEC §7 limits the intent
|
|
//! it may claim: `replicate` only over the standard classes, where a sink accepts
|
|
//! it unpinned. It used to write `intent = replicate` over every capability,
|
|
//! `wai.image.jpegai` included. These tests run the binary itself; the rule it
|
|
//! applies is `codecs::unpinned_envelope_intent`, which the library tests check
|
|
//! for every registered capability.
|
|
//!
|
|
//! `wrap` needs no codec feature, so these run in the no-system-dependency CI
|
|
//! matrix (`--test cli_wrap_intent`).
|
|
|
|
use std::path::{Path, PathBuf};
|
|
use std::process::{Command, Output};
|
|
|
|
use wai::container::{Wai, WaiMulti};
|
|
|
|
/// The committed JPEG AI reference codestream; `wrap` treats any payload as opaque.
|
|
fn payload() -> PathBuf {
|
|
Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/vectors/jpegai/test256.bin")
|
|
}
|
|
|
|
fn scratch(name: &str) -> PathBuf {
|
|
let dir = Path::new(env!("CARGO_TARGET_TMPDIR")).join("cli_wrap_intent");
|
|
std::fs::create_dir_all(&dir).unwrap();
|
|
let p = dir.join(name);
|
|
let _ = std::fs::remove_file(&p);
|
|
p
|
|
}
|
|
|
|
fn wrap(cap: &str, out: &Path, extra: &[&str]) -> Output {
|
|
Command::new(env!("CARGO_BIN_EXE_wai"))
|
|
.arg("wrap").arg(cap).arg(payload()).arg("-o").arg(out).args(extra)
|
|
.output()
|
|
.expect("run wai")
|
|
}
|
|
|
|
#[test]
|
|
fn wrap_refuses_replicate_over_jpegai_and_writes_nothing() {
|
|
for extra in [&[][..], &["--intent", "replicate"][..]] {
|
|
let out = scratch("jpegai.wai");
|
|
let run = wrap("wai.image.jpegai", &out, extra);
|
|
let stderr = String::from_utf8_lossy(&run.stderr);
|
|
assert!(!run.status.success(), "{extra:?}: wrap must refuse; stderr: {stderr}");
|
|
assert!(stderr.contains("not writing intent=replicate over wai.image.jpegai"), "{stderr}");
|
|
assert!(stderr.contains("entropy-consistency"), "the refusal names the tier: {stderr}");
|
|
assert!(stderr.contains("--intent"), "the refusal says how to proceed: {stderr}");
|
|
assert!(!out.exists(), "{extra:?}: a refused wrap must not write an envelope");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn wrap_writes_another_intent_over_jpegai_when_asked() {
|
|
let out = scratch("jpegai-improve.wai");
|
|
let run = wrap("wai.image.jpegai", &out, &["--intent", "improve"]);
|
|
assert!(run.status.success(), "{}", String::from_utf8_lossy(&run.stderr));
|
|
let env = Wai::read(&out).unwrap();
|
|
assert_eq!(env.intent(), "improve");
|
|
assert_eq!(env.replicate_refusal(), None);
|
|
assert_eq!(env.payload, std::fs::read(payload()).unwrap(), "the payload is carried byte-identically");
|
|
}
|
|
|
|
#[test]
|
|
fn wrap_refuses_replicate_when_the_fallback_is_jpegai() {
|
|
// The primary backs an unpinned replicate, but a sink without it decodes
|
|
// through the fallback (SPEC §4 step 5), where replicate is refused.
|
|
for extra in [&["--fallback", "wai.image.jpegai"][..],
|
|
&["--fallback", "wai.image.jpegai", "--intent", "replicate"][..]] {
|
|
let out = scratch("jp2-fb-jpegai.wai");
|
|
let run = wrap("wai.image.jp2", &out, extra);
|
|
let stderr = String::from_utf8_lossy(&run.stderr);
|
|
assert!(!run.status.success(), "{extra:?}: wrap must refuse; stderr: {stderr}");
|
|
assert!(stderr.contains("with fallback wai.image.jpegai"), "{stderr}");
|
|
assert!(stderr.contains("entropy-consistency"), "the refusal names the tier: {stderr}");
|
|
assert!(!out.exists(), "{extra:?}: a refused wrap must not write an envelope");
|
|
}
|
|
// Another intent is carried, fallback and all.
|
|
let out = scratch("jp2-fb-jpegai-improve.wai");
|
|
let run = wrap("wai.image.jp2", &out, &["--fallback", "wai.image.jpegai", "--intent", "improve"]);
|
|
assert!(run.status.success(), "{}", String::from_utf8_lossy(&run.stderr));
|
|
let env = Wai::read(&out).unwrap();
|
|
assert_eq!(env.intent(), "improve");
|
|
assert_eq!(env.fallback(), Some("wai.image.jpegai"));
|
|
}
|
|
|
|
#[test]
|
|
fn wrap_still_writes_replicate_with_a_standard_fallback() {
|
|
let out = scratch("jp2-fb-png.wai");
|
|
let run = wrap("wai.image.jp2", &out, &["--fallback", "wai.image.png"]);
|
|
assert!(run.status.success(), "{}", String::from_utf8_lossy(&run.stderr));
|
|
let env = Wai::read(&out).unwrap();
|
|
assert_eq!(env.intent(), "replicate");
|
|
assert_eq!(env.fallback(), Some("wai.image.png"));
|
|
}
|
|
|
|
#[test]
|
|
fn wrap_refuses_an_unpinned_replicate_over_an_integer_exact_neural_codec() {
|
|
// Integer-exact, but `replicate` over it needs a pinned integer-exact prior,
|
|
// which `wrap` does not write.
|
|
let out = scratch("int_hyper.wai");
|
|
let run = wrap("wai.neural.int_hyper", &out, &[]);
|
|
assert!(!run.status.success());
|
|
assert!(String::from_utf8_lossy(&run.stderr).contains("no pinned prior"));
|
|
assert!(!out.exists());
|
|
}
|
|
|
|
#[test]
|
|
fn wrap_still_writes_replicate_over_a_standard_codec() {
|
|
// `wai.image.jp2` is StandardTolerance: replicate is honoured, promising the
|
|
// standard's decoder conformance, and needs no prior.
|
|
let out = scratch("jp2.wai");
|
|
let run = wrap("wai.image.jp2", &out, &[]);
|
|
assert!(run.status.success(), "{}", String::from_utf8_lossy(&run.stderr));
|
|
let env = Wai::read(&out).unwrap();
|
|
assert_eq!(env.intent(), "replicate");
|
|
assert_eq!(env.replicate_refusal(), None, "a sink accepts what wrap wrote");
|
|
assert_eq!(env.payload, std::fs::read(payload()).unwrap());
|
|
}
|
|
|
|
#[test]
|
|
fn wrap_holds_a_companion_envelope_to_the_same_intent_rule() {
|
|
// With `--companion` the output is a WAI2 envelope; its intent is checked over
|
|
// the base payload's capability as the WAI1 form's is (and over each
|
|
// companion's). HDR dynamic metadata may bind to a neural video payload
|
|
// (SPEC §7.1), whose class is NeuralFloat.
|
|
let meta = payload();
|
|
let meta = meta.to_str().unwrap();
|
|
let hdr = ["--companion", "wai.meta.hdr10plus", meta];
|
|
for extra in [hdr.to_vec(), [&["--intent", "replicate"][..], &hdr[..]].concat()] {
|
|
let out = scratch("dcvc-hdr.wai");
|
|
let run = wrap("wai.neural.dcvc_rt", &out, &extra);
|
|
let stderr = String::from_utf8_lossy(&run.stderr);
|
|
assert!(!run.status.success(), "{extra:?}: wrap must refuse; stderr: {stderr}");
|
|
assert!(stderr.contains("not writing intent=replicate over wai.neural.dcvc_rt"), "{stderr}");
|
|
assert!(!out.exists(), "{extra:?}: a refused wrap must not write an envelope");
|
|
}
|
|
// Another intent is carried, companion and all.
|
|
let out = scratch("dcvc-hdr-improve.wai");
|
|
let run = wrap("wai.neural.dcvc_rt", &out, &[&["--intent", "improve"][..], &hdr[..]].concat());
|
|
assert!(run.status.success(), "{}", String::from_utf8_lossy(&run.stderr));
|
|
let env = WaiMulti::read(&out).unwrap();
|
|
assert_eq!(env.intent(), "improve");
|
|
assert_eq!(env.check_component_roles(), Ok(()));
|
|
// A standard base still gets `replicate`.
|
|
let out = scratch("hevc-hdr.wai");
|
|
let run = wrap("wai.video.hevc", &out, &hdr);
|
|
assert!(run.status.success(), "{}", String::from_utf8_lossy(&run.stderr));
|
|
let env = WaiMulti::read(&out).unwrap();
|
|
assert_eq!(env.intent(), "replicate");
|
|
assert_eq!(env.check_component_roles(), Ok(()));
|
|
// The WAI2 form takes no fallback; that is the refusal, whatever the
|
|
// fallback's class, rather than the WAI1 fallback-intent check.
|
|
let out = scratch("hevc-hdr-fb.wai");
|
|
let run = wrap("wai.video.hevc", &out,
|
|
&[&["--fallback", "wai.image.jpegai"][..], &hdr[..]].concat());
|
|
let stderr = String::from_utf8_lossy(&run.stderr);
|
|
assert!(!run.status.success(), "wrap must refuse; stderr: {stderr}");
|
|
assert!(stderr.contains("--fallback names a WAI1 alternative"), "{stderr}");
|
|
assert!(!out.exists(), "a refused wrap must not write an envelope");
|
|
}
|