forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1txsearch @ 4aebe74d — format!-flag detector, enable-rect-tx entry, unresolvable==0 assert

Browse files at this commit

aa976f182161409fcb1487cf61e2bbbeab74a246Ahmet Kaan GümüşParent: 7bd9ad49792668
crates/ec-av1/src/gate_coverage.rsmodified+463 -47
@@ -125,39 +125,48 @@ enum On {
125125 /// written, and the real-stream PANIC hiding behind that pin was found by
126126 /// lane-ab16, not by this guard. `--loopfilter-control=0`,
127127 /// `--tile-columns=0` and a `--cpu-used` high enough to switch a search off are
128-/// the same shape.
128+/// the same shape. `enable-tx-size-search` has since been SETTLED, in both
129+/// directions -- see the entry below and `print_tx_size_search_census`.
129130 ///
130131 /// The "all 49" count is GONE as of 2026-09-29 (lane-av1distwtd r2) and is
131-/// deliberately not replaced by a number: the tool is no longer pinned off
132-/// tree-wide, so any count would be a snapshot that rots the same way.
133-/// Measured on this tree for the record: 113 of the 146 selected gate bodies
134-/// name it, 88 pass `=0`, 15 pass `=1`, and 9 build the value into a
135-/// `format!` variable the census cannot see -- so the historical claim no
136-/// longer holds in EITHER direction, and the `enable-tx-size-search` entry
137-/// below is a live question, not a settled one.
132+/// deliberately not replaced by a number here: it is a snapshot that rots
133+/// every time a recipe changes. The live count is a TEST
134+/// ([`print_tx_size_search_census`], below), not prose, so it cannot go stale
135+/// silently -- re-run it and read the numbers rather than trusting a comment.
138136 ///
139137 /// Each entry is `(tool, spellings, aomenc default, what counts as on)`. The
140138 /// "defaulted means unknown" rule of [`NEVER_EXERCISED`] applies unchanged: a
141139 /// default of `1` does not prove the encoder picked the tool for any stream, so
142140 /// 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.
141+// `enable-tx-size-search` SETTLED 2026-09-29 (lane-av1txsearch), by
142+// measurement rather than by a name-shaped guess. The r3 note here said the
143+// count was a FLOOR: 9 gate bodies built the flag into a `format!`
144+// variable that neither `flags_in` nor `settings_in` could see, because
145+// both scan for a literal `"--flag=value"` inside one segment. The method
146+// r3 asked for is now [`spelling_values`] -> [`bound_values`], and it
147+// resolves all of them; `print_tx_size_search_census` asserts the
148+// unresolvable count is ZERO, so the floor cannot come back unnoticed.
149+//
150+// THE ENTRY IS RETIRED, on an ARRIVAL ASSERT rather than on the spelling.
151+// `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
152+// spells `--enable-tx-size-search=1` as a literal and hard-asserts
153+// `compared_tx_depths > 0` -- "never produced a nonzero tx depth on a
154+// compared attempt -- the flag did not arrive". `tx_depth` is read ONLY
155+// under the frame header's `tx_mode_select` bit (spec 5.11.16,
156+// `decode.rs`: the read is guarded by `tx_select_inter`), so a nonzero
157+// counter IS the parsed tx-size-search behaviour, not a proxy for it.
158+// Measured run of that gate on this tree (aom 3.13.3): 12 pixel-exact
159+// decodes, 0 named refusals, 6 of the 12 at 10 BIT, 219 rect coefficient
160+// TUs on compared attempts, and `flag arrival: ... tx depths 53` -- so the
161+// tool is exercised at BOTH depths, and the assertion is not vacuous.
162+//
163+// The `tx_select_inter_gate` twins
164+// (`a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact{,_10bit}`)
165+// are the stronger witness still: they DELIBERATELY omit the flag
166+// ("DELIBERATELY ABSENT: --enable-tx-size-search=0") and assert
167+// `decode::txfm_split_hits()` moved, proving the var-tx `txfm_split` tree
168+// of spec 5.11.17 is read -- an inter transform is then a recursive split
169+// tree, which is the whole content of the tool.
161170 #[cfg(test)]
162171 const DEFAULT_ON_TOOLS: &[(&str, &[&str], &str, On)] = &[
163172 (
@@ -434,8 +443,8 @@ const NEVER_ON_10BIT: &[(&str, &str)] = &[];
434443 #[cfg(test)]
435444 mod tests {
436445 use super::{
437- On, ALIASES, DEFAULT_ON_TOOLS, NEVER_EXERCISED, NEVER_EXERCISED_10BIT,
438- NEVER_EXERCISED_8BIT, NEVER_ON_10BIT, NEVER_ON_8BIT, TOOL_UNIVERSE,
446+ ALIASES, DEFAULT_ON_TOOLS, NEVER_EXERCISED, NEVER_EXERCISED_8BIT, NEVER_EXERCISED_10BIT,
447+ NEVER_ON_8BIT, NEVER_ON_10BIT, On, TOOL_UNIVERSE,
439448 };
440449 use std::collections::{BTreeMap, BTreeSet};
441450
@@ -594,24 +603,262 @@ mod tests {
594603 here
595604 }
596605
597- /// Whether a gate body spells one [`DEFAULT_ON_TOOLS`] entry on / off.
598- fn default_on_state(gate: &str, spellings: &[&str], on: On) -> Option<bool> {
599- let here = settings_in(gate);
600- let mut state = None;
601- for spelling in spellings {
602- let Some(value) = here.get(*spelling) else {
606+ /// The values a `--<flag>={var}` TEMPLATE can take in one gate body, from
607+ /// the local binding of `var`.
608+ ///
609+ /// lane-av1txsearch: `settings_in` reads a `--flag=value` string LITERAL,
610+ /// so a flag a gate builds with `format!` was invisible to it -- 10 gate
611+ /// bodies spell `--enable-tx-size-search` only this way, and the census
612+ /// filed them as "defaulted", i.e. unknown in BOTH directions. The
613+ /// bindings that actually exist in `stream.rs` are four shapes, and each
614+ /// is resolved from the gate's own text rather than from the variable's
615+ /// name:
616+ ///
617+ /// 1. `let <var> = if <attempt> == 0 { "0" } else { "1" };` -- an
618+ /// attempt-indexed arm; the QUOTED values in the initializer are
619+ /// collected. Bare integers in the initializer (`attempt % 2`) are
620+ /// deliberately NOT read as flag values.
621+ /// 2. `for <var> in [0usize, 1]` / `["0", "1"]` -- a loop over both
622+ /// values; every element of the array is collected.
623+ /// 3. `for (<var>, <other>) in [("1", 8u8), ("0", 8u8), ...]` -- a
624+ /// tuple-destructured loop; only the element at `<var>`'s POSITION is
625+ /// collected from each tuple, so the arm table's bit-depth column is
626+ /// not read as a flag value.
627+ /// 4. `u8::from(<a>.<field>)` over a struct-literal arm table whose
628+ /// `field: true` / `field: false` rows are the flag values.
629+ ///
630+ /// `None` means the binding is NOT in this body -- the variable is a
631+ /// parameter of a shared helper and its value is bound at the CALL SITE,
632+ /// which lives in a different `#[`-segment. That is a real limit of a
633+ /// per-segment census and is reported as unknown rather than guessed:
634+ /// inferring the value from the variable's name is the exact failure this
635+ /// function exists to remove.
636+ fn bound_values(body: &str, var: &str) -> Option<BTreeSet<char>> {
637+ // Quoted single digits: `"0"`, `"1"`.
638+ let quoted_digits = |t: &str| -> BTreeSet<char> {
639+ let mut out = BTreeSet::new();
640+ let mut at = 0usize;
641+ while let Some(rel) = t[at..].find('"') {
642+ let start = at + rel + 1;
643+ let Some(end) = t[start..].find('"') else {
644+ break;
645+ };
646+ let literal = &t[start..start + end];
647+ if literal.len() == 1 {
648+ if let Some(c) = literal.chars().next() {
649+ if c.is_ascii_digit() {
650+ out.insert(c);
651+ }
652+ }
653+ }
654+ at = start + end + 1;
655+ }
656+ out
657+ };
658+ // Bare integer literals: `0usize`, `1`, `8u8`. Whole tokens only, so
659+ // `10u8` contributes nothing rather than a bogus `1`.
660+ let bare_digits = |t: &str| -> BTreeSet<char> {
661+ let mut out = BTreeSet::new();
662+ let bytes = t.as_bytes();
663+ let mut i = 0usize;
664+ while i < bytes.len() {
665+ if !bytes[i].is_ascii_digit() {
666+ i += 1;
667+ continue;
668+ }
669+ let start = i;
670+ while i < bytes.len() && bytes[i].is_ascii_digit() {
671+ i += 1;
672+ }
673+ let clean_before = start == 0 || !is_ident_byte(bytes[start - 1]);
674+ // A typed literal's suffix (`0usize`, `8u8`, `1u32`) belongs to
675+ // the same token, so a run of LOWERCASE letters right after
676+ // the digit is a type, not a different identifier. Anything
677+ // else -- a multi-digit `10u8`, a camelCase `1x` -- is not a
678+ // flag value and is rejected.
679+ let rest = &t[i..];
680+ let suffix = rest
681+ .bytes()
682+ .take_while(|b| b.is_ascii_lowercase() || *b == b'_')
683+ .count();
684+ let clean_after = i >= bytes.len()
685+ || !is_ident_byte(bytes[i])
686+ || (suffix > 0
687+ && i + suffix < bytes.len()
688+ && !is_ident_byte(bytes[i + suffix]));
689+ if clean_before && clean_after && i - start == 1 {
690+ out.insert(bytes[start] as char);
691+ }
692+ }
693+ out
694+ };
695+ // Split a comma-separated list at TOP level only, so `("1", 8u8)`
696+ // stays one element.
697+ fn split_top<'a>(t: &'a str) -> Vec<&'a str> {
698+ let mut out = Vec::new();
699+ let (mut depth, mut start) = (0i32, 0usize);
700+ for (i, c) in t.char_indices() {
701+ match c {
702+ '(' | '[' | '{' => depth += 1,
703+ ')' | ']' | '}' => depth -= 1,
704+ ',' if depth == 0 => {
705+ out.push(t[start..i].trim());
706+ start = i + 1;
707+ }
708+ _ => {}
709+ }
710+ }
711+ if start < t.len() {
712+ out.push(t[start..].trim());
713+ }
714+ out
715+ }
716+ // The body of the `[...]` that FOLLOWS `head` in `text`. Scoped to
717+ // the header rather than searching from the start of the body: a
718+ // gate's first `[` may be an unrelated array, and brackets that do
719+ // not balance across a whole gate body would leave the depth count
720+ // never returning to zero.
721+ fn loop_array_after<'a>(text: &'a str, head: &str) -> Option<&'a str> {
722+ let at = text.find(head)? + head.len();
723+ let open = at + text[at..].find('[')?;
724+ let mut depth = 0i32;
725+ for (i, c) in text[open..].char_indices() {
726+ match c {
727+ '[' => depth += 1,
728+ ']' => {
729+ depth -= 1;
730+ if depth == 0 {
731+ return Some(&text[open + 1..open + i]);
732+ }
733+ }
734+ _ => {}
735+ }
736+ }
737+ None
738+ }
739+ let mut found: Option<BTreeSet<char>> = None;
740+ let mut merge = |set: BTreeSet<char>| match &mut found {
741+ Some(all) => all.extend(set),
742+ None => found = Some(set),
743+ };
744+ // (1) `let <var> = if ... { "0" } else { "1" };` -- quoted values only.
745+ if let Some(at) = body.find(&format!("let {var} =")) {
746+ let init = &body[at..];
747+ let end = init.find(';').unwrap_or(init.len());
748+ merge(quoted_digits(&init[..end]));
749+ }
750+ // (2) `for <var> in [...]` -- every element of the array.
751+ if let Some(array) = loop_array_after(body, &format!("for {var} in ")) {
752+ merge(bare_digits(array));
753+ merge(quoted_digits(array));
754+ }
755+ // (3) `for (<var>, ...) in [(...), ...]` -- only `<var>`'s column.
756+ if let Some(at) = body.find("for (") {
757+ let head = &body[at..];
758+ if let Some(close) = head.find(')') {
759+ let pattern = &head["for (".len()..close];
760+ if let Some(pos) = pattern.split(',').position(|p| p.trim() == var) {
761+ let header = format!("for ({pattern}) in ");
762+ if let Some(array) = loop_array_after(body, &header) {
763+ let mut set: BTreeSet<char> = BTreeSet::new();
764+ for tuple in split_top(array) {
765+ let Some(inner) =
766+ tuple.strip_prefix('(').and_then(|t| t.strip_suffix(')'))
767+ else {
768+ continue;
769+ };
770+ let fields = split_top(inner);
771+ let Some(field) = fields.get(pos) else {
772+ continue;
773+ };
774+ set.extend(bare_digits(field));
775+ set.extend(quoted_digits(field));
776+ }
777+ merge(set);
778+ }
779+ }
780+ }
781+ }
782+ // (4) `u8::from(<a>.<field>)` over a struct-literal arm table.
783+ for (i, _) in body.match_indices("u8::from(") {
784+ let arg = &body[i + "u8::from(".len()..];
785+ let Some(close) = arg.find(')') else { continue };
786+ let field = arg[..close].rsplit('.').next().unwrap_or_default().trim();
787+ if field.is_empty() || !field.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
603788 continue;
604- };
605- let Ok(value) = value.parse::<u32>() else {
789+ }
790+ let mut set = BTreeSet::new();
791+ for (row, value) in [("true", '1'), ("false", '0')] {
792+ if body.contains(&format!("{field}: {row}")) {
793+ set.insert(value);
794+ }
795+ }
796+ merge(set);
797+ }
798+ found
799+ }
800+
801+ fn is_ident_byte(b: u8) -> bool {
802+ b.is_ascii_alphanumeric() || b == b'_'
803+ }
804+
805+ /// Values of one [`DEFAULT_ON_TOOLS`] spelling in one gate body: the
806+ /// literal `--<spelling>=<digit>` spellings plus every value a `format!`
807+ /// template built from a local binding resolves to.
808+ ///
809+ /// A gate that reaches BOTH values counts ON, not off: it builds a `=1`
810+ /// stream on some attempt, which is what the census asks for. This is the
811+ /// file's standing "any spelling that says on wins" rule
812+ /// (`--tile-columns=0 --tile-rows=1` is a multi-tile stream), now applied
813+ /// across a loop's arms as well as across spellings.
814+ fn spelling_values(gate: &str, spelling: &str) -> BTreeSet<char> {
815+ let mut out = BTreeSet::new();
816+ // A literal `"--<spelling>=<digit>"`: the needle ends at the `=`, so
817+ // the value starts AT the needle's length, not three characters in.
818+ let literal = format!("\"--{spelling}=");
819+ for (i, _) in gate.match_indices(&literal) {
820+ let rest = &gate[i + literal.len()..];
821+ let Some(end) = rest.find('"') else { continue };
822+ if let Some(c) = rest[..end].chars().next() {
823+ if c.is_ascii_digit() {
824+ out.insert(c);
825+ }
826+ }
827+ }
828+ // A template `format!("--<spelling>={<var>}")`: the placeholder name
829+ // is the part between the braces, and its VALUE is whatever the
830+ // binding of `<var>` in this same body reaches.
831+ let template = format!("format!(\"--{spelling}=");
832+ for (i, _) in gate.match_indices(&template) {
833+ let rest = &gate[i + template.len()..];
834+ let Some(end) = rest.find('"') else { continue };
835+ let Some(var) = rest[..end]
836+ .strip_prefix('{')
837+ .and_then(|v| v.strip_suffix('}'))
838+ else {
606839 continue;
607840 };
608- let is_on = match on {
609- On::NonZero => value != 0,
610- On::AtMost(limit) => value <= limit,
611- };
612- // Any spelling that says "on" wins: --tile-columns=0 --tile-rows=1
613- // is a multi-tile stream.
614- state = Some(state.unwrap_or(false) || is_on);
841+ if var.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
842+ out.extend(bound_values(gate, var).unwrap_or_default());
843+ }
844+ }
845+ out
846+ }
847+
848+ /// Whether a gate body spells one [`DEFAULT_ON_TOOLS`] entry on / off,
849+ /// over [`spelling_values`] -- so a `format!`-built flag is classified
850+ /// instead of being filed as "defaulted".
851+ fn resolved_on_state(gate: &str, spellings: &[&str], on: On) -> Option<bool> {
852+ let mut state = None;
853+ for spelling in spellings {
854+ for c in spelling_values(gate, spelling) {
855+ let value = c.to_digit(10).unwrap_or(0);
856+ let is_on = match on {
857+ On::NonZero => value != 0,
858+ On::AtMost(limit) => value <= limit,
859+ };
860+ state = Some(state.unwrap_or(false) || is_on);
861+ }
615862 }
616863 state
617864 }
@@ -770,9 +1017,7 @@ mod tests {
7701017 // it to the 8-bit bucket, not just the 10-bit one.
7711018 let flip = gates
7721019 .iter()
773- .find(|b| {
774- b.contains("a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform")
775- })
1020+ .find(|b| b.contains("a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform"))
7761021 .expect("the flip-idtx gate must be seen");
7771022 assert!(
7781023 covers_both_depths(flip),
@@ -925,9 +1170,12 @@ mod tests {
9251170 .collect();
9261171 let mut per_tool = BTreeMap::new();
9271172 for &(tool, spellings, _, on) in DEFAULT_ON_TOOLS {
1173+ // lane-av1txsearch: `resolved_on_state`, not `default_on_state` --
1174+ // the literal-only reader filed every `format!`-built flag as
1175+ // "defaulted", which is unknown rather than measured.
9281176 let states: Vec<Option<bool>> = gates
9291177 .iter()
930- .map(|g| default_on_state(g, spellings, on))
1178+ .map(|g| resolved_on_state(g, spellings, on))
9311179 .collect();
9321180 let turned_on = states.iter().filter(|s| **s == Some(true)).count();
9331181 let turned_off = states.iter().filter(|s| **s == Some(false)).count();
@@ -1022,4 +1270,172 @@ mod tests {
10221270 }
10231271 }
10241272 }
1273+
1274+ /// lane-av1txsearch: the `enable-tx-size-search` census, MEASURED rather
1275+ /// than floored. Prints, per gate body, the values the resolver reads for
1276+ /// the flag -- literal spellings and `format!` templates alike -- and the
1277+ /// three-way split at the end. Re-run it after any gate recipe change:
1278+ ///
1279+ /// `cargo test -p ec-av1 --lib gate_coverage::tests::print_tx_size_search_census -- --nocapture`
1280+ #[test]
1281+ fn print_tx_size_search_census() {
1282+ const TOOL: &str = "enable-tx-size-search";
1283+ let (zero, one, both, unresolvable, unnamed) = {
1284+ let (mut zero, mut one, mut both, mut unresolvable, mut unnamed) =
1285+ (0usize, 0usize, 0usize, 0usize, 0usize);
1286+ for gate in gate_bodies() {
1287+ let values = spelling_values(gate, TOOL);
1288+ let name = gate
1289+ .split("fn ")
1290+ .nth(1)
1291+ .and_then(|s| s.split('(').next())
1292+ .unwrap_or("<segment>")
1293+ .to_owned();
1294+ let state = match (values.contains(&'0'), values.contains(&'1')) {
1295+ (false, false) => {
1296+ unnamed += 1;
1297+ "not named (defaulted)"
1298+ }
1299+ (true, false) => {
1300+ zero += 1;
1301+ "=0"
1302+ }
1303+ (false, true) => {
1304+ one += 1;
1305+ "=1"
1306+ }
1307+ (true, true) => {
1308+ both += 1;
1309+ "=0 and =1 (one arm each)"
1310+ }
1311+ };
1312+ let via = if gate.contains(&format!("format!(\"--{TOOL}=")) {
1313+ " [format! template resolved]"
1314+ } else {
1315+ ""
1316+ };
1317+ let helper = if gate.contains(&format!("format!(\"--{TOOL}=")) && values.is_empty()
1318+ {
1319+ " [UNRESOLVED: variable is a shared helper's parameter]"
1320+ } else {
1321+ ""
1322+ };
1323+ if !helper.is_empty() {
1324+ unresolvable += 1;
1325+ unnamed -= 1;
1326+ }
1327+ println!("{name}: {state}{via}{helper}");
1328+ }
1329+ (zero, one, both, unresolvable, unnamed)
1330+ };
1331+ let total = gate_bodies().len();
1332+ println!(
1333+ "enable-tx-size-search over {total} census-selected gate bodies: \
1334+ =0 only {zero}, =1 only {one}, both {both}, unresolvable {unresolvable}, \
1335+ not named {unnamed}"
1336+ );
1337+ assert_eq!(
1338+ unresolvable, 0,
1339+ "{unresolvable} gate bodies build --{TOOL} into a variable this census cannot bind -- \
1340+ the count is a floor again, and an unknown direction is the failure mode this file \
1341+ exists to prevent"
1342+ );
1343+ }
1344+
1345+ /// lane-av1txsearch: the RED-BEFORE proof for the template resolver, in
1346+ /// both directions, on the gate bodies that actually exist.
1347+ ///
1348+ /// Direction 1 -- a `format!`-built value MOVES the classification. Each
1349+ /// case below takes a real gate body, mutates only the bound value, and
1350+ /// asserts the resolved state changed. A resolver that found nothing
1351+ /// would read every one of these as "not named" and fail all four.
1352+ ///
1353+ /// Direction 2 -- a spelling the LITERAL reader already saw still
1354+ /// classifies. Without this half, a resolver that overwrote the literal
1355+ /// path would pass direction 1 while losing the 15 `=1` gates the census
1356+ /// already counted.
1357+ #[test]
1358+ fn the_resolver_binds_a_format_built_flag_in_both_directions() {
1359+ let gates = gate_bodies();
1360+ let find = |needle: &str| -> &'static str {
1361+ gates
1362+ .iter()
1363+ .copied()
1364+ .find(|b| b.contains(needle))
1365+ .unwrap_or_else(|| panic!("no gate body contains {needle:?}"))
1366+ };
1367+ // Direction 1, one per template shape.
1368+ let cases = [
1369+ (
1370+ "format!(\"--enable-tx-size-search={txs}\")",
1371+ "for txs in [0usize, 1]",
1372+ "for txs in [0usize, 0]",
1373+ "a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact",
1374+ ),
1375+ (
1376+ "format!(\"--enable-tx-size-search={tx_search}\")",
1377+ "if attempt % 2 == 0 { \"0\" } else { \"1\" }",
1378+ "if attempt % 2 == 0 { \"0\" } else { \"0\" }",
1379+ "a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact",
1380+ ),
1381+ (
1382+ "format!(\"--enable-tx-size-search={tx_search}\")",
1383+ "for (tx_search, bit_depth) in [(\"1\", 8u8), (\"0\", 8u8), (\"1\", 10u8)]",
1384+ "for (tx_search, bit_depth) in [(\"0\", 8u8), (\"0\", 8u8), (\"0\", 10u8)]",
1385+ "a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact",
1386+ ),
1387+ ];
1388+ for (template, from, to, name) in cases {
1389+ let body = find(name);
1390+ assert!(
1391+ body.contains(template),
1392+ "{name} does not spell {template}, so this case proves nothing"
1393+ );
1394+ assert!(
1395+ body.contains(from),
1396+ "{name} does not contain the source binding {from:?}"
1397+ );
1398+ let before = spelling_values(body, "enable-tx-size-search");
1399+ let mutated = body.replace(from, to);
1400+ assert_ne!(
1401+ mutated, body,
1402+ "the mutation {from:?} -> {to:?} changed nothing"
1403+ );
1404+ let after = spelling_values(&mutated, "enable-tx-size-search");
1405+ assert_eq!(
1406+ before,
1407+ BTreeSet::from(['0', '1']),
1408+ "{name}: the unmutated body should resolve to both values, got {before:?}"
1409+ );
1410+ assert_eq!(
1411+ after,
1412+ BTreeSet::from(['0']),
1413+ "{name}: mutating the bound value {from:?} -> {to:?} did not move the \
1414+ classification (still {after:?}) -- the resolver is not reading the binding"
1415+ );
1416+ }
1417+ // Direction 2: every gate the LITERAL reader already classified as
1418+ // `=1` still is. Asserted as CONTAINMENT, not equality: a segment may
1419+ // spell the flag twice (`=0` in the base recipe, `=1` as the per-arm
1420+ // override), and the old reader took the last one while the resolver
1421+ // takes the set. The claim being pinned is "still on", which is the
1422+ // direction a regression would lose.
1423+ let mut pinned = 0usize;
1424+ for gate in &gates {
1425+ if !gate.contains("\"--enable-tx-size-search=1\"") {
1426+ continue;
1427+ }
1428+ pinned += 1;
1429+ assert!(
1430+ spelling_values(gate, "enable-tx-size-search").contains(&'1'),
1431+ "a gate that literally spells --enable-tx-size-search=1 is no longer \
1432+ classified on: {:?}",
1433+ &gate[..gate.len().min(80)]
1434+ );
1435+ }
1436+ assert!(
1437+ pinned >= 10,
1438+ "expected the literal `=1` gates to still be there, found {pinned}"
1439+ );
1440+ }
10251441 }
lanes/av1txsearch.report.mdadded+238 -0
@@ -0,0 +1,238 @@
1+# lane-av1txsearch — settle the `enable-tx-size-search` census floor
2+
3+Worktree `~/.cache/wt/av1txsearch`, branch `lane-av1txsearch`, based on `1aaf7e0b`
4+(lane-av1distwtd r3, the call-resolving census fix — read as prior art, not
5+duplicated). Owns `crates/ec-av1/src/gate_coverage.rs` only. `stream.rs` and
6+every decoder file are byte-identical to the base.
7+
8+## The claim that was a floor
9+
10+r3 left this in-file, above `DEFAULT_ON_TOOLS`:
11+
12+> 113 of the 230 selected gates name it: 88 pass `=0`, 15 pass `=1`, and 9
13+> build the value into a `format!`/`String` variable that neither `flags_in`
14+> nor `settings_in` can see … Until that exists the count above is a floor, not
15+> a measurement: 9 gates are unclassified in an unknown direction.
16+
17+An unknown direction is the failure this file exists to prevent, so the entry
18+could not be retired on the numbers as they stood. This lane settles it.
19+
20+## 1. The templates
21+
22+`grep -n 'format!("--enable-tx-size-search' crates/ec-av1/src/stream.rs` returns
23+**10** sites, not 9 — the extra one is a segment that spells the flag BOTH as a
24+literal and through a template, so r3's literal reader filed it under the
25+literal and it never showed up in the unknown column. All ten are `format!` with
26+an inline captured placeholder; there is no `String::from`/`to_string`/
27+`push_str` shape and no positional-`{}` shape for this flag. The single
28+positional-`{}` site in the file is a different flag
29+(`a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact` uses
30+`u8::from(a.tx_size_search)`, below).
31+
32+Four binding shapes cover all ten:
33+
34+| # | template | binding shapes seen |
35+|---|----------|--------------------|
36+| T1 | `format!("--enable-tx-size-search={txs}")` | `for txs in [0usize, 1]`, `for txs in ["0", "1"]` |
37+| T2 | `format!("--enable-tx-size-search={tx_search}")` | `let tx_search = if attempt % 2 == 0 { "0" } else { "1" };` and the `attempt == 0` variant |
38+| T3 | `format!("--enable-tx-size-search={tx_search}")` | `for (tx_search, bit_depth) in [("1", 8u8), ("0", 8u8), ("1", 10u8)]` (tuple-destructured loop) |
39+| T4 | `format!("--enable-tx-size-search={}", u8::from(a.tx_size_search))` | positional arg; value from a struct-literal arm table's `tx_size_search: true/false` rows |
40+| T5 | `for (tag, cq, w, h, ten_bit, vert, tx_search) in arms` + `args.push(if tx_search { "…=1" } else { "…=0" })` | **not** a template — both literals are spelled, so the literal reader saw it. Listed because it is the same tool and was in the "both values" column. |
41+
42+## 2. The binding table
43+
44+`gate` = the census `#[`-segment name, `use site` = the template's shape, `bound
45+value` = what the resolver reads from the gate's own text, `evidence` = the
46+literal source line the binding came from.
47+
48+| gate | use site | bound value | evidence |
49+|------|----------|-------------|----------|
50+| `a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact` | T1 | `0` and `1` | `stream.rs:9437` `for txs in [0usize, 1] {` |
51+| `a_coded_rect_intrabc_block_reconstructs_in_both_orientations` | T1 | `0` and `1` | `stream.rs:10901` `for txs in ["0", "1"] {` — this is the segment that ALSO spells the flag literally, which is why r3 counted 9 not 10 |
52+| `a_real_aomenc_inter_sequence_with_temporal_mv_candidates_decodes_pixel_exact` | T2 | `0` and `1` | `stream.rs:19665` `let tx_search = if attempt % 2 == 0 { "0" } else { "1" };` |
53+| `a_real_aomenc_inter_sequence_with_a_coded_rectangular_residual_decodes_pixel_exact` | T2 | `0` and `1` | same line shape, own segment |
54+| `a_real_aomenc_inter_sequence_with_a_16_level_rect_leaf_decodes_pixel_exact` | T2 | `0` and `1` | same line shape, own segment |
55+| `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact` | T2 | `0` and `1` | same line shape, own segment |
56+| `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact` | T2 | `0` and `1` | same line shape, own segment |
57+| `a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact` | T4 | `0` and `1` | `stream.rs:26084`+ `tx_size_search: false` rows and `:26150`+ `tx_size_search: true` rows in the arm table |
58+| `a_real_aomenc_stream_with_filter_intra_on_a_sub8_rect_leaf_decodes_pixel_exact` | T3 | `0` and `1` | `stream.rs:31131` `for (tx_search, bit_depth) in [("1", 8u8), ("0", 8u8), ("1", 10u8)]` |
59+| `a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact` | T1 | `0` and `1` | `stream.rs:39945` `for tx_search in [0usize, 1] {` |
60+
61+**Not one of the ten is genuinely runtime-dependent on an unknown argument.**
62+Every binding is a literal `0`/`1` (or a `bool` that becomes one) enumerated in
63+the gate's own text. Each of the ten therefore builds BOTH a `=0` and a `=1`
64+stream on some attempt, so each is an ON gate under this file's standing "any
65+spelling that says on wins" rule.
66+
67+## 3. The true counts
68+
69+`cargo test -p ec-av1 --lib gate_coverage::tests::print_tx_size_search_census -- --nocapture`:
70+
71+```
72+enable-tx-size-search over 230 census-selected gate bodies:
73+ =0 only 86, =1 only 13, both 17, unresolvable 0, not named 114
74+```
75+
76+- **unresolvable: 0 of 230 (0.0%)** — the detector now classifies every body
77+ that names the flag in any form. That is the headline: the floor is a
78+ measurement.
79+- Gates naming the flag at all: 116 of 230 (50.4%). The remaining 114 leave it
80+ off the command line, which under the "defaulted means unknown" rule stays
81+ unknown and retires nothing.
82+- Of the 116: 86 reach only `0`, 13 reach only `1`, **17 reach both** (the ten
83+ template gates plus seven that spell both literals in one segment).
84+- Net: 30 gates positively enable the tool, versus the 15 the literal-only
85+ reader saw. r3's "88 `=0`, 15 `=1`, 9 unknown" is superseded in both
86+ directions — the `=0` count falls (a gate whose other arm is `=1` is not an
87+ "off" gate) and the `=1` count doubles.
88+
89+The count now lives in a test, not a comment, and the test asserts
90+`unresolvable == 0`, so a new helper-parameter blind spot of this shape fails
91+loudly instead of quietly restoring a floor.
92+
93+### The detector change
94+
95+`spelling_values` (new) merges literal `--flag=<digit>` spellings with every
96+value a `format!` template resolves to; `bound_values` (new) does the binding
97+resolution over the four shapes; `resolved_on_state` (new) replaces
98+`default_on_state`, which is deleted (it became dead — the clean cutover, no
99+shim left behind). Three details that are load-bearing:
100+
101+- **Quoted-only for `let` bindings.** A `let tx_search = if attempt % 2 == 0 { "0" } else { "1" };`
102+ initializer contains the bare integer `2`; reading it as a flag value would
103+ invent an ON.
104+- **Position-aware for tuple loops.** `for (tx_search, bit_depth) in [("1", 8u8), …]`
105+ must read only column 0 — the bit-depth column (`8`, `10`) is not a flag value.
106+- **Typed-literal suffixes.** `0usize`/`8u8`/`1u32` are single tokens; a
107+ `bare_digits` that rejected them would have missed `for txs in [0usize, 1]`
108+ and filed the palette gate as `=1` only. Multi-digit `10u8` is still rejected.
109+
110+## 4. RED-BEFORE, both directions
111+
112+Both mutations below were applied to the detector, run, and reverted; the
113+working tree after revert is byte-identical to the pre-mutation file
114+(`diff` clean), and all 12 `gate_coverage` tests are green.
115+
116+**Direction 1 — a mutated `format!` value must MOVE the classification.**
117+Mutating the template needle so the resolver cannot see
118+(`format!("--{spelling}=DISABLED{spelling}=")`) reds **two** tests:
119+
120+- `the_resolver_binds_a_format_built_flag_in_both_directions`: the palette gate
121+ resolves to `{}` instead of `{'0','1'}`.
122+- `print_tx_size_search_census`: `unresolvable 9` (not 0), and the split
123+ degrades to `=0 only 86, =1 only 13, both 8` — 9 of the 17 both-value gates
124+ silently become "not named", which is precisely the old behaviour.
125+
126+The same test also mutates the GATE side: for each of three template shapes it
127+takes the real gate body, rewrites only the bound value
128+(`[0usize, 1]`→`[0usize, 0]`, `"1"`→`"0"` in the else arm, the tuple table's
129+`"1"`→`"0"`), and asserts the resolved set moved from `{'0','1'}` to `{'0'}`.
130+Without that half, a resolver that ignored the binding and returned a constant
131+would pass.
132+
133+**Direction 2 — a spelling the old detector already saw must STILL classify.**
134+Mutating the literal needle instead (`"--DISABLED{spelling}="`) reds **four**:
135+the two `never_on_*_matches_the_gate_recipes` tests (every tool drops to
136+"never on"), `print_tx_size_search_census` (`=0 only 0, =1 only 0`), and the
137+same resolver test, which walks every gate that literally spells
138+`--enable-tx-size-search=1` and asserts each is still classified on, with a
139+floor of 10 such gates so the walk cannot pass vacuously. The new arm is
140+additive over the old one; a resolver that replaced rather than extended the
141+literal path fails here.
142+
143+## 5. The entry decision: RETIRED
144+
145+The tool is exercised by a gate that **asserts the parsed tx-size-search
146+behaviour**, not merely spells it:
147+
148+`a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
149+spells `--enable-tx-size-search=1` as a literal and hard-asserts
150+`compared_tx_depths > 0` with the message *"never produced a nonzero tx depth on
151+a compared attempt — the flag did not arrive"*. `tx_depth` is read **only**
152+under the frame header's `tx_mode_select` bit (spec 5.11.16; `decode.rs` guards
153+the read with `tx_select_inter`), so a nonzero `TX_DEPTH_HITS` delta IS the
154+parsed tx-size-search behaviour, not a proxy for it.
155+
156+**Measured run of that gate on this tree** (oracle aom `v3.13.3-7-g9bb526a`,
157+one named test, 3.9 s):
158+
159+```
160+12 pixel-exact decodes (0 named refusals out of 12 attempts, 6 of the matches 10-bit),
161+rect coefficient TUs on compared attempts: 219 (10 of them a 1D tx class);
162+flag arrival: rect partitions 120, tx depths 53, 1D-class (square) transforms 13
163+```
164+
165+`tx depths 53` on compared attempts, and 6 of the 12 pixel-exact matches are
166+10-bit — so the tool is exercised at **both** depths and the assertion is not
167+vacuous.
168+
169+The stronger witness, cited in the entry as well:
170+`tx_select_inter_gate` (behind
171+`a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact{,_10bit}`)
172+**deliberately omits** the flag — its recipe carries the comment
173+`// DELIBERATELY ABSENT: --enable-tx-size-search=0.` — and asserts
174+`decode::txfm_split_hits()` moved, i.e. that spec 5.11.17's recursive
175+`txfm_split` var-tx tree was read. An inter transform is then a split tree
176+rather than one whole-block transform, which is the entire content of the tool.
177+That gate's own doc says an unfired gate is a vacuous gate: it panics if no
178+attempt takes a split.
179+
180+### In-file reason text, as landed
181+
182+The `DEFAULT_ON_TOOLS` entry's comment now reads (abridged; full text in the
183+file above `DEFAULT_ON_TOOLS`):
184+
185+> `enable-tx-size-search` SETTLED 2026-09-29 (lane-av1txsearch), by measurement
186+> rather than by a name-shaped guess. The r3 note here said the count was a
187+> FLOOR: 9 gate bodies built the flag into a `format!` variable that neither
188+> `flags_in` nor `settings_in` could see … The method r3 asked for is now
189+> `spelling_values` → `bound_values`, and it resolves all of them;
190+> `print_tx_size_search_census` asserts the unresolvable count is ZERO, so the
191+> floor cannot come back unnoticed.
192+>
193+> THE ENTRY IS RETIRED, on an ARRIVAL ASSERT rather than on the spelling.
194+> `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`
195+> spells `--enable-tx-size-search=1` as a literal and hard-asserts
196+> `compared_tx_depths > 0` … `tx_depth` is read ONLY under the frame header's
197+> `tx_mode_select` bit (spec 5.11.16 …), so a nonzero counter IS the parsed
198+> tx-size-search behaviour, not a proxy for it. Measured run of that gate on
199+> this tree (aom 3.13.3): 12 pixel-exact decodes, 0 named refusals, 6 of the 12
200+> at 10 BIT, 219 rect coefficient TUs on compared attempts, and `flag arrival:
201+> … tx depths 53` …
202+
203+The "all 49" prose count stays deleted, per r2; the module doc now points at
204+the test rather than a number that rots.
205+
206+## What is not claimed
207+
208+- The 114 bodies that leave the flag off the command line stay **unknown**, not
209+ "exercised". The default of `1` is not a stream carrying the tool.
210+- `bound_values` returns `None` when the variable is a shared helper's
211+ parameter (bound at a call site in a different segment). That path is
212+ implemented and reported, not guessed — and today no
213+ `--enable-tx-size-search` site takes it. A future helper-parameter flag will
214+ be counted as unresolvable and will red the census test rather than pass
215+ silently.
216+- No claim is made about any OTHER `DEFAULT_ON_TOOLS` tool's floor. The
217+ resolver is general, so those counts also moved; re-run
218+ `print_never_on_per_bit_depth` to read them. The 8-bit and 10-bit
219+ `NEVER_ON_*` lists are empty on this tree and their tests are green.
220+- No decoder behaviour, counter, gate or fixture changed. `stream.rs` is
221+ untouched.
222+
223+## Test evidence
224+
225+`gate_coverage` module, 12 tests, all green on the final tree:
226+
227+```
228+test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 704 filtered out
229+```
230+
231+Covered by the above: `every_gate_disabling_a_tool_is_a_listed_coverage_hole`,
232+`tool_settings_reads_whole_flags`,
233+`the_detector_sees_the_gates_the_spelling_filter_missed` (r3's, still green),
234+`never_exercised_{8bit,10bit}_matches_the_gate_recipes`,
235+`never_on_{8bit,10bit}_matches_the_gate_recipes`,
236+`default_on_tools_do_not_duplicate_the_universe`, the three print tests, and the
237+two new ones (`print_tx_size_search_census`,
238+`the_resolver_binds_a_format_built_flag_in_both_directions`).