diff --git a/crates/ec-av1/src/gate_coverage.rs b/crates/ec-av1/src/gate_coverage.rs index 1aaf14a9..ac83f388 100644 --- a/crates/ec-av1/src/gate_coverage.rs +++ b/crates/ec-av1/src/gate_coverage.rs @@ -2092,50 +2092,176 @@ mod count_vacuity { pub fixable_from: Option, } - /// A census/probe/diagnostic gate: it reports, it does not assert a verdict. - fn is_probe(gate: &str) -> bool { - [ - "census", - "probe", - "sweep", - "first_diff", - "scratch", - "rectx", - "diagnostic", - ] - .iter() - .any(|m| gate.contains(m)) - } + /// The scanner's matchers, as SINGLE-SOURCE tables. + /// + /// They are `pub const` rather than inline literals because the sweep's + /// floor only catches a LOST shape; nothing caught a matcher that has + /// never fired, so a dead spelling sat in this list advertising coverage + /// the scan does not have (class: unexercised matcher in a source + /// scanner). [`count_vacuity_tests::every_scanner_matcher_fires_on_a_known_site`] + /// iterates THESE arrays, so a matcher cannot be added here without a + /// positive control that has to pass. + + /// Oracle call spellings whose LAST argument is a locally derived count. + /// `ffmpeg_decode_sequence_444(` fires on five real `stream.rs` gates + /// (stream.rs:7030/7545/7735/8439/11643) but yields no count-vacuity SITE, + /// because every one of those five passes the spec const `FRAMES` rather + /// than a decode-derived `.len()`. It is live coverage, not a dead + /// spelling, and the control below measures the spelling, not the site. + pub const CALLEES: &[&str] = &[ + "ffmpeg_decode_sequence(", + "ffmpeg_decode_sequence_10bit(", + "ffmpeg_decode_sequence_444(", + ]; + + /// Gate-name substrings that mark a census/probe/diagnostic gate: it + /// reports, it does not assert a verdict. `"diagnostic"` was here and has + /// no gate in the tree carrying it (and no other occurrence in the crate + /// outside this list), so it was DELETED rather than kept: there is no + /// hypothetical caller to name, and a probe that later wants that name + /// re-adds one line here, where the control then holds it to firing. + pub const PROBE_SUBSTRINGS: &[&str] = + &["census", "probe", "sweep", "first_diff", "scratch", "rectx"]; /// Encode helpers a gate can drive INDIRECTLY. The r7 extraction found 21 of /// the 25 bucket-b gates encode through one of these, not through /// `aomenc_path()` directly -- which is why a first pass that only looked for /// `aomenc_path()` classified 6 gates "unclassified" that plainly encode. + /// Six further names (`the_chroma_rect_gates`, `restore_gate`, + /// `cdef_gate`, `superres_gate`, `grain_gate`, `sgate`) were here and + /// matched no `fn` body in the tree; `grep -rn '\bNAME\b' crates/ec-av1/src` + /// returns these six and NOTHING ELSE -- no helper, no caller, no comment + /// naming them -- so they were rot and are DELETED, not kept with a + /// hypothetical-caller note. + pub const ENC_HELPERS: &[&str] = &[ + "encode_aomenc_stream", + "screen_intrabc_stream_at_depth", + "screen_intrabc_stream_with", + "libaom_encode_with", + "libaom_encode", + "run_multi_tile_gate", + "edge32_gate", + "rect_tx_tool_gate", + "warp_gate", + ]; + + /// Frame-count bindings that are a SPEC rather than a self-fulfilling + /// number. `NFRAMES` and `frames_expected` were here, matched no `fn` + /// body, and appear nowhere else in the crate -- DELETED as rot. + pub const FIXABLE_CANDS: &[&str] = &["FRAMES", "frame_count"]; + + /// How many lines above a count site an `assert(..)` on the same binding + /// may sit and still call the count spec-pinned. A single-sourced const so + /// the control below can hold the WINDOW itself to being the window the + /// sweep walks (a window widened to EOF would pin sites it never pinned). + pub const PIN_WINDOW: usize = 14; + + /// The bucket-(b) leaf: a gate that drives aomenc directly rather than + /// through [`ENC_HELPERS`]. + pub const AOMENC_LEAF: &str = "aomenc_path()"; + + /// The bucket-(a) leaves: a gate that reads its stream from disk. + pub const DISK_READ_LEAVES: &[&str] = &["fs::read", "crate_pin"]; + + /// A census/probe/diagnostic gate: it reports, it does not assert a verdict. + fn is_probe(gate: &str) -> bool { + PROBE_SUBSTRINGS.iter().any(|m| gate.contains(m)) + } + + /// Encode helpers a gate can drive INDIRECTLY -- see [`ENC_HELPERS`]. fn enc_helpers(body: &str) -> Vec<&'static str> { - const NAMES: &[&str] = &[ - "encode_aomenc_stream", - "screen_intrabc_stream_at_depth", - "screen_intrabc_stream_with", - "libaom_encode_with", - "libaom_encode", - "run_multi_tile_gate", - "edge32_gate", - "rect_tx_tool_gate", - "the_chroma_rect_gates", - "restore_gate", - "cdef_gate", - "warp_gate", - "superres_gate", - "grain_gate", - "sgate", - ]; - NAMES + ENC_HELPERS .iter() .copied() .filter(|n| body.contains(&format!("{n}("))) .collect() } + /// End byte of the `fn` body starting at `fn_start`: a STRING- and + /// line-comment-aware brace walk (the trap it dodges is recorded at the + /// call site). Extracted so the matchers' positive-control test walks the + /// EXACT slice the scanner classifies -- a control that re-implemented the + /// walk would be measuring a different thing than the guard (class + /// control-and-measurement-drift). + pub fn fn_body_end(src: &str, fn_start: usize) -> usize { + let bytes = src.as_bytes(); + let mut depth = 0i32; + let mut started = false; + let mut fn_end = src.len(); + let mut in_str = false; + let mut in_line_comment = false; + let mut k = fn_start; + while k < bytes.len() { + let c = bytes[k]; + if in_line_comment { + if c == b'\n' { + in_line_comment = false; + } + k += 1; + continue; + } + if in_str { + if c == b'\\' { + k += 2; + continue; + } + if c == b'"' { + in_str = false; + } + k += 1; + continue; + } + match c { + b'"' => in_str = true, + b'/' if bytes.get(k + 1) == Some(&b'/') => { + in_line_comment = true; + k += 1; + } + b'{' => { + depth += 1; + started = true; + } + b'}' => { + depth -= 1; + if started && depth == 0 { + fn_end = k + 1; + break; + } + } + _ => {} + } + k += 1; + } + fn_end + } + + /// `(fn name, body slice)` for every top-level `fn` in `src`, attributed + /// the way [`sites`] attributes a site to its gate. + pub fn fn_slices(src: &str) -> Vec<(String, &str)> { + let lines: Vec<&str> = src.lines().collect(); + let mut offsets: Vec = Vec::with_capacity(lines.len()); + { + let mut o = 0usize; + for l in &lines { + offsets.push(o); + o += l.len() + 1; + } + } + let mut out: Vec<(String, &str)> = Vec::new(); + for (i, line) in lines.iter().enumerate() { + let t = line.trim_start(); + let Some(rest) = t.strip_prefix("fn ") else { continue }; + let Some(nm) = rest.split('(').next() else { continue }; + if nm.contains(' ') { + continue; + } + let at = offsets[i]; + let end = fn_body_end(src, at); + out.push((nm.to_string(), &src[at..end])); + } + out + } + pub fn sites(src: &str) -> Vec { let mut out = Vec::new(); let lines: Vec<&str> = src.lines().collect(); @@ -2163,11 +2289,7 @@ mod count_vacuity { } } } - for callee in [ - "ffmpeg_decode_sequence(", - "ffmpeg_decode_sequence_10bit(", - "ffmpeg_decode_sequence_444(", - ] { + for callee in CALLEES { let Some(at) = line.find(callee) else { continue; }; @@ -2207,7 +2329,7 @@ mod count_vacuity { // every multi-line spelling and inflated the unpinned count. let want = format!("{binding}.len()"); let mut pinned = None; - for back in 1..=14usize { + for back in 1..=PIN_WINDOW { if i < back { break; } @@ -2242,54 +2364,7 @@ mod count_vacuity { // body and made every compare-detection read false -- the same // trap that made stream.rs look 2 braces short in the first // review of this wave. - let bytes = src.as_bytes(); - let mut depth = 0i32; - let mut started = false; - let mut fn_end = src.len(); - let mut in_str = false; - let mut in_line_comment = false; - let mut k = fn_start; - while k < bytes.len() { - let c = bytes[k]; - if in_line_comment { - if c == b'\n' { - in_line_comment = false; - } - k += 1; - continue; - } - if in_str { - if c == b'\\' { - k += 2; - continue; - } - if c == b'"' { - in_str = false; - } - k += 1; - continue; - } - match c { - b'"' => in_str = true, - b'/' if bytes.get(k + 1) == Some(&b'/') => { - in_line_comment = true; - k += 1; - } - b'{' => { - depth += 1; - started = true; - } - b'}' => { - depth -= 1; - if started && depth == 0 { - fn_end = k + 1; - break; - } - } - _ => {} - } - k += 1; - } + let fn_end = fn_body_end(src, fn_start); let body = &src[fn_start..fn_end]; // APPROXIMATE, and known to be so: the body slice is a // hand-rolled brace walk, and this crate's compare idioms vary @@ -2307,7 +2382,7 @@ mod count_vacuity { || body.contains("vs ffmpeg")); // A SPEC already in scope for this gate? let mut fixable = None; - for cand in ["FRAMES", "frame_count", "NFRAMES", "frames_expected"] { + for cand in FIXABLE_CANDS { if body.contains(&format!("const {cand}")) || body.contains(&format!("let {cand}")) { @@ -2341,12 +2416,12 @@ mod count_vacuity { Some("c"), "census/probe: reports, does not assert a verdict".to_string(), ) - } else if body.contains("aomenc_path()") || !enc_helpers(body).is_empty() { + } else if body.contains(AOMENC_LEAF) || !enc_helpers(body).is_empty() { ( Some("b"), "live aomenc encode: count belongs to the encoder".to_string(), ) - } else if body.contains("fs::read") || body.contains("crate_pin") { + } else if DISK_READ_LEAVES.iter().any(|leaf| body.contains(leaf)) { ( Some("a"), "stream read from disk: count belongs to the pin".to_string(), @@ -2374,6 +2449,109 @@ mod count_vacuity { } out } + + /// Every matcher's POSITIVE CONTROL: each spelling in this module's tables + /// must fire on at least one real thing in the scanned source, or the + /// spelling is advertising coverage the scan does not have. + /// + /// This is the missing half of the sweep's own floor. `s.len() >= 40` and + /// the unpinned ceiling both catch a LOST shape; nothing caught a matcher + /// that never fired -- which is how six encode-helper names, two spec + /// binding names and one probe substring sat in these tables matching + /// nothing anywhere in the crate (class: unexercised matcher in a source + /// scanner). Those nine are deleted. The control reads the SAME `const` + /// tables the scanner reads, so a matcher added later cannot skip it. + /// + /// `fn_slices` walks the same `fn_body_end` the scanner classifies with, so + /// "fires" means fires on the slice the guard actually reads. + #[test] + fn every_scanner_matcher_fires_on_a_known_site() { + let src = include_str!("stream.rs"); + let lines: Vec<&str> = src.lines().collect(); + let fns = fn_slices(src); + + // The callee list, as a SPELLING. Not as a produced site: the + // `_444` spelling fires on five real gates that all pass the spec + // const `FRAMES`, so it correctly yields no count-vacuity site. A + // spelling that no `stream.rs` line uses is a spelling that has + // stopped being written and is now dead weight in the table. + for callee in CALLEES { + let hits = lines.iter().filter(|l| l.contains(callee)).count(); + assert!( + hits > 0, + "the callee matcher `{callee}` fires on NO line of stream.rs -- it is dead \ + coverage: either a gate stopped using that spelling (drop the entry) or a \ + new one is expected to (add the call site first, not the matcher)" + ); + } + + // The gate-name probe substrings, against real fn names. + for sub in PROBE_SUBSTRINGS { + let hits = fns.iter().filter(|(g, _)| g.contains(sub)).count(); + assert!( + hits > 0, + "the probe substring `{sub}` matches NO fn name in stream.rs -- bucket (c) is \ + unpopulated and the substring is dead weight" + ); + } + + // The indirect-encode helpers, against real fn BODIES. + for helper in ENC_HELPERS { + let hits = fns + .iter() + .filter(|(_, b)| b.contains(&format!("{helper}("))) + .count(); + assert!( + hits > 0, + "the encode-helper matcher `{helper}(` matches NO fn body in stream.rs -- it is \ + dead coverage (grep the crate: if the helper has no caller, delete the entry; if \ + it has a caller outside stream.rs, say so here and name the file)" + ); + } + + // The spec-binding candidates, against real fn BODIES. + for cand in FIXABLE_CANDS { + let hits = fns + .iter() + .filter(|(_, b)| { + b.contains(&format!("const {cand}")) || b.contains(&format!("let {cand}")) + }) + .count(); + assert!( + hits > 0, + "the spec-binding matcher `{cand}` matches NO fn body in stream.rs -- `fixable_from` \ + can never name it, so it is dead coverage" + ); + } + + // The two bucket leaves the classifier short-circuits on. + assert!( + fns.iter().any(|(_, b)| b.contains(AOMENC_LEAF)), + "no fn body in stream.rs calls `{AOMENC_LEAF}`, so the bucket-(b) direct-encode leaf \ + never fires" + ); + for leaf in DISK_READ_LEAVES { + let hits = fns.iter().filter(|(_, b)| b.contains(leaf)).count(); + assert!( + hits > 0, + "the disk-read leaf `{leaf}` matches NO fn body in stream.rs -- bucket (a) is \ + unpopulated by that spelling" + ); + } + + // The pin window is a matcher too: a window so wide it pinned + // everything, or so narrow it pinned nothing, would leave the + // ceiling reading a population it no longer describes. + let s = sites(src); + let pinned = s.iter().filter(|x| x.pinned_by.is_some()).count(); + assert!( + PIN_WINDOW > 0 && pinned > 0, + "PIN_WINDOW={PIN_WINDOW} pins {pinned} of {} site(s) -- the window must be the one \ + the sweep walks and must still pin at least one site", + s.len() + ); + } + } #[cfg(test)] diff --git a/lanes/av1w3erefute.report.md b/lanes/av1w3erefute.report.md new file mode 100644 index 00000000..3c0454ef --- /dev/null +++ b/lanes/av1w3erefute.report.md @@ -0,0 +1,344 @@ +# lanes/av1w3erefute — wave-3e refutation, read-only + +Worktree `/home/user/.cache/wt/av1w3erefute`, branch `lane-av1w3erefute`, base `3b691e13` +(main). `CARGO_TARGET_DIR=/home/user/.cache/wt/tgt-av1w3erefute`. Oracle: +`~/.cache/aom-oracle/build/{aomenc,aomdec}`. + +Note on provenance: the tip sha `4bfe8d8e` is NOT an ancestor of main +(`git merge-base --is-ancestor 4bfe8d8e main` → NO). The *content* landed +squashed/rebased through `c0727d64` inside `lane-av1txsizeaudit-r5`; all three +items below were located in main's tree, not in the foreign branch's. + +## Verdict table + +| # | Item | Verdict | Deciding raw line | +|---|------|---------|-------------------| +| 1 | `4bfe8d8e` intra-in-inter fix, gate `stream::tests::a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact` | **PASS** | `3 decode-order frames pixel-exact (0 hidden), intra_128_in_inter=1 mu_chunk_chroma_reads=4` | +| 2 | `C1` `fctx` into `suppress_internal_lf_edges` + source-scan gate | **PASS** (gate), with one dead assertion (see Not-done) | `suppress_internal_lf_edges must publish the block's own chroma extent per axis ... not a hardcoded `/2`` | +| 3 | `pins5` generalised count/pin guard, ceiling 43 / floor 40 | **PASS** | `count-vacuity sweep: 60 site(s); 17 spec-pinned by a prior assert, 43 not` | + +--- + +## Item 1 — intra-in-inter 128-root mu-chunk chroma gate + +### Exists, runs, cannot skip + +`crates/ec-av1/src/stream.rs:37628` — `#[test] fn +a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact()`. + +Non-vacuity is asserted three ways in the gate itself, not merely "ok": +sequence header asserted 4:4:4/128-SB, `intra_128_in_inter_hits() >= 1`, +`intra_128_in_inter_mu_chroma_hits() >= 4`, plus byte-exact compare per frame. + +``` +$ EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -- --nocapture --test-threads=1 \ + a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact +running 1 test +test stream::tests::... ... a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact: 3 decode-order frames pixel-exact (0 hidden), intra_128_in_inter=1 mu_chunk_chroma_reads=4 +ok +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 761 filtered out; finished in 0.53s +``` + +Route counters are `> 0` (1 root, 4 mu-chunk chroma reads) — the arm ran. + +### The env really reaches the test (it cannot report green off a SKIP) + +`stream.rs:9404` `have_aomenc()` asserts when `EC_AV1_REQUIRE_AOMENC` is set; +`stream.rs:5283` `have_ffmpeg()` asserts the same for the ffmpeg half. + +``` +$ EC_AV1_AOMENC=/nonexistent/aomenc EC_AV1_REQUIRE_AOMENC=1 cargo test ... +EC_AV1_REQUIRE_AOMENC is set but no aomenc at /nonexistent/aomenc -- run scripts/build-aom-oracle.sh +test result: FAILED. 0 passed; 1 failed; ... # env reached the test + +$ EC_AV1_AOMENC=/nonexistent/aomenc cargo test ... # env unset +test ... SKIP a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact: no ffmpeg/aomenc/aomdec +test result: ok. 1 passed; ... # the developer escape, and only this one +``` + +### Mutation proof (RED → restored GREEN) + +Guarded value: the per-mu-chunk CHROMA extent at `decode.rs:43262-43263`, mutated from the +ss-aware form back to the 4:2:0-hardcoded literal. + +```diff + crates/ec-av1/src/decode.rs + let chunk_luma = 64usize; +- let chunk_chroma_w = chunk_luma >> ss_x(fctx); +- let chunk_chroma_h = chunk_luma >> ss_y(fctx); ++ let chunk_chroma_w = 32usize; ++ let chunk_chroma_h = 32usize; +``` + +RED: + +``` +$ EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -- --nocapture --test-threads=1 +thread '...pixel_exact' panicked at crates/ec-av1/src/stream.rs:9683:17: +a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact: decode-order frame 2 of 3 (3 shown, 0 hidden) differs from the oracle at byte 15450 (ours 142 vs 141), 44649 bytes differ +test result: FAILED. 0 passed; 1 failed; ... +``` + +The 44649-byte figure matches the number the gate's own doc comment claims +(`stream.rs:37620-37623`) — the claimed red-before is real, and the red is on +PIXELS, not on the counter. + +Restore (`git checkout -- crates/ec-av1/src/decode.rs`, `git status --short` empty): + +``` +a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact: 3 decode-order frames pixel-exact (0 hidden), intra_128_in_inter=1 mu_chunk_chroma_reads=4 +ok +test result: ok. 1 passed; 0 failed; ... +``` + +**Item 1: PASS.** + +--- + +## Item 2 — `C1`, `fctx` threaded into `suppress_internal_lf_edges` + +Gate: `refusal_inventory::tests::the_skipped_128_root_chroma_suppression_publishes_the_blocks_own_per_axis_chroma_extent` +(`crates/ec-av1/src/refusal_inventory.rs:1862`). + +Baseline: + +``` +$ cargo test -p ec-av1 --lib -- --test-threads=1 the_skipped_128_root_...extent +test refusal_inventory::tests::... ... ok +test result: ok. 1 passed; 0 failed; ... +``` + +### Mutation A — guarded expression + +```diff + crates/ec-av1/src/decode.rs:9279 +- let (uv_w, uv_h) = (((w_mi * MI) >> ss_x(fctx)).max(4) as u8, ((h_mi * MI) >> ss_y(fctx)).max(4) as u8); ++ let (uv_w, uv_h) = ((w_mi * MI / 2).max(4) as u8, (h_mi * MI / 2).max(4) as u8); +``` + +RED: + +``` +suppress_internal_lf_edges must publish the block's own chroma extent per axis -- `w_mi * MI >> ss_x(fctx)`, not a hardcoded `/2` +test result: FAILED. 0 passed; 1 failed; ... +``` + +### Mutation A also proves the scan reads the BODY, not a same-indent window / EOF + +`decode.rs:9301` — the *sibling* `fill_lf_grid_rect` — still carries the identical +correct string `((w_mi * MI) >> ss_x(fctx))`, and it sits 22 lines BELOW +`suppress_internal_lf_edges`'s closing brace. If the `&src[body_start..body_start + +src[body_start..].find("\n }")]` slice over-ran (to EOF, or past the function), +the positive `body.contains(...)` would have been satisfied by the sibling and the +gate would have stayed green. It went RED. The window is bounded at the function's +own 4-space closing brace (`decode.rs:9285`), and the `stale` loop +(`"w_mi * MI / 2"`, `"h_mi * MI / 2"`) is inside the same window. + +Restore: `git checkout -- crates/ec-av1/src/decode.rs` → gate `ok` again. + +### Is the change observable on any committed fixture? + +No. Full mutation (`w_mi * MI / 2`, the pre-`C1` form) over the whole committed +4:4:4 corpus: + +``` +$ EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib 444 +... +test result: ok. 38 passed; 0 failed; 0 ignored; 0 measured; 724 filtered out; finished in 22.70s +``` + +38/38 pixel-exact gates stay green with the fix reverted, including +`a_real_aomenc_444_intra_in_inter_128_root_codes_chroma_per_mu_chunk_unit_pixel_exact` +and `a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact`. 4:2:0 is +unaffected by construction (`>> 1 == / 2`). + +#### What is REPRODUCED here vs what is QUOTED from the author + +| Claim | Status | +|---|---| +| Reverting `suppress_internal_lf_edges` to `w_mi * MI / 2` changes no committed 4:4:4 pixel (38/38 green) | **REPRODUCED here** — command and output above | +| The source-scan gate goes RED on exactly that revert, and green again on restore | **REPRODUCED here** — red/green pair above | +| The source-scan reads the function BODY, not a same-indent run to EOF | **REPRODUCED here** — the sibling at `decode.rs:9301` carries the identical correct string and the mutated gate still red | +| "30 fires / 2 555 904 samples / 26 frames across five 4:4:4 `--sb-size=128` streams" | **QUOTED, NOT REPRODUCED** — author-reported (`refusal_inventory.rs:1852-1858`). I did not re-run those five streams or re-count the arm firings. My evidence is the WEAKER claim in the first row, and it is sufficient for the verdict. | +| "no pixel gate can exist for this site / the masking is TOTAL" | **PARTLY REPRODUCED** — no committed 4:4:4 fixture observes the value, consistent with it. The universal statement (no possible input distinguishes 64 from 128 here) is quoted, not proven. | + +**Item 2: PASS** on the gate's existence, non-vacuity, body-scoping, and +correct restoration. Caveat kept: the third assert (`sig_end` contains +`fctx: &FrameCtx`) can never be the deciding assertion — the positive body +assert reds first. Defense-in-depth, not a failure. + +--- + +## Item 3 — `pins5` count/pin guard + +Gates: `gate_coverage::count_vacuity_tests::the_count_vacuity_sweep_finds_the_known_sites` +(floor 40 + ceiling 43, `gate_coverage.rs:2374-2427`) and +`...::every_locally_derived_oracle_count_is_reported` (the table). + +Baseline: + +``` +$ cargo test -p ec-av1 --lib count_vacuity -- --nocapture --test-threads=1 +count-vacuity sweep: 60 site(s); 17 spec-pinned by a prior assert, 43 not +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 760 filtered out; finished in 0.08s +``` + +Arithmetic checks out: 17 + 43 = 60 exactly, and the 43 reported lines +(`NOT SPEC-PINNED`) counted by grep = 43. The reported sweep line, the ceiling +constant and the unpinned population are one number, not three. + +### Mutation A — drop one site ⇒ the tracked count falls 43 → 42 + +```diff + crates/ec-av1/src/stream.rs:5631 +- let want = ffmpeg_decode_sequence(&data, width, height, decoded.len()); ++ let want = ffmpeg_decode_sequence(&data, width, height, decoded.len() + 0); +``` + +``` +count-vacuity sweep: 59 site(s); 17 spec-pinned by a prior assert, 42 not +test result: ok. 2 passed; 0 failed; ... +``` + +The site set, the pinned count and the unpinned count all move together. With the +ceiling lowered to 41 the same tree reds, naming the LIVE count: + +``` +42 unpinned count site(s), ceiling is 41 -- a new one was added (lower the ceiling only when a site is actually fixed) +test result: FAILED. 0 passed; 1 failed; ... +``` + +So the "correct ceiling" after that fix is 42, one lower than 43 — removing a site +moves the ceiling DOWN, as required. (The guard deliberately does not force the +constant down; the constant is only a "no new site" tripwire.) + +### Mutation B — a new unpinned site ⇒ immediate red at the real ceiling 43 + +Narrowed the pin-detection window (`gate_coverage.rs:2209`) from `1..=14` to +`1..=1` so five previously-pinned sites read as unpinned; ceiling restored to 43: + +``` +count-vacuity sweep: 60 site(s); 12 spec-pinned by a prior assert, 48 not +48 unpinned count site(s), ceiling is 43 -- a new one was added (lower the ceiling only when a site is actually fixed) +test result: FAILED. 1 passed; 1 failed; ... +``` + +### Mutation C — the floor is live + +Dropped `"ffmpeg_decode_sequence("` from the scanner's callee list +(`gate_coverage.rs:2167`): + +``` +count-vacuity sweep: 25 site(s); 12 spec-pinned by a prior assert, 13 not +the count-vacuity sweep found only 25 site(s); expected 40+ -- it has lost a shape +test result: FAILED. 1 passed; 1 failed; ... +``` + +Restore: `git checkout -- crates/ec-av1/src/gate_coverage.rs crates/ec-av1/src/decode.rs +crates/ec-av1/src/stream.rs`; `git status --short` empty; all three gates green +again (`60 site(s); 17 spec-pinned ... 43 not`, `1 passed` for each of the two +pixel/source gates). + +**Item 3: PASS.** + +### Class sweep — unexercised matcher in a source scanner + +My first pass called `"ffmpeg_decode_sequence_444("` a dead matcher. **That was +wrong, and the correction is the interesting part.** Deleting it left the sweep at +`60/17/43` because it produces no count-vacuity SITE — but it is not rot: it fires +on five real `stream.rs` gates (`stream.rs:7030, 7545, 7735, 8439, 11643`), each +of which passes the spec const `FRAMES` rather than a decode-derived `.len()`, so +the `.len()`/`.count()` filter correctly rejects all five. **KEPT, with a reason**, +and the control measures the SPELLING (≥1 line uses it) rather than the produced +site — measuring the site is what made it look dead in the first place. + +So the real defect is one level up: the sweep's floor catches a LOST shape, and +nothing caught a matcher that never fired. Every matcher in the scanner was +measured. Nine of them fire on nothing anywhere in the crate: + +| Matcher | Table | Decision | Evidence | +|---|---|---|---| +| `ffmpeg_decode_sequence(` | callee | keep (live) | 174 lines; 35 of the 60 sites | +| `ffmpeg_decode_sequence_10bit(` | callee | keep (live) | 87 lines; 25 of the 60 sites | +| `ffmpeg_decode_sequence_444(` | callee | **keep + reason** | 6 lines, 5 call sites, 0 sites by construction — see above | +| `census`/`probe`/`sweep`/`first_diff`/`scratch`/`rectx` | probe substrings | keep (live) | 9/2/4/1/2/1 fns | +| `diagnostic` | probe substrings | **DELETE** | 0 fns; `grep -rn '\bdiagnostic\b' crates/ec-av1/src` hits only prose in other files, never a fn name | +| `encode_aomenc_stream`, `screen_intrabc_stream_at_depth`, `screen_intrabc_stream_with`, `libaom_encode_with`, `libaom_encode`, `run_multi_tile_gate`, `edge32_gate`, `rect_tx_tool_gate`, `warp_gate` | enc helpers | keep (live) | 3/3/5/5/2/8/4/3/5 fn bodies | +| `the_chroma_rect_gates`, `restore_gate`, `cdef_gate`, `superres_gate`, `grain_gate`, `sgate` | enc helpers | **DELETE (6)** | 0 fn bodies; `grep -rn '\bNAME\b' crates/ec-av1/src` returns the matcher list and NOTHING ELSE — no helper, no caller, no comment | +| `FRAMES` / `frame_count` | spec bindings | keep (live) | 24 / 7 fn bodies | +| `NFRAMES`, `frames_expected` | spec bindings | **DELETE (2)** | 0 fn bodies; occur nowhere else in the crate | +| `aomenc_path()`, `fs::read`, `crate_pin` | bucket leaves | keep (live) | 188 / 71 / 9 fn bodies | +| pin-detection window (14) | `for back in 1..=14` | keep (live) | pins 17 of 60 | + +**Nine dead spellings, all deleted** (1 probe substring + 6 encode helpers + 2 spec +bindings). Every one was provably rot — the string appears nowhere in the crate +outside the matcher table itself, so there is no hypothetical caller to name and +nothing loses coverage by removing it. Per the lane's stop rule I went no further: +no behavioural change to the scanner beyond the deletions, and no re-design of the +classifier. + +### The positive control, and its own mutation proof + +All the tables are now single-sourced `pub const`s (`CALLEES`, `PROBE_SUBSTRINGS`, +`ENC_HELPERS`, `FIXABLE_CANDS`, `AOMENC_LEAF`, `DISK_READ_LEAVES`, `PIN_WINDOW`) and +the scanner reads those same consts, so a matcher added later cannot skip its +control. The control is +`gate_coverage::count_vacuity::every_scanner_matcher_fires_on_a_known_site` +(`gate_coverage.rs:2467`), and it measures "fires" on the EXACT `fn` body slice the +scanner classifies with — the brace walk was extracted from `sites` into +`count_vacuity::fn_body_end` so the control cannot drift onto a different slice +(class: control-and-measurement-drift). + +Green after the change: + +``` +$ cargo test -p ec-av1 --lib -- --nocapture --test-threads=1 count_vacuity +test gate_coverage::count_vacuity::every_scanner_matcher_fires_on_a_known_site ... ok +test gate_coverage::count_vacuity_tests::every_locally_derived_oracle_count_is_reported ... count-vacuity sweep: 60 site(s); 17 spec-pinned by a prior assert, 43 not +test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 760 filtered out; finished in 0.13s +``` + +The sweep line is UNCHANGED at **60 / 17 / 43** after the nine deletions, which is +the proof the deletions cost no coverage. + +RED — one of the deleted spellings re-added (`ENC_HELPERS += "sgate"`): + +``` +thread 'gate_coverage::count_vacuity::every_scanner_matcher_fires_on_a_known_site' panicked at crates/ec-av1/src/gate_coverage.rs:2505:13: +the encode-helper matcher `sgate(` matches NO fn body in stream.rs -- it is dead coverage (grep the crate: if the helper has no caller, delete the entry; if it has a caller outside stream.rs, say so here and name the file) +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 762 filtered out; finished in 0.04s +``` + +Restored: the entry is cut again and the control is `ok`. + +--- + +## Declared but unproven / not done + +1. **The `sig_end` assertion in the C1 gate is unreachable as a deciding + assertion.** The positive `body.contains("((w_mi * MI) >> ss_x(fctx))")` assert + runs first, so any edit that drops `fctx: &FrameCtx` from the signature must + also change the body, and the body assert reds first. Not a defect (the code + would not compile without the parameter, which the comment states correctly), + but the third assert is defense-in-depth that never fires on its own. +2. **C1's "30 fires / 2 555 904 samples over 26 frames across five 4:4:4 + `--sb-size=128` streams" is AUTHOR-REPORTED and NOT REPRODUCED here.** What I + verified is weaker and stated precisely: reverting the value changes no + committed 4:4:4 pixel (38/38 green), and the source scan's red on exactly that + revert is mutation-proven. See the "REPRODUCED here vs QUOTED from the author" + table under Item 2. +3. **No per-route counter exists for `suppress_internal_lf_edges`**, so item 2's + non-vacuity rests entirely on the source scan plus the negative pixel + evidence. That is consistent with the gate's own argument, but it means no + positive "this arm fired" witness exists for the site. +4. **No full suite was run** (per lane contract; heavy runs belong to the server + fleet). Every run here was `cargo test -p ec-av1 --lib `, on a + `cargo check`-clean tree, with a per-lane `CARGO_TARGET_DIR`. +5. **The `main`-vs-`4bfe8d8e` provenance** is by content equivalence at + `3b691e13`, not by ancestry: the sha is not in main's history. +6. **Decoder code was temporarily mutated** in this worktree for the red/green + pairs above and restored via `git checkout --` after each. The only PERMANENT + change is `crates/ec-av1/src/gate_coverage.rs`: the nine dead matcher + deletions, the const single-sourcing, the extracted `fn_body_end`, and the new + positive-control test. The sweep is UNCHANGED at `60 site(s); 17 spec-pinned, + 43 not`. No guard was relaxed; no decoder change is proposed.