### Packaging: a declared policy, its digest, and pieces cut at scene changes

- **The extension** [packaging](extensions/packaging.md), first sections: a package is
  made under one TOML policy, `wai.pack.policy/1` (§3), read in a fixed order with
  every refusal named: value kinds a canonical JSON cannot carry exactly (floats,
  dates, negatives, integers past `2^53 − 1`), then the schema, every default written
  in, then the constraints across members (ladders and their refinement chains,
  classes, rules, deadlines against layer lags). The effective policy's digest is
  BLAKE3 over its RFC 8785 form, so two spellings of one policy have one digest.
- **Pieces** (§4): `wai.pack.scenecut/1` cuts a video component at scene changes by
  integer histogram distance, with a bounded lookahead whose return and revisit
  clauses keep a short flash from cutting; a decision reads no frame past the
  lookahead, so live and on-demand packing cut alike. Pieces are bounded by `min` and
  `max`, aligned across components to the lead, and classified static, synthetic,
  high-motion or natural. Y4M and WAV sources convert by stated integer rules.
- **`wai-pack`**, the reference packager, as far as a plan (`wai-pack policy`,
  `wai-pack plan`), with float arithmetic denied for the whole crate, and the corpus
  [`pack-conformance/`](pack-conformance/) with a second implementation in Python.
- **What a packager may emit** (§3.6): only capabilities SPEC §5 registers as payloads
  with a pinned format, in a role each can play, and under `royalty_free_only` only
  royalty-free ones; every refusal names the capability (`capability-unknown`,
  `capability-not-payload`, `capability-candidate`, `capability-role`,
  `license-unclassified`, `license-refused`).
- **One integer video encoder** (§5.5): `int_video_enc` codes RGB8 frames as the
  `WIV1` keyframe-0 payload SPEC §5 pins to `wai.video.int_motion`, with integer block
  motion search (whole- or half-pel) over the decoder's own prediction, residuals
  quantized in a closed loop, and one residual table for the clip; it states the SSE
  of its reconstruction. `int_payload::encode_wiv1_zero_motion` is its zero-motion
  case and writes the bytes it wrote before. The corpus holds its payloads for every
  piece of every fixture, decoded independently to the same frames.
- **`wai::jcs`**: the canonical JSON form moves out of `claim_receipt` into a module
  of its own, compiled under every feature set, unchanged in behaviour.
- **Choosing the step** (§5.6), specified and built ahead of the stage that writes
  objects: the largest of `q_candidates` (read as a set) whose SSE per sample, in
  thousandths, is at most `max_sse_px_milli`, else the smallest
  (`wai_pack::encode::choose_q`), with goldens recomputed independently.
- **Reading what a packager is given**: a policy is read from its bytes (UTF-8, no
  byte-order mark, nesting at most 32 deep, `policy-toml` otherwise), ids are unique
  across every kind, a cut window holds at least 3 scores, a WAV block alignment is
  compared without wrapping, and no declared size sizes a buffer; the segmenter's state
  is bounded by its lookahead and window. The encoder codes in two passes and states
  what it holds (`int_video_enc::working_bytes`), and `rans::RansReverseEncoder` codes
  values last-first into the same bytes.

