extensions/synthesis.md: the origin claim of an object, a group or a track (captured, reconstructed, assistive, synthesized; the class rises along a chain of derivations and never falls), its IPTC digital source type and C2PA statement as functions of the claim, two pinned integer derivations whose recomputation proves an assistive claim, the marking and detection records of the second layer and their agreement with the first, AI participants' tracks, reviews a player presents only on a decode path of the review's tier, and a player's signed label log with the EU icons pinned by digest. The wai-rs module (feature `synthesis`), its vectors generator and the corpus. Co-Authored-By: Claude Opus 5.5 <[email protected]>
71 lines
3.3 KiB
Rust
71 lines
3.3 KiB
Rust
//! `wai.media.synthesis` (extensions/synthesis.md): the committed corpus
|
|
//! `live-conformance/synthesis/` regenerates byte for byte from its fixed seeds, holds no
|
|
//! other file, every case in it gets the outcome it states, and the extension's §12 lists
|
|
//! exactly the reasons the reference reports. The generator itself asserts that the corpus
|
|
//! gives every one of them.
|
|
#![cfg(feature = "synthesis")]
|
|
|
|
use std::collections::BTreeMap;
|
|
use std::path::PathBuf;
|
|
use wai::synthesis::{corpus, Reason};
|
|
|
|
fn wai_dir() -> PathBuf {
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("..")
|
|
}
|
|
|
|
fn committed() -> BTreeMap<String, String> {
|
|
let dir = wai_dir().join("live-conformance/synthesis");
|
|
std::fs::read_dir(&dir)
|
|
.expect("the committed corpus")
|
|
.flatten()
|
|
.map(|e| (e.file_name().to_string_lossy().into_owned(), e.path()))
|
|
.filter(|(n, _)| n != "README.md")
|
|
.map(|(n, p)| (n, std::fs::read_to_string(p).expect("a text file")))
|
|
.collect()
|
|
}
|
|
|
|
#[test]
|
|
fn the_committed_corpus_regenerates_from_its_seeds() {
|
|
let files = committed();
|
|
let generated: BTreeMap<String, String> = corpus::generate().into_iter().collect();
|
|
let extra: Vec<&String> = files.keys().filter(|k| !generated.contains_key(*k)).collect();
|
|
let missing: Vec<&String> = generated.keys().filter(|k| !files.contains_key(*k)).collect();
|
|
let differ: Vec<&String> = generated.iter().filter(|(k, v)| files.get(*k).is_some_and(|f| f != *v)).map(|(k, _)| k).collect();
|
|
assert!(extra.is_empty() && missing.is_empty() && differ.is_empty(), "extra {extra:?}, missing {missing:?}, differ {differ:?}: run `wai_synthesis_vectors gen`");
|
|
}
|
|
|
|
#[test]
|
|
fn every_case_gets_its_stated_outcome() {
|
|
let fails = corpus::verify(&committed());
|
|
assert!(fails.is_empty(), "{}", fails.join("\n"));
|
|
}
|
|
|
|
/// §12 of the extension lists exactly the codes `Reason::ALL` has, each once, in order.
|
|
#[test]
|
|
fn the_extension_lists_the_reasons() {
|
|
let text = std::fs::read_to_string(wai_dir().join("extensions/synthesis.md")).expect("the extension");
|
|
let at = text.find("\n## 12. Reasons").expect("a §12");
|
|
let end = text[at + 1..].find("\n## ").map_or(text.len(), |e| at + 1 + e);
|
|
let listed: Vec<String> =
|
|
text[at..end].lines().filter(|l| l.starts_with("| `")).filter_map(|l| l.split('`').nth(1).map(String::from)).collect();
|
|
let want: Vec<String> = Reason::ALL.iter().map(|r| r.code().to_string()).collect();
|
|
assert_eq!(listed, want, "§12's table and Reason::ALL differ");
|
|
}
|
|
|
|
/// §10.2's table pins exactly the icons `EU_ICONS` holds, each by its SHA-256, in order.
|
|
#[test]
|
|
fn the_extension_pins_the_icons() {
|
|
let text = std::fs::read_to_string(wai_dir().join("extensions/synthesis.md")).expect("the extension");
|
|
let at = text.find("\n### 10.2 ").expect("a §10.2");
|
|
let end = text[at + 1..].find("\n### ").map_or(text.len(), |e| at + 1 + e);
|
|
let pinned: Vec<(String, String)> = text[at..end]
|
|
.lines()
|
|
.filter(|l| l.starts_with("| `LABEL_AI"))
|
|
.filter_map(|l| {
|
|
let cells: Vec<&str> = l.split('`').collect();
|
|
Some((cells.get(1)?.to_string(), cells.get(3)?.to_string()))
|
|
})
|
|
.collect();
|
|
let want: Vec<(String, String)> = wai::synthesis::EU_ICONS.iter().map(|(n, d)| (n.to_string(), d.to_string())).collect();
|
|
assert_eq!(pinned, want, "§10.2's table and EU_ICONS differ");
|
|
}
|