open-standards/wai/wai-audit
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Transaction Science 8da651a54b
Some checks failed
WAI breaking changes and the conformance runner / WAI breaking · does this change touch WAI (push) Successful in 21s
wai-fleet service / does this change touch it (push) Successful in 17s
joule-moq-web browser client / joule-moq-web · does this change touch it (push) Successful in 26s
joule-moq-room room service / joule-moq-room · does this change touch it (push) Successful in 28s
wai-app and Create / wai-app · does this change touch it (push) Successful in 22s
wai-quantum energy-landscape jobs / does this change touch it (push) Successful in 15s
joule-code conformance gate / joule-moq-relay, its own energy on a counter (macos) (push) Successful in 50s
wai-quantum editors / does this change touch it (push) Successful in 31s
wai-quantum for JavaScript / does this change touch it (push) Successful in 29s
wai-app and Create / wai-app · tests, clippy, the line language's verifier (linux) (push) Successful in 40s
wai-audit collector and player integration / does this change touch it (push) Successful in 1m23s
wai-quantum studio and desktop / does this change touch it (push) Successful in 30s
wai-fleet service / service · macos (push) Successful in 59s
wai-quantum for Python / does this change touch it (push) Successful in 31s
wai-quantum docs, course and locales / does this change touch it (push) Successful in 1m27s
wai-quantum views in agent hosts / does this change touch it (push) Successful in 21s
joule-moq-remote host agent / joule-moq-remote · does this change touch it (push) Successful in 2m4s
wai-key-proxy / does this change touch it (push) Successful in 1m55s
WAI operation catalogue / does this change touch it (push) Successful in 1m56s
wai-quantum command line / does this change touch it (push) Successful in 1m40s
wai-ledger service / does this change touch it (push) Successful in 1m50s
wai-quantum contract / does this change touch it (push) Successful in 1m41s
WAI Studio / does this change touch it (push) Successful in 12s
wai-sink-swift native sink package / does this change touch it (push) Successful in 25s
WAI breaking changes and the conformance runner / WAI breaking · wire, record and API against main · linux (push) Successful in 1m43s
wai-sink-android native sink library / does this change touch it (push) Successful in 42s
joule-code conformance gate / Build + round-trip C1-C4 vectors (push) Successful in 2m45s
wai-quantum editors / editors · macos (push) Successful in 2m2s
wai-audit collector and player integration / collector, player integration and the browser end to end · macos (push) Successful in 2m21s
wai-fleet service / service · linux (push) Successful in 3m36s
wai-quantum docs, course and locales / the Studio's words in every locale · linux (push) Successful in 12s
joule-moq-remote host agent / joule-moq-remote, every target (macos) (push) Successful in 52s
joule-moq-remote host agent / joule-moq-remote, every target (linux-arm64) (push) Successful in 2m37s
wai-quantum for Python / python · macos (push) Successful in 2m57s
wai-ledger service / service · macos (push) Successful in 1m16s
wai-quantum editors / editors · linux (push) Successful in 3m46s
wai-audit collector and player integration / collector · linux (push) Successful in 3m39s
wai-quantum docs, course and locales / the course and the command line's languages · linux (push) Successful in 3m23s
wai-quantum for Python / python · linux (push) Successful in 4m26s
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (push) Failing after 6m38s
wai-quantum studio and desktop / desktop app · macos (push) Successful in 5m7s
wai-quantum command line / command line · macos (push) Successful in 2m33s
wai-quantum for JavaScript / javascript · linux (push) Successful in 5m35s
wai-key-proxy / proxy · linux (push) Successful in 1m12s
joule-moq-room room service / joule-moq-room, every target (push) Successful in 7m3s
WAI breaking changes and the conformance runner / WAI breaking and conform · their tests, and the independent verifiers through wai conform · linux (push) Successful in 7m40s
wai-quantum energy-landscape jobs / native against WebAssembly, over many seeds (push) Successful in 7m39s
wai-ledger service / service · linux (push) Successful in 2m5s
wai-quantum contract / the policy is linked, and the deprecations page reads (push) Successful in 7s
wai-app and Create / wai-app · Create, browser end-to-end (macos) (push) Successful in 8m36s
wai-quantum energy-landscape jobs / the same bits · macos (push) Successful in 8m36s
WAI Studio / the catalogue's actions, the unit tests and the core · linux (push) Successful in 1m10s
wai-quantum views in agent hosts / views · a scripted host (push) Successful in 4m26s
wai-quantum views in agent hosts / views · the page and its engine (push) Successful in 6m33s
wai-quantum contract / API compatibility · linux (push) Successful in 4m44s
wai-quantum energy-landscape jobs / the same bits · linux-arm64 (push) Successful in 13m4s
wai-sink-android native sink library / every ABI, the AAR, and the instrumented tests in a headless emulator · macos (push) Successful in 6m46s
wai-quantum energy-landscape jobs / reader, kernels, answers and the stated result · linux, release (push) Successful in 14m11s
wai-quantum energy-landscape jobs / the module under wasm32-wasip2 (wasmtime) (push) Successful in 14m12s
wai-quantum studio and desktop / desktop app · linux (push) Successful in 13m18s
WAI operation catalogue / the catalogue and every door · linux (push) Successful in 10m49s
WAI Studio / Studio in Chromium and Firefox · macos (push) Successful in 11m36s
wai-sink-swift native sink package / libwai slices, desktop tests, simulator tests · macos (push) Successful in 12m10s
joule-moq-web browser client / joule-moq-web · browser end-to-end (macos) (push) Successful in 16m36s
wai-quantum contract / schemas and the committed tool lists · linux (push) Successful in 9m58s
wai-quantum studio and desktop / studio · browser (push) Successful in 16m35s
WAI Studio / Studio in WebKit · linux (push) Successful in 12m22s
wai-quantum docs, course and locales / every command and snippet in the docs · linux (push) Successful in 22m0s
wai release binaries build on Windows / the seven release binaries · windows (push) Successful in 24m31s
joule-code conformance gate / joule-moq-ingest, every target (push) Successful in 28m51s
joule-code conformance gate / joule-moq-relay, every target (push) Successful in 28m59s
wai-sink-android native sink library / the JNI layer and the platform-free half on the host JVM · linux-arm64 (push) Successful in 29m41s
wai-quantum studio and desktop / desktop app · windows (push) Successful in 11m58s
wai-quantum command line / command line · linux (push) Successful in 48m17s
wai: one command for the rest of the toolchain: audit, serve, quantum, cmcd, receipt create, and every record kind in wai verify
Folds, each the program it folds run as itself, so what it prints and its exit
status are the program's for the same arguments: wai audit report|check|verify
(audit.create, audit.check, audit.verify) is wai-audit, --owner its
WAI_AUDIT_OWNER; wai serve <role> [--config F] [--check] (service.start) starts
wai-<role>: relay, room, ingest and key-release from a file, audit, fleet,
ledger and quantum-service from their environment; wai quantum
run|plan|lint|verify|methods (quantum.run, .inspect, .check, .verify, .list)
is wai-quantum with that verb, and no other verb of it is reached. A program is
its flag, WAI_<NAME>_BIN, beside wai, or on PATH; one not there is exit 5,
program-not-found. report is not an N3 verb, so wai audit report is the
operation audit.create.

--check on the daemons: wai-relay, wai-room (its keys too) and wai-ingest
--config F --check, and wai-key-release serve F --check, read the
configuration as each starts from it and start nothing, exit 1 with the reason
when it does not read. The proxy is installed as wai-key-release; wai-key-proxy
is the same program under its earlier name.

wai cmcd encode|decode|verify is wai_telemetry's tool compiled in (cmcd.rs, one
module behind both; telemetry joins full). wai receipt create <file>... --from
<input>... [--key] signs the operation receipt a toolchain write leaves, for
files made elsewhere. wai verify reads every record by its kind: by name, and a
JSON record by what it holds (a delivery receipt or claim as receipt_verify
answers it, a room session, an audit bundle as wai-audit verify does with
--owner/--channel, a sealed playlist by its mr/<blake3>.json as check-playlist
does); a file of no kind is exit 2, unknown-record. wai mcp --toolset quantum
starts wai-quantum mcp and answers each quantum_* tool with that server's own
answer and schemas. wai media score build|render alias wai score. The quantum
operations' SDK names are registered labels.

Tests, each fold against what it folds: cli_folds (cmcd over the whole corpus,
receipt create against wrap's receipt, verify on the claim, JWP, room and audit
corpora and a sealed playlist, audit|serve|quantum against stand-ins);
wai-audit tests/fold.rs, wai-quantum-cli tests/wai_fold.rs and joule-moq-room
tests/cli_serve.rs against the real programs; cli_mcp's quantum toolset; the
daemons' --check (config_check.rs, check.rs). ops.json, mcp.json, the registry
export and Studio's actions regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-10 02:57:54 -05:00
..
e2e wai-audit e2e: the collector ends with the run, however it ends 2026-10-25 22:23:59 -04:00
src wai-audit's tests hold bad_period, the error outcomes and every route the router declares to its pattern 2026-11-07 01:50:41 -05:00
tests wai: one command for the rest of the toolchain: audit, serve, quantum, cmcd, receipt create, and every record kind in wai verify 2026-11-10 02:57:54 -05:00
web wai: native-sink, the extension text, its corpus README, and the page's replay 2026-10-25 22:21:10 -04:00
.gitignore wai-audit: the stream audit collector and the player integration 2026-10-25 21:41:51 -04:00
Cargo.lock wai 0.6.0 2026-11-09 16:17:06 -05:00
Cargo.toml Six WAI services answer GET /metrics, and wai-audit builds as a library 2026-11-07 01:50:40 -05:00
README.md wai-audit's tests hold bad_period, the error outcomes and every route the router declares to its pattern 2026-11-07 01:50:41 -05:00

wai-audit

The stream audit kit of extensions/stream-audit.md: evidence a content owner gathers from the players of a stream another service packages and delivers over HTTP, with nothing asked of that service.

  • The player integration (web/): for each playback session the player makes a fresh key, hashes every playlist and segment it fetches, and signs settlement acknowledgements (WDA1) of them by plain SHA-256, one chain per origin; a presentation claim (WPC1) for each ad the playlist marks; and the session record (WAS1): the spans it presented, in view and audible, its start time and stalls, its energy per role with each figure's class, and how it ended. It sends Event-mode CMCD version 2 to the collector as it plays, and the session's bundle when it ends.
  • The collector (wai-audit serve): verifies each bundle, stores the accepted ones one per session, takes the CMCD batches, and serves each channel's report, signed: time presented, ads presented and the quartile each reached, start time and stalls once 50 sessions hold them, acknowledged bytes per origin and class, and joules per role and class, never summed across classes. Anyone holding the stored bundles recomputes the report byte for byte (wai-audit check).

No price, tariff or amount is computed anywhere here.

Run the collector

cargo build --release
WAI_AUDIT_CHANNELS=news-east,film-library \
WAI_AUDIT_ALLOW_ORIGINS=https://player.example \
  ./target/release/wai-audit serve
variable default meaning
WAI_AUDIT_CHANNELS (required) the channel names served, comma-separated, each 1 to 255 bytes of printable ASCII (§3.1)
WAI_AUDIT_ADDR 127.0.0.1:9694 where it listens
WAI_AUDIT_DATA ~/.local/share/wai-audit where it stores sessions and CMCD batches
WAI_AUDIT_KEY ~/.config/wai-audit/signing.key the owner's Ed25519 key, 32 bytes, created readable by its owner alone if absent
WAI_AUDIT_ALLOW_ORIGINS none the page origins a browser may send from (CORS), or *
WAI_AUDIT_TRUSTED_PROXIES 127.0.0.1,::1 peers whose X-Forwarded-For names the client
WAI_AUDIT_PER_MINUTE 120 requests a client may make a minute (an IPv4 address, or an IPv6 /64)
WAI_AUDIT_MAX_BUNDLE 4194304 the largest bundle, bytes
WAI_AUDIT_MAX_BATCH 262144 the largest CMCD batch, bytes

Routes

route answer
GET /v1 the collector: its key, its channels and their ids, its limits
GET /v1/health {"ok": true}
GET /v1/key the owner's key, hexadecimal, as text: what a player's records name as owner
POST /v1/sessions a bundle (§9), any media type: 201 stored, 200 stored before, 409 another record of a stored session (audit_session_duplicate), 413 too large, 422 refused, 429 too many; with the outcome (§10.3)
POST /v1/cmcd an Event-mode CMCD batch (application/cmcd, live-metering §6.3): 204, or 422 naming the first line that is not an Event-mode report of version 2
GET /v1/channels/{name}/report?from=&to= the channel's report over the period (microseconds since 1970), {"report", "sig"} (§11.3)
GET /metrics the collector's counters in the text exposition format (../wai-metrics): requests by route, method and status (wai_audit_requests_total), session bundles verified by outcome (wai_audit_sessions_total: stored, stored again, duplicate, refused, error), CMCD batches and reports by outcome, and the channels served. No channel, session, key or client is a label. Through a front: 404

Storage: <data>/channels/<channel id>/<session>.json, the bundle as the player sent it, written to a temporary name and renamed; <data>/cmcd/<UTC date>.cmcd, the batches as they came. A report verifies every stored session of its channel again, so a stored file that no longer verifies (another key, a channel no longer served) is an error, not a silent omission.

As a library

The collector and its routes are the crate's library, for a service that hosts them; the binary reads its configuration from the environment and calls them:

let key = wai_audit::load_or_create(&key_path)?;             // the owner's key, as `serve` keeps it
let collector = Arc::new(wai_audit::collector::Collector::new(config, key));
let app = Arc::new(wai_audit::http::App::new(collector, trusted_proxies));
axum::serve(listener, wai_audit::http::router(app).into_make_service_with_connect_info::<SocketAddr>()).await?;

The command line

wai-audit key [PATH]                          # the owner's key at PATH (created if absent)
WAI_AUDIT_OWNER=<hex> wai-audit verify bundle.json news-east
WAI_AUDIT_KEY=<path>  wai-audit report <data> news-east <from> <to>
WAI_AUDIT_OWNER=<hex> wai-audit check served.json news-east bundle-1.json bundle-2.json …

verify prints a bundle's outcome; report recomputes a channel's report from a data directory and signs it; check recomputes a served report from the bundles it reads (§11.4) and checks its signature.

Put it in a page

<script type="module">
  import { AuditSession, attach, CLASS, ROLE } from "./audit.js";
  import { tap } from "./adapter-tap.js";
  const session = await AuditSession.start({ channel: "news-east", owner: "<the collector's key>", collector: "https://audit.example/" });
  session.energy(ROLE.SINK_DECODE, 0, CLASS.UNMETERED); // a page has no meter (§8.1)
  session.energy(ROLE.DISPLAY, 0, CLASS.UNMETERED);
  tap(session, { manifest: src });                      // before the player starts fetching
  // ... start the page's own player on `src` ...
  attach(video, session, { programMs: () => session.programAt(video.currentTime) });
</script>
  • adapter-tap.js wraps the page's fetch and XMLHttpRequest and hands the session every response the presentation names: for any web player that fetches over them.
  • adapter-hlsjs.js wraps the loader class of a player whose configuration takes one, and gives the program time of the position from the player itself, which a live stream needs.
  • attach observes the media element every 200 ms and on its events, logs the first presentation, stalls and the end, and closes and sends the session when playback ends or the page goes away.

The origin serving the stream must answer cross-origin requests (players need that already), and must list CMSD-Static and CMSD-Dynamic in Access-Control-Expose-Headers for the kit to record them. Ad markers are read from HLS EXT-X-DATERANGE tags with SCTE35-OUT, SCTE35-CMD or a configured CLASS; DASH events are not read in this revision. A bundle sent as a page goes away rides on a keep-alive request, which a user agent may refuse past its quota (64 KiB in the Fetch Standard); the kit sends at the end of playback first.

Tests

  • cargo test --release: every session of the corpus live-conformance/audit/ posted gets the corpus's outcome, and the stored sessions report exactly the corpus's served reports, byte for byte and signature; CORS, body and request limits, CMCD intake; GET /metrics read strictly as the text format, its counters moved by those requests, and none of their keys, digests, sessions, channels, origins or addresses in it.
  • node --test web/audit.test.mjs: a session driven with the corpus's inputs signs the corpus's records byte for byte, its log and CMCD batch too; the playlist reader, the tap and the loader adapter.
  • e2e/run.sh: a real browser plays an HLS stream from another origin through an open-source web player, audited through the loader adapter and through the tap, each session verified, stored and reported by a collector on loopback, the report recomputed by wai-audit check. It needs the host's media tool and a browser (BROWSER_BIN).

Deploy

One process per owner key, on loopback behind the site's reverse proxy, which terminates TLS and strips a path prefix (/audit/ → /); the proxy is the trusted peer whose X-Forwarded-For names the client. Keep WAI_AUDIT_DATA on storage that is backed up: the stored bundles are the evidence a report is recomputed from. Back up the key apart from the data, readable by the service's user alone. Run it under the host's service manager with restart on failure, and check GET /v1/health. GET /metrics is for the operator's scraper, at the service's own address: a request that came through the proxy, one carrying X-Forwarded-For or another of the fields a front sets, is answered 404, and a proxy that sets none of them is configured not to pass the path on.