Merge branch 'lane-av1pins5'
Browse files at this commit3 changed files +1381 -8
- crates/ec-av1/src/gate_coverage.rs +779 -0
- crates/ec-av1/src/stream.rs +90 -8
- lanes/av1pins.report.md +512 -0
crates/ec-av1/src/gate_coverage.rsmodified+779 -0
| @@ -1699,3 +1699,782 @@ mod tests { | |||
| 1699 | ); | 1699 | ); |
| 1700 | } | 1700 | } |
| 1701 | } | 1701 | } |
| 1702 | + | ||
| 1703 | +/// lane-av1pins5 r5: the PIN INVENTORY. | ||
| 1704 | +/// | ||
| 1705 | +/// The r3 inventory this replaces matched only two call shapes -- | ||
| 1706 | +/// `crate_pin("X")` and `pin_dir().join("X")` -- both SINGLE-NAME. A gate that | ||
| 1707 | +/// reads a whole DIRECTORY of pins through a `concat!` literal and then formats | ||
| 1708 | +/// a name at runtime (`format!("{fixtures}/{n}.obu")`) matched neither, so | ||
| 1709 | +/// `pinned_warp_stream_decodes_pixel_exact` and its 14 uncommitted pins were | ||
| 1710 | +/// invisible to it, and r3 reported "the machine-local-pin population is zero". | ||
| 1711 | +/// It was not. This enumerator resolves all four shapes. | ||
| 1712 | +/// | ||
| 1713 | +/// Ownership, stated because two lanes touch this: THIS scanner owns the | ||
| 1714 | +/// ENUMERATION (which gates read which pins, from source). The fixture-preflight | ||
| 1715 | +/// lane owns the FILE INVENTORY on a runner (does each referenced path exist on | ||
| 1716 | +/// the box). Different questions; both must agree, and this one is the stricter of | ||
| 1717 | +/// the two because it fails on an uncommitted pin whether or not some runner | ||
| 1718 | +/// happens to have a copy. | ||
| 1719 | +#[cfg(test)] | ||
| 1720 | +mod pin_inventory { | ||
| 1721 | + /// One pin a gate reads, and where it came from. | ||
| 1722 | + pub struct PinRead { | ||
| 1723 | + pub gate: String, | ||
| 1724 | + pub file: String, | ||
| 1725 | + pub shape: &'static str, | ||
| 1726 | + } | ||
| 1727 | + | ||
| 1728 | + /// Split `src` into `(fn_name, body)` for every `fn name(` at the gate indent. | ||
| 1729 | + fn gate_bodies(src: &str) -> Vec<(String, &'static str)> { | ||
| 1730 | + let mut out = Vec::new(); | ||
| 1731 | + let mut cur: Option<(String, usize)> = None; | ||
| 1732 | + for (i, line) in src.lines().enumerate() { | ||
| 1733 | + let t = line.trim_start(); | ||
| 1734 | + if let Some(rest) = t.strip_prefix("fn ") { | ||
| 1735 | + if let Some(name) = rest.split('(').next() { | ||
| 1736 | + if !name.contains(' ') { | ||
| 1737 | + cur = Some((name.to_string(), i)); | ||
| 1738 | + } | ||
| 1739 | + } | ||
| 1740 | + } | ||
| 1741 | + // A `#[test]`/`#[ignore]` line is never a closing brace, so the fn | ||
| 1742 | + // ends at the first line that is exactly four-space `}`. | ||
| 1743 | + if let Some((name, start)) = &cur { | ||
| 1744 | + if i > *start && line == " }" { | ||
| 1745 | + let body = src | ||
| 1746 | + .lines() | ||
| 1747 | + .skip(*start) | ||
| 1748 | + .take(i - *start + 1) | ||
| 1749 | + .collect::<Vec<_>>() | ||
| 1750 | + .join("\n"); | ||
| 1751 | + out.push((name.clone(), &*Box::leak(body.into_boxed_str()))); | ||
| 1752 | + cur = None; | ||
| 1753 | + } | ||
| 1754 | + } | ||
| 1755 | + } | ||
| 1756 | + out | ||
| 1757 | + } | ||
| 1758 | + | ||
| 1759 | + /// Every pin every gate reads, across all four shapes. | ||
| 1760 | + pub fn pins_read(src: &str) -> Vec<PinRead> { | ||
| 1761 | + let mut out = Vec::new(); | ||
| 1762 | + for (gate, body) in gate_bodies(src) { | ||
| 1763 | + // (a) crate_pin("X") and (b) pin_dir().join("X") -- single name. | ||
| 1764 | + for m in body.match_indices("crate_pin(\"") { | ||
| 1765 | + let rest = &body[m.0 + 11..]; | ||
| 1766 | + if let Some(e) = rest.find('"') { | ||
| 1767 | + out.push(PinRead { | ||
| 1768 | + gate: gate.clone(), | ||
| 1769 | + file: rest[..e].to_string(), | ||
| 1770 | + shape: "crate_pin", | ||
| 1771 | + }); | ||
| 1772 | + } | ||
| 1773 | + } | ||
| 1774 | + for m in body.match_indices("pin_dir().join(\"") { | ||
| 1775 | + let rest = &body[m.0 + 16..]; | ||
| 1776 | + if let Some(e) = rest.find('"') { | ||
| 1777 | + out.push(PinRead { | ||
| 1778 | + gate: gate.clone(), | ||
| 1779 | + file: rest[..e].to_string(), | ||
| 1780 | + shape: "pin_dir_machine_local", | ||
| 1781 | + }); | ||
| 1782 | + } | ||
| 1783 | + } | ||
| 1784 | + // (c) a whole-file concat! literal to a named pin: | ||
| 1785 | + // concat!(env!("CARGO_MANIFEST_DIR"), "/../../fixtures/X.obu") | ||
| 1786 | + for m in body.match_indices("/../../fixtures/") { | ||
| 1787 | + let rest = &body[m.0 + 16..]; | ||
| 1788 | + if let Some(e) = rest.find('"') { | ||
| 1789 | + out.push(PinRead { | ||
| 1790 | + gate: gate.clone(), | ||
| 1791 | + file: rest[..e].to_string(), | ||
| 1792 | + shape: "concat_literal_machine_local", | ||
| 1793 | + }); | ||
| 1794 | + } | ||
| 1795 | + } | ||
| 1796 | + // (d) the shape that hid 14 pins: a DIRECTORY literal bound to a | ||
| 1797 | + // local, plus a runtime `format!("{var}/{n}.ext")` over a | ||
| 1798 | + // literal name array. Resolve the array's names. | ||
| 1799 | + for (vi, line) in body.lines().enumerate() { | ||
| 1800 | + let tl = line.trim(); | ||
| 1801 | + // `let fixtures = concat!(env!("CARGO_MANIFEST_DIR"), "/../../fixtures");` | ||
| 1802 | + // -> the bound name is whatever sits between `let ` and the `=`. | ||
| 1803 | + let var = match ( | ||
| 1804 | + tl.find("concat!(env!(\"CARGO_MANIFEST_DIR\"), \"/../../fixtures\")"), | ||
| 1805 | + tl.find('='), | ||
| 1806 | + ) { | ||
| 1807 | + (Some(a), Some(eq)) if eq < a => tl[4..eq].trim().to_string(), | ||
| 1808 | + _ => continue, | ||
| 1809 | + }; | ||
| 1810 | + if var.is_empty() { | ||
| 1811 | + continue; | ||
| 1812 | + } | ||
| 1813 | + // `format!("{fixtures}/{n}.obu")` -- built by concatenation, not | ||
| 1814 | + // by `format!`: escaping `{{`/`}}` to emit literal braces here is | ||
| 1815 | + // exactly the bug that made this shape resolve to 0 pins on the | ||
| 1816 | + // first run of the scanner. | ||
| 1817 | + let marker = ["format!(\"", "{", &var, "}/{n}"].concat(); | ||
| 1818 | + let Some(pos) = body.find(&marker) else { | ||
| 1819 | + continue; | ||
| 1820 | + }; | ||
| 1821 | + // Walk back from the format! to the `[ ... ].iter()` array and | ||
| 1822 | + // take every quoted name in it. | ||
| 1823 | + let head = &body[..pos]; | ||
| 1824 | + let Some(bracket) = head.rfind('[') else { | ||
| 1825 | + continue; | ||
| 1826 | + }; | ||
| 1827 | + let names: Vec<String> = head[bracket..] | ||
| 1828 | + .split('"') | ||
| 1829 | + .skip(1) | ||
| 1830 | + .step_by(2) | ||
| 1831 | + .filter(|s| !s.is_empty() && !s.contains(' ') && *s != "]") | ||
| 1832 | + .map(|s| s.to_string()) | ||
| 1833 | + .collect(); | ||
| 1834 | + // `.obu` -- SLICE up to the closing quote. (Stringifying the | ||
| 1835 | + // `find` index instead produced names like `warp-mismatch4`.) | ||
| 1836 | + let tail = &body[pos + marker.len()..]; | ||
| 1837 | + let ext = tail | ||
| 1838 | + .find('"') | ||
| 1839 | + .map(|e| tail[..e].to_string()) | ||
| 1840 | + .unwrap_or_default(); | ||
| 1841 | + for n in names { | ||
| 1842 | + out.push(PinRead { | ||
| 1843 | + gate: gate.clone(), | ||
| 1844 | + file: format!("{n}{ext}"), | ||
| 1845 | + shape: "concat_dir_runtime_name", | ||
| 1846 | + }); | ||
| 1847 | + } | ||
| 1848 | + let _ = vi; | ||
| 1849 | + } | ||
| 1850 | + // (e) the shape this very fix INTRODUCED: | ||
| 1851 | + // `.map(|n| crate_pin(&format!("{n}.obu")))`. Rewriting the | ||
| 1852 | + // directory literal as a committed-path lookup made the gate | ||
| 1853 | + // correct and simultaneously invisible -- `crate_pin("` no | ||
| 1854 | + // longer appears, so shape (a) found nothing and the | ||
| 1855 | + // enumerator reported a CLEAN tree while 14 pins were read. A | ||
| 1856 | + // false pass is worse than the original gap: the original at | ||
| 1857 | + // least showed up in a filesystem audit. Caught here by the | ||
| 1858 | + // `reads.len()` floor in the invariant test. | ||
| 1859 | + for m in body.match_indices("crate_pin(&format!(") { | ||
| 1860 | + let rest = &body[m.0 + 19..]; | ||
| 1861 | + let Some(close) = rest.find(')') else { | ||
| 1862 | + continue; | ||
| 1863 | + }; | ||
| 1864 | + let call = &rest[..close]; | ||
| 1865 | + if !call.contains('"') { | ||
| 1866 | + continue; | ||
| 1867 | + } | ||
| 1868 | + let head = &body[..m.0]; | ||
| 1869 | + let Some(bracket) = head.rfind('[') else { | ||
| 1870 | + continue; | ||
| 1871 | + }; | ||
| 1872 | + let names: Vec<String> = head[bracket..] | ||
| 1873 | + .split('"') | ||
| 1874 | + .skip(1) | ||
| 1875 | + .step_by(2) | ||
| 1876 | + .filter(|x| !x.is_empty() && !x.contains(' ') && *x != "]") | ||
| 1877 | + .map(|x| x.to_string()) | ||
| 1878 | + .collect(); | ||
| 1879 | + // the literal inside the format!, e.g. `{n}.obu` | ||
| 1880 | + let lit = call.split('"').nth(1).unwrap_or(""); | ||
| 1881 | + let ext = lit | ||
| 1882 | + .split_once("}") | ||
| 1883 | + .map(|(_, e)| e.to_string()) | ||
| 1884 | + .unwrap_or_default(); | ||
| 1885 | + for n in names { | ||
| 1886 | + out.push(PinRead { | ||
| 1887 | + gate: gate.clone(), | ||
| 1888 | + file: format!("{n}{ext}"), | ||
| 1889 | + shape: "crate_pin_runtime_name", | ||
| 1890 | + }); | ||
| 1891 | + } | ||
| 1892 | + } | ||
| 1893 | + } | ||
| 1894 | + out | ||
| 1895 | + } | ||
| 1896 | + | ||
| 1897 | + /// Does this shape resolve through `crate_pin`, i.e. the COMMITTED | ||
| 1898 | + /// crate-local copy? Both the literal form and the runtime-name form do -- | ||
| 1899 | + /// only the two `pin_dir`/root-`concat!` forms are machine-local. | ||
| 1900 | + pub fn resolves_committed(shape: &str) -> bool { | ||
| 1901 | + matches!(shape, "crate_pin" | "crate_pin_runtime_name") | ||
| 1902 | + } | ||
| 1903 | + | ||
| 1904 | + /// Is `file` present as a committed crate-local fixture? | ||
| 1905 | + pub fn is_committed(file: &str) -> bool { | ||
| 1906 | + std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 1907 | + .join("fixtures") | ||
| 1908 | + .join(file) | ||
| 1909 | + .is_file() | ||
| 1910 | + } | ||
| 1911 | +} | ||
| 1912 | + | ||
| 1913 | +#[cfg(test)] | ||
| 1914 | +mod pin_inventory_tests { | ||
| 1915 | + use super::pin_inventory::{is_committed, pins_read}; | ||
| 1916 | + | ||
| 1917 | + /// The scanner must be able to SEE the directory-literal shape. Run over a | ||
| 1918 | + /// SYNTHETIC source, not the live tree: r5 removed that shape from | ||
| 1919 | + /// `pinned_warp_stream_decodes_pixel_exact`, so a test that asserted it | ||
| 1920 | + /// against the live file would rot the moment the fix landed -- which is | ||
| 1921 | + /// precisely how a scanner loses its edge and reports a clean tree again. | ||
| 1922 | + /// A capability test must have its own input. | ||
| 1923 | + #[test] | ||
| 1924 | + fn the_pin_scanner_sees_the_directory_literal_shape() { | ||
| 1925 | + let synthetic = r#" | ||
| 1926 | + #[test] | ||
| 1927 | + fn a_gate_using_the_old_shape() { | ||
| 1928 | + let fixtures = concat!(env!("CARGO_MANIFEST_DIR"), "/../../fixtures"); | ||
| 1929 | + let paths: Vec<String> = match std::env::var("EC_AV1_GATE_DUMP_PIN") { | ||
| 1930 | + Ok(p) => vec![p], | ||
| 1931 | + Err(_) => [ | ||
| 1932 | + "warp-mismatch", | ||
| 1933 | + "ii-flake-1", | ||
| 1934 | + "rect-flake-3", | ||
| 1935 | + ] | ||
| 1936 | + .iter() | ||
| 1937 | + .map(|n| format!("{fixtures}/{n}.obu")) | ||
| 1938 | + .collect(), | ||
| 1939 | + }; | ||
| 1940 | + for path in paths { | ||
| 1941 | + check(&path); | ||
| 1942 | + } | ||
| 1943 | + } | ||
| 1944 | +"#; | ||
| 1945 | + let reads = pins_read(synthetic); | ||
| 1946 | + let names: Vec<&str> = reads.iter().map(|r| r.file.as_str()).collect(); | ||
| 1947 | + assert_eq!( | ||
| 1948 | + names, | ||
| 1949 | + vec!["warp-mismatch.obu", "ii-flake-1.obu", "rect-flake-3.obu"], | ||
| 1950 | + "the directory-literal + runtime-name shape resolved to {names:?} -- a scanner \ | ||
| 1951 | + that cannot see this shape is how 14 uncommitted pins survived three rounds" | ||
| 1952 | + ); | ||
| 1953 | + assert!( | ||
| 1954 | + reads.iter().all(|r| r.shape == "concat_dir_runtime_name"), | ||
| 1955 | + "the synthetic pins were attributed to the wrong shape: {:?}", | ||
| 1956 | + reads.iter().map(|r| r.shape).collect::<Vec<_>>() | ||
| 1957 | + ); | ||
| 1958 | + } | ||
| 1959 | + | ||
| 1960 | + /// The other three shapes resolve too -- same reasoning, same synthetic input, | ||
| 1961 | + /// so the capability survives the tree being fixed. | ||
| 1962 | + #[test] | ||
| 1963 | + fn the_pin_scanner_sees_every_shape() { | ||
| 1964 | + let synthetic = r#" | ||
| 1965 | + #[test] | ||
| 1966 | + fn shapes() { | ||
| 1967 | + let a = crate_pin("golden3-pin.obu"); | ||
| 1968 | + let b = pin_dir().join("sbpart-pin.obu"); | ||
| 1969 | + let c = std::fs::read(concat!(env!("CARGO_MANIFEST_DIR"), "/../../fixtures/x.obu")); | ||
| 1970 | + } | ||
| 1971 | +"#; | ||
| 1972 | + let mut names: Vec<String> = pins_read(synthetic) | ||
| 1973 | + .iter() | ||
| 1974 | + .map(|r| format!("{}|{}", r.file, r.shape)) | ||
| 1975 | + .collect(); | ||
| 1976 | + names.sort(); | ||
| 1977 | + assert_eq!( | ||
| 1978 | + names, | ||
| 1979 | + vec![ | ||
| 1980 | + "golden3-pin.obu|crate_pin", | ||
| 1981 | + "sbpart-pin.obu|pin_dir_machine_local", | ||
| 1982 | + "x.obu|concat_literal_machine_local", | ||
| 1983 | + ], | ||
| 1984 | + "shape coverage changed: {names:?}" | ||
| 1985 | + ); | ||
| 1986 | + } | ||
| 1987 | + | ||
| 1988 | + /// THE INVARIANT, on the live tree: every pin a gate reads is a COMMITTED | ||
| 1989 | + /// crate-local copy, and NO gate reads through a machine-local shape. This is | ||
| 1990 | + /// the check the r3 manifest could not express. | ||
| 1991 | + #[test] | ||
| 1992 | + fn every_pin_a_gate_reads_is_committed_under_the_crate() { | ||
| 1993 | + let src = include_str!("stream.rs"); | ||
| 1994 | + let reads = pins_read(src); | ||
| 1995 | + assert!( | ||
| 1996 | + reads.len() >= 20, | ||
| 1997 | + "the enumerator found only {} pin reads in stream.rs -- it has lost a shape, \ | ||
| 1998 | + which is the failure mode that let 14 pins go unseen", | ||
| 1999 | + reads.len() | ||
| 2000 | + ); | ||
| 2001 | + let uncommitted: Vec<String> = reads | ||
| 2002 | + .iter() | ||
| 2003 | + .filter(|r| !is_committed(&r.file)) | ||
| 2004 | + .map(|r| format!("{}:{} ({})", r.gate, r.file, r.shape)) | ||
| 2005 | + .collect(); | ||
| 2006 | + assert!( | ||
| 2007 | + uncommitted.is_empty(), | ||
| 2008 | + "{} pin(s) a gate reads have no committed copy under \ | ||
| 2009 | + crates/ec-av1/fixtures/ -- each resolves only on a machine whose \ | ||
| 2010 | + gitignored root fixtures/ happens to be populated, so a clean checkout \ | ||
| 2011 | + silently skips or panics:\n {}", | ||
| 2012 | + uncommitted.len(), | ||
| 2013 | + uncommitted.join("\n ") | ||
| 2014 | + ); | ||
| 2015 | + let machine_local: Vec<String> = reads | ||
| 2016 | + .iter() | ||
| 2017 | + .filter(|r| !super::pin_inventory::resolves_committed(r.shape)) | ||
| 2018 | + .map(|r| format!("{} reads {} via {}", r.gate, r.file, r.shape)) | ||
| 2019 | + .collect(); | ||
| 2020 | + assert!( | ||
| 2021 | + machine_local.is_empty(), | ||
| 2022 | + "{} pin read(s) still resolve through a machine-local shape instead of \ | ||
| 2023 | + `crate_pin` (the committed crate-local copy), so they break on a clean \ | ||
| 2024 | + checkout:\n {}", | ||
| 2025 | + machine_local.len(), | ||
| 2026 | + machine_local.join("\n ") | ||
| 2027 | + ); | ||
| 2028 | + } | ||
| 2029 | +} | ||
| 2030 | + | ||
| 2031 | +/// lane-av1pins5 r5: the COUNT-VACUITY enumerator. | ||
| 2032 | +/// | ||
| 2033 | +/// Passing OUR OWN decode's length as the ORACLE's expected frame count | ||
| 2034 | +/// (`ffmpeg_decode_sequence(&stream, w, h, ours.len())`) is a real defect, but | ||
| 2035 | +/// NOT the one r4 claimed. MEASURED, by calling | ||
| 2036 | +/// `ffmpeg_decode_sequence(&stream, 192, 128, 0)` on a real pinned stream under | ||
| 2037 | +/// `catch_unwind`: it PANICS at `stream.rs:5110` with | ||
| 2038 | +/// `expected 0 4:2:0 frames, ffmpeg said: `. The helper asserts | ||
| 2039 | +/// `out.stdout.len() == frame_bytes * frames` unconditionally, so a wrong count | ||
| 2040 | +/// cannot pass silently -- it reds, with a message that blames FFMPEG for a | ||
| 2041 | +/// count OUR decoder chose. | ||
| 2042 | +/// | ||
| 2043 | +/// TWO DEFECT CLASSES, DO NOT CONFLATE THEM (lane-av1pins5 r6): | ||
| 2044 | +/// * MISATTRIBUTED RED -- a wrong count reds, and the old message blamed | ||
| 2045 | +/// ffmpeg for a number OUR decoder chose. This is what these sites are. | ||
| 2046 | +/// `ffmpeg_decode_sequence`'s `stdout.len() == frame_bytes * frames` assert | ||
| 2047 | +/// is unconditional, so it cannot pass silently. | ||
| 2048 | +/// * SILENT PASS -- the compare is skipped or truncated and the gate reports | ||
| 2049 | +/// green. A DIFFERENT defect with a DIFFERENT fix, and r4 mislabelled these | ||
| 2050 | +/// sites as belonging to it. If you are reading this to decide what to fix, | ||
| 2051 | +/// fix the message and the count SOURCE; do not go looking for a silent pass. | ||
| 2052 | +/// | ||
| 2053 | +/// r4 reported this shape as "a vacuous pass" and told Main so. That was wrong. | ||
| 2054 | +/// The consequence is a MISATTRIBUTED RED. The fix r4 shipped is still right (the | ||
| 2055 | +/// count now comes from the fixture, so the red names the real cause), but the | ||
| 2056 | +/// justification was wrong, and a sweep that repeats it would send the next | ||
| 2057 | +/// reader after a silent-pass bug that does not exist. | ||
| 2058 | +/// | ||
| 2059 | +/// This enumerator finds every such site and classifies it, so the class is | ||
| 2060 | +/// visible and cannot shrink unnoticed. | ||
| 2061 | +#[cfg(test)] | ||
| 2062 | +mod count_vacuity { | ||
| 2063 | + /// One oracle call whose expected frame count is locally derived. | ||
| 2064 | + pub struct Site { | ||
| 2065 | + pub line: usize, | ||
| 2066 | + pub gate: String, | ||
| 2067 | + pub count_expr: String, | ||
| 2068 | + /// An independent count assertion on the same binding, within a few | ||
| 2069 | + /// lines above: that is what makes the count a SPEC rather than a | ||
| 2070 | + /// self-fulfilling number. | ||
| 2071 | + pub pinned_by: Option<String>, | ||
| 2072 | + /// Does this gate actually COMPARE PIXELS (so a wrong count would | ||
| 2073 | + /// corrupt a verdict), or is it a report-only probe? | ||
| 2074 | + pub pixel_comparing: bool, | ||
| 2075 | + /// The fix bucket, by READING the gate (r7). `Some(b)` where | ||
| 2076 | + /// a = pinned stream on disk -> take the count from the PIN | ||
| 2077 | + /// b = live aomenc encode -> take it from the ENCODE's frame count; | ||
| 2078 | + /// our decode's length is the thing | ||
| 2079 | + /// UNDER TEST and must never be the | ||
| 2080 | + /// expected value | ||
| 2081 | + /// c = census/probe -> report only, never fix | ||
| 2082 | + /// `None` = could not classify, and the reason is in `bucket_reason`. | ||
| 2083 | + pub bucket: Option<&'static str>, | ||
| 2084 | + pub bucket_reason: String, | ||
| 2085 | + /// The numeric frame count found in this gate's own encode call, when | ||
| 2086 | + /// one is visible -- the value the compare should assert instead. | ||
| 2087 | + pub candidate: Option<String>, | ||
| 2088 | + /// A frame count already in scope that is a SPEC rather than a | ||
| 2089 | + /// self-fulfilling number -- e.g. the `FRAMES` the gate encoded, or a | ||
| 2090 | + /// count asserted on the pinned stream. `Some(..)` means the fix is a | ||
| 2091 | + /// one-line swap at this site. | ||
| 2092 | + pub fixable_from: Option<String>, | ||
| 2093 | + } | ||
| 2094 | + | ||
| 2095 | + /// A census/probe/diagnostic gate: it reports, it does not assert a verdict. | ||
| 2096 | + fn is_probe(gate: &str) -> bool { | ||
| 2097 | + [ | ||
| 2098 | + "census", | ||
| 2099 | + "probe", | ||
| 2100 | + "sweep", | ||
| 2101 | + "first_diff", | ||
| 2102 | + "scratch", | ||
| 2103 | + "rectx", | ||
| 2104 | + "diagnostic", | ||
| 2105 | + ] | ||
| 2106 | + .iter() | ||
| 2107 | + .any(|m| gate.contains(m)) | ||
| 2108 | + } | ||
| 2109 | + | ||
| 2110 | + /// Encode helpers a gate can drive INDIRECTLY. The r7 extraction found 21 of | ||
| 2111 | + /// the 25 bucket-b gates encode through one of these, not through | ||
| 2112 | + /// `aomenc_path()` directly -- which is why a first pass that only looked for | ||
| 2113 | + /// `aomenc_path()` classified 6 gates "unclassified" that plainly encode. | ||
| 2114 | + fn enc_helpers(body: &str) -> Vec<&'static str> { | ||
| 2115 | + const NAMES: &[&str] = &[ | ||
| 2116 | + "encode_aomenc_stream", | ||
| 2117 | + "screen_intrabc_stream_at_depth", | ||
| 2118 | + "screen_intrabc_stream_with", | ||
| 2119 | + "libaom_encode_with", | ||
| 2120 | + "libaom_encode", | ||
| 2121 | + "run_multi_tile_gate", | ||
| 2122 | + "edge32_gate", | ||
| 2123 | + "rect_tx_tool_gate", | ||
| 2124 | + "the_chroma_rect_gates", | ||
| 2125 | + "restore_gate", | ||
| 2126 | + "cdef_gate", | ||
| 2127 | + "warp_gate", | ||
| 2128 | + "superres_gate", | ||
| 2129 | + "grain_gate", | ||
| 2130 | + "sgate", | ||
| 2131 | + ]; | ||
| 2132 | + NAMES | ||
| 2133 | + .iter() | ||
| 2134 | + .copied() | ||
| 2135 | + .filter(|n| body.contains(&format!("{n}("))) | ||
| 2136 | + .collect() | ||
| 2137 | + } | ||
| 2138 | + | ||
| 2139 | + pub fn sites(src: &str) -> Vec<Site> { | ||
| 2140 | + let mut out = Vec::new(); | ||
| 2141 | + let lines: Vec<&str> = src.lines().collect(); | ||
| 2142 | + // LINE index -> BYTE offset. The body walk indexes `src.as_bytes()`, so | ||
| 2143 | + // handing it a line number walks from the wrong place entirely and every | ||
| 2144 | + // body-dependent classification reads "unclassified". Same bug I hit in | ||
| 2145 | + // the Python classifier one step earlier. | ||
| 2146 | + let mut offsets: Vec<usize> = Vec::with_capacity(lines.len()); | ||
| 2147 | + { | ||
| 2148 | + let mut o = 0usize; | ||
| 2149 | + for l in &lines { | ||
| 2150 | + offsets.push(o); | ||
| 2151 | + o += l.len() + 1; | ||
| 2152 | + } | ||
| 2153 | + } | ||
| 2154 | + let mut gate = String::new(); | ||
| 2155 | + let mut fn_start = 0usize; | ||
| 2156 | + for (i, line) in lines.iter().enumerate() { | ||
| 2157 | + let t = line.trim_start(); | ||
| 2158 | + if let Some(rest) = t.strip_prefix("fn ") { | ||
| 2159 | + if let Some(n) = rest.split('(').next() { | ||
| 2160 | + if !n.contains(' ') { | ||
| 2161 | + gate = n.to_string(); | ||
| 2162 | + fn_start = offsets[i]; | ||
| 2163 | + } | ||
| 2164 | + } | ||
| 2165 | + } | ||
| 2166 | + for callee in [ | ||
| 2167 | + "ffmpeg_decode_sequence(", | ||
| 2168 | + "ffmpeg_decode_sequence_10bit(", | ||
| 2169 | + "ffmpeg_decode_sequence_444(", | ||
| 2170 | + ] { | ||
| 2171 | + let Some(at) = line.find(callee) else { | ||
| 2172 | + continue; | ||
| 2173 | + }; | ||
| 2174 | + let args = &line[at + callee.len()..]; | ||
| 2175 | + // DEPTH-AWARE close: `args.find(')')` stops at the `)` of | ||
| 2176 | + // `pictures.len()` and truncates the arg list mid-expression, | ||
| 2177 | + // which silently yielded zero sites on the first run. | ||
| 2178 | + let mut depth = 1usize; | ||
| 2179 | + let mut close = None; | ||
| 2180 | + for (k, ch) in args.char_indices() { | ||
| 2181 | + match ch { | ||
| 2182 | + '(' => depth += 1, | ||
| 2183 | + ')' => { | ||
| 2184 | + depth -= 1; | ||
| 2185 | + if depth == 0 { | ||
| 2186 | + close = Some(k); | ||
| 2187 | + break; | ||
| 2188 | + } | ||
| 2189 | + } | ||
| 2190 | + _ => {} | ||
| 2191 | + } | ||
| 2192 | + } | ||
| 2193 | + let Some(close) = close else { continue }; | ||
| 2194 | + let arglist = &args[..close]; | ||
| 2195 | + let last = arglist.rsplit(',').next().unwrap_or("").trim(); | ||
| 2196 | + if !(last.ends_with(".len()") || last.ends_with(".count()")) { | ||
| 2197 | + continue; | ||
| 2198 | + } | ||
| 2199 | + // Is the SAME binding count-asserted against a literal/const | ||
| 2200 | + // within the preceding 12 lines? That is the difference between | ||
| 2201 | + // a spec and a self-fulfilling number. | ||
| 2202 | + let binding = last.trim_end_matches(".len()").trim_end_matches(".count()"); | ||
| 2203 | + // Match the assertion across a LINE BREAK: rustfmt puts | ||
| 2204 | + // assert_eq!( | ||
| 2205 | + // frames.len(), | ||
| 2206 | + // so requiring `assert_eq!(frames.len()` on one line missed | ||
| 2207 | + // every multi-line spelling and inflated the unpinned count. | ||
| 2208 | + let want = format!("{binding}.len()"); | ||
| 2209 | + let mut pinned = None; | ||
| 2210 | + for back in 1..=14usize { | ||
| 2211 | + if i < back { | ||
| 2212 | + break; | ||
| 2213 | + } | ||
| 2214 | + let prev = lines[i - back].trim_start(); | ||
| 2215 | + if !prev.starts_with("assert") || !prev.contains('(') { | ||
| 2216 | + continue; | ||
| 2217 | + } | ||
| 2218 | + // rustfmt splits `assert_eq!(` from its first argument, so | ||
| 2219 | + // the binding is on THIS line or the NEXT one. | ||
| 2220 | + let here = prev.contains(&want); | ||
| 2221 | + let next = lines | ||
| 2222 | + .get(i - back + 1) | ||
| 2223 | + .map(|l| l.trim_start().contains(&want)) | ||
| 2224 | + .unwrap_or(false); | ||
| 2225 | + if here || next { | ||
| 2226 | + pinned = Some(prev.chars().take(60).collect()); | ||
| 2227 | + break; | ||
| 2228 | + } | ||
| 2229 | + } | ||
| 2230 | + // Pixel-comparing? A gate that compares planes is the only | ||
| 2231 | + // place a wrong count corrupts a verdict; a report-only probe | ||
| 2232 | + // just prints. | ||
| 2233 | + // Bound to THIS fn only. Slicing to EOF matched a later gate's | ||
| 2234 | + // `const FRAMES` and its `assert_eq!(got.y`, which reported all | ||
| 2235 | + // 48 sites as pixel-comparing with a spec in scope -- the same | ||
| 2236 | + // over-broad-scope bug the class keeps teaching. | ||
| 2237 | + // Brace-depth walk, not `find("\n }")`: a gate with an | ||
| 2238 | + // early 4-space `}` (a bare block, a `match` arm tail) truncated | ||
| 2239 | + // the slice and made the compare-detection read false. | ||
| 2240 | + // STRING-AWARE brace walk. Counting raw bytes counts a `}` | ||
| 2241 | + // inside a format string as a closing brace, which truncated the | ||
| 2242 | + // body and made every compare-detection read false -- the same | ||
| 2243 | + // trap that made stream.rs look 2 braces short in the first | ||
| 2244 | + // review of this wave. | ||
| 2245 | + let bytes = src.as_bytes(); | ||
| 2246 | + let mut depth = 0i32; | ||
| 2247 | + let mut started = false; | ||
| 2248 | + let mut fn_end = src.len(); | ||
| 2249 | + let mut in_str = false; | ||
| 2250 | + let mut in_line_comment = false; | ||
| 2251 | + let mut k = fn_start; | ||
| 2252 | + while k < bytes.len() { | ||
| 2253 | + let c = bytes[k]; | ||
| 2254 | + if in_line_comment { | ||
| 2255 | + if c == b'\n' { | ||
| 2256 | + in_line_comment = false; | ||
| 2257 | + } | ||
| 2258 | + k += 1; | ||
| 2259 | + continue; | ||
| 2260 | + } | ||
| 2261 | + if in_str { | ||
| 2262 | + if c == b'\\' { | ||
| 2263 | + k += 2; | ||
| 2264 | + continue; | ||
| 2265 | + } | ||
| 2266 | + if c == b'"' { | ||
| 2267 | + in_str = false; | ||
| 2268 | + } | ||
| 2269 | + k += 1; | ||
| 2270 | + continue; | ||
| 2271 | + } | ||
| 2272 | + match c { | ||
| 2273 | + b'"' => in_str = true, | ||
| 2274 | + b'/' if bytes.get(k + 1) == Some(&b'/') => { | ||
| 2275 | + in_line_comment = true; | ||
| 2276 | + k += 1; | ||
| 2277 | + } | ||
| 2278 | + b'{' => { | ||
| 2279 | + depth += 1; | ||
| 2280 | + started = true; | ||
| 2281 | + } | ||
| 2282 | + b'}' => { | ||
| 2283 | + depth -= 1; | ||
| 2284 | + if started && depth == 0 { | ||
| 2285 | + fn_end = k + 1; | ||
| 2286 | + break; | ||
| 2287 | + } | ||
| 2288 | + } | ||
| 2289 | + _ => {} | ||
| 2290 | + } | ||
| 2291 | + k += 1; | ||
| 2292 | + } | ||
| 2293 | + let body = &src[fn_start..fn_end]; | ||
| 2294 | + // APPROXIMATE, and known to be so: the body slice is a | ||
| 2295 | + // hand-rolled brace walk, and this crate's compare idioms vary | ||
| 2296 | + // enough that the column under-reports. The LINE, GATE and | ||
| 2297 | + // COUNT EXPR columns are exact (line-based scan, no body | ||
| 2298 | + // slicing); treat `pixel_comparing` as a hint, not a verdict. | ||
| 2299 | + // Idiom-tolerant: this crate spells the compare every which way | ||
| 2300 | + // (`assert_eq!(got.y, want.y)`, `assert_eq!(g, w)`, | ||
| 2301 | + // `let ok = ours.y == ref_f.y`, `ours.y, want.y`), so match the | ||
| 2302 | + // PLANE inside an assertion, not one fixed spelling. | ||
| 2303 | + let pixel_comparing = body.contains("assert") | ||
| 2304 | + && (body.contains(".y,") | ||
| 2305 | + || body.contains(".y ==") | ||
| 2306 | + || body.contains(".y)") | ||
| 2307 | + || body.contains("vs ffmpeg")); | ||
| 2308 | + // A SPEC already in scope for this gate? | ||
| 2309 | + let mut fixable = None; | ||
| 2310 | + for cand in ["FRAMES", "frame_count", "NFRAMES", "frames_expected"] { | ||
| 2311 | + if body.contains(&format!("const {cand}")) | ||
| 2312 | + || body.contains(&format!("let {cand}")) | ||
| 2313 | + { | ||
| 2314 | + fixable = Some(cand.to_string()); | ||
| 2315 | + break; | ||
| 2316 | + } | ||
| 2317 | + } | ||
| 2318 | + // Bucket by READING the gate. A census/probe reports and never | ||
| 2319 | + // asserts, so its count is not a verdict and is left alone. A | ||
| 2320 | + // gate that drives aomenc takes the count from the ENCODE -- our | ||
| 2321 | + // decode's length is what is under test, so using it as the | ||
| 2322 | + // expected value is circular. A gate that reads a stream from | ||
| 2323 | + // disk takes it from that stream. | ||
| 2324 | + // The candidate fix: the numeric frame count in this gate's own | ||
| 2325 | + // encode call. For bucket (b) that number IS the encoder's frame | ||
| 2326 | + // count, so it is the spec the compare should assert. | ||
| 2327 | + let candidate = enc_helpers(body).first().and_then(|h| { | ||
| 2328 | + let at = body.find(&format!("{h}("))?; | ||
| 2329 | + let open = at + h.len() + 1; | ||
| 2330 | + let seg = &body[open..(open + 400).min(body.len())]; | ||
| 2331 | + let close = seg.find(';')?; | ||
| 2332 | + let nums: Vec<&str> = seg[..close] | ||
| 2333 | + .split(',') | ||
| 2334 | + .map(|x| x.trim()) | ||
| 2335 | + .filter(|x| !x.is_empty() && x.chars().all(|c| c.is_ascii_digit())) | ||
| 2336 | + .collect(); | ||
| 2337 | + nums.last().map(|x| x.to_string()) | ||
| 2338 | + }); | ||
| 2339 | + let (bucket, bucket_reason) = if is_probe(&gate) { | ||
| 2340 | + ( | ||
| 2341 | + Some("c"), | ||
| 2342 | + "census/probe: reports, does not assert a verdict".to_string(), | ||
| 2343 | + ) | ||
| 2344 | + } else if body.contains("aomenc_path()") || !enc_helpers(body).is_empty() { | ||
| 2345 | + ( | ||
| 2346 | + Some("b"), | ||
| 2347 | + "live aomenc encode: count belongs to the encoder".to_string(), | ||
| 2348 | + ) | ||
| 2349 | + } else if body.contains("fs::read") || body.contains("crate_pin") { | ||
| 2350 | + ( | ||
| 2351 | + Some("a"), | ||
| 2352 | + "stream read from disk: count belongs to the pin".to_string(), | ||
| 2353 | + ) | ||
| 2354 | + } else { | ||
| 2355 | + ( | ||
| 2356 | + None, | ||
| 2357 | + "unclassified: no aomenc drive, no disk read, and not a probe -- \ | ||
| 2358 | + needs a reader" | ||
| 2359 | + .to_string(), | ||
| 2360 | + ) | ||
| 2361 | + }; | ||
| 2362 | + out.push(Site { | ||
| 2363 | + line: i + 1, | ||
| 2364 | + gate: gate.clone(), | ||
| 2365 | + count_expr: last.to_string(), | ||
| 2366 | + pinned_by: pinned, | ||
| 2367 | + pixel_comparing, | ||
| 2368 | + fixable_from: fixable, | ||
| 2369 | + bucket, | ||
| 2370 | + bucket_reason, | ||
| 2371 | + candidate, | ||
| 2372 | + }); | ||
| 2373 | + } | ||
| 2374 | + } | ||
| 2375 | + out | ||
| 2376 | + } | ||
| 2377 | +} | ||
| 2378 | + | ||
| 2379 | +#[cfg(test)] | ||
| 2380 | +mod count_vacuity_tests { | ||
| 2381 | + use super::count_vacuity::sites; | ||
| 2382 | + | ||
| 2383 | + /// The shape is real and widespread; this pins the FLOOR so the sweep cannot | ||
| 2384 | + /// silently stop finding sites. Measured count is well above this. | ||
| 2385 | + #[test] | ||
| 2386 | + fn the_count_vacuity_sweep_finds_the_known_sites() { | ||
| 2387 | + let src = include_str!("stream.rs"); | ||
| 2388 | + let s = sites(src); | ||
| 2389 | + assert!( | ||
| 2390 | + s.len() >= 40, | ||
| 2391 | + "the count-vacuity sweep found only {} site(s); expected 40+ -- it has lost a \ | ||
| 2392 | + shape", | ||
| 2393 | + s.len() | ||
| 2394 | + ); | ||
| 2395 | + // r7: the first reported site (3895, `pictures.len()`) is FIXED -- it now | ||
| 2396 | + // asserts `ENCODED_FRAMES`, the encode's own count. The anchor therefore | ||
| 2397 | + // moved from "the site is still there" to "the fix is still in place AND | ||
| 2398 | + // the dominant remaining shape is still found", so the sweep cannot go | ||
| 2399 | + // quiet by either route. | ||
| 2400 | + // The GENERAL rule, not the one literal r7 fixed. Every decode-derived | ||
| 2401 | + // count expression is banned at the gate r7 fixed, so a future edit that | ||
| 2402 | + // reintroduces the shape under a different binding name is caught, and so | ||
| 2403 | + // the guard does not go quiet as the OTHER sites are fixed later. | ||
| 2404 | + const DECODE_DERIVED: &[&str] = &["pictures.len()", "decoded.len()", "frames.len()"]; | ||
| 2405 | + assert!( | ||
| 2406 | + !s.iter().any(|x| x.gate | ||
| 2407 | + == "a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact" | ||
| 2408 | + && DECODE_DERIVED.contains(&x.count_expr.as_str())), | ||
| 2409 | + "the r7 fix regressed: {} is passing a decode-derived count as the oracle's \ | ||
| 2410 | + expected count again -- our decode's length is the thing UNDER TEST and \ | ||
| 2411 | + must never be the expected value", | ||
| 2412 | + "a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact" | ||
| 2413 | + ); | ||
| 2414 | + // A CEILING on the unpinned population, so a NEW site cannot be added | ||
| 2415 | + // silently. Lower it as sites are fixed; a fix that does not lower it is | ||
| 2416 | + // still a fix, but a NEW site is an immediate red. | ||
| 2417 | + let unpinned = s.iter().filter(|x| x.pinned_by.is_none()).count(); | ||
| 2418 | + const UNPINNED_CEILING: usize = 43; | ||
| 2419 | + assert!( | ||
| 2420 | + unpinned <= UNPINNED_CEILING, | ||
| 2421 | + "{unpinned} unpinned count site(s), ceiling is {UNPINNED_CEILING} -- a new one \ | ||
| 2422 | + was added (lower the ceiling only when a site is actually fixed)" | ||
| 2423 | + ); | ||
| 2424 | + assert!( | ||
| 2425 | + s.iter().any(|x| x.count_expr == "frames.len()"), | ||
| 2426 | + "the dominant `frames.len()` shape is no longer found -- the sweep has lost a \ | ||
| 2427 | + shape, not gained a fix" | ||
| 2428 | + ); | ||
| 2429 | + } | ||
| 2430 | + | ||
| 2431 | + /// Report, per site: does the count come from a SPEC or from our own decode? | ||
| 2432 | + /// Prints the table the r5 report carries. The assertion is the FLOOR above, | ||
| 2433 | + /// not "zero unpinned" -- the residual unpinned sites are handed to another | ||
| 2434 | + /// lane with this table, and forcing them all here would be an unbounded | ||
| 2435 | + /// change dressed as a fix. | ||
| 2436 | + #[test] | ||
| 2437 | + fn every_locally_derived_oracle_count_is_reported() { | ||
| 2438 | + let src = include_str!("stream.rs"); | ||
| 2439 | + let s = sites(src); | ||
| 2440 | + let unpinned: Vec<String> = s | ||
| 2441 | + .iter() | ||
| 2442 | + .filter(|x| x.pinned_by.is_none()) | ||
| 2443 | + .map(|x| { | ||
| 2444 | + format!( | ||
| 2445 | + "stream.rs:{} | {} | {} | NOT SPEC-PINNED", | ||
| 2446 | + x.line, x.gate, x.count_expr | ||
| 2447 | + ) | ||
| 2448 | + }) | ||
| 2449 | + .collect(); | ||
| 2450 | + let pinned = s.len() - unpinned.len(); | ||
| 2451 | + eprintln!( | ||
| 2452 | + "count-vacuity sweep: {} site(s); {} spec-pinned by a prior assert, {} not", | ||
| 2453 | + s.len(), | ||
| 2454 | + pinned, | ||
| 2455 | + unpinned.len() | ||
| 2456 | + ); | ||
| 2457 | + for line in unpinned.iter() { | ||
| 2458 | + eprintln!(" {line}"); | ||
| 2459 | + } | ||
| 2460 | + // The table Main asked for, as columns the guard itself computes. | ||
| 2461 | + for x in s.iter().filter(|x| x.pinned_by.is_none()) { | ||
| 2462 | + eprintln!( | ||
| 2463 | + "ROW {} | {} | {} | bucket={} | candidate={} | spec_in_scope={} | {} | \ | ||
| 2464 | + pixel_comparing={}", | ||
| 2465 | + x.line, | ||
| 2466 | + x.gate, | ||
| 2467 | + x.count_expr, | ||
| 2468 | + x.bucket.unwrap_or("?"), | ||
| 2469 | + x.candidate.clone().unwrap_or_else(|| "-".into()), | ||
| 2470 | + x.fixable_from.clone().unwrap_or_else(|| "-".into()), | ||
| 2471 | + x.bucket_reason, | ||
| 2472 | + x.pixel_comparing | ||
| 2473 | + ); | ||
| 2474 | + } | ||
| 2475 | + assert!( | ||
| 2476 | + !s.is_empty() && s.iter().all(|x| !x.gate.is_empty()), | ||
| 2477 | + "a site has no owning gate -- the sweep's gate attribution is broken" | ||
| 2478 | + ); | ||
| 2479 | + } | ||
| 2480 | +} | ||
crates/ec-av1/src/stream.rsmodified+90 -8
| @@ -3856,7 +3856,10 @@ pub(crate) mod tests { | |||
| 3856 | ("film mandelbrot", "mandelbrot", 192, 128), | 3856 | ("film mandelbrot", "mandelbrot", 192, 128), |
| 3857 | ]; | 3857 | ]; |
| 3858 | for (arm, source, width, height) in &arms { | 3858 | for (arm, source, width, height) in &arms { |
| 3859 | - let stream = encode_aomenc_stream(source, *width, *height, 40, &extra); | 3859 | + // r7: the ENCODE's frame count, bound so the compare below asserts a |
| 3860 | + // spec rather than our own decode's length. | ||
| 3861 | + const ENCODED_FRAMES: usize = 40; | ||
| 3862 | + let stream = encode_aomenc_stream(source, *width, *height, ENCODED_FRAMES, &extra); | ||
| 3860 | // Premise: the shape under test really arrived -- segmentation on | 3863 | // Premise: the shape under test really arrived -- segmentation on |
| 3861 | // every frame, the map both coded and inherited, and real ALT_Q | 3864 | // every frame, the map both coded and inherited, and real ALT_Q |
| 3862 | // tables. An aomenc drift that dropped any of these would make | 3865 | // tables. An aomenc drift that dropped any of these would make |
| @@ -3904,7 +3907,11 @@ pub(crate) mod tests { | |||
| 3904 | "{arm}: every block dequantized at the same qindex ({lo}) -- SEG_LVL_ALT_Q \ | 3907 | "{arm}: every block dequantized at the same qindex ({lo}) -- SEG_LVL_ALT_Q \ |
| 3905 | never changed any block's quantizer" | 3908 | never changed any block's quantizer" |
| 3906 | ); | 3909 | ); |
| 3907 | - let ffmpeg_frames = ffmpeg_decode_sequence(&stream, *width, *height, pictures.len()); | 3910 | + // `ENCODED_FRAMES`, not `pictures.len()`: our decode's length is the |
| 3911 | + // thing UNDER TEST, so using it as the oracle's expected count is | ||
| 3912 | + // circular -- a decode that dropped a frame would ask ffmpeg for the | ||
| 3913 | + // same short count and the compare would silently shrink. | ||
| 3914 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, *width, *height, ENCODED_FRAMES); | ||
| 3908 | for (i, (ours, theirs)) in pictures.iter().zip(&ffmpeg_frames).enumerate() { | 3915 | for (i, (ours, theirs)) in pictures.iter().zip(&ffmpeg_frames).enumerate() { |
| 3909 | assert_eq!(ours.y, theirs.y, "{NAME} {arm}: frame {i} luma vs ffmpeg"); | 3916 | assert_eq!(ours.y, theirs.y, "{NAME} {arm}: frame {i} luma vs ffmpeg"); |
| 3910 | assert_eq!(ours.u, theirs.u, "{NAME} {arm}: frame {i} U vs ffmpeg"); | 3917 | assert_eq!(ours.u, theirs.u, "{NAME} {arm}: frame {i} U vs ffmpeg"); |
| @@ -5290,6 +5297,57 @@ pub(crate) mod tests { | |||
| 5290 | } | 5297 | } |
| 5291 | 5298 | ||
| 5292 | /// Decodes `frames` concatenated 4:2:0 frames out of one AV1 OBU stream. | 5299 | /// Decodes `frames` concatenated 4:2:0 frames out of one AV1 OBU stream. |
| 5300 | + /// The frame-count diagnostic shared by the three `ffmpeg_decode_sequence*` | ||
| 5301 | + /// helpers (lane-av1pins5 r6). | ||
| 5302 | + /// | ||
| 5303 | + /// Before this, a caller that passed its OWN decode's length as the expected | ||
| 5304 | + /// count got `expected N 4:2:0 frames, ffmpeg said: ` -- with an EMPTY tail, | ||
| 5305 | + /// because ffmpeg ran at `-v error` and succeeded. The message named ffmpeg, | ||
| 5306 | + /// said nothing about where `N` came from, and sent the next reader hunting | ||
| 5307 | + /// ffmpeg for a count ffmpeg never chose. | ||
| 5308 | + /// | ||
| 5309 | + /// The class is MISATTRIBUTED RED, not silent pass: the helper's | ||
| 5310 | + /// `out.stdout.len() == frame_bytes * frames` assert fires unconditionally, so | ||
| 5311 | + /// a wrong count cannot pass -- it just fails while blaming the wrong | ||
| 5312 | + /// component. (Measured: `ffmpeg_decode_sequence(&s, 192, 128, 0)` panics | ||
| 5313 | + /// here, not silently.) Naming the real cause is the whole fix; no caller has | ||
| 5314 | + /// to change to benefit. | ||
| 5315 | + fn frame_count_diagnosis( | ||
| 5316 | + format: &str, | ||
| 5317 | + frames: usize, | ||
| 5318 | + width: usize, | ||
| 5319 | + height: usize, | ||
| 5320 | + frame_bytes: usize, | ||
| 5321 | + got: usize, | ||
| 5322 | + stderr: &[u8], | ||
| 5323 | + ) -> String { | ||
| 5324 | + let actual = if frame_bytes == 0 { | ||
| 5325 | + 0 | ||
| 5326 | + } else { | ||
| 5327 | + got / frame_bytes | ||
| 5328 | + }; | ||
| 5329 | + let leftover = if frame_bytes == 0 { | ||
| 5330 | + got | ||
| 5331 | + } else { | ||
| 5332 | + got % frame_bytes | ||
| 5333 | + }; | ||
| 5334 | + format!( | ||
| 5335 | + "FRAME COUNT MISMATCH ({format} {width}x{height}): the caller passed \ | ||
| 5336 | + `frames={frames}`, ffmpeg produced {actual} frame(s) ({got} bytes, \ | ||
| 5337 | + {leftover} byte(s) not a whole frame, at {frame_bytes} B/frame).\n\ | ||
| 5338 | + `frames` is the EXPECTED count the CALLER asserted -- it is NOT measured \ | ||
| 5339 | + from ffmpeg, so it never had ffmpeg's agreement. If it came from our own \ | ||
| 5340 | + decode_stream(), this is OUR decoder disagreeing with ffmpeg about how many \ | ||
| 5341 | + frames the stream holds, and the fix is on OUR side, not ffmpeg's. ffmpeg \ | ||
| 5342 | + itself exited cleanly{}.", | ||
| 5343 | + if stderr.is_empty() { | ||
| 5344 | + " with no diagnostics (`-v error`)" | ||
| 5345 | + } else { | ||
| 5346 | + "" | ||
| 5347 | + } | ||
| 5348 | + ) | ||
| 5349 | + } | ||
| 5350 | + | ||
| 5293 | fn ffmpeg_decode_sequence( | 5351 | fn ffmpeg_decode_sequence( |
| 5294 | stream: &[u8], | 5352 | stream: &[u8], |
| 5295 | width: usize, | 5353 | width: usize, |
| @@ -5312,8 +5370,16 @@ pub(crate) mod tests { | |||
| 5312 | assert_eq!( | 5370 | assert_eq!( |
| 5313 | out.stdout.len(), | 5371 | out.stdout.len(), |
| 5314 | frame_bytes * frames, | 5372 | frame_bytes * frames, |
| 5315 | - "expected {frames} 4:2:0 frames, ffmpeg said: {}", | 5373 | + "{}", |
| 5316 | - String::from_utf8_lossy(&out.stderr) | 5374 | + frame_count_diagnosis( |
| 5375 | + "4:2:0", | ||
| 5376 | + frames, | ||
| 5377 | + width, | ||
| 5378 | + height, | ||
| 5379 | + frame_bytes, | ||
| 5380 | + out.stdout.len(), | ||
| 5381 | + &out.stderr | ||
| 5382 | + ) | ||
| 5317 | ); | 5383 | ); |
| 5318 | (0..frames) | 5384 | (0..frames) |
| 5319 | .map(|i| { | 5385 | .map(|i| { |
| @@ -5406,8 +5472,16 @@ pub(crate) mod tests { | |||
| 5406 | assert_eq!( | 5472 | assert_eq!( |
| 5407 | out.stdout.len(), | 5473 | out.stdout.len(), |
| 5408 | frame_bytes * frames, | 5474 | frame_bytes * frames, |
| 5409 | - "expected {frames} 4:2:0 10-bit frames, ffmpeg said: {}", | 5475 | + "{}", |
| 5410 | - String::from_utf8_lossy(&out.stderr) | 5476 | + frame_count_diagnosis( |
| 5477 | + "4:2:0 10-bit", | ||
| 5478 | + frames, | ||
| 5479 | + width, | ||
| 5480 | + height, | ||
| 5481 | + frame_bytes, | ||
| 5482 | + out.stdout.len(), | ||
| 5483 | + &out.stderr | ||
| 5484 | + ) | ||
| 5411 | ); | 5485 | ); |
| 5412 | fn le16(bytes: &[u8]) -> Vec<u16> { | 5486 | fn le16(bytes: &[u8]) -> Vec<u16> { |
| 5413 | bytes | 5487 | bytes |
| @@ -6811,8 +6885,16 @@ pub(crate) mod tests { | |||
| 6811 | assert_eq!( | 6885 | assert_eq!( |
| 6812 | out.stdout.len(), | 6886 | out.stdout.len(), |
| 6813 | frame_bytes * frames, | 6887 | frame_bytes * frames, |
| 6814 | - "expected {frames} 4:4:4 frames, ffmpeg said: {}", | 6888 | + "{}", |
| 6815 | - String::from_utf8_lossy(&out.stderr) | 6889 | + frame_count_diagnosis( |
| 6890 | + "4:4:4", | ||
| 6891 | + frames, | ||
| 6892 | + width, | ||
| 6893 | + height, | ||
| 6894 | + frame_bytes, | ||
| 6895 | + out.stdout.len(), | ||
| 6896 | + &out.stderr | ||
| 6897 | + ) | ||
| 6816 | ); | 6898 | ); |
| 6817 | (0..frames) | 6899 | (0..frames) |
| 6818 | .map(|i| { | 6900 | .map(|i| { |
lanes/av1pins.report.mdmodified+512 -0
| @@ -559,3 +559,515 @@ Follow-on handed back rather than folded in: the 14 `pinned_warp` pins, which ar | |||
| 559 | the same defect as r3's four and want the same `crate_pin` + committed-copy | 559 | the same defect as r3's four and want the same `crate_pin` + committed-copy |
| 560 | treatment. Not verified: a full `cargo test -p ec-av1` run (project-wide validation | 560 | treatment. Not verified: a full `cargo test -p ec-av1` run (project-wide validation |
| 561 | is Main's). | 561 | is Main's). |
| 562 | + | ||
| 563 | +--- | ||
| 564 | + | ||
| 565 | +# r5 — the scanner, the 14 pins, and a correction to r4 | ||
| 566 | + | ||
| 567 | +Branch `lane-av1pins5`, forked from the r4 tip `2e5509e9`. Commits `e200fede` | ||
| 568 | +(the 14 pins), `3eb90648` (scanner + sweep), plus this report. Tests and test | ||
| 569 | +helpers only. Not pushed; main untouched. | ||
| 570 | + | ||
| 571 | +**Authoritative location, as the batch-close audit asked:** this lane lives in | ||
| 572 | +`~/.cache/wt/av1pins5` (branch `lane-av1pins5`). It is **not** a stale duplicate of | ||
| 573 | +`~/.cache/wt/av1pinslive` — `av1pinslive` sits at the same tip `2e5509e9` but does | ||
| 574 | +**not** carry the 14 pins; they were only ever in `av1pins5`. All 14 were verified | ||
| 575 | +byte-identical in three independent locations (this worktree's staged copy, a | ||
| 576 | +local `/tmp` copy, and the runner library) before committing: **14/14 identical, | ||
| 577 | +0 mismatches**. They are now committed, so no worktree holds the only copy. | ||
| 578 | + | ||
| 579 | +## 1. The scanner | ||
| 580 | + | ||
| 581 | +`pin_inventory` in `gate_coverage.rs` resolves **five** shapes: | ||
| 582 | + | ||
| 583 | +| # | shape | example | | ||
| 584 | +|---|---|---| | ||
| 585 | +| (a) | single-name committed | `crate_pin("golden3-pin.obu")` | | ||
| 586 | +| (b) | single-name machine-local | `pin_dir().join("x.obu")` | | ||
| 587 | +| (c) | whole-file `concat!` literal | `concat!(env!("CARGO_MANIFEST_DIR"), "/../../fixtures/x.obu")` | | ||
| 588 | +| (d) | directory literal + runtime name | `let fixtures = concat!(...); … format!("{fixtures}/{n}.obu")` | | ||
| 589 | +| (e) | committed + runtime name | `crate_pin(&format!("{n}.obu"))` | | ||
| 590 | + | ||
| 591 | +### Scanner before/after on the live tree | ||
| 592 | + | ||
| 593 | +``` | ||
| 594 | +BEFORE (r3 inventory): gate=pinned_warp_stream_decodes_pixel_exact reads=0 | ||
| 595 | +AFTER (r5 inventory): 14 pin(s) a gate reads have no committed copy under | ||
| 596 | + crates/ec-av1/fixtures/: | ||
| 597 | + pinned_warp_stream_decodes_pixel_exact:warp-mismatch.obu (concat_dir_runtime_name) | ||
| 598 | + … all 14 named, then 0 after the fix landed. | ||
| 599 | +``` | ||
| 600 | + | ||
| 601 | +### Shape (e) is the finding worth reading | ||
| 602 | + | ||
| 603 | +Rewriting the directory literal as a committed-path lookup made the gate | ||
| 604 | +**correct and simultaneously invisible**: `crate_pin("` no longer appears, shape | ||
| 605 | +(a) found nothing, and the enumerator reported a **clean tree while 14 pins were | ||
| 606 | +read**. A false pass is worse than the original gap — the original at least | ||
| 607 | +surfaced in a filesystem audit, which is exactly how the batch-close audit found | ||
| 608 | +it. It was caught by the `reads.len() >= 20` floor in the invariant test. That | ||
| 609 | +floor exists for this and I would not remove it. | ||
| 610 | + | ||
| 611 | +**The general lesson:** fixing a shape can blind the check that was watching it. | ||
| 612 | + | ||
| 613 | +### Two scanner bugs, both found by the capability tests | ||
| 614 | + | ||
| 615 | +* A `format!` brace escape emitted `{n` instead of `{n}`, so the marker never | ||
| 616 | + matched and shape (d) resolved 0 pins. | ||
| 617 | +* `args.find(')')` stopped at the `)` of `pictures.len()`, truncating the argument | ||
| 618 | + list and yielding **zero** sites overall — the sweep reported a clean tree. | ||
| 619 | + | ||
| 620 | +Capability tests therefore use **synthetic source**, never the live file. Asserting | ||
| 621 | +against the live tree would rot the moment the fix lands, which is precisely how a | ||
| 622 | +scanner loses its edge. | ||
| 623 | + | ||
| 624 | +**Ownership, stated because two lanes touch this:** the scanner owns the | ||
| 625 | +**enumeration** (which gates read which pins, from source). The fixture-preflight | ||
| 626 | +lane owns the **file inventory on a runner** (does each path exist on the box). | ||
| 627 | +The scanner is the stricter of the two — it fails on an uncommitted pin whether or | ||
| 628 | +not some runner happens to have a copy. | ||
| 629 | + | ||
| 630 | +## 2. The 14 pins — provenance `recovered-original` | ||
| 631 | + | ||
| 632 | +Fetched byte-for-byte from the runner library. **Not regenerated**: these are the | ||
| 633 | +actual historical mismatch witnesses, and a re-encode would be a different stream | ||
| 634 | +that must not be called the pin. | ||
| 635 | + | ||
| 636 | +| pin | size | sha256 | | ||
| 637 | +|---|---|---| | ||
| 638 | +| warp-mismatch.obu | 621 B | `24cca5beb41c1078f8109d8fa7e35f10cc1eefb67c6d1d1ea248a0b6842287bb` | | ||
| 639 | +| warp-flake-5.obu | 602 B | `1a99f9e5b257eed0ebae055441904d6c40962a26c0c2d63c3e051732569ff0a0` | | ||
| 640 | +| warp-flake-7.obu | 723 B | `c2f8b93f5a59c56b1c4453ea789e0fc955557ed9b63c0e2cb8683fa483eff2b5` | | ||
| 641 | +| ii-flake-1.obu | 579 B | `700ded3e61e15bc3573d339d7fcc6ab94500adb796c30021094d354306662238` | | ||
| 642 | +| ii-flake-2.obu | 581 B | `edc4ad3a6c00c6bc909c626fa24433ef31a88ed519ed57403f5373a160e590af` | | ||
| 643 | +| ii-flake-3.obu | 670 B | `994bfbdc952ecef18ae1560d5e7f121ba1000172e0bc2ad05e5b8cfaa17b15cb` | | ||
| 644 | +| ii-flake-5.obu | 681 B | `f43fe77ea0e8ddd9c1524b642e09f935921cb0d00c4a60061a52d2260af38b9a` | | ||
| 645 | +| ii-flake-6.obu | 632 B | `84a1f60011dfdb77ede98ce95a25d247d270b0af1cff2c44aa1e6b311ca63dce` | | ||
| 646 | +| ii-flake-7.obu | 654 B | `61ba4d114aa55ebcf95ae691abbce3307146a2d969c0627ea3ceea02f3875574` | | ||
| 647 | +| ii-flake-8.obu | 635 B | `f19d3d80ed564850cec02a26cfe7ab00e282afa7896821c535a117f5541bef5d` | | ||
| 648 | +| ii-flake-9.obu | 690 B | `0df4874737cc615258c0fdfb4bcb157c9a3663127cbf0a896af44d4deb83c653` | | ||
| 649 | +| rect-flake-1.obu | 607 B | `a3869b5d2bd8a8bc5413e0d039d5e3375a48601cdeb2edb8d4b732402926d357` | | ||
| 650 | +| rect-flake-2.obu | 601 B | `c780ddee1adf25cf63a6ba70ff449820f6f4474b23ef16615c1e843ad0c86adb` | | ||
| 651 | +| rect-flake-3.obu | 572 B | `3b23d204549b7bcfbd7166b1b3e2920580236c78de12e8f23f7fb64c1864f3e6` | | ||
| 652 | + | ||
| 653 | +`.gitignore`'s `!crates/*/fixtures/**` negation means a plain `git add` suffices — | ||
| 654 | +verified with `git check-ignore -q` (returns 1) and by staging with no `-f`. | ||
| 655 | + | ||
| 656 | +## 3. The gate is live | ||
| 657 | + | ||
| 658 | +`pinned_warp_stream_decodes_pixel_exact` reads all 14 from | ||
| 659 | +`crates/ec-av1/fixtures/`, via `crate_pin`, with `require_pin` in the helper. | ||
| 660 | +Plain run (no `--ignored`): **1 passed; 0 failed; 0 ignored; 744 filtered out; | ||
| 661 | +1.47 s**, printing each `pin: …/crates/ec-av1/fixtures/<name>`. | ||
| 662 | + | ||
| 663 | +The asserts live in `check_pinned_warp_stream`, which this gate delegates to — | ||
| 664 | +stated in the gate's doc comment, because a body-only scan reads as assert-free, | ||
| 665 | +which is how the r4 audit got it wrong. `#[ignore]` **36 → 35**. | ||
| 666 | + | ||
| 667 | +## 4. The count-vacuity sweep — and a CORRECTION to r4 | ||
| 668 | + | ||
| 669 | +`count_vacuity` enumerates every site passing a locally-derived count as the | ||
| 670 | +oracle's expected frame count: **61 sites, 13 spec-pinned by a prior assert, 48 | ||
| 671 | +not**. The floor (`>= 40`) stops the sweep silently shrinking. | ||
| 672 | + | ||
| 673 | +**r4 reported this shape as a "vacuous pass" and I told Main so. That was wrong.** | ||
| 674 | +Measured, by calling `ffmpeg_decode_sequence(&stream, 192, 128, 0)` on a real | ||
| 675 | +pinned stream under `catch_unwind`: | ||
| 676 | + | ||
| 677 | +``` | ||
| 678 | +panicked at crates/ec-av1/src/stream.rs:5110:9: | ||
| 679 | +expected 0 4:2:0 frames, ffmpeg said: | ||
| 680 | +``` | ||
| 681 | + | ||
| 682 | +The helper asserts `out.stdout.len() == frame_bytes * frames` unconditionally, so | ||
| 683 | +a wrong count **cannot pass silently** — it REDS, with a message that blames | ||
| 684 | +FFmpeg for a count our decoder chose. The consequence is a **misattributed red**, | ||
| 685 | +not a silent pass. | ||
| 686 | + | ||
| 687 | +r4's *fix* still stands (the count now comes from the fixture, so the red names the | ||
| 688 | +real cause). The *justification* was wrong, and a sweep repeating it would send | ||
| 689 | +the next reader after a bug that does not exist. | ||
| 690 | + | ||
| 691 | +| column | meaning | | ||
| 692 | +|---|---| | ||
| 693 | +| `stream.rs:3895` | `a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact` — `pictures.len()`, not spec-pinned: a wrong count reds, blaming ffmpeg | | ||
| 694 | +| `stream.rs:5355` | `an_svt_screen_palette_block_with_a_split_transform_decodes_exactly` — `decoded.len()`, not spec-pinned | | ||
| 695 | +| `stream.rs:10287/10289` | `rect_tx_tool_gate` — `decoded.len()`, not spec-pinned | | ||
| 696 | +| … 48 total | full list printed by the test; the floor pins the count | | ||
| 697 | + | ||
| 698 | +**All 48 are reported, none fixed.** That is an unbounded change across gates this | ||
| 699 | +lane does not own, and dressing it as a fix would be dishonest. The pin-class gates | ||
| 700 | +are clean: **0** unpinned count sites in `pinned_lr_sgr`, | ||
| 701 | +`check_pinned_warp_stream`, `pinned_golden3`, `pinned_sbpart` and the film-grain | ||
| 702 | +gate. | ||
| 703 | + | ||
| 704 | +## 5. State | ||
| 705 | + | ||
| 706 | +`lane-av1pins5`, three commits on top of `2e5509e9`. `cargo check -p ec-av1 | ||
| 707 | +--all-targets` clean, **0 warnings**. `gate_coverage` **15 passed** (10 pre-existing | ||
| 708 | ++ 5 new scanner tests), `refusal_inventory` 15 passed. Not verified: a full | ||
| 709 | +`cargo test -p ec-av1` run (project-wide validation is Main's). | ||
| 710 | + | ||
| 711 | +The rule this lane earns, on top of r3's: **a fix can blind the check that was | ||
| 712 | +watching the shape it changed.** The pin inventory went from blind, to correct, to | ||
| 713 | +blind-again-in-a-new-guise, across three commits in three rounds. The floor and the | ||
| 714 | +synthetic capability tests are what make that survivable. | ||
| 715 | + | ||
| 716 | +--- | ||
| 717 | + | ||
| 718 | +# r6 — name the real cause, classify the defect, and report the 44 | ||
| 719 | + | ||
| 720 | +Branch `lane-av1pins5`. Commit `02c8e7a8`. Tests and test helpers only. Not | ||
| 721 | +pushed; main untouched. | ||
| 722 | + | ||
| 723 | +**Canonical branch: `lane-av1pins5`.** `av1pinslive` is a **stale duplicate** at | ||
| 724 | +`2e5509e9` with no work of its own beyond r4; every r5/r6 commit is here only. | ||
| 725 | +`av1pinslive` can be dropped. No pins are at risk either way — all 18 recovered | ||
| 726 | +pins are committed. | ||
| 727 | + | ||
| 728 | +## 1. The change that matters: the failure now names the real cause | ||
| 729 | + | ||
| 730 | +Before, a caller passing our own decode's length got: | ||
| 731 | + | ||
| 732 | +``` | ||
| 733 | +expected N 4:2:0 frames, ffmpeg said: <empty> | ||
| 734 | +``` | ||
| 735 | + | ||
| 736 | +Empty tail, because ffmpeg runs at `-v error` and succeeds. It named ffmpeg, said | ||
| 737 | +nothing about where `N` came from, and sent the reader hunting ffmpeg for a count | ||
| 738 | +ffmpeg never chose. | ||
| 739 | + | ||
| 740 | +All three helpers (`ffmpeg_decode_sequence`, `_10bit`, `_444`) now share | ||
| 741 | +`frame_count_diagnosis`. Measured with the same probe r5 used: | ||
| 742 | + | ||
| 743 | +``` | ||
| 744 | +FRAME COUNT MISMATCH (4:2:0 192x128): the caller passed `frames=0`, ffmpeg produced | ||
| 745 | +1 frame(s) (36864 bytes, 0 byte(s) not a whole frame, at 36864 B/frame). | ||
| 746 | +`frames` is the EXPECTED count the CALLER asserted -- it is NOT measured from ffmpeg, | ||
| 747 | +so it never had ffmpeg's agreement. If it came from our own decode_stream(), this is | ||
| 748 | +OUR decoder disagreeing with ffmpeg about how many frames the stream holds, and the | ||
| 749 | +fix is on OUR side, not ffmpeg's. ffmpeg itself exited cleanly with no diagnostics. | ||
| 750 | +``` | ||
| 751 | + | ||
| 752 | +**This converts most of the 44 from confusing to diagnosable without touching a | ||
| 753 | +single caller** — which is exactly the de-risking Main asked for, since "48 edits | ||
| 754 | +of unclear value" was the risk. | ||
| 755 | + | ||
| 756 | +## 2. Two defect classes, named so r4 is not repeated | ||
| 757 | + | ||
| 758 | +The sweep's doc comment now states: | ||
| 759 | + | ||
| 760 | +* **MISATTRIBUTED RED** — a wrong count reds, and the old message blamed ffmpeg. | ||
| 761 | + **This is what these sites are.** The `stdout.len() == frame_bytes * frames` | ||
| 762 | + assert is unconditional, so a wrong count cannot pass silently. | ||
| 763 | +* **SILENT PASS** — the compare is skipped or truncated and the gate reports green. | ||
| 764 | + A *different* defect with a *different* fix. **These sites are not that.** | ||
| 765 | + | ||
| 766 | +## 3. The sweep: 61 sites, 17 spec-pinned, 44 not, 30 distinct gates | ||
| 767 | + | ||
| 768 | +Two detection bugs of mine, both inflating the number: | ||
| 769 | + | ||
| 770 | +* `assert_eq!` is split across lines by rustfmt (`assert_eq!(` then | ||
| 771 | + `frames.len(),`), so a one-line containment check missed every multi-line | ||
| 772 | + spelling. Now matched over a two-line window: **13 → 17** spec-pinned. | ||
| 773 | +* The body slice used to classify each gate is a hand-rolled brace walk, and raw | ||
| 774 | + byte counting treats a `}` inside a format string as a closing brace — the same | ||
| 775 | + trap that made `stream.rs` look two braces short in the first review of this wave. | ||
| 776 | + | ||
| 777 | +**The `pixel_comparing` column is APPROXIMATE and under-reports, and I am not | ||
| 778 | +building the 44-row table on it.** I sampled three gates it marks `false` and all | ||
| 779 | +three plainly compare planes (`a_real_aomenc_stream_with_rect_palette…` 4 | ||
| 780 | +plane-compare lines, `…palette_stream_with_8x8_leaves…` 5, | ||
| 781 | +`a_16x4_intrabc_pair_strip…` 1). The column's `line`, `gate` and `count_expr` | ||
| 782 | +are exact — a line-based scan with no body slicing — but whether a gate | ||
| 783 | +pixel-compares needs a reader, not a regex. | ||
| 784 | + | ||
| 785 | +## 4. The table — 44 sites, exact columns | ||
| 786 | + | ||
| 787 | +`file:line | gate | count source before | fixture's own count known? | status` | ||
| 788 | + | ||
| 789 | +| file:line | gate | count source before → after | fixture count known? | status | | ||
| 790 | +|---|---|---|---|---| | ||
| 791 | +| stream.rs:3895 | `a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact` | `pictures.len()` → unchanged | no (live aomenc; use the encode's frame count) | reported | | ||
| 792 | +| stream.rs:5414 | `an_svt_screen_palette_block_with_a_split_transform_decodes_exactly` | `decoded.len()` → unchanged | no (SVT stream read from a file) | reported | | ||
| 793 | +| stream.rs:10135 | `a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact` | `frames.len()` → unchanged | yes (the gate's own `frames` const) | reported | | ||
| 794 | +| stream.rs:10354, :10356 | `rect_tx_tool_gate` | `decoded.len()` ×2 → unchanged | yes (encode frame count) | reported | | ||
| 795 | +| stream.rs:10834 | `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` | `frames.len()` → unchanged | yes | reported | | ||
| 796 | +| stream.rs:11005 | `a_16x4_intrabc_pair_strip_decodes_pixel_exact` | `frames.len()` → unchanged | yes (pinned fixture) | reported | | ||
| 797 | +| stream.rs:11077 | `a_lossless_16x4_chroma_pair_repairs_the_measured_site` | `frames.len()` → unchanged | yes (pinned fixture) | reported | | ||
| 798 | +| stream.rs:11465, :11608 | `a_coded_rect_intrabc_block_reconstructs_in_both_orientations` | `frames.len()` ×2 → unchanged | yes | reported | | ||
| 799 | +| stream.rs:11851, :11853 | `an_sb128_screen_stream_with_intrabc_decodes_pixel_exact` | `frames.len()` ×2 → unchanged | yes | reported | | ||
| 800 | +| stream.rs:12239 | `a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal` | `frames.len()` → unchanged | n/a (census/probe) | report-only | | ||
| 801 | +| stream.rs:12314 | `an_intrabc_vartx_census_measures_the_mixed_leaf_refusal` | `frames.len()` → unchanged | n/a (census/probe) | report-only | | ||
| 802 | +| stream.rs:12418 | `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal` | `frames.len()` → unchanged | no (live aomenc) | reported | | ||
| 803 | +| stream.rs:12720 | `an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` | `frames.len()` → unchanged | yes | reported | | ||
| 804 | +| stream.rs:12781 | `a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact` | `frames.len()` → unchanged | no (live aomenc) | reported | | ||
| 805 | +| stream.rs:12987, :12989 | `a_real_aomenc_stream_with_rect_strip_palette_decodes_pixel_exact` | `frames.len()` ×2 → unchanged | no (live aomenc) | reported | | ||
| 806 | +| stream.rs:15126 | `first_diff` (helper) | `decoded.len()` → unchanged | n/a (diagnostic helper) | report-only | | ||
| 807 | +| … 27 more across 15 gates | — | `frames.len()` / `decoded.len()` | mixed | reported | | ||
| 808 | + | ||
| 809 | +The full 44-line list is printed by `every_locally_derived_oracle_count_is_reported` | ||
| 810 | +on every run, so it cannot drift from the source. | ||
| 811 | + | ||
| 812 | +**None fixed in this commit beyond r4's.** The per-site fix is to derive each count | ||
| 813 | +from the fixture — a recorded frame count, a parsed OBU frame count, a length | ||
| 814 | +assert on the pinned stream — or, for a live-aomenc gate, from **the encoder's own | ||
| 815 | +frame count**, not from our decode. That is 30 gates of real work and it is the | ||
| 816 | +next lane. | ||
| 817 | + | ||
| 818 | +## 5. State | ||
| 819 | + | ||
| 820 | +`lane-av1pins5`, four commits on top of `2e5509e9`. `cargo check -p ec-av1 | ||
| 821 | +--all-targets` clean, **0 warnings**. `gate_coverage` 15 passed, | ||
| 822 | +`refusal_inventory` 15, `count_vacuity` 2, `pin_inventory` 3, `pinned_golden3` | ||
| 823 | +green. `#[ignore]` unchanged at 34. Not verified: a full `cargo test -p ec-av1` | ||
| 824 | +run (project-wide validation is Main's). | ||
| 825 | + | ||
| 826 | +The rule r6 adds, on top of r3's and r5's: **a scanner's own columns are only as | ||
| 827 | +trustworthy as the slice it parsed, and a column that is "approximately right" is | ||
| 828 | +worse than no column** — because a 44-row table built on it would send a lane | ||
| 829 | +after the wrong gates. Two of the four bugs in this lane's scanners were exactly | ||
| 830 | +this: a slice that stopped at `len()`'s own paren, and a brace count that did not | ||
| 831 | +skip string literals. | ||
| 832 | + | ||
| 833 | +--- | ||
| 834 | + | ||
| 835 | +# r7 — classify by reading, fix the first, hand back 38 | ||
| 836 | + | ||
| 837 | +Branch `lane-av1pins5`. Commit `71afc8c9`. Tests and test helpers only. Not | ||
| 838 | +pushed. **Canonical branch: `lane-av1pins5`**; `av1pinslive` is dropped. | ||
| 839 | + | ||
| 840 | +## 1. The classification, printed per site so it is auditable | ||
| 841 | + | ||
| 842 | +The sweep now emits, on every run: | ||
| 843 | + | ||
| 844 | +``` | ||
| 845 | +ROW <line> | <gate> | <count expr> | bucket | candidate | spec_in_scope | <reason> | pixel_comparing | ||
| 846 | +``` | ||
| 847 | + | ||
| 848 | +| bucket | sites | rule | | ||
| 849 | +|---|---|---| | ||
| 850 | +| **b** | 37 | live aomenc encode → the count belongs to the **encoder** | | ||
| 851 | +| **a** | 1 | stream read from disk → the count belongs to the **pin** | | ||
| 852 | +| **c** | 4 | census/probe → report only, never fix | | ||
| 853 | +| **?** | 1 | unclassified, **with the reason printed** rather than a guess | | ||
| 854 | + | ||
| 855 | +Each gate is classified from its own body, over a **string-aware** extent. Two | ||
| 856 | +details that changed the answer: 21 of the bucket-b gates encode through a | ||
| 857 | +*helper* (`screen_intrabc_stream_at_depth`, `run_multi_tile_gate`, `edge32_gate`, | ||
| 858 | +`rect_tx_tool_gate`, …) rather than calling `aomenc_path()` directly, so a first | ||
| 859 | +pass that only looked for `aomenc_path()` called six plainly-encoding gates | ||
| 860 | +"unclassified". | ||
| 861 | + | ||
| 862 | +**A third offset bug, same family as the two r6 caught.** The sweep handed its | ||
| 863 | +body-walk a **line index** where a **byte offset** was required, so every | ||
| 864 | +body-dependent classification read "unclassified" — 40 of 44, all looking like a | ||
| 865 | +legitimate result. It is the third time in this lane that a line/byte or | ||
| 866 | +slice-boundary confusion has silently produced a plausible clean output. | ||
| 867 | + | ||
| 868 | +## 2. Fixed: `stream.rs:3895` | ||
| 869 | + | ||
| 870 | +`a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact`: | ||
| 871 | +`ffmpeg_decode_sequence(..., pictures.len())` → `ENCODED_FRAMES` (40), the count | ||
| 872 | +its own `encode_aomenc_stream(source, w, h, 40, &extra)` call encodes. Our | ||
| 873 | +decode's length is the thing **under test**, so using it as the oracle's expected | ||
| 874 | +count was circular. Gate green, 2.05 s, now comparing 40 frames against ffmpeg's | ||
| 875 | +40 rather than a self-fulfilling number. | ||
| 876 | + | ||
| 877 | +**The sweep's "known site" anchor moved with the fix.** It used to assert that | ||
| 878 | +`pictures.len()` was still present, which went red the moment the fix landed — a | ||
| 879 | +guard that punishes the fix. It now asserts the *opposite* (no site may pass | ||
| 880 | +`pictures.len()` again) **and** that the dominant `frames.len()` shape is still | ||
| 881 | +found, so the sweep cannot go quiet by either route. | ||
| 882 | + | ||
| 883 | +## 3. NOT DONE: 38 of the 39 fixable sites | ||
| 884 | + | ||
| 885 | +The sweep prints a `candidate` — the numeric frame count in the gate's own encode | ||
| 886 | +call — and it resolves for exactly **one** gate. The rest encode inside loops or | ||
| 887 | +through per-gate helpers whose frame-count argument has to be read per gate, and | ||
| 888 | +only 3 of 44 are a clean one-line swap to something already in scope. | ||
| 889 | + | ||
| 890 | +I am handing those back with the method rather than editing 38 call sites on a | ||
| 891 | +guess, for the same reason r6 refused the 44-row table on an untrustworthy column: | ||
| 892 | +a plausible-looking bulk edit built on a heuristic I have now shown wrong three | ||
| 893 | +times in this lane would send the next reader after the wrong lines. | ||
| 894 | + | ||
| 895 | +Per-gate recipe for whoever takes it: | ||
| 896 | + | ||
| 897 | +* **bucket b** — bind the encoder's frame count to a named const at the encode | ||
| 898 | + call (`const ENCODED_FRAMES: usize = <n>;`) and pass that to | ||
| 899 | + `ffmpeg_decode_sequence`, exactly as `stream.rs:3895` now does. Where the | ||
| 900 | + encode is inside a loop over `cq`/`depth`, the count is the helper's frame-count | ||
| 901 | + argument and must be read from that call. | ||
| 902 | +* **bucket a** — the count is the pinned stream's; take it from the pin's recorded | ||
| 903 | + frame count or a length assert on the pinned bytes, not from `decode_stream`. | ||
| 904 | +* **bucket c** — leave. A census reports; it asserts no verdict, so a wrong count | ||
| 905 | + there is not a wrong count. | ||
| 906 | + | ||
| 907 | +The sweep prints the full 44-row table on every run, so the ledger cannot drift | ||
| 908 | +from the source, and the `>= 40` floor plus the two-direction anchor stop the | ||
| 909 | +class from quietly shrinking or from being "fixed" away. | ||
| 910 | + | ||
| 911 | +## 4. State | ||
| 912 | + | ||
| 913 | +`lane-av1pins5`, five commits on top of `2e5509e9`. `cargo check -p ec-av1 | ||
| 914 | +--all-targets` clean, **0 warnings**. `gate_coverage` 15, `refusal_inventory` 15, | ||
| 915 | +`count_vacuity` 2, `pin_inventory` 3, and the fixed gate all green. `#[ignore]` | ||
| 916 | +unchanged at 34. Lane-scoped `CARGO_TARGET_DIR` with touch-first, per the | ||
| 917 | +observation that the shared target dir served another worktree's binary. | ||
| 918 | + | ||
| 919 | +Not verified: a full `cargo test -p ec-av1` run (project-wide validation is | ||
| 920 | +Main's). | ||
| 921 | + | ||
| 922 | +The rule r7 adds: **a scanner that classifies by reading must print its | ||
| 923 | +reasoning per row.** Every unclassifiable row in this table carries the sentence | ||
| 924 | +that disqualified it, so a reader can disagree with a bucket instead of | ||
| 925 | +inheriting it — and the one `?` in the table is more useful than a confident | ||
| 926 | +guess would have been. | ||
| 927 | + | ||
| 928 | +--- | ||
| 929 | + | ||
| 930 | +# r7 closeout — rebased onto main, ledger handed forward | ||
| 931 | + | ||
| 932 | +Rebased onto main `97b4ee04`. **One conflict worth recording:** the fixture-preflight | ||
| 933 | +lane had, independently, already landed the r5 work — the 14 pins are committed | ||
| 934 | +under `crates/ec-av1/fixtures/` and `pinned_warp_stream_decodes_pixel_exact` was | ||
| 935 | +rewired to `crate_pin` with **string literals**, which is a better shape than my | ||
| 936 | +`crate_pin(&format!("{n}.ext"))`: a literal is resolvable name-by-name, so it does | ||
| 937 | +not create the shape-(e) blind spot at all. All three conflicted hunks resolved to | ||
| 938 | +main's side; my duplicate pin commit became a no-op. | ||
| 939 | + | ||
| 940 | +**Ownership, settled:** main's `scripts/pin-gate-audit.py` owns the standalone | ||
| 941 | +census (a human/agent runs it); `pin_inventory` in `gate_coverage.rs` owns the | ||
| 942 | +CI-enforced invariant (it fails the suite when a pin is uncommitted). Different | ||
| 943 | +jobs, same question, both run. | ||
| 944 | + | ||
| 945 | +`git diff main --stat`: **3 files, 1215 insertions, 8 deletions** — pure additions. | ||
| 946 | +`gate_coverage` 18, `refusal_inventory` 19, `count_vacuity` 2, `pin_inventory` 3, | ||
| 947 | +`cargo check --all-targets` **0 warnings**. | ||
| 948 | + | ||
| 949 | +## 1. Merge readiness | ||
| 950 | + | ||
| 951 | +| | | | ||
| 952 | +|---|---| | ||
| 953 | +| branch | `lane-av1pins5` (canonical), rebased onto main `97b4ee04` | | ||
| 954 | +| diff vs main | 3 files, +1215 / −8 — additions only | | ||
| 955 | +| test-count delta | branch carries +5 CI tests over main (pin_inventory 3, count_vacuity 2); the 18/19 gate_coverage/refusal_inventory totals include the preflight lane's | | ||
| 956 | +| sweep floor | holds: 61 sites ≥ 40; unpinned ceiling 43 holds | | ||
| 957 | +| warnings | 0 | | ||
| 958 | + | ||
| 959 | +## 2. The class note — stop the next reader chasing a nonexistent bug | ||
| 960 | + | ||
| 961 | +**A wrong count here cannot pass silently.** `ffmpeg_decode_sequence`'s | ||
| 962 | +`out.stdout.len() == frame_bytes * frames` assert is unconditional, so a wrong | ||
| 963 | +count REDS. The defect is a **misattributed red**: the old message | ||
| 964 | +(`expected N 4:2:0 frames, ffmpeg said: <empty>`) named ffmpeg for a count ffmpeg | ||
| 965 | +never chose. `frame_count_diagnosis` — the class-level fix — reports the caller's | ||
| 966 | +count, ffmpeg's actual count, the byte arithmetic, and states that the fix is on | ||
| 967 | +OUR side. That single change converts the class from confusing to diagnosable | ||
| 968 | +without touching a caller. **This, not the 38 sites, is what the branch is for.** | ||
| 969 | + | ||
| 970 | +## 3. The three detection bugs, each of which produced a plausible clean output | ||
| 971 | + | ||
| 972 | +1. **A line index handed to a byte-offset walk** (r7). The sweep computed each | ||
| 973 | + gate's body by indexing `src.as_bytes()` with a LINE number. 40 of 44 rows read | ||
| 974 | + "unclassified" — and "unclassified" looks like a finding, not a bug. | ||
| 975 | +2. **`assert_eq!` split by rustfmt** (r6). The lookback required | ||
| 976 | + `assert_eq!(frames.len()` on one line, but rustfmt emits `assert_eq!(` then | ||
| 977 | + `frames.len(),` on the next. Every multi-line spelling was missed, inflating the | ||
| 978 | + unpinned count 48 → 44 once a two-line window was used. | ||
| 979 | +3. **A `}` inside a format string counted as a closing brace** (r6). The body walk | ||
| 980 | + counted raw bytes, so a brace in a message truncated the slice and every | ||
| 981 | + compare-detection read false. Same trap that made `stream.rs` look two braces | ||
| 982 | + short in the first review of this wave. | ||
| 983 | + | ||
| 984 | +Each was caught by a floor or a synthetic-input capability test, and each would | ||
| 985 | +have survived an honest-looking table. The rules they earn: **walk offsets in the | ||
| 986 | +units you index; match a call across the line breaks rustfmt introduces; and never | ||
| 987 | +count braces without skipping string literals.** A scanner column derived from a | ||
| 988 | +hand-rolled slice is a hypothesis, not a measurement. | ||
| 989 | + | ||
| 990 | +## 4. The ledger — 43 sites, handed forward | ||
| 991 | + | ||
| 992 | +| file:line | gate | count expr before | bucket | candidate | spec_in_scope | disposition | | ||
| 993 | +|---|---|---|---|---|---|---| | ||
| 994 | +| stream.rs:5631 | `an_svt_screen_palette_block_with_a_split_transform_decodes_exactly` | `decoded.len()` | a | candidate=- | spec_in_scope=- | deferred(bucket a first: count from the PIN) | | ||
| 995 | +| stream.rs:10513 | `a_real_aomenc_palette_stream_with_8x8_leaves_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 996 | +| stream.rs:10732 | `rect_tx_tool_gate` | `decoded.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 997 | +| stream.rs:10734 | `rect_tx_tool_gate` | `decoded.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 998 | +| stream.rs:11212 | `a_real_aomenc_screen_key_frame_reads_use_intrabc_on_rect_strips` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 999 | +| stream.rs:11383 | `a_16x4_intrabc_pair_strip_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1000 | +| stream.rs:11455 | `a_lossless_16x4_chroma_pair_repairs_the_measured_site` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1001 | +| stream.rs:11838 | `a_coded_rect_intrabc_block_reconstructs_in_both_orientations` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1002 | +| stream.rs:11981 | `a_coded_rect_intrabc_block_reconstructs_in_both_orientations` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1003 | +| stream.rs:12224 | `an_sb128_screen_stream_with_intrabc_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1004 | +| stream.rs:12226 | `an_sb128_screen_stream_with_intrabc_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1005 | +| stream.rs:12612 | `a_sub8_leaf_census_over_intrabc_screen_streams_measures_the_sub8_refusal` | `frames.len()` | c | candidate=- | spec_in_scope=- | report-only (census/probe asserts no verdict) | | ||
| 1006 | +| stream.rs:12687 | `an_intrabc_vartx_census_measures_the_mixed_leaf_refusal` | `frames.len()` | c | candidate=- | spec_in_scope=- | report-only (census/probe asserts no verdict) | | ||
| 1007 | +| stream.rs:12791 | `a_real_aomenc_intrabc_mixed_vartx_tree_decodes_without_the_mixed_leaf_refusal` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1008 | +| stream.rs:13093 | `an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` | `frames.len()` | ? | candidate=- | spec_in_scope=- | UNCLASSIFIED - needs a reader | | ||
| 1009 | +| stream.rs:13154 | `a_real_aomenc_stream_with_cdf_update_disabled_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1010 | +| stream.rs:13360 | `a_real_aomenc_rect_strip_palette_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1011 | +| stream.rs:13362 | `a_real_aomenc_rect_strip_palette_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1012 | +| stream.rs:15497 | `first_diff` | `decoded.len()` | c | candidate=- | spec_in_scope=- | report-only (census/probe asserts no verdict) | | ||
| 1013 | +| stream.rs:27636 | `a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1014 | +| stream.rs:27764 | `a_real_aomenc_stream_whose_square_block_reads_a_sub16_neighbours_mode_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1015 | +| stream.rs:27933 | `a_real_aomenc_stream_whose_chroma_edge_filter_reads_a_sub16_neighbours_uv_mode_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1016 | +| stream.rs:27935 | `a_real_aomenc_stream_whose_chroma_edge_filter_reads_a_sub16_neighbours_uv_mode_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1017 | +| stream.rs:28129 | `a_real_aomenc_sb128_stream_whose_skipped_cfl_and_1to4_chroma_pairs_decode_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1018 | +| stream.rs:28131 | `a_real_aomenc_sb128_stream_whose_skipped_cfl_and_1to4_chroma_pairs_decode_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1019 | +| stream.rs:28456 | `a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1020 | +| stream.rs:28458 | `a_real_aomenc_stream_with_ab_partitions_below_16x16_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1021 | +| stream.rs:28609 | `sweep_rectx_recipes` | `frames.len()` | c | candidate=- | spec_in_scope=- | report-only (census/probe asserts no verdict) | | ||
| 1022 | +| stream.rs:29212 | `a_real_aomenc_stream_with_a_32_level_ab_partition_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1023 | +| stream.rs:30646 | `a_real_aomenc_stream_with_restoration_reads_lr_symbols_correctly` | `pics.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1024 | +| stream.rs:30744 | `a_real_aomenc_stream_with_restoration_reads_lr_symbols_correctly` | `pics.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1025 | +| stream.rs:38033 | `edge32_gate` | `decoded.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1026 | +| stream.rs:38035 | `edge32_gate` | `decoded.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1027 | +| stream.rs:41761 | `a_real_aomenc_stream_with_a_coded_strip_whose_chroma_is_a_4to1_or_sub8_rect_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1028 | +| stream.rs:41763 | `a_real_aomenc_stream_with_a_coded_strip_whose_chroma_is_a_4to1_or_sub8_rect_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1029 | +| stream.rs:41998 | `the_chroma_rect_gates_excluded_seed_46_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1030 | +| stream.rs:42000 | `the_chroma_rect_gates_excluded_seed_46_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1031 | +| stream.rs:42167 | `a_real_aomenc_band_stream_seed46_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1032 | +| stream.rs:42169 | `a_real_aomenc_band_stream_seed46_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1033 | +| stream.rs:42376 | `a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1034 | +| stream.rs:42378 | `a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=- | deferred(bucket b: count from the ENCODER) | | ||
| 1035 | +| stream.rs:42602 | `a_real_aomenc_rect_inter_block_predicts_chroma_with_the_narrow_kernel_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=FRAMES | deferred(bucket b: count from the ENCODER) | | ||
| 1036 | +| stream.rs:42604 | `a_real_aomenc_rect_inter_block_predicts_chroma_with_the_narrow_kernel_pixel_exact` | `frames.len()` | b | candidate=- | spec_in_scope=FRAMES | deferred(bucket b: count from the ENCODER) | | ||
| 1037 | + | ||
| 1038 | +TOTALS: a=1 b=37 c=4 ?=1 total=43 | ||
| 1039 | + | ||
| 1040 | +Totals: **a=1, b=37, c=4, ?=1**. | ||
| 1041 | + | ||
| 1042 | +**The `?` row is genuinely unclassified**, not a guess: | ||
| 1043 | +`an_intrabc_block_under_tx_mode_select_decodes_pixel_exact` neither drives aomenc | ||
| 1044 | +in its own body nor reads from disk, and is not a probe. It most likely encodes | ||
| 1045 | +through a path the helper list does not name. Left as `?` with the reason rather | ||
| 1046 | +than assigned a bucket I cannot justify. | ||
| 1047 | + | ||
| 1048 | +**Per-gate recipe.** Bucket **a** first (1 site): take the count from the pinned | ||
| 1049 | +stream's recorded frame count or a length assert on the pinned bytes. Then bucket | ||
| 1050 | +**b** (37 sites): bind the encoder's frame count to a named const at the encode | ||
| 1051 | +call and pass that, exactly as `stream.rs:3895` does (`const ENCODED_FRAMES: usize | ||
| 1052 | += 40;` from its own `encode_aomenc_stream(source, w, h, 40, …)`). Where the encode | ||
| 1053 | +is inside a `cq`/`depth` loop, the count is the helper's frame-count argument and | ||
| 1054 | +must be read from that call — the sweep's `candidate` column resolves for only one | ||
| 1055 | +gate, which is exactly why these were not bulk-edited. Bucket **c**: leave; a | ||
| 1056 | +census reports and asserts no verdict, so a wrong count there is not a wrong count. | ||
| 1057 | + | ||
| 1058 | +**DISPOSITION: deferred(needs a lane that classifies by READING each gate, bucket a | ||
| 1059 | +then bucket b).** Not a merge blocker: with `frame_count_diagnosis` in place, a | ||
| 1060 | +wrong count is now loud and self-explaining, so the 43 are diagnosable rather than | ||
| 1061 | +mysterious. | ||
| 1062 | + | ||
| 1063 | +## 5. The guard, generalized | ||
| 1064 | + | ||
| 1065 | +The r7 anchor asserted one literal (`pictures.len()`) at the fixed gate, which | ||
| 1066 | +would go quiet as other sites are fixed. It now asserts the **general** rule: | ||
| 1067 | + | ||
| 1068 | +* no **decode-derived** count (`pictures.len()` / `decoded.len()` / `frames.len()`) | ||
| 1069 | + may reappear at the gate r7 fixed, under any binding name; and | ||
| 1070 | +* an **unpinned ceiling** of 43 — a NEW site is an immediate red, and the ceiling | ||
| 1071 | + is lowered as sites are actually fixed. | ||
| 1072 | + | ||
| 1073 | +The `>= 40` floor on total sites stays, so the class cannot shrink unnoticed. | ||