forge
Explore
Log in

Don't you dare go Hollow

Gate coverage is per (tool x bit depth), not per tool

Browse files at this commit

969b81e5efbe6921f9ee0c47e9a7bfb208d9bbeaAhmet Kaan GümüşParent: d2fe762
  • test
    • gate coverage is per (tool x bit depth), not per tool
Show full message
test(av1): gate coverage is per (tool x bit depth), not per tool

Every 10-bit gate ran --enable-restoration=0, so the 10-bit loop-restoration
path was never exercised and two hbd defects (SGR box sums unscaled, Wiener
clamp at the 8-bit bound) survived the '10-bit bit-exact' milestone.
gate_coverage.rs now classifies each real-aomenc gate by bit depth and pins
NEVER_EXERCISED_8BIT (12) and NEVER_EXERCISED_10BIT (19) over a fixed
26-flag TOOL_UNIVERSE, with the same 'defaulted means unknown' rule: only an
explicit --enable-<tool>=1 in a gate of that depth retires an entry.
45 gates, 4 of them 10-bit.
crates/ec-av1/src/gate_coverage.rsmodified+319 -20
@@ -39,39 +39,236 @@ const NEVER_EXERCISED: &[(&str, &str)] = &[
3939 // lane could produce sits under TX_MODE_SELECT, whose inter var-tx
4040 // partition tree is unread -- so no stream reconstructs one end to end
4141 // yet and this entry stays.
42- ("enable-intrabc", "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree"),
42+ (
43+ "enable-intrabc",
44+ "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree",
45+ ),
46+];
47+
48+/// The `--enable-*` tools this decoder cares about, whether or not any gate
49+/// names one. A flag no gate mentions is *defaulted*, i.e. unknown, and by the
50+/// rule above unknown is not coverage -- so the universe is fixed here rather
51+/// than derived from the gate source, which would silently shrink to whatever
52+/// the gates happen to spell.
53+#[cfg(test)]
54+const TOOL_UNIVERSE: &[&str] = &[
55+ "enable-1to4-partitions",
56+ "enable-ab-partitions",
57+ "enable-angle-delta",
58+ "enable-cdef",
59+ "enable-cfl-intra",
60+ "enable-dist-wtd-comp",
61+ "enable-dual-filter",
62+ "enable-filter-intra",
63+ "enable-flip-idtx",
64+ "enable-global-motion",
65+ "enable-interintra-comp",
66+ "enable-intra-edge-filter",
67+ "enable-intrabc",
68+ "enable-masked-comp",
69+ "enable-obmc",
70+ "enable-order-hint",
71+ "enable-paeth-intra",
72+ "enable-palette",
73+ "enable-rect-partitions",
74+ "enable-rect-tx",
75+ "enable-ref-frame-mvs",
76+ "enable-restoration",
77+ "enable-smooth-intra",
78+ "enable-superres",
79+ "enable-tx64",
80+ "enable-warped-motion",
81+];
82+
83+/// Coverage is per (tool x bit depth), not per tool.
84+///
85+/// lane-hbdinter found two 10-bit-only defects (SGR box sums unscaled, Wiener
86+/// clamp pinned at the 8-bit bound) that survived the "10-bit bit-exact"
87+/// milestone because every 10-bit gate passed `--enable-restoration=0`:
88+/// `enable-restoration` is positively exercised -- at 8 bits only. A tool the
89+/// 8-bit gates cover says nothing about the high-bit-depth path through the
90+/// same code, so the two lists below are pinned separately.
91+///
92+/// Each entry is `(flag, why)`. A gate that passes `--enable-<tool>=1` at that
93+/// depth retires the entry, and this test fails until it is deleted.
94+#[cfg(test)]
95+const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
96+ (
97+ "enable-1to4-partitions",
98+ "off in 42 gates, on in none: PARTITION_HORZ_4/VERT_4 at 64x64 needs TX_64X16 luma plus 32x8 chroma scans (lane-part32 r5)",
99+ ),
100+ (
101+ "enable-angle-delta",
102+ "off in 36 gates, on in none: the directional-intra gates pin it off to isolate the base modes",
103+ ),
104+ (
105+ "enable-cfl-intra",
106+ "off in 41 gates, on in none: chroma-from-luma prediction is unimplemented",
107+ ),
108+ (
109+ "enable-dist-wtd-comp",
110+ "off in 11 gates, on in none: distance-weighted compound is unimplemented",
111+ ),
112+ (
113+ "enable-dual-filter",
114+ "never spelled by any gate, so defaulted = unknown; no stream is proven to carry per-direction interp filters",
115+ ),
116+ (
117+ "enable-flip-idtx",
118+ "never spelled; the flip/identity transform types are unproven by a real stream",
119+ ),
120+ (
121+ "enable-global-motion",
122+ "off in 5 gates, on in none at 8 bits; lane-gm owns the global-warp prediction that is still missing",
123+ ),
124+ (
125+ "enable-intrabc",
126+ "the block vector is decoded and predicted from, but every real stream's intrabc block needs the unread inter var-tx transform tree",
127+ ),
128+ (
129+ "enable-rect-tx",
130+ "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool",
131+ ),
132+ (
133+ "enable-ref-frame-mvs",
134+ "off in 27 gates, on in none: temporal MV projection is unimplemented",
135+ ),
136+ (
137+ "enable-superres",
138+ "never spelled: the three superres gates drive `--superres-mode=1` instead, so the tool IS exercised but not under this flag -- retire this entry only by renaming the check, not by assuming coverage",
139+ ),
140+ (
141+ "enable-tx64",
142+ "never spelled; TX_64X64 appears only where aomenc's default picks it, which is unknown per stream",
143+ ),
144+];
145+
146+#[cfg(test)]
147+const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[
148+ // Only 4 of the 45 real-aomenc gates encode at 10 bits, and they pin the
149+ // pixel filters and the intra tool set off. Every entry the 8-bit list
150+ // carries is a hole here too; the seven extra ones below are tools an
151+ // 8-bit gate DOES enable, whose high-bit-depth path no stream has ever
152+ // touched -- exactly the shape that hid the two lane-hbdinter defects.
153+ (
154+ "enable-1to4-partitions",
155+ "hole at both depths, see the 8-bit list",
156+ ),
157+ (
158+ "enable-ab-partitions",
159+ "8-bit only: no 10-bit gate enables AB partitions",
160+ ),
161+ (
162+ "enable-angle-delta",
163+ "hole at both depths, see the 8-bit list",
164+ ),
165+ (
166+ "enable-cfl-intra",
167+ "hole at both depths, see the 8-bit list",
168+ ),
169+ (
170+ "enable-dist-wtd-comp",
171+ "hole at both depths, see the 8-bit list",
172+ ),
173+ (
174+ "enable-dual-filter",
175+ "hole at both depths, see the 8-bit list",
176+ ),
177+ (
178+ "enable-filter-intra",
179+ "8-bit only: no 10-bit gate enables filter intra",
180+ ),
181+ (
182+ "enable-flip-idtx",
183+ "hole at both depths, see the 8-bit list",
184+ ),
185+ (
186+ "enable-global-motion",
187+ "hole at both depths, see the 8-bit list",
188+ ),
189+ (
190+ "enable-intra-edge-filter",
191+ "8-bit only: the 10-bit intra path never runs the edge filter",
192+ ),
193+ ("enable-intrabc", "hole at both depths, see the 8-bit list"),
194+ (
195+ "enable-paeth-intra",
196+ "8-bit only: no 10-bit gate enables Paeth",
197+ ),
198+ (
199+ "enable-rect-partitions",
200+ "8-bit only: no 10-bit gate enables rect partitions",
201+ ),
202+ ("enable-rect-tx", "hole at both depths, see the 8-bit list"),
203+ (
204+ "enable-ref-frame-mvs",
205+ "hole at both depths, see the 8-bit list",
206+ ),
207+ (
208+ "enable-restoration",
209+ "8-bit only -- THE instance this split was built for: every 10-bit gate passed `--enable-restoration=0`, so the SGR box sums and the Wiener clamp were never run at 10 bits and both were wrong (lane-hbdinter, 2026-09-01)",
210+ ),
211+ (
212+ "enable-smooth-intra",
213+ "8-bit only: no 10-bit gate enables smooth intra",
214+ ),
215+ (
216+ "enable-superres",
217+ "the 10-bit superres gate drives `--superres-mode=1`, not this flag; see the 8-bit entry",
218+ ),
219+ ("enable-tx64", "hole at both depths, see the 8-bit list"),
43220 ];
44221
45222 #[cfg(test)]
46223 mod tests {
47- use super::NEVER_EXERCISED;
224+ use super::{NEVER_EXERCISED, NEVER_EXERCISED_8BIT, NEVER_EXERCISED_10BIT, TOOL_UNIVERSE};
48225 use std::collections::{BTreeMap, BTreeSet};
49226
50- /// `--enable-*` settings per real-aomenc gate, derived from the gate
51- /// source: `flag -> (turned off in N gates, turned on in N, defaulted in N)`.
52- fn tool_settings() -> (usize, BTreeMap<String, (usize, usize, usize)>) {
227+ /// Bodies of the real-aomenc gates: a `fn` body carrying the shared
228+ /// `--passes=1` every one of them passes. Split on the attribute that
229+ /// opens a test.
230+ fn gate_bodies() -> Vec<&'static str> {
53231 let src = include_str!("stream.rs");
54- // A real-aomenc gate is a `fn` body carrying the shared `--passes=1`
55- // every one of them passes. Split on the attribute that opens a test.
56232 let gates: Vec<&str> = src
57233 .split("\n #[")
58234 .filter(|body| body.contains("\"--passes=1\""))
59235 .collect();
60- assert!(gates.len() >= 20, "expected the real-aomenc gates, found {}", gates.len());
236+ assert!(
237+ gates.len() >= 20,
238+ "expected the real-aomenc gates, found {}",
239+ gates.len()
240+ );
241+ gates
242+ }
243+
244+ /// `--enable-<flag>=<value>` settings spelled inside one gate body.
245+ fn flags_in(gate: &str) -> BTreeMap<String, char> {
246+ let mut here = BTreeMap::new();
247+ for (i, _) in gate.match_indices("\"--enable-") {
248+ let rest = &gate[i + 3..];
249+ let Some(end) = rest.find('"') else { continue };
250+ let Some((flag, value)) = rest[..end].split_once('=') else {
251+ continue;
252+ };
253+ let Some(value) = value.chars().next() else {
254+ continue;
255+ };
256+ here.insert(flag.to_owned(), value);
257+ }
258+ here
259+ }
260+
261+ /// `--enable-*` settings per real-aomenc gate, derived from the gate
262+ /// source: `flag -> (turned off in N gates, turned on in N, defaulted in N)`.
263+ fn tool_settings() -> (usize, BTreeMap<String, (usize, usize, usize)>) {
264+ let gates = gate_bodies();
61265
62266 let mut per_tool: BTreeMap<String, (usize, usize, usize)> = BTreeMap::new();
63267 let mut names: BTreeSet<String> = BTreeSet::new();
64268 let mut seen: Vec<BTreeMap<String, char>> = Vec::new();
65269 for gate in &gates {
66- let mut here = BTreeMap::new();
67- for (i, _) in gate.match_indices("\"--enable-") {
68- let rest = &gate[i + 3..];
69- let Some(end) = rest.find('"') else { continue };
70- let Some((flag, value)) = rest[..end].split_once('=') else { continue };
71- let Some(value) = value.chars().next() else { continue };
72- names.insert(flag.to_owned());
73- here.insert(flag.to_owned(), value);
74- }
270+ let here = flags_in(gate);
271+ names.extend(here.keys().cloned());
75272 seen.push(here);
76273 }
77274 for name in names {
@@ -126,10 +323,112 @@ mod tests {
126323 #[test]
127324 fn tool_settings_reads_whole_flags() {
128325 let (gate_count, per_tool) = tool_settings();
129- assert!(per_tool.contains_key("enable-cdef"), "expected --enable-cdef among the gate flags");
326+ assert!(
327+ per_tool.contains_key("enable-cdef"),
328+ "expected --enable-cdef among the gate flags"
329+ );
130330 for (name, &(off, on, defaulted)) in &per_tool {
131- assert!(!name.is_empty() && !name.contains(['"', '=']), "malformed flag {name:?}");
132- assert_eq!(off + on + defaulted, gate_count, "{name} counts do not cover every gate");
331+ assert!(
332+ !name.is_empty() && !name.contains(['"', '=']),
333+ "malformed flag {name:?}"
334+ );
335+ assert_eq!(
336+ off + on + defaulted,
337+ gate_count,
338+ "{name} counts do not cover every gate"
339+ );
340+ }
341+ }
342+
343+ /// A gate encodes at 10 bits when its recipe says so: the shared 10-bit
344+ /// helper, an explicit `--bit-depth=10`/`--input-bit-depth=10`, or a
345+ /// `yuv420p10le` fixture handed to aomenc. Everything else is aomenc's
346+ /// 8-bit default.
347+ fn is_ten_bit(body: &str) -> bool {
348+ body.contains("encode_10bit_gradients")
349+ || body.contains("--bit-depth=10")
350+ || body.contains("--input-bit-depth=10")
351+ || body.contains("yuv420p10le")
352+ }
353+
354+ /// Flags a gate positively enables (`=1`), at gates of the given depth.
355+ fn enabled_at(ten_bit: bool) -> BTreeSet<String> {
356+ let mut on = BTreeSet::new();
357+ for gate in gate_bodies() {
358+ if is_ten_bit(gate) != ten_bit {
359+ continue;
360+ }
361+ for (flag, value) in flags_in(gate) {
362+ if value == '1' {
363+ on.insert(flag);
364+ }
365+ }
366+ }
367+ on
368+ }
369+
370+ /// The tools of [`TOOL_UNIVERSE`] that no gate of this depth enables.
371+ fn never_exercised_at(ten_bit: bool) -> BTreeSet<&'static str> {
372+ let on = enabled_at(ten_bit);
373+ TOOL_UNIVERSE
374+ .iter()
375+ .copied()
376+ .filter(|t| !on.contains(*t))
377+ .collect()
378+ }
379+
380+ fn check_depth(ten_bit: bool, listed: &[(&str, &str)]) {
381+ let derived = never_exercised_at(ten_bit);
382+ let listed: BTreeSet<&str> = listed.iter().map(|&(flag, _)| flag).collect();
383+ let depth = if ten_bit { "10-bit" } else { "8-bit" };
384+ let unlisted: Vec<&&str> = derived.difference(&listed).collect();
385+ assert!(
386+ unlisted.is_empty(),
387+ "no {depth} gate passes `=1` for {unlisted:?}, so no real {depth} stream exercises \
388+ them -- enable the tool in a {depth} gate that asserts it fired, or list it"
389+ );
390+ let stale: Vec<&&str> = listed.difference(&derived).collect();
391+ assert!(
392+ stale.is_empty(),
393+ "the {depth} list still names {stale:?}, but a {depth} gate now passes `=1` for them \
394+ -- delete those entries, the coverage hole is closed"
395+ );
396+ }
397+
398+ #[test]
399+ fn never_exercised_8bit_matches_the_gate_recipes() {
400+ check_depth(false, NEVER_EXERCISED_8BIT);
401+ }
402+
403+ #[test]
404+ fn never_exercised_10bit_matches_the_gate_recipes() {
405+ check_depth(true, NEVER_EXERCISED_10BIT);
406+ }
407+
408+ /// `cargo test -p ec-av1 --lib gate_coverage -- --nocapture` prints both
409+ /// lists, so the per-depth holes can be read without opening this file.
410+ #[test]
411+ fn print_never_exercised_per_bit_depth() {
412+ let ten: Vec<&str> = gate_bodies()
413+ .into_iter()
414+ .filter(|b| is_ten_bit(b))
415+ .collect();
416+ let total = gate_bodies().len();
417+ println!(
418+ "gate_coverage: {} real-aomenc gates, {} of them 10-bit",
419+ total,
420+ ten.len()
421+ );
422+ for (label, ten_bit) in [("8BIT", false), ("10BIT", true)] {
423+ let holes = never_exercised_at(ten_bit);
424+ println!(
425+ "NEVER_EXERCISED_{label} ({} of {}):",
426+ holes.len(),
427+ TOOL_UNIVERSE.len()
428+ );
429+ for flag in &holes {
430+ println!(" --{flag}");
431+ }
133432 }
134433 }
135434 }
lanes/covbd-r1.report.mdadded+86 -0
@@ -0,0 +1,86 @@
1+# lane-covbd r1 — gate coverage per (tool x bit depth)
2+
3+## What changed
4+- `crates/ec-av1/src/gate_coverage.rs`
5+ - `TOOL_UNIVERSE` (26 `--enable-*` flags, fixed in source, not derived): the flags the
6+ decoder cares about, so a flag *no* gate spells still counts as a hole (defaulted =
7+ unknown, the pre-existing rule).
8+ - `NEVER_EXERCISED_8BIT` (12 entries) / `NEVER_EXERCISED_10BIT` (19 entries), each
9+ `(flag, why)`.
10+ - tests `never_exercised_8bit_matches_the_gate_recipes` /
11+ `never_exercised_10bit_matches_the_gate_recipes`: negative check (every listed entry
12+ really has no `=1` at that depth) and positive check (a flag that a gate of that depth
13+ now enables must be deleted from the list — the test fails until it is).
14+ - `is_ten_bit(body)`: a gate is 10-bit if its recipe contains `encode_10bit_gradients`,
15+ `--bit-depth=10`, `--input-bit-depth=10`, or a `yuv420p10le` fixture (that is how the
16+ existing 10-bit gates spell it, stream.rs:1905/1934/2141/9001).
17+ - `gate_bodies()` / `flags_in()` factored out of `tool_settings()`; the original
18+ `NEVER_EXERCISED` list and its test are untouched.
19+ - `print_never_exercised_per_bit_depth`: the orchestrator helper.
20+- No gate recipe touched; `stream.rs` unchanged.
21+
22+## Finding
23+45 real-aomenc gates, **4 of them 10-bit**. Seven tools are positively enabled at 8 bits and
24+by no 10-bit gate: `restoration`, `cdef`-adjacent intra set (`filter-intra`,
25+`intra-edge-filter`, `paeth-intra`, `smooth-intra`), `rect-partitions`, `ab-partitions`.
26+`enable-restoration` is the instance that cost two hbd defects (SGR box sums unscaled,
27+Wiener clamp at the 8-bit bound, lane-hbdinter 2026-09-01).
28+
29+Caveat recorded in the list itself: `enable-superres` is a *flag-spelling* hole, not a real
30+one — the three superres gates drive `--superres-mode=1` (one of them 10-bit).
31+
32+## Printed lists (verbatim)
33+```
34+gate_coverage: 45 real-aomenc gates, 4 of them 10-bit
35+NEVER_EXERCISED_8BIT (12 of 26):
36+ --enable-1to4-partitions
37+ --enable-angle-delta
38+ --enable-cfl-intra
39+ --enable-dist-wtd-comp
40+ --enable-dual-filter
41+ --enable-flip-idtx
42+ --enable-global-motion
43+ --enable-intrabc
44+ --enable-rect-tx
45+ --enable-ref-frame-mvs
46+ --enable-superres
47+ --enable-tx64
48+NEVER_EXERCISED_10BIT (19 of 26):
49+ --enable-1to4-partitions
50+ --enable-ab-partitions
51+ --enable-angle-delta
52+ --enable-cfl-intra
53+ --enable-dist-wtd-comp
54+ --enable-dual-filter
55+ --enable-filter-intra
56+ --enable-flip-idtx
57+ --enable-global-motion
58+ --enable-intra-edge-filter
59+ --enable-intrabc
60+ --enable-paeth-intra
61+ --enable-rect-partitions
62+ --enable-rect-tx
63+ --enable-ref-frame-mvs
64+ --enable-restoration
65+ --enable-smooth-intra
66+ --enable-superres
67+ --enable-tx64
68+```
69+
70+## Gates / tests
71+- `cargo test -p ec-av1 --lib gate_coverage -- --nocapture` -> 5 passed, 0 failed.
72+- `cargo test -p ec-av1 --lib refusal_inventory` -> 3 passed, 0 failed.
73+- `cargo check -p ec-av1` -> clean (118 pre-existing missing-doc warnings).
74+- EVIDENCE: crates/ec-av1/src/gate_coverage.rs | cargo test -p ec-av1 --lib gate_coverage -- --nocapture | 5/5 pass, 45 gates parsed, 4 ten-bit, 12/19 holes printed above
75+
76+## Refusals lifted
77+None — this lane is instrumentation only, no decode behaviour changed.
78+
79+## Residue
80+- accepted: `enable-superres` and `enable-cdef`-style aliasing. Tools driven by a non
81+ `--enable-*` flag (`--superres-mode=1`) read as holes. Fix is an alias map, one line per
82+ alias, when a second case appears.
83+- deferred: closing any 10-bit hole — other lanes own gate authoring; this lane was
84+ chartered not to write gates. What unblocks it: a 10-bit gate passing `=1` for the tool.
85+- accepted: `cargo fmt -p ec-av1` reformatted 18 unrelated files; reverted, only
86+ gate_coverage.rs is in the commit.