Some checks failed
no-vanity-metrics / Scan committed Markdown for vanity metrics (pull_request) Successful in 4s
no-vanity-metrics / WAI public text names no comparison (pull_request) Successful in 3s
no-vanity-metrics / WAI public text names no company or product (pull_request) Successful in 3s
standards workspaces build + test / eoc-rs (pull_request) Successful in 1m53s
standards workspaces build + test / jouleclaw-rs (pull_request) Successful in 3m31s
standards workspaces build + test / jcp-rs (pull_request) Successful in 1m26s
standards workspaces build + test / proof-rs (pull_request) Successful in 1m12s
standards workspaces build + test / aac-rs (pull_request) Successful in 1m38s
standards workspaces build + test / sandbox-rs (pull_request) Successful in 2m12s
standards workspaces build + test / joule-code-rs (pull_request) Successful in 1m52s
standards workspaces build + test / joulecontract-rs (pull_request) Successful in 2m11s
standards workspaces build + test / map-rs (pull_request) Successful in 1m8s
standards workspaces build + test / smart-byte-rs (pull_request) Successful in 3m41s
wai cross-architecture byte-equality / linux-x86_64 (pull_request) Successful in 26s
standards workspaces build + test / mesh-rs (pull_request) Successful in 47s
standards workspaces build + test / openpay (pull_request) Successful in 3m34s
wai cross-architecture byte-equality / linux-aarch64 (pull_request) Successful in 44s
WAI conformance / cargo-class corpora · linux (pull_request) Successful in 4m29s
WAI conformance / v2 vocabulary · manifests validate as stated (pull_request) Successful in 13s
WAI conformance / independent verifiers · claims, JWP, key discovery and integer payloads (Python) (pull_request) Successful in 2m16s
WAI conformance / cross-arch byte-equality · linux (pull_request) Successful in 23s
WAI conformance / C2PA manifest emission · signed, read back, validated (pull_request) Successful in 45s
WAI energy receipts / energy receipts · linux (pull_request) Successful in 1m6s
WAI conformance / cargo-class corpora · linux-arm64 (pull_request) Successful in 6m28s
WAI conformance / cross-arch byte-equality · linux-arm64 (pull_request) Successful in 40s
WAI energy receipts / energy receipts · linux-arm64 (pull_request) Successful in 1m41s
wai formal verification (integer core) / kani (pull_request) Successful in 5m5s
WAI JPEG-AI whole decode (pinned inputs, required) / fetch pinned JPEG-AI inputs → whole decode + pixel hash, required (pull_request) Successful in 58s
WAI neural sink gates / model-free refusals of the neural sink (pull_request) Successful in 1m2s
WAI section references / cited sections exist (pull_request) Successful in 10s
WAI mbt2018_mean integer decode (regenerated vectors) / regenerate mbt2018_mean integer vectors → Rust decode, required (pull_request) Successful in 3m54s
wai-web wasm32 / wai-web wasm32 build · corpus, menu and writers (pull_request) Successful in 1m45s
standards workspaces build + test / arl-rs (pull_request) Has been cancelled
standards workspaces build + test / joule-ui-rs (pull_request) Has been cancelled
standards workspaces build + test / jouledesk-rs (pull_request) Has been cancelled
standards workspaces build + test / joulehook-rs (pull_request) Has been cancelled
standards workspaces build + test / sense-rs (pull_request) Has been cancelled
standards workspaces build + test / macOS energy backends (pull_request) Has been cancelled
wai cross-architecture byte-equality / macos-arm64 (reference) (pull_request) Has been cancelled
WAI conformance / cargo-class corpora · macos (pull_request) Has been cancelled
WAI conformance / cross-arch byte-equality · macos (pull_request) Has been cancelled
WAI energy receipts / energy receipts · macos (pull_request) Has been cancelled
Co-Authored-By: Claude Opus 5.5 <[email protected]>
87 lines
4.5 KiB
JavaScript
87 lines
4.5 KiB
JavaScript
// Checks the browser writers against SPEC §5, *Candidate capabilities*: `pack`
|
|
// and `packMulti` refuse a manifest that names a candidate in any place an
|
|
// envelope can name one (the WAI1 capability or fallback; a WAI2 component in
|
|
// either role), and still write an envelope that names none. The candidates are
|
|
// read from the committed export wai/registry/capabilities.json, so a newly
|
|
// registered candidate is checked without editing this script. They also refuse a
|
|
// manifest that names a member twice in one object (SPEC §2), which no reader reads.
|
|
//
|
|
// node verify_pack.mjs [path/to/wai_web.js] [path/to/capabilities.json]
|
|
// The package path is relative to this directory (as in the other verify scripts);
|
|
// the export path is relative to the working directory (default: this tree's).
|
|
// Exit 0 iff every check holds.
|
|
|
|
import { readFileSync } from 'node:fs';
|
|
import { dirname, resolve } from 'node:path';
|
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
const pkg = resolve(here, process.argv[2] ?? './pkg-node/wai_web.js');
|
|
const exportPath = process.argv[3] ? resolve(process.argv[3]) : resolve(here, '../../registry/capabilities.json');
|
|
const wai = await import(pathToFileURL(pkg).href);
|
|
const candidates = JSON.parse(readFileSync(exportPath, 'utf8')).capabilities
|
|
.filter((c) => c.status === 'candidate')
|
|
.map((c) => c.capability);
|
|
|
|
let pass = true;
|
|
const fail = (msg) => { pass = false; console.log(`FAIL ${msg}`); };
|
|
const bytes = new Uint8Array([1, 2, 3]);
|
|
|
|
const v1 = (capability, fallback) => JSON.stringify({
|
|
wai: '1.0', media: 'binary', intent: 'improve',
|
|
model_requirement: fallback ? { capability, fallback } : { capability },
|
|
conditioning: { kind: 'bytes' }, target: null,
|
|
});
|
|
const v2 = (components) => JSON.stringify({
|
|
wai: '1.1', media: 'video', intent: 'improve', target: null,
|
|
renditions: components.map(([capability, base]) => base
|
|
? { capability, kind: 'bytes', role: 'companion', companion_of: base }
|
|
: { capability, kind: 'bytes' }),
|
|
});
|
|
|
|
function refuses(what, write) {
|
|
try {
|
|
write();
|
|
fail(`${what}: written, but a candidate MUST NOT be emitted`);
|
|
} catch (e) {
|
|
if (!String(e.message ?? e).includes('candidate')) fail(`${what}: refused for another reason: ${e.message ?? e}`);
|
|
}
|
|
}
|
|
|
|
if (candidates.length === 0) fail(`no candidate in ${exportPath}`);
|
|
for (const cand of candidates) {
|
|
refuses(`pack, ${cand} as the capability`, () => wai.pack(v1(cand), bytes));
|
|
refuses(`pack, ${cand} as the fallback`, () => wai.pack(v1('wai.image.png', cand), bytes));
|
|
refuses(`packMulti, ${cand} as a rendition`, () => wai.packMulti(v2([[cand]]), [bytes]));
|
|
refuses(`packMulti, ${cand} as a companion`,
|
|
() => wai.packMulti(v2([['wai.video.av1'], [cand, 'wai.video.av1']]), [bytes, bytes]));
|
|
}
|
|
// A manifest that names a member twice in one object is refused (SPEC §2): every
|
|
// reader refuses it, so a writer never emits it.
|
|
function refusesTwice(what, write) {
|
|
try {
|
|
write();
|
|
fail(`${what}: written, but no reader reads it`);
|
|
} catch (e) {
|
|
if (!String(e.message ?? e).includes('twice')) fail(`${what}: refused for another reason: ${e.message ?? e}`);
|
|
}
|
|
}
|
|
const v1Text = v1('wai.image.png');
|
|
refusesTwice('pack, a member twice at the top', () => wai.pack(v1Text.slice(0, -1) + ',"zz":1,"zz":2}', bytes));
|
|
refusesTwice('pack, a member twice in target', () => wai.pack(v1Text.replace('"target":null', '"target":{"w":1,"w":2}'), bytes));
|
|
refusesTwice('pack, a member twice in model_requirement',
|
|
() => wai.pack(v1Text.replace('"capability":"wai.image.png"', '"capability":"wai.image.png","q":1,"q":2'), bytes));
|
|
refusesTwice('packMulti, a member twice in an entry',
|
|
() => wai.packMulti(v2([['wai.video.av1']]).replace('"kind":"bytes"', '"kind":"bytes","zz":1,"zz":2'), [bytes]));
|
|
// An envelope that names no candidate is still written, and parses back.
|
|
try {
|
|
const one = wai.pack(v1('wai.image.png', 'wai.image.jpeg'), bytes);
|
|
if (wai.detectVersion(one) !== 1) fail('pack: the written envelope is not WAI1');
|
|
const two = wai.packMulti(v2([['wai.video.av1'], ['wai.meta.hdr10plus', 'wai.video.av1']]), [bytes, bytes]);
|
|
if (wai.detectVersion(two) !== 2) fail('packMulti: the written envelope is not WAI2');
|
|
} catch (e) {
|
|
fail(`an envelope with no candidate was refused: ${e.message ?? e}`);
|
|
}
|
|
console.log(pass ? `PASS pack and packMulti refuse every candidate (${candidates.join(', ')}) and a member named twice`
|
|
: '\n✗ a browser writer emits what no reader may take');
|
|
process.exit(pass ? 0 : 1);
|