From 1f8005ce452ab2ecc3bd278641b79c6b3c56a06a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 29 Sep 2026 05:26:36 +0300 Subject: [PATCH] =?UTF-8?q?ec-av1:=20r2=20=E2=80=94=20route=20the=20five?= =?UTF-8?q?=20guards=20that=20merged=20in=20after=20r1,=20close=20the=20cl?= =?UTF-8?q?ass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The merge review measured the CURRENT tree (9b2f6c9d), not r1's base: 21 `aomdec_path().is_file()` occurrences there, of which 18 were bare guard sites. Six gates that merged after r1 branched were added with the same silent shape and reported GREEN with the compare skipped under EC_AV1_REQUIRE_AOMENC=1. The lesson is the stale base: a class sweep run against a base that is still moving is a snapshot of the past, so the fix has to leave the decision in ONE place rather than in thirteen. All five remaining guards now call `aomdec_available`, including the inverted `if !aomdec_path().is_file() { … return; }` in a_444_lossless_sb64_intrabc_rect_chroma_walks_4x4_units. Seven redundant `else { eprintln!("… pixel arm skipped") }` arms are deleted (six scripted, one found by running the gates and seeing two SKIP lines for one skip), so a skip prints exactly one line, from the probe. 18 bare guard sites -> 0; the presence check survives in the probe, two hard asserts and two doc comments. Red-before re-proven on the current tree (r2 reverted, r1 as rebased) with EC_AV1_AOMDEC=/nonexistent/oracle/aomdec EC_AV1_REQUIRE_AOMENC=1: before: ok. 3 passed — a_444_lossless_sb64_intrabc… "no oracle aomdec at /nonexistent/oracle/aomdec, pixel arm skipped", a_lossless_block_clips_its_transform_grid… SKIP, and the rect4-strip gate printing one skip per pinned fixture after: FAILED. 0 passed; 3 failed — each naming the gate, the missing path and the env that should have caught it. Oracle present: the six plus the two superres-mode gates that share a_444_superres_arm pass (7 passed). Absent with the env unset: one SKIP per gate, developer-only convenience, unchanged. Acceptance: cargo test -p ec-av1 --lib -- gate_coverage refusal_inventory -> 26 passed, 0 failed (the enable-rect-tx staleness r1 reported is retired upstream). Report corrections in the same commit: the r1 header cited commit ee4f2d55, which does not exist (git cat-file: fatal) — replaced with 644bdbb8, the real rebased commit; and "thirteen gates" is thirteen CALL SITES across twelve distinct gates (a_444_lossy_rect4_inter_stream_decodes_pixel_exact calls the probe twice, for its 4:4:4 stream and its 4:2:0 control). --- crates/ec-av1/src/stream.rs | 76 ++++++++++----------- lanes/av1oracleSkip.report.md | 123 +++++++++++++++++++++++++++++++--- 2 files changed, 152 insertions(+), 47 deletions(-) diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index d253a274..3fd972f1 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -6969,13 +6969,8 @@ pub(crate) mod tests { for f in &frames { assert_eq!((f.width, f.height), (W, H), "{NAME}: dimensions"); } - if aomdec_path().is_file() { + if aomdec_available(NAME) { assert_rawvideo_matches(&obu, &stream, NAME, FRAMES); - } else { - eprintln!( - "SKIP {NAME} aomdec arm: no oracle aomdec at {}", - aomdec_path().display() - ); } // Control: a stream whose roots all fit must not clip at all. @@ -7427,8 +7422,6 @@ pub(crate) mod tests { "{NAME}: {decoded} frame(s) byte-exact vs aomdec, {own_chroma} \ own-extent 1:4 chroma gather(s)" ); - } else { - eprintln!("{NAME}: no oracle aomdec, pixel arm skipped"); } // The specificity arm: the SAME source, flags and 1:4 partitions at @@ -7862,8 +7855,6 @@ pub(crate) mod tests { (U/V first wrong at index 20532, entropy fork read 12465 at \ mi (90,108)) -- see lanes/av1444rect.report.md \u{00a7}6" ); - } else { - eprintln!("{NAME}: no oracle aomdec, pixel arm skipped"); } } @@ -14215,8 +14206,6 @@ pub(crate) mod tests { width) per frame, {scaled_up} upscale(s), {scaled_mc} scaled MC block(s); \ fixture sha256 {fixture_sha}" ); - } else { - eprintln!("{name}: no oracle aomdec, pixel arm skipped"); } heads } @@ -46059,7 +46048,9 @@ pub(crate) mod tests { let mut parser = Av1Parser::new(); let mut pos = 0usize; while pos < stream.len() { - let obu = parser.parse_obu(&stream[pos..]).expect("parsing our own OBUs"); + let obu = parser + .parse_obu(&stream[pos..]) + .expect("parsing our own OBUs"); pos += obu.total_size; } parser @@ -46243,12 +46234,12 @@ pub(crate) mod tests { ); assert_eq!(frames.len(), FRAMES, "{NAME}: frame count"); - if !aomdec_path().is_file() { + // The probe decides; its own SKIP (and its assert under + // EC_AV1_REQUIRE_AOMDEC / EC_AV1_REQUIRE_AOMENC) has already been said. + if !aomdec_available(NAME) { eprintln!( - "{NAME}: {chroma4} lossless rect intra-BC block(s) walked 4x4 chroma \ - units, {wht} WHT units, 0 split; no oracle aomdec at {}, pixel arm \ - skipped", - aomdec_path().display() + "{NAME}: {chroma4} lossless rect intra-BC block(s) walked 4x4 chroma units, \ + {wht} WHT units, 0 split" ); return; } @@ -46428,9 +46419,8 @@ pub(crate) mod tests { h + v }; crate::decode::reset_rect4_inter_own_chroma444_hits(); - let frames = decode_stream(&stream).unwrap_or_else(|e| { - panic!("{NAME}: {fixture} no longer decodes cleanly: {e}") - }); + let frames = decode_stream(&stream) + .unwrap_or_else(|e| panic!("{NAME}: {fixture} no longer decodes cleanly: {e}")); let own_chroma = crate::decode::rect4_inter_own_chroma444_hits(); let strips = { let (h, v, _, _) = crate::decode::inter16_rect4_counters(); @@ -46467,15 +46457,13 @@ pub(crate) mod tests { f.u.len() ); } - if aomdec_path().is_file() { + if aomdec_available(NAME) { let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME); eprintln!( "{NAME}: {fixture} {decoded} decode-order frame(s) \ ({hidden} hidden) byte-exact vs aomdec, {own_chroma} own-extent \ 1:4 chroma gather(s), {strips} 1:4 inter strip(s)" ); - } else { - eprintln!("{NAME}: {fixture}: no oracle aomdec, pixel arm skipped"); } } } @@ -46696,7 +46684,7 @@ pub(crate) mod tests { f.v.len() ); } - if aomdec_path().is_file() { + if aomdec_available(NAME) { let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, NAME); eprintln!( "{NAME}: {decoded} decode-order frame(s) ({hidden} hidden) byte-exact vs \ @@ -46704,8 +46692,6 @@ pub(crate) mod tests { {scaled_up} upscale(s), {scaled_mc} scaled MC block(s); fixture sha256 \ {FIXTURE_SHA256}" ); - } else { - eprintln!("{NAME}: no oracle aomdec, pixel arm skipped"); } } @@ -46842,8 +46828,9 @@ pub(crate) mod tests { let _guard = lock_gate_counters(); let before_sr = crate::superres::superres_hits(); let before_scaled = crate::mc::predict_scaled_hits(); - let frames = decode_stream(&stream) - .unwrap_or_else(|e| panic!("{name}: the pinned 4:4:4 superres stream was refused: {e}")); + let frames = decode_stream(&stream).unwrap_or_else(|e| { + panic!("{name}: the pinned 4:4:4 superres stream was refused: {e}") + }); let scaled_up = crate::superres::superres_hits() - before_sr; let scaled_mc = crate::mc::predict_scaled_hits() - before_scaled; assert!( @@ -46883,7 +46870,7 @@ pub(crate) mod tests { ); } } - if aomdec_path().is_file() { + if aomdec_available(name) { let (decoded, hidden) = decode_all_frames_vs_oracle(&stream, name); eprintln!( "{name}: {decoded} decode-order frame(s) ({hidden} hidden) byte-exact vs \ @@ -46891,8 +46878,6 @@ pub(crate) mod tests { width) per frame, {scaled_up} upscale(s), {scaled_mc} scaled MC block(s); \ fixture sha256 {fixture_sha}" ); - } else { - eprintln!("{name}: no oracle aomdec, pixel arm skipped"); } heads } @@ -47009,9 +46994,21 @@ pub(crate) mod tests { } let y4m = Command::new("ffmpeg") .args([ - "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=256x128:rate=25", - "-frames:v", "4", "-pix_fmt", "yuv444p", "-strict", "-1", "-f", - "yuv4mpegpipe", "-", + "-v", + "error", + "-f", + "lavfi", + "-i", + "testsrc2=size=256x128:rate=25", + "-frames:v", + "4", + "-pix_fmt", + "yuv444p", + "-strict", + "-1", + "-f", + "yuv4mpegpipe", + "-", ]) .stdin(Stdio::null()) .stdout(Stdio::piped()) @@ -47023,10 +47020,11 @@ pub(crate) mod tests { "{NAME}: ffmpeg refused to generate the y4m source: {}", String::from_utf8_lossy(&y4m.stderr) ); - let pinned = - std::fs::read(std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/444_lossy_superres_mode2_256x128.obu")) - .expect("pinned fixture disappeared between the two reads"); + let pinned = std::fs::read( + std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("fixtures/444_lossy_superres_mode2_256x128.obu"), + ) + .expect("pinned fixture disappeared between the two reads"); for extra in [ vec![], vec!["--superres-denominator=9"], diff --git a/lanes/av1oracleSkip.report.md b/lanes/av1oracleSkip.report.md index 062fa89a..676b04df 100644 --- a/lanes/av1oracleSkip.report.md +++ b/lanes/av1oracleSkip.report.md @@ -1,12 +1,12 @@ # lane-av1oracleskip — gate-honesty: the oracle SKIP class -**Tree.** `lane-av1oracleskip` off **main `7f8817cb`** ("Merge lane-av1pins @ -44a05b40"), worktree `~/.cache/wt/av1oracleskip`, branch -`lane-av1oracleskip`. Commit `ee4f2d55` (see §5). The primary checkout was -mid-merge when this lane started (`UU crates/ec-av1/src/stream.rs` in its -index), so this worktree is pinned to the last merge commit rather than to a -moving HEAD. Built in a lane-private `CARGO_TARGET_DIR` -(`~/.cache/cargo-target-av1oracleskip`). +**Tree.** `lane-av1oracleskip`, worktree `~/.cache/wt/av1oracleskip`. r1 was +cut from main `7f8817cb` ("Merge lane-av1pins @ 44a05b40") and is commit +`644bdbb8` after the r2 rebase onto `9b2f6c9d` ("Merge lane-av1dumpyuv @ +60a7788a"). The r1 text of this report was written when the primary checkout +was mid-merge (`UU crates/ec-av1/src/stream.rs` in its index), so the worktree +was pinned to a merge commit rather than to a moving HEAD. Built in a +lane-private `CARGO_TARGET_DIR` (`~/.cache/cargo-target-av1oracleskip`). **Scope.** (1) the three `lane-av1gates444` gates that reported green having measured nothing on a host without the oracle; (2) the class sweep behind it, @@ -86,7 +86,9 @@ env var, and this commit does not change that. **Shape B is the part the sweep found that nobody had named**, and it is worse than the three gates Main pointed at: those three fail loudly in REQUIRE mode (through `have_aomenc`), while all thirteen B sites had **no env escape at -all** — with `EC_AV1_REQUIRE_AOMENC=1` set and aomdec absent, they encoded, +all** (r2 correction: thirteen CALL SITES across **twelve** distinct gates — +`a_444_lossy_rect4_inter_stream_decodes_pixel_exact` calls the probe twice, +once for the 4:4:4 stream and once for its 4:2:0 control) — with `EC_AV1_REQUIRE_AOMENC=1` set and aomdec absent, they encoded, decoded, asserted their geometry and counters, skipped the compare, and reported green. Four of the thirteen printed nothing at all. @@ -157,3 +159,108 @@ fixture to fall back on, so a missing aomdec there really is a broken oracle and stays a hard failure. If the house wants the pinned gates to fail unconditionally too, that is a one-line change per site and a policy call, not a bug. + +--- + +# r2 — the class was NOT closed: a stale base + +r1 fixed thirteen call sites found on base `7f8817cb`. The merge review then +measured the CURRENT tree and found **21** bare `aomdec_path().is_file()` +occurrences there, not 13: six gates that merged after r1 branched were added +with the same silent shape, and under `EC_AV1_REQUIRE_AOMENC=1` with aomdec +absent all six reported GREEN with the compare skipped. **The lesson is bigger +than the fix: a class sweep run against a base that is still moving is a +snapshot of the past.** A lane that merges into main while others are +measuring will reopen the class behind your back unless the probe is the only +place the decision is made — which is why r2 leaves exactly one. + +## 7. The sweep, re-run on the current tree + +Current main at the r2 rebase: `9b2f6c9d`. `grep -c 'aomdec_path().is_file()'` +over `crates/ec-av1/src/stream.rs` gives **21**, which decomposes exactly: + +| kind | count on main | what r2 did | +|---|---|---| +| bare `if aomdec_path().is_file() { …compare… }` guards (17 positive + 1 inverted `if !…`) | **18** | **all 18 routed through `aomdec_available()`** — 13 in r1, 5 in r2 | +| `assert!(aomdec_path().is_file(), …)` — a deliberate hard failure | 2 | kept (they are the strict form) | +| a doc comment naming the old shape | 1 | kept (it documents the defect) | +| the presence check inside `aomdec_available` itself | 0 (it did not exist) | **the one place the decision is made** | + +**Before/after: 18 bare guard sites -> 0. The presence check now exists in +exactly one place** (`aomdec_available`, `stream.rs:9131-9160`), called from +**18 call sites**. Two of those sites sit in shared helpers, so the 18 sites +serve **20 tests**: `a_444_hbd_superres_arm` (site 14201) is called by +`a_444_lossy_superres_{10bit_d12,12bit_d12,12bit_d9}_stream_decodes_pixel_exact` +and `a_444_superres_arm` (site 46871) by +`a_444_lossy_superres_mode1_den9_stream_decodes_pixel_exact` (and the +`mode2_random_denom` gate, which calls the same helper through a second +path). Counting direct `NAME`-bearing tests only: **16 gates**, plus four more +reaching the same probe through a shared helper. The +`aomdec_path().is_file()` string now survives only in two doc comments, two +hard asserts, and the probe's own body. + +### The six gates the review named, routed in r2 + +| gate | r2 site (post-rebase line) | shape it had | now | +|---|---|---|---| +| `a_444_lossless_sb64_intrabc_rect_chroma_walks_4x4_units` | `stream.rs:46246` | **inverted** `if !aomdec_path().is_file() { eprintln!(… "pixel arm skipped"); return; }` | `if !aomdec_available(NAME) { …; return; }` — the probe has already said SKIP or failed | +| `a_lossless_block_clips_its_transform_grid_at_the_frame_edge` | `stream.rs:6972` | `if aomdec_path().is_file() { … } else { eprintln!("SKIP … aomdec arm: no oracle aomdec at {}") }` | `if aomdec_available(NAME) { … }`, else arm deleted | +| `a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries` | `stream.rs:46470` | nested `if aomdec_path().is_file()`, else arm deleted in r2 | `if aomdec_available(NAME) { … }` | +| `a_444_lossy_superres_stream_decodes_pixel_exact` | `stream.rs:46699` | `if aomdec_path().is_file() { … } else { eprintln!("… pixel arm skipped") }` | `if aomdec_available(NAME) { … }` | +| `a_444_superres_arm` (shared helper; reached by `a_444_lossy_superres_mode1_den9_stream_decodes_pixel_exact` and `a_444_lossy_superres_mode2_random_denom_stream_decodes_pixel_exact`) | `stream.rs:46886` | `if aomdec_path().is_file() { … } else { eprintln!("… pixel arm skipped") }` | `if aomdec_available(name) { … }` | +| `a_distance_weighted_compound_stream_decodes_pixel_exact` | routed in **r1** (one of the 13) | bare guard, no env escape | `if aomdec_available(NAME) { … }` | + +**Redundant `else { eprintln!("… pixel arm skipped") }` arms deleted: 7** (6 in +the scripted pass, 1 found afterwards by running the gates and reading the +output — `a_lossless_block_clips_its_transform_grid_at_the_frame_edge` printed +TWO skip lines for one skip, which is how the survivor was located). After +that, a skip prints exactly one line, from the probe. + +## 8. Red-before, re-proven on the CURRENT tree + +Base for this proof is **r1 as rebased** (r2's edits reverted by +`git checkout --`, i.e. exactly what main `9b2f6c9d` would give with r1 +applied) — the point is that a lane merging AFTER r1 branched reintroduces the +class, so the proof has to stand on the tree the six gates actually live in. + +`EC_AV1_AOMDEC=/nonexistent/oracle/aomdec EC_AV1_REQUIRE_AOMENC=1`: + +| gate | before r2 | after r2 | +|---|---|---| +| `a_444_lossless_sb64_intrabc_rect_chroma_walks_4x4_units` | `… 0 split; no oracle aomdec at /nonexistent/oracle/aomdec, pixel arm skipped` | **FAILED**: `no oracle aomdec at /nonexistent/oracle/aomdec -- the pixel compare this gate exists for would be skipped, and EC_AV1_REQUIRE_AOMDEC/EC_AV1_REQUIRE_AOMENC is set.` | +| `a_lossless_block_clips_its_transform_grid_at_the_frame_edge` | `SKIP … aomdec arm: no oracle aomdec at /nonexistent/oracle/aomdec` | **FAILED**, same message | +| `a_444_lossy_rect4_strip_stream_decodes_pixel_exact_at_odd_and_wide_geometries` | two `…: no oracle aomdec, pixel arm skipped` lines (one per pinned fixture) | **FAILED**, same message | + +`test result: ok. 3 passed` before, **`test result: FAILED. 0 passed; 3 +failed`** after — with `EC_AV1_REQUIRE_AOMENC=1` set, i.e. exactly the mode a +batch run is supposed to be in. + +## 9. The other two directions, on the current tree + +* **Oracle present** — the six (plus the two superres-mode gates that share + `a_444_superres_arm`) run and pass: `a_444_lossy_superres_mode1_den9… 4 + decode-order frame(s) byte-exact vs aomdec at (256,128) upscaled from + [(9,228)…]`, `a_444_lossy_rect4_strip… 12 / 24 own-extent 1:4 chroma + gather(s)`, `a_444_lossless_sb64_intrabc… 4 lossless rect intra-BC block(s) + walked 4x4 chroma units, 24576 WHT units`. **7 passed, 0 failed.** +* **Absent, env unset** — one SKIP line per gate, from the probe, naming the + path and the escape hatch; the gates still pass. Developer-only + convenience, unchanged from r1 and now impossible to print twice. + +Acceptance: `cargo test -p ec-av1 --lib -- gate_coverage refusal_inventory` -> +**26 passed, 0 failed** on the rebased tree (the `enable-rect-tx` staleness +r1 reported is gone — lane-av1toolgates' entries were retired upstream). + +## 10. What is still open after r2 + +* **Shape A stays.** ~445 `if !have_aomenc()` / `if !have_ffmpeg()` early + returns, plus `have_affine_aomenc` (which does have the assert-last shape). + They fail under the REQUIRE vars because their probes assert; a future lane + adding a NEW guard must call a probe rather than re-derive `.is_file()`. +* **The anti-regression is procedural, not enforced.** A guard written as + `aomdec_path().is_file()` compiles, passes review and re-opens the class. The + mechanical guard is a source-scan test ("no `aomdec_path().is_file()` outside + `aomdec_available` and the two documented asserts"); it was NOT added here + because the source-scan pattern for a whole-file assertion is itself a new + piece of machinery, and this lane's charter is the probe. It is the obvious + next step and it is small.