forge
Explore
Log in

Don't you dare go Hollow

Pin the decode path's refusals, and the claims they make

Browse files at this commit

093155e1233df104c1a0f60030d3dec4f2ebaa88Ahmet Kaan GümüşParent: 21b2356
  • test
    • pin the decode path's refusals, and the claims they make
Show full message
test(av1): pin the decode path's refusals, and the claims they make

Two things this decoder keeps relearning. A refusal string is a claim: 'this
encoder never writes one' asserts something about the world, and one such
string was disproved by the very gate that carried it. And refusals accumulate
silently -- each one is the right call for the lane that adds it (refuse by
name rather than desync), but the total is the distance to decoding a
default-settings stream, and nothing printed the total.

refusal_inventory derives every unsupported(...) reason reachable on the decode
path -- decode.rs and stream.rs, both call shapes -- and pins it: 39 distinct
refusals, of which 7 are phrased as claims about what an encoder emits and are
now declared in their own list rather than scattered. Adding, renaming or
removing a refusal fails until the inventory is updated, so the diff of this
file is the decoder's capability delta in English. A new claim-shaped refusal
fails separately, with the reason it needs evidence.

Negative-checked: dropping one entry fails both tests naming that exact string.
Suite 236 passed / 0 failed.
crates/ec-av1/src/lib.rsmodified+1 -0
@@ -30,6 +30,7 @@ pub mod msac;
3030 pub mod mvstack;
3131 pub mod obu;
3232 pub mod quant;
33+mod refusal_inventory;
3334 pub mod sequence;
3435 pub mod stream;
3536 pub mod tile;
crates/ec-av1/src/refusal_inventory.rsadded+189 -0
@@ -0,0 +1,189 @@
1+//! An inventory of what this decoder refuses, and a check on the claims those
2+//! refusals make.
3+//!
4+//! Two rules this repository keeps learning the hard way:
5+//!
6+//! 1. A refusal string is a **claim**. "This encoder never writes one" asserts
7+//! that a real encoder cannot emit the case -- and one such string was
8+//! disproved by the very gate that carried it (the wedge-interintra hang,
9+//! 2026-08-30): the refusal was written from a mismatching frame's header
10+//! state, so it named a correlate rather than the defect. Any refusal
11+//! phrased as a capability claim about the ENCODER, rather than about this
12+//! decoder, needs evidence, and this module makes the set of such strings
13+//! explicit instead of letting it grow quietly.
14+//! 2. Refusals accumulate silently. A lane that adds one to unblock itself is
15+//! doing the right thing (refuse by name rather than desync), but the total
16+//! is the distance to a decoder that handles a default-settings stream, and
17+//! nobody sees a total that nothing prints.
18+//!
19+//! So the test below re-derives every `unsupported(...)` reason reachable on
20+//! the decode path -- `decode.rs` and `stream.rs` -- and pins it. Adding or
21+//! removing a refusal fails until the list is updated, which is the point: the
22+//! diff of this file is the decoder's capability delta, in one place, in
23+//! English.
24+
25+#[cfg(test)]
26+const CAPABILITY_CLAIMS: &[&str] = &[
27+ "a non-2D tx class on a rectangular transform (never expected at this size)",
28+ "a non-DC chroma mode on an 8x8 inter-frame leaf (this encoder never writes one)",
29+ "a nonzero angle delta (this encoder never writes one)",
30+ "a partition below 16x16 other than a clean split (this encoder never writes one)",
31+ "a partition below 8x8 (this encoder never writes one)",
32+ "a partition type this encoder never writes",
33+ "a tx_type symbol on a rectangular transform (never expected at this size)",
34+];
35+
36+#[cfg(test)]
37+const REFUSALS: &[&str] = &[
38+ "GLOBALMV (round 3)",
39+ "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
40+ "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet",
41+ "a Golomb tail longer than this decoder reads",
42+ "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)",
43+ "a HORZ/VERT intra strip with a split transform (per-unit rect prediction is not ported)",
44+ "a block that actually uses a palette (UV) -- reconstruction is out of scope",
45+ "a block that actually uses a palette (Y) -- reconstruction is out of scope",
46+ "a block that actually uses intrabc (this decoder never reconstructs one)",
47+ "a directional chroma mode (round 2)",
48+ "a frame OBU with no tile group",
49+ "a frame naming primary_ref_frame at a reference slot with no saved CDF state",
50+ "a frame with cdef_bits > 0 (this decoder never reads the per-64x64 cdef_idx symbol)",
51+ "a frame with delta_q_present or delta_lf_present set (this decoder never reads the per-superblock delta symbols)",
52+ "a frame with loop restoration enabled (this decoder never reads the per-unit lr symbols)",
53+ "a frame with more than one tile (this decoder only ever decodes tile 0)",
54+ "a frame with no mode-info grid",
55+ "a frame with segmentation enabled (this decoder never reads a per-block segment_id symbol)",
56+ "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding",
57+ "a reference frame other than LAST_FRAME (round 2)",
58+ "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it",
59+ "a reference picture that is not this frame's own true size",
60+ "a show_existing_frame header naming an empty reference slot",
61+ "a smooth or paeth chroma mode (round 2)",
62+ "an 8x8 leaf that coded WARPED_CAUSAL (motion_mode == 2): av1_find_projection/the affine warp filter are not ported, only motion_mode_allowed's alphabet choice is",
63+ "an inter frame using TxMode::Select (this decoder's inter path never reads a tx_depth symbol, so it desyncs after the first block's mode)",
64+ "an inter frame whose global motion for a single-reference frame is AFFINE (unverified this round; ROTZOOM/TRANSLATION/IDENTITY are proven)",
65+ "an inter frame with no key frame before it",
66+ "an inter partition below 16x16 (8x8 and smaller inter blocks are not coded yet)",
67+ "an intra mode this decoder does not code (round 2)",
68+ "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet",
69+ "filter intra on a HORZ/VERT strip (this decoder predicts square-only)",
70+];
71+
72+#[cfg(test)]
73+mod tests {
74+ use super::{CAPABILITY_CLAIMS, REFUSALS};
75+ use std::collections::BTreeSet;
76+
77+ /// Every distinct `unsupported(...)` reason on the decode path.
78+ ///
79+ /// Both sources use the same shape -- `stream.rs` calls
80+ /// `Error::unsupported(context, reason)` and `decode.rs` a local
81+ /// `unsupported(reason)` helper -- so the reason is always the LAST string
82+ /// literal of the call, and Rust's `\` line continuations inside it are
83+ /// joined the way rustc joins them.
84+ fn decode_path_refusals() -> BTreeSet<String> {
85+ let mut found = BTreeSet::new();
86+ for src in [include_str!("decode.rs"), include_str!("stream.rs")] {
87+ let bytes = src.as_bytes();
88+ for (start, _) in src.match_indices("unsupported(") {
89+ // `Error::unsupported(` and the bare helper both end here.
90+ let mut i = start + "unsupported(".len();
91+ let mut last: Option<String> = None;
92+ loop {
93+ while i < bytes.len() && (bytes[i] as char).is_whitespace() {
94+ i += 1;
95+ }
96+ if i >= bytes.len() || bytes[i] != b'"' {
97+ break;
98+ }
99+ i += 1;
100+ let mut lit = String::new();
101+ while i < bytes.len() && bytes[i] != b'"' {
102+ if bytes[i] == b'\\' {
103+ // A backslash-newline continuation drops the newline
104+ // and the indentation that follows it.
105+ if bytes.get(i + 1) == Some(&b'\n') {
106+ i += 2;
107+ while i < bytes.len() && matches!(bytes[i], b' ' | b'\t') {
108+ i += 1;
109+ }
110+ continue;
111+ }
112+ lit.push(bytes[i] as char);
113+ lit.push(bytes[i + 1] as char);
114+ i += 2;
115+ continue;
116+ }
117+ lit.push(bytes[i] as char);
118+ i += 1;
119+ }
120+ i += 1;
121+ last = Some(lit);
122+ while i < bytes.len() && (bytes[i] as char).is_whitespace() {
123+ i += 1;
124+ }
125+ if i < bytes.len() && bytes[i] == b',' {
126+ i += 1;
127+ continue;
128+ }
129+ break;
130+ }
131+ if let Some(reason) = last {
132+ // `Error::unsupported`'s first argument is the context
133+ // ("AV1 tile"), which is not a reason.
134+ if reason != "AV1 tile" {
135+ found.insert(reason);
136+ }
137+ }
138+ }
139+ }
140+ found
141+ }
142+
143+ #[test]
144+ fn the_decode_path_refuses_exactly_the_listed_cases() {
145+ let found = decode_path_refusals();
146+ let listed: BTreeSet<String> = CAPABILITY_CLAIMS
147+ .iter()
148+ .chain(REFUSALS)
149+ .map(|&s| s.to_owned())
150+ .collect();
151+ assert!(found.len() >= 30, "the refusal scan found only {} reasons -- it is broken, not the decoder", found.len());
152+
153+ let added: Vec<&String> = found.difference(&listed).collect();
154+ assert!(
155+ added.is_empty(),
156+ "new decode-path refusals are not in the inventory: {added:#?}\n\
157+ Add each to REFUSALS -- or, if it claims something about what an ENCODER can \
158+ emit, to CAPABILITY_CLAIMS, which requires evidence that the case is genuinely \
159+ unreachable rather than merely unseen."
160+ );
161+ let removed: Vec<&String> = listed.difference(&found).collect();
162+ assert!(
163+ removed.is_empty(),
164+ "these refusals are listed but no longer in the decode path: {removed:#?}\n\
165+ Delete them from the inventory -- the capability landed, which is the good case."
166+ );
167+ }
168+
169+ /// A refusal may say what THIS DECODER does not do. Saying what an encoder
170+ /// never emits is a claim about the world, and this repository has already
171+ /// shipped one that was false.
172+ #[test]
173+ fn capability_claims_are_declared_not_scattered() {
174+ let claimy: Vec<String> = decode_path_refusals()
175+ .into_iter()
176+ .filter(|r| r.contains("never writes") || r.contains("never expected"))
177+ .collect();
178+ let declared: BTreeSet<&str> = CAPABILITY_CLAIMS.iter().copied().collect();
179+ for reason in &claimy {
180+ assert!(
181+ declared.contains(reason.as_str()),
182+ "{reason:?} claims an encoder never emits this case but is not in \
183+ CAPABILITY_CLAIMS. Such a claim needs a gate that proves the case is \
184+ unreachable; until it has one, phrase the refusal as what this decoder \
185+ does not decode."
186+ );
187+ }
188+ }
189+}