open-standards/wai/tools/weft_import.py
Transaction Science 657daba14a
Some checks failed
WAI breaking changes and the conformance runner / WAI breaking · does this change touch WAI (push) Successful in 11s
wai-quantum energy-landscape jobs / does this change touch it (push) Successful in 14s
joule-code conformance gate / joule-moq-relay, its own energy on a counter (macos) (push) Successful in 1m8s
wai-quantum energy-landscape jobs / the module under wasm32-wasip2 (wasmtime) (push) Successful in 2m30s
WAI breaking changes and the conformance runner / WAI breaking · wire, record and API against main · linux (push) Successful in 2m53s
joule-code conformance gate / Build + round-trip C1-C4 vectors (push) Successful in 4m4s
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (push) Failing after 4m26s
wai-quantum energy-landscape jobs / the same bits · macos (push) Successful in 4m5s
wai-quantum energy-landscape jobs / native against WebAssembly, over many seeds (push) Successful in 5m14s
WAI breaking changes and the conformance runner / WAI breaking and conform · their tests, and the independent verifiers through wai conform · linux (push) Successful in 5m51s
joule-code conformance gate / joule-moq-relay, every target (push) Successful in 7m59s
wai-quantum energy-landscape jobs / the same bits · linux-arm64 (push) Successful in 7m41s
wai-quantum energy-landscape jobs / reader, kernels, answers and the stated result · linux, release (push) Successful in 7m57s
joule-moq-remote host agent / joule-moq-remote · does this change touch it (push) Has been cancelled
joule-moq-remote host agent / joule-moq-remote, every target (linux-arm64) (push) Has been cancelled
joule-moq-remote host agent / joule-moq-remote, every target (macos) (push) Has been cancelled
joule-code conformance gate / joule-moq-ingest, every target (push) Successful in 8m58s
joule-moq-room room service / joule-moq-room · does this change touch it (push) Has been cancelled
joule-moq-room room service / joule-moq-room, every target (push) Has been cancelled
joule-moq-web browser client / joule-moq-web · does this change touch it (push) Has been cancelled
joule-moq-web browser client / joule-moq-web · browser end-to-end (macos) (push) Has been cancelled
wai-app and Create / wai-app · does this change touch it (push) Has been cancelled
wai-app and Create / wai-app · tests, clippy, the line language's verifier (linux) (push) Has been cancelled
wai-app and Create / wai-app · Create, browser end-to-end (macos) (push) Has been cancelled
wai-audit collector and player integration / does this change touch it (push) Has been cancelled
wai-audit collector and player integration / collector · linux (push) Has been cancelled
wai-audit collector and player integration / collector, player integration and the browser end to end · macos (push) Has been cancelled
WAI operation catalogue / does this change touch it (push) Has been cancelled
WAI operation catalogue / the catalogue and every door · linux (push) Has been cancelled
wai-fleet service / does this change touch it (push) Has been cancelled
wai-fleet service / service · linux (push) Has been cancelled
wai-fleet service / service · macos (push) Has been cancelled
wai-key-proxy / does this change touch it (push) Has been cancelled
wai-key-proxy / proxy · linux (push) Has been cancelled
wai-ledger service / does this change touch it (push) Has been cancelled
wai-ledger service / service · linux (push) Has been cancelled
wai-ledger service / service · macos (push) Has been cancelled
wai-quantum for JavaScript / does this change touch it (push) Has been cancelled
wai-quantum for JavaScript / javascript · linux (push) Has been cancelled
wai-quantum studio and desktop / does this change touch it (push) Has been cancelled
wai-quantum studio and desktop / studio · browser (push) Has been cancelled
wai-quantum studio and desktop / desktop app · macos (push) Has been cancelled
wai-quantum studio and desktop / desktop app · linux (push) Has been cancelled
wai-quantum studio and desktop / desktop app · windows (push) Has been cancelled
wai-sink-android native sink library / does this change touch it (push) Has been cancelled
wai-sink-android native sink library / the JNI layer and the platform-free half on the host JVM · linux-arm64 (push) Has been cancelled
wai-sink-android native sink library / every ABI, the AAR, and the instrumented tests in a headless emulator · macos (push) Has been cancelled
wai-sink-swift native sink package / does this change touch it (push) Has been cancelled
wai-sink-swift native sink package / libwai slices, desktop tests, simulator tests · macos (push) Has been cancelled
WAI Studio / does this change touch it (push) Has been cancelled
WAI Studio / the catalogue's actions, the unit tests and the core · linux (push) Has been cancelled
WAI Studio / Studio in Chromium and Firefox · macos (push) Has been cancelled
WAI Studio / Studio in WebKit · linux (push) Has been cancelled
wai cross-architecture byte-equality / does this change touch it (push) Has been cancelled
wai cross-architecture byte-equality / linux-aarch64 (push) Has been cancelled
wai cross-architecture byte-equality / linux-x86_64 (push) Has been cancelled
wai cross-architecture byte-equality / macos-arm64 (reference) (push) Has been cancelled
wai cross-architecture byte-equality / windows-x86_64 (push) Has been cancelled
wai: the DCVC family and NNVC registered as candidates, and WFT1 tensor frames registered with their decoder
WAI named two of the DCVC neural video codecs and none of the rest, nothing for the
neural-network-based video coding exploration of ITU-T and ISO/IEC, and no lossless frame
format for tensors.

SPEC §5 registers wai.neural.dcvc, .dcvc_tcm, .dcvc_hem, .dcvc_dc and .dcvc_uf as candidates
(neural-float, media class video, patent-pool provisionally: the code is under MIT, which grants
no patent licence). Each published decoder takes its latent's entropy parameters from a temporal
context as well as the hyperprior, most from a spatial prior of two or four passes too, four
decode a motion latent, and DCVC-UF codes a chunk of frames as one latent; none fits the
inter-frame route of neural/video_dcvc.rs, whose latent comes from the hyperprior alone, and
none pins a bitstream. A new SPEC note says so, and that dcvc_rt and dcvc_fm decode through
that route with a sink-supplied temporal decoder. wai.video.nnvc is a candidate too: no
standard is published and the reference software's bitstream follows its release. Candidates
are refused by dispatch and never picked (SPEC §7.1), which the existing candidate tests now
cover for all six.

wai.tensor.weft registers one frame of the WeftCodec format 1.0 (WEFTCODEC-FORMAT v1.0.0,
WEFT-AI-CODEC v1.3.0, weftcodec 1.2.0) in mode RAW, TENSOR or FLOAT_TENSOR, naming no
dependency: lossless, its plaintext bound by a BLAKE3 content hash, so standard-defined;
royalty-free (text CC BY 4.0, reference implementation Apache-2.0). Any other mode is
UnsupportedMode, as the format requires of a decoder that does not implement a mode. The
reference is codecs::weft (feature weft): a decoder that checks a frame in the format's order
and refuses it with the format's own class, and writers that give the format's own frames byte
for byte. The corpus, tensor-conformance/, holds 77 of the format's frozen vectors with the
outcome this capability gives each, and 70 generated frames, five that decode and the rest with
one planted defect each, every class and every limit reached. weft_verify.py, its second
implementation, agrees on all 147, refuses all 143 changed frames, and requires each of its 77
checks to refuse some vector and to be needed: 72 alone, five (always backed by another check
with the same class) together with that check. staged_verify.py's video class names the DCVC
candidates as the reference's does. The registry export, REGISTRY.md and wai.h are regenerated.

Thirteen faults planted, each failing its tests: DCVC-HEM not a candidate, NNVC royalty-free,
DCVC-UF outside the video class, ZSTD admitted, no content hash, no header CRC, a 25-bit code
admitted, no exponent range, no table_len check, weft as neural-float, SPEC missing a class
(both implementations), and the second verifier without its exponent range.

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

82 lines
3.2 KiB
Python

#!/usr/bin/env python3
"""weft_import.py: copies the frames of the WeftCodec format's frozen conformance vectors
(conformance/v1/codec/ of the format's reference implementation, Apache-2.0) into
tensor-conformance/vectors/, one directory a vector holding frame.wft, and prints the rows
of the third-party table of wai-rs/src/codecs/weft/corpus.rs: each vector's name, the
SHA-256 of its frame, what the format's own vectors expect of it, and what a sink of
wai.tensor.weft gives it.
weft_import.py <codec-vector-dir> <tensor-conformance-dir>
The vectors a later vector supersedes (their mode value has since been allocated) and the
one-mebibyte RAW vector are not copied. A frame of a mode wai.tensor.weft admits (0, 6, 9)
keeps the format's expectation; any other frame whose header is sound is UnsupportedMode,
the class the format gives a mode a decoder does not implement. Standard library only.
"""
import hashlib
import json
import os
import struct
import sys
ADMITTED = {0, 6, 9}
SKIP = {"004_raw_1m"}
def crc32c(data):
c = 0xFFFFFFFF
for b in data:
c ^= b
for _ in range(8):
c = (c >> 1) ^ 0x82F63B78 if c & 1 else c >> 1
return c ^ 0xFFFFFFFF
def header_sound(frame):
"""Magic, version and header CRC as a decoder checks them before reading the mode."""
if len(frame) < 100 or frame[:4] != b"WFT1" or frame[4] != 1 or frame[5] != 0:
return False
return crc32c(frame[:72] + frame[76:96]) == struct.unpack_from("<I", frame, 72)[0]
def main():
src, dst = sys.argv[1], sys.argv[2]
rows = []
for fn in sorted(os.listdir(src)):
if not fn.endswith(".json"):
continue
with open(os.path.join(src, fn), encoding="utf-8") as fh:
v = json.load(fh)
name = v["name"]
if name in SKIP or "superseded_by" in v:
continue
frame = bytes.fromhex(v["frame_hex"])
d = os.path.join(dst, "vectors", name)
os.makedirs(d, exist_ok=True)
with open(os.path.join(d, "frame.wft"), "wb") as fh:
fh.write(frame)
exp = v["expect"]
upstream = "ok" if exp.get("ok") else exp["error"]
mode = frame[7] if len(frame) > 7 else None
if header_sound(frame) and mode not in ADMITTED and mode is not None and mode <= 18:
ours = "UnsupportedMode"
elif header_sound(frame) and mode is not None and mode > 18:
ours = "UnsupportedMode"
else:
ours = upstream
# A limit belongs to the mode the vector exercises; a frame refused for its mode keeps none.
limits = v.get("limits", {}) if ours != "UnsupportedMode" else {}
plain = ""
if ours == "ok":
p = bytes.fromhex(v["plaintext_hex"])
plain = f"Some(({len(p)}, \"{hashlib.sha256(p).hexdigest()}\"))"
else:
plain = "None"
lim = ", ".join(f"(\"{k}\", {n})" for k, n in sorted(limits.items()))
rows.append(f" Upstream {{ name: \"{name}\", frame_sha256: \"{hashlib.sha256(frame).hexdigest()}\", "
f"upstream: \"{upstream}\", expect: \"{ours if ours != 'ok' else 'decode'}\", plaintext: {plain}, limits: &[{lim}] }},")
print("\n".join(rows))
if __name__ == "__main__":
main()