forge
Explore
Log in

Don't you dare go Hollow

gate_coverage: fix the two census defects that generated the false entries

Browse files at this commit

143cdf919c3fda9e8fce919dba66b7769bf710faAhmet Kaan GümüşParent: c784567
r2 corrected the false CLAIMS. This fixes the LOGIC, so it stops generating
them. gate_coverage.rs only: no gate, counter, fixture or decoder behaviour
touched, and stream.rs is byte-identical to HEAD.

1. gate_bodies() now recognises a gate by what it CALLS, not only by what it
   spells. fn_units parses every fn in stream.rs as (name, body); encoder_fns
   takes the transitive closure of fns reaching one that names
   aomenc_path(); the filter is `legacy_gate_tokens || contains aomenc_path()
   || any calls_fn`. The call test is deliberately the weak half of an OR, so
   the fix is strictly ADDITIVE: it can add gates but can never stop
   recognising one the old filter did, and the new test asserts exactly that
   containment. calls_fn requires `(` after the name and rejects a name that
   is the tail of a longer identifier, so inter_sb_none_gate does not "call"
   sb_none_gate.

2. covers_both_depths gained the third spelling of the lane-defon/reelckf blind
   spot: a body naming BOTH fixture formats builds both depths, whatever the
   parameter is called. The quotes matter -- a bare `yuv420p` substring test
   also matches `yuv420p10le` and would fire on every 10-bit gate, retiring
   entries on no evidence.

Before/after: 146 -> 230 gate bodies seen, 83 -> 107 classified 10-bit+.
Retired `enable-dual-filter` and `enable-flip-idtx` from the 8-bit list, each
citing the arrival assert that pays it (dual_filter_diff_hits() moved;
compared_class1 > 0). NEVER_EXERCISED_8BIT is down to one live entry
(enable-rect-tx, the tool with no header bit and no spelling anywhere).

RED-BEFORE, three mutations, all reverted. Mutating the helper-based
dual-filter spelling to =0 reds two tests: the 8-bit list correctly reports
the entry back as a hole, and the new detector test reports "seen, but its
=1 spelling is not visible" -- which separates recognition-broken from
tool-no-longer-enabled. Mutating --enable-dist-wtd-comp=1 -> 0 in a gate the
OLD filter already recognised reds at both depths, so the spelling path is
intact. Reverting only the pair-of-formats clause reds the flip-idtx entry
back plus the detector test. All 10 gate_coverage tests green after revert.

`enable-dual-filter` at 10 BITS STAYS, and that is the finding, not an
oversight: the only =1 witness calls inter_sb_none_gate with ten_bit=false, so
it builds an 8-bit stream only. The 10-bit entry now says so and names the
fix (pass `true` in that gate, assert the differing-direction counter still
moves). Reported rather than papered over.

Also recorded, as a separate row in the report and in-file: the
enable-tx-size-search claim is STILL unsettled, because 9 gates build the
flag into a format! variable neither flags_in nor settings_in can see. 113
name it (88 =0, 15 =1, 9 unknown) -- a floor, not a measurement. The report
gives the method: resolve the local binding the way gate_bodies now resolves
calls, then re-count.

New test the_detector_sees_the_gates_the_spelling_filter_missed pins all of
it, so the next blind spot of this shape fails loudly instead of quietly
overstating coverage again.
crates/ec-av1/src/gate_coverage.rsmodified+257 -77
@@ -140,6 +140,24 @@ enum On {
140 /// "defaulted means unknown" rule of [`NEVER_EXERCISED`] applies unchanged: a140 /// "defaulted means unknown" rule of [`NEVER_EXERCISED`] applies unchanged: a
141 /// default of `1` does not prove the encoder picked the tool for any stream, so141 /// default of `1` does not prove the encoder picked the tool for any stream, so
142 /// only a gate that spells an on-value at that bit depth retires an entry.142 /// only a gate that spells an on-value at that bit depth retires an entry.
143+ // lane-av1distwtd r3: `enable-tx-size-search` is the one DEFAULT_ON_TOOLS
144+ // entry the r2 audit could NOT settle, and the reason is a THIRD detector
145+ // limit rather than a coverage fact. After the r3 call-resolving fix, 113
146+ // of the 230 selected gates name it: 88 pass `=0`, 15 pass `=1`, and 9
147+ // build the value into a `format!`/`String` variable that neither
148+ // `flags_in` nor `settings_in` can see, because both scan for a literal
149+ // `"--flag=value"` inside one segment.
150+ //
151+ // WHAT WOULD SETTLE IT, for whoever takes it next -- the method, not a
152+ // guess: extend `flags_in`/`settings_in` to resolve a local binding, the
153+ // same way `gate_bodies` now resolves calls. Concretely, when a segment
154+ // contains `let <name> = format!("--enable-tx-size-search={tx_search}")`
155+ // (or a `String::from`/`to_string` of the same shape), record the
156+ // TEMPLATE and bind the variable's value at each use site. Re-count, and
157+ // only then decide whether the tool is a live hole. Until that exists the
158+ // count above is a floor, not a measurement: 9 gates are unclassified in
159+ // an unknown direction, and an unknown direction is exactly the failure
160+ // mode this file exists to prevent.
143 #[cfg(test)]161 #[cfg(test)]
144 const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[162 const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[
145 (163 (
@@ -236,62 +254,37 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[
236 // The existing lane-cwarp compound-warp gates already SPELLED `=1` and254 // The existing lane-cwarp compound-warp gates already SPELLED `=1` and
237 // the census still read this entry as open, so the hole was a missing255 // the census still read this entry as open, so the hole was a missing
238 // witness, not a missing flag.256 // witness, not a missing flag.
239- // `enable-dual-filter` -- reason CORRECTED 2026-09-29 (lane-av1distwtd257+ // `enable-dual-filter` LEFT this list on 2026-09-29 (lane-av1distwtd r3),
240- // r2). The old reason ("never spelled by any gate, so defaulted =258+ // paid by a DETECTOR fix rather than by a new gate. The r2 audit found
241- // unknown; no stream is proven to carry per-direction interp filters")259+ // this entry's reason false on both halves. It is spelled -- as `=0`, by
242- // was FALSE on both halves, and the entry does not describe a coverage260+ // `real_aomenc_1to4_streams_...` and
243- // hole at all:261+ // `a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_...` -- so
244- // - it IS spelled, as `=0`, by 2 gates262+ // "never spelled" was wrong; and a stream IS proven to carry the tool,
245- // (`real_aomenc_1to4_streams_...` and263+ // because `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
246- // `a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_...`),
247- // so "never spelled" was wrong;
248- // - a stream IS proven to carry the tool, and the default reaches the
249- // header. Measured on this oracle (aom 3.13.3) with this crate's own
250- // parser: one recipe, flag left off the command line, parses
251- // `dual_filter=true` (6855 B); the same recipe with
252- // `--enable-dual-filter=0` parses `dual_filter=false` and encodes
253- // DIFFERENT bytes (6874 B). "Defaulted = unknown" is the right rule
254- // for a tool whose default may not reach the header; for this one it
255- // measurably does, so the rule was applied to a premise that does
256- // not hold.
257- // The real reason this entry survives: `gate_bodies()` (below) only sees
258- // a `#[test]`-shaped segment that spells `--passes=1`,
259- // `ten_bit_tool_gate(` or `encode_10bit_gradients`. A gate that hands
260- // its recipe to a shared helper keeps its flags in the HELPER, so the
261- // segment is filtered out and the census never sees the spelling.
262- // `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`
263 // spells `--enable-dual-filter=1` and hard-asserts264 // spells `--enable-dual-filter=1` and hard-asserts
264- // `decode::dual_filter_diff_hits()` moved, which is the arrival assert265+ // `decode::dual_filter_diff_hits()` moved, the differing-direction arrival
265- // this file's own rule demands ("an explicit `--enable-<tool>=1` in a266+ // assert (`resolve_interp_filter` in decode.rs). That gate builds its
266- // gate that then asserts the feature fired"). The tool is exercised.267+ // stream through `inter_sb_none_gate`, so it spells none of the three
267- // Left in place ONLY because deleting it would redden this file's own268+ // tokens `gate_bodies()` used to filter on and was INVISIBLE to the
268- // test while the selection blind spot stands -- fixing the filter is a269+ // census; r3 made `gate_bodies()` resolve calls as well as spellings, and
269- // census change, out of scope for a claim-correction lane.270+ // `the_detector_sees_the_gates_the_spelling_filter_missed` pins that.
270- (271+ // Supporting measurement: with the flag left off the command line the
271- "enable-dual-filter",272+ // parsed sequence header already carries `enable_dual_filter = true`
272- "EXERCISED but invisible to this census: a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact spells =1 and asserts dual_filter_diff_hits() moved; gate_bodies() filters that gate out because its recipe lives in a shared helper. Delete once the filter counts helper-delegating gates",273+ // (6855 B), while `--enable-dual-filter=0` parses false and encodes
273- ),274+ // different bytes (6874 B) -- so the gates pinning it `=0` were removing
274- // `enable-flip-idtx` -- reason CORRECTED 2026-09-29 (lane-av1distwtd r2).275+ // the tool and the ones leaving it defaulted carry it.
275- // "never spelled" is FALSE: TWO gates spell `--enable-flip-idtx=1`, and276+ //
276- // one of them is exactly the gate the 10-bit list's own comment names277+ // `enable-flip-idtx` LEFT this list the same day, also by detector fix.
277- // (`a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`,278+ // `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
278- // which hard-asserts `compared_class1 > 0` -- "--enable-flip-idtx=1 never279+ // spells `=1` and hard-asserts `compared_class1 > 0` ("--enable-flip-idtx=1
279- // produced a V_DCT/H_DCT transform on a compared attempt"). That comment280+ // never produced a V_DCT/H_DCT transform on a compared attempt"). Its
280- // claims the gate passes `=1` "at both depths", and MEASURED run of it:281+ // recipe is parameterised on `ten_bit` and names BOTH fixture formats, so
281- // 12 pixel-exact decodes, 6 of them 10-bit (so 6 at 8 bits), 219 rect282+ // `is_ten_bit` filed the whole body 10-bit-ONLY and the 8-bit bucket
282- // coefficient TUs on compared attempts of which 10 carry a 1D tx class.283+ // never saw it -- the lane-defon/reelckf blind spot through a THIRD
283- // So the 1D transform types are proven to reach a real 8-bit stream this284+ // spelling, which r3 taught `covers_both_depths` to recognise as the
284- // decoder reconstructs exactly.285+ // pair-of-formats marker. Measured run of that gate: 12 pixel-exact
285- // It survives at 8 bits purely as a classification artefact: the gate286+ // decodes, 6 of them 8-bit, 219 rect coefficient TUs of which 10 carry a
286- // builds both depths from one `ten_bit` recipe, `is_ten_bit` sees the287+ // 1D tx class.
287- // `yuv420p10le` in its conditional and files it 10-bit-ONLY, and
288- // `covers_both_depths` recognises only "if bit_depth == 10" / "if depth
289- // == 10" / "for depth in [8usize, 10]" -- the lane-defon/reelckf blind
290- // spot its own doc comment describes, reached through a third spelling.
291- (
292- "enable-flip-idtx",
293- "EXERCISED at 8 bits: a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact spells =1, asserts tx_class1_hits moved, and 6 of its 12 pixel-exact decodes are 8-bit (measured). Mis-filed 10-bit-only by is_ten_bit, which covers_both_depths cannot see through a `ten_bit` recipe",
294- ),
295 // `enable-global-motion` LEFT this list on 2026-09-25 (lane-av1gwarp12 r2):288 // `enable-global-motion` LEFT this list on 2026-09-25 (lane-av1gwarp12 r2):
296 // `a_real_affine_global_motion_stream_decodes_pixel_exact` loops289 // `a_real_affine_global_motion_stream_decodes_pixel_exact` loops
297 // `for depth in [8u32, 10u32]` passing `--enable-global-motion=1` and290 // `for depth in [8u32, 10u32]` passing `--enable-global-motion=1` and
@@ -355,25 +348,32 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[
355 // lane-tx64x16 r4's 32-level 1:4 gate has a 10-bit arm that asserts both348 // lane-tx64x16 r4's 32-level 1:4 gate has a 10-bit arm that asserts both
356 // orientations and coded strips inside pixel-exact attempts.349 // orientations and coded strips inside pixel-exact attempts.
357 // `enable-dual-filter` -- reason CORRECTED 2026-09-29 (lane-av1distwtd350 // `enable-dual-filter` -- reason CORRECTED 2026-09-29 (lane-av1distwtd
358- // r2). "hole at both depths, see the 8-bit list" inherited the 8-bit351+ // r3), and this entry STAYS while its 8-bit twin was retired. That is the
359- // entry's false "never spelled" claim. The same named gate352+ // honest outcome, not an oversight: after the r3 detector fix the 8-bit
360- // (`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`)353+ // bucket sees the tool exercised and the 10-bit bucket still does not.
361- // spells `--enable-dual-filter=1` and hard-asserts354+ // The only `=1` witness is
362- // `dual_filter_diff_hits()` moved; it is simply invisible to355+ // `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`,
363- // `gate_bodies()` because its recipe lives in a shared helper. Same356+ // and it calls `inter_sb_none_gate(NAME, false, ...)` -- `false` is the
364- // entry, same cause, both depths.357+ // `ten_bit` parameter, so that gate builds an 8-bit stream only. Its
365- // The two numbers in the `enable-flip-idtx` retirement below are358+ // sibling `a_real_aomenc_10bit_inter_sequence_with_a_whole_superblock_block_decodes_pixel_exact`
359+ // passes `true`, and the 8x8-leaf pair likewise, but none of those spells
360+ // `--enable-dual-filter=1`. So: exercised at 8 bits (arrival assert
361+ // `dual_filter_diff_hits()` moved, `resolve_interp_filter` in decode.rs),
362+ // NOT exercised at 10 bits. Retiring this entry needs a 10-bit arm of that
363+ // gate -- pass `true` to `inter_sb_none_gate` and assert the differing-
364+ // direction counter still moves there.
365+ //
366+ // The two numbers in the `enable-flip-idtx` retirement below were
366 // RE-MEASURED 2026-09-29 (lane-av1distwtd r2) by running the gate, and367 // RE-MEASURED 2026-09-29 (lane-av1distwtd r2) by running the gate, and
367 // both still hold exactly: "pixel-compares six 10-bit decodes" (the run368 // both still hold exactly: "pixel-compares six 10-bit decodes" (the run
368 // reports 12 pixel-exact decodes, 6 of them 10-bit) and "10 of its rect369 // reports 12 pixel-exact decodes, 6 of them 10-bit) and "10 of its rect
369- // coefficient TUs carry a 1D tx class" (the run reports 219 rect370+ // coefficient TUs carry a 1D tx class" (219 rect coefficient TUs on
370- // coefficient TUs on compared attempts, 10 of them 1D). The gate also371+ // compared attempts, 10 of them 1D). The gate also hard-asserts
371- // hard-asserts `compared_class1 > 0`, so the claim that it "passes =1 at372+ // `compared_class1 > 0`, so its "passes =1 at both depths" is backed by an
372- // both depths" is backed by an arrival assert, not just a spelling --373+ // arrival assert, not just a spelling.
373- // which is what makes the 8-bit entry's "never spelled" untenable.
374 (374 (
375 "enable-dual-filter",375 "enable-dual-filter",
376- "EXERCISED but invisible to this census, at both depths -- see the 8-bit entry: a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact spells =1 and asserts dual_filter_diff_hits() moved, and gate_bodies() filters it out",376+ "exercised at 8 bits only, by a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact (=1, asserts dual_filter_diff_hits moved); no 10-bit gate spells =1 -- that gate calls inter_sb_none_gate with ten_bit=false. Retire by adding its 10-bit arm",
377 ),377 ),
378 // `enable-flip-idtx` LEFT this list on 2026-09-02 (lane-rect1d r1):378 // `enable-flip-idtx` LEFT this list on 2026-09-02 (lane-rect1d r1):
379 // `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`379 // `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
@@ -415,23 +415,119 @@ mod tests {
415 };415 };
416 use std::collections::{BTreeMap, BTreeSet};416 use std::collections::{BTreeMap, BTreeSet};
417 417
418- /// Bodies of the real-aomenc gates: a `fn` body carrying the shared418+ /// Whether `body` contains a call to the `fn` named `name`.
419- /// `--passes=1` every one of them passes. Split on the attribute that419+ ///
420- /// opens a test.420+ /// The name must not be the tail of a longer identifier, or
421+ /// `inter_sb_none_gate` would "call" `sb_none_gate`.
422+ fn calls_fn(body: &str, name: &str) -> bool {
423+ let ident = |b: u8| b.is_ascii_alphanumeric() || b == b'_';
424+ let mut at = 0usize;
425+ while let Some(rel) = body[at..].find(name) {
426+ let start = at + rel;
427+ let end = start + name.len();
428+ let starts_clean = start == 0 || !ident(body.as_bytes()[start - 1]);
429+ if starts_clean && body[end..].starts_with('(') {
430+ return true;
431+ }
432+ at = end;
433+ }
434+ false
435+ }
436+
437+ /// Every `fn` defined in `stream.rs`'s test module, as `(name, body)`.
438+ ///
439+ /// The census reasons about whole `#[`-segments (see [`gate_bodies`]) but
440+ /// has to know which segment DEFINES or CALLS an encoder-driving `fn`, and
441+ /// the only way to answer that is to name the units.
442+ fn fn_units(src: &'static str) -> Vec<(&'static str, &'static str)> {
443+ const OPEN: &str = "\n fn ";
444+ let mut units = Vec::new();
445+ let mut at = 0usize;
446+ while let Some(rel) = src[at..].find(OPEN) {
447+ let head = at + rel + OPEN.len();
448+ let Some(paren) = src[head..].find('(') else {
449+ break;
450+ };
451+ let close = src[head..]
452+ .find("\n }\n")
453+ .map_or(src.len(), |e| head + e);
454+ units.push((&src[head..head + paren], &src[head..close]));
455+ at = close.max(head + paren + 1);
456+ }
457+ units
458+ }
459+
460+ /// Names of every `fn` in `stream.rs` that drives the real `aomenc`,
461+ /// DIRECTLY (it mentions `aomenc_path()`) or by DELEGATING to one.
462+ ///
463+ /// lane-av1distwtd r3: the transitive closure is the whole point. A gate
464+ /// that hands its recipe to a shared helper (`inter_sb_none_gate` and
465+ /// friends) never spells `--passes=1` itself, so the old token filter
466+ /// dropped it -- 165 of 311 segments, 6 of which spell `--enable-X=1`.
467+ /// That is not a coverage fact, it is a segmentation fact, and it is what
468+ /// kept `enable-dual-filter` on the never-exercised lists while a named
469+ /// gate exercised the tool and hard-asserted the arrival.
470+ fn encoder_fns(src: &'static str) -> BTreeSet<&'static str> {
471+ let units = fn_units(src);
472+ let mut enc: BTreeSet<&'static str> = units
473+ .iter()
474+ .filter(|(_, body)| body.contains("aomenc_path()"))
475+ .map(|(name, _)| *name)
476+ .collect();
477+ // Fixpoint: `inter_sb_none_gate` is an encoder fn because it names
478+ // `aomenc_path()`; the `#[test]` that only CALLS it is a gate too.
479+ loop {
480+ let mut grew = false;
481+ for (name, body) in &units {
482+ if enc.contains(name) {
483+ continue;
484+ }
485+ if enc.iter().any(|e| calls_fn(body, e)) {
486+ enc.insert(name);
487+ grew = true;
488+ }
489+ }
490+ if !grew {
491+ return enc;
492+ }
493+ }
494+ }
495+
496+ /// The token spellings the filter used before it resolved calls. Kept as a
497+ /// floor: a gate is still recognised by these even if the call graph
498+ /// misses it, so the fix can only ever ADD gates, never lose one.
499+ fn legacy_gate_tokens(body: &str) -> bool {
500+ body.contains("\"--passes=1\"")
501+ || body.contains("ten_bit_tool_gate(")
502+ || body.contains("encode_10bit_gradients")
503+ }
504+
505+ /// Bodies of the real-aomenc gates: a `fn` body that drives the real
506+ /// `aomenc`, however it gets there. Split on the attribute that opens a
507+ /// test.
508+ ///
509+ /// lane-av1distwtd r3: a segment qualifies if it spells one of the
510+ /// [`legacy_gate_tokens`] OR names an encoder `fn` -- either by defining
511+ /// one (it mentions `aomenc_path()`) or by calling one. Recognition by
512+ /// CALL is what a helper-delegating gate needs: its flags live in the
513+ /// helper it calls, and it is invisible to a spelling-only filter.
421 fn gate_bodies() -> Vec<&'static str> {514 fn gate_bodies() -> Vec<&'static str> {
422 let src = include_str!("stream.rs");515 let src = include_str!("stream.rs");
516+ let enc = encoder_fns(src);
423 let gates: Vec<&str> = src517 let gates: Vec<&str> = src
424 .split("\n #[")518 .split("\n #[")
425 // lane-hbdgates r1: an `#[ignore]`d gate exercises nothing, so it519 // lane-hbdgates r1: an `#[ignore]`d gate exercises nothing, so it
426 // must not close a hole. Its body is the segment that opens with520 // must not close a hole. Its body is the segment that opens with
427 // the ignore attribute.521 // the ignore attribute.
428 .filter(|body| !body.starts_with("ignore"))522 .filter(|body| !body.starts_with("ignore"))
429- // lane-hbdgates r1: gates that build their stream through the523+ // lane-av1distwtd r3: a segment qualifies by what it SPELLS
430- // shared 10-bit helpers spell `--passes=1` there, not inline.524+ // (`legacy_gate_tokens`) or by what it CALLS. `calls_fn` is
525+ // deliberately the weak half of an OR, so the fix can only add
526+ // gates -- it can never stop recognising one the old filter did.
431 .filter(|body| {527 .filter(|body| {
432- body.contains("\"--passes=1\"")528+ legacy_gate_tokens(body)
433- || body.contains("ten_bit_tool_gate(")529+ || body.contains("aomenc_path()")
434- || body.contains("encode_10bit_gradients")530+ || enc.iter().any(|e| calls_fn(body, e))
435 })531 })
436 .collect();532 .collect();
437 assert!(533 assert!(
@@ -596,10 +692,94 @@ mod tests {
596 /// this marker that gate's own 8-bit-only flags read as 10-bit-only -- the692 /// this marker that gate's own 8-bit-only flags read as 10-bit-only -- the
597 /// lane-defon/reelckf blind spot with `depth` spelled instead of693 /// lane-defon/reelckf blind spot with `depth` spelled instead of
598 /// `bit_depth`. Three gates share the helper, at both depths.694 /// `bit_depth`. Three gates share the helper, at both depths.
695+ /// lane-av1distwtd r3: the THIRD spelling of the same blind spot, still
696+ /// live after lane-defon and lane-reelckf. A recipe parameterised on
697+ /// `ten_bit` names BOTH fixture formats in one body -- `let pix_fmt = if
698+ /// ten_bit { "yuv420p10le" } else { "yuv420p" };` -- so `is_ten_bit` saw
699+ /// the 10-bit arm and filed the whole body 10-bit-ONLY, hiding its 8-bit
700+ /// arm from the 8-bit bucket. The marker is the PAIR OF FORMATS, not the
701+ /// parameter name: a body spelling both pixel formats builds streams at
702+ /// both depths, whatever it calls the flag. The quotes matter -- a bare
703+ /// `yuv420p` substring test also matches `yuv420p10le` and would fire on
704+ /// every 10-bit gate, retiring entries on no evidence.
705+ ///
706+ /// This is what mis-filed `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
707+ /// and kept `enable-flip-idtx` on the 8-bit list while that gate ran 6
708+ /// pixel-exact 8-bit decodes through it.
599 fn covers_both_depths(body: &str) -> bool {709 fn covers_both_depths(body: &str) -> bool {
600 body.contains("if bit_depth == 10")710 body.contains("if bit_depth == 10")
601 || body.contains("if depth == 10")711 || body.contains("if depth == 10")
602 || body.contains("for depth in [8usize, 10]")712 || body.contains("for depth in [8usize, 10]")
713+ || (body.contains("\"yuv420p\"") && body.contains("\"yuv420p10le\""))
714+ }
715+
716+ /// lane-av1distwtd r3: the detector fix, pinned. A detector change with
717+ /// no test can only be shown to find MORE, never to stop missing, so this
718+ /// asserts the three gates the two blind spots actually hid are now seen
719+ /// -- the two `enable-dual-filter` witnesses and the `enable-flip-idtx`
720+ /// both-depths gate -- and that the fix is strictly ADDITIVE against the
721+ /// old spelling-only filter.
722+ #[test]
723+ fn the_detector_sees_the_gates_the_spelling_filter_missed() {
724+ let src = include_str!("stream.rs");
725+ let gates = gate_bodies();
726+ // The helper-delegation half: each of these builds its stream through
727+ // `inter_sb_none_gate` and spells none of `legacy_gate_tokens`, so the
728+ // old filter dropped both while each hard-asserts its tool arrived.
729+ for name in [
730+ "a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact",
731+ "a_real_obmc_stream_reads_a_recorded_switchable_filter_for_every_neighbour",
732+ ] {
733+ let body = gates
734+ .iter()
735+ .find(|b| b.contains(name))
736+ .unwrap_or_else(|| panic!("{name}: not seen by gate_bodies()"));
737+ assert_eq!(
738+ flags_in(body).get("enable-dual-filter"),
739+ Some(&'1'),
740+ "{name}: seen, but its --enable-dual-filter=1 spelling is not visible to \
741+ flags_in, so recognising the gate would not retire the entry"
742+ );
743+ }
744+ // The both-depths half: this gate's recipe is parameterised on `ten_bit`
745+ // and names both fixture formats, so `covers_both_depths` must credit
746+ // it to the 8-bit bucket, not just the 10-bit one.
747+ let flip = gates
748+ .iter()
749+ .find(|b| {
750+ b.contains("a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform")
751+ })
752+ .expect("the flip-idtx gate must be seen");
753+ assert!(
754+ covers_both_depths(flip),
755+ "the flip-idtx gate spells both fixture formats, so covers_both_depths must \
756+ credit it to the 8-bit bucket as well"
757+ );
758+ assert!(
759+ covers_depth(flip, false) && covers_depth(flip, true),
760+ "the flip-idtx gate must cover BOTH depths"
761+ );
762+ // Strictly additive: every segment the old spelling-only filter kept
763+ // is still kept, so the fix cannot have cost the census a gate.
764+ let legacy_only: Vec<&str> = src
765+ .split("\n #[")
766+ .filter(|b| !b.starts_with("ignore") && legacy_gate_tokens(b))
767+ .collect();
768+ assert!(
769+ legacy_only.len() < gates.len(),
770+ "the call-resolving filter found {} gates, the old spelling-only filter found \
771+ {} -- the fix is expected to ADD gates, never to drop one",
772+ gates.len(),
773+ legacy_only.len()
774+ );
775+ for body in &legacy_only {
776+ assert!(
777+ gates.contains(body),
778+ "a gate the spelling-only filter recognised is no longer recognised: \
779+ {:?}",
780+ &body[..body.len().min(60)]
781+ );
782+ }
603 }783 }
604 784
605 /// Whether a gate body drives a stream at this depth.785 /// Whether a gate body drives a stream at this depth.
lanes/av1distwtd.report.mdmodified+109 -0
@@ -118,3 +118,112 @@ only**: verified — the only non-comment lines changed are 3 entry *reason
118 strings* (`gate_coverage.rs:272, 293, 376`). No flag name, entry membership,118 strings* (`gate_coverage.rs:272, 293, 376`). No flag name, entry membership,
119 counter, gate, or decoder behaviour was touched. All 9 `gate_coverage` tests119 counter, gate, or decoder behaviour was touched. All 9 `gate_coverage` tests
120 green after the change. No stream, gate, or counter behaviour altered, per brief.120 green after the change. No stream, gate, or counter behaviour altered, per brief.
121+
122+---
123+
124+# r3 appendix: fix the two structural census defects
125+
126+r2 corrected the false CLAIMS. r3 fixes the LOGIC that generated them, so it
127+stops generating them. `crates/ec-av1/src/gate_coverage.rs` only; no gate,
128+counter, fixture, or decoder behaviour touched.
129+
130+## Evidence table — before / after
131+
132+| measure | before (r2, spelling-only) | after (r3, call-resolving) |
133+|---|---|---|
134+| gate bodies seen by `gate_bodies()` | 146 | **230** (+84) |
135+| of those, classified 10-bit-or-higher | 83 | **107** (+24) |
136+| `enable-dual-filter` 8-bit | listed as a hole | **retired** (gate found) |
137+| `enable-flip-idtx` 8-bit | listed as a hole | **retired** (gate classified both-depths) |
138+| `NEVER_EXERCISED_8BIT` | 3 live entries | **1** (`enable-rect-tx`) |
139+| `NEVER_EXERCISED_10BIT` | 3 live entries | **2** (`enable-dual-filter`, `enable-rect-tx`) |
140+| tests | 9 | **10** (new `the_detector_sees_the_gates_the_spelling_filter_missed`) |
141+
142+The three gates the fix had to find, all now found and asserted by the new test:
143+
144+| gate | was invisible because | now found by |
145+|---|---|---|
146+| `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | recipe lives in `inter_sb_none_gate` | `encoder_fns` call closure |
147+| `a_real_obmc_stream_reads_a_recorded_switchable_filter_for_every_neighbour` | same | `encoder_fns` call closure |
148+| `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact` | `ten_bit` recipe, `is_ten_bit` filed it 10-bit-only | `covers_both_depths` pair-of-formats marker |
149+
150+## The two fixes
151+
152+**1. `gate_bodies()` — recognise a gate by what it CALLS, not only what it spells.**
153+New `fn_units` parses every `fn` in `stream.rs` as `(name, body)`; `encoder_fns`
154+computes the transitive closure of fns that reach one naming `aomenc_path()`.
155+The filter is now `legacy_gate_tokens(body) || body.contains("aomenc_path()")
156+|| enc.iter().any(|e| calls_fn(body, e))`. The call test is deliberately the
157+weak half of an OR, so the fix is **strictly additive** — it can add gates but
158+can never stop recognising one the old filter did. `calls_fn` requires the name
159+to be followed by `(` and not be the tail of a longer identifier, so
160+`inter_sb_none_gate` does not "call" `sb_none_gate`.
161+
162+**2. `covers_both_depths` — the third spelling.** Added
163+`body.contains("\"yuv420p\"") && body.contains("\"yuv420p10le\"")`: a body
164+naming BOTH fixture formats builds streams at both depths, whatever the
165+parameter is called. The quotes matter — a bare `yuv420p` substring test also
166+matches `yuv420p10le` and would fire on every 10-bit gate, retiring entries on
167+no evidence. This is not a special case for the flip-idtx gate; it is the
168+lane-defon/reelckf blind spot closed on its third spelling.
169+
170+## Red-before (three mutations, all reverted; `stream.rs` byte-identical to HEAD)
171+
172+A detector change can only be shown to find MORE, never to stop missing, so
173+each half was shown to be **causal** — neuter it and the retired entry must come
174+back.
175+
176+**Mutation A — the helper-delegation half.** Set `--enable-dual-filter=1` to
177+`=0` in both helper-based gates. TWO tests red:
178+- `never_exercised_8bit_matches_the_gate_recipes`: *"no 8-bit gate passes `=1`
179+ for ["enable-dual-filter"], so no real 8-bit stream exercises them"* — the
180+ retired entry correctly RETURNS as a hole.
181+- `the_detector_sees_the_gates_the_spelling_filter_missed`: *"seen, but its
182+ --enable-dual-filter=1 spelling is not visible to flags_in"*, `left: Some('0')
183+ right: Some('1')`. The second red is the valuable one: it separates
184+ *recognition broke* from *the gate no longer enables the tool*.
185+
186+**Mutation B — the legacy path still works.** Set `--enable-dist-wtd-comp=1` to
187+`=0` in the r1 gate, a gate the OLD filter already recognised (it spells
188+`--passes=1`). Red at BOTH depths: *"no 10-bit gate passes `=1` for
189+["enable-dist-wtd-comp"]"* and the 8-bit twin. The spelling path is intact.
190+
191+**Mutation C — the both-depths half.** Reverted only the pair-of-formats
192+clause. TWO tests red: `never_exercised_8bit...`: *"no 8-bit gate passes `=1`
193+for ["enable-flip-idtx"]"*, and the new detector test: *"the flip-idtx gate
194+spells both fixture formats, so covers_both_depths must credit it to the 8-bit
195+bucket as well"*.
196+
197+All three reverted; `git diff --stat crates/ec-av1/src/stream.rs` is empty, and
198+all 10 tests are green.
199+
200+## `enable-dual-filter` 10-bit: the entry STAYS — a finding, not an oversight
201+
202+After the fix the 8-bit entry retires and the 10-bit one does not, which is the
203+honest outcome and exactly the case Main said to report rather than paper over.
204+The only `=1` witness is `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact`,
205+and it calls `inter_sb_none_gate(NAME, false, ...)` — `false` is the `ten_bit`
206+parameter, so it builds an 8-bit stream only. Its `ten_bit=true` siblings
207+(`..._10bit_inter_sequence_with_a_whole_superblock_block_...` and the 8x8-leaf
208+pair) do not spell `--enable-dual-filter=1`. **To retire it: add the 10-bit arm
209+— pass `true` to `inter_sb_none_gate` in that gate and assert
210+`dual_filter_diff_hits()` still moves there.**
211+
212+## Row: `enable-tx-size-search` — the one claim this audit could not settle
213+
214+A third detector limit, and the method for whoever takes it next. After the r3
215+fix, 113 of the 230 selected gates name it: **88 pass `=0`, 15 pass `=1`, and 9
216+build the value into a `format!`/`String` variable** that neither `flags_in` nor
217+`settings_in` can see — both scan for a literal `"--flag=value"` inside one
218+segment. So the r2 finding stands and sharpens: the historical "all 49 pass 0"
219+claim no longer holds in either direction, and 9 gates are unclassified in an
220+**unknown direction**, which is the exact failure mode this file exists to
221+prevent.
222+
223+**What would settle it (method, not a guess):** extend `flags_in`/`settings_in`
224+to resolve a local binding the way `gate_bodies` now resolves calls. When a
225+segment contains `let <name> = format!("--enable-tx-size-search={tx_search}")`
226+(or the `String::from`/`to_string` equivalent), record the TEMPLATE and bind the
227+variable's value at each use site. Re-count, and only then decide whether the
228+tool is a live hole. Until that exists the 113/88/15 split is a floor, not a
229+measurement. This is recorded in-file above `DEFAULT_ON_TOOLS` as well.