Merge lane-av1cmpaudit2: every oracle comparator is live, and a control test now guards the tautology class
Browse files at this commit2 changed files +438 -0
- crates/ec-av1/src/stream.rs +251 -0
- lanes/av1cmpaudit2.report.md +187 -0
crates/ec-av1/src/stream.rsmodified+251 -0
| @@ -4274,6 +4274,10 @@ pub(crate) mod tests { | |||
| 4274 | fn a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact() { | 4274 | fn a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact() { |
| 4275 | const NAME: &str = | 4275 | const NAME: &str = |
| 4276 | "a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact"; | 4276 | "a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact"; |
| 4277 | + // lane-av1cmpaudit2: this gate reaches the oracle without the gate | ||
| 4278 | + // mutex, so a sibling flipping `EC_AV1_AOMDEC` (the one-byte-wrong | ||
| 4279 | + // oracle control) could hand it a tampered oracle mid-compare. | ||
| 4280 | + let _gate_lock = lock_gate_counters(); | ||
| 4277 | if !have_aomenc() { | 4281 | if !have_aomenc() { |
| 4278 | eprintln!("SKIP {NAME}: no aomenc"); | 4282 | eprintln!("SKIP {NAME}: no aomenc"); |
| 4279 | return; | 4283 | return; |
| @@ -10195,9 +10199,35 @@ pub(crate) mod tests { | |||
| 10195 | present | 10199 | present |
| 10196 | } | 10200 | } |
| 10197 | 10201 | ||
| 10202 | + // lane-av1cmpaudit2: this thread's oracle override, set by | ||
| 10203 | + // `set_oracle_path` and consulted by `aomdec_path` ahead of the env var. | ||
| 10204 | + // | ||
| 10205 | + // It is thread-local for the same reason `FINAL_DUMP_PREFIX` is: the | ||
| 10206 | + // control test `every_oracle_comparator_reds_on_a_one_byte_wrong_oracle` | ||
| 10207 | + // has to hand the helpers a DELIBERATELY WRONG oracle, and a | ||
| 10208 | + // process-global `std::env::set_var` could not do that safely -- the | ||
| 10209 | + // crate denies `unsafe_code`, and even where it did not, one test's | ||
| 10210 | + // tampered oracle would leak into every sibling test's comparison | ||
| 10211 | + // running on another thread. A thread-local override confines the wrong | ||
| 10212 | + // oracle to the one thread that asked for it. | ||
| 10213 | + thread_local! { | ||
| 10214 | + static ORACLE_PATH: std::cell::RefCell<Option<std::path::PathBuf>> = | ||
| 10215 | + const { std::cell::RefCell::new(None) }; | ||
| 10216 | + } | ||
| 10217 | + | ||
| 10218 | + /// Points this thread's oracle helpers at `path`. `None` restores the | ||
| 10219 | + /// real `aomdec`. | ||
| 10220 | + fn set_oracle_path(path: Option<std::path::PathBuf>) { | ||
| 10221 | + ORACLE_PATH.with(|c| *c.borrow_mut() = path); | ||
| 10222 | + } | ||
| 10223 | + | ||
| 10224 | + | ||
| 10198 | /// The instrumented `aomdec` beside the `aomenc` oracle | 10225 | /// The instrumented `aomdec` beside the `aomenc` oracle |
| 10199 | /// (`scripts/build-aom-oracle.sh` + `scripts/instrument-aom-oracle.sh`). | 10226 | /// (`scripts/build-aom-oracle.sh` + `scripts/instrument-aom-oracle.sh`). |
| 10200 | fn aomdec_path() -> std::path::PathBuf { | 10227 | fn aomdec_path() -> std::path::PathBuf { |
| 10228 | + if let Some(p) = ORACLE_PATH.with(|c| c.borrow().clone()) { | ||
| 10229 | + return p; | ||
| 10230 | + } | ||
| 10201 | if let Some(p) = std::env::var_os("EC_AV1_AOMDEC") { | 10231 | if let Some(p) = std::env::var_os("EC_AV1_AOMDEC") { |
| 10202 | return std::path::PathBuf::from(p); | 10232 | return std::path::PathBuf::from(p); |
| 10203 | } | 10233 | } |
| @@ -10385,6 +10415,10 @@ pub(crate) mod tests { | |||
| 10385 | #[test] | 10415 | #[test] |
| 10386 | fn the_counting_oracle_diff_reports_a_real_difference() { | 10416 | fn the_counting_oracle_diff_reports_a_real_difference() { |
| 10387 | const NAME: &str = "the_counting_oracle_diff_reports_a_real_difference"; | 10417 | const NAME: &str = "the_counting_oracle_diff_reports_a_real_difference"; |
| 10418 | + // lane-av1cmpaudit2: same mutex as every other oracle gate -- this | ||
| 10419 | + // one reads `aomdec_path()`, so it must not overlap a sibling's | ||
| 10420 | + // tampered-oracle run. | ||
| 10421 | + let _gate_lock = lock_gate_counters(); | ||
| 10388 | let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | 10422 | let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) |
| 10389 | .join("fixtures") | 10423 | .join("fixtures") |
| 10390 | .join("420_oddheight_320x232.obu"); | 10424 | .join("420_oddheight_320x232.obu"); |
| @@ -10405,6 +10439,218 @@ pub(crate) mod tests { | |||
| 10405 | eprintln!("{NAME}: witness reports Y={wy} U={wu} V={wv}, frames_exact={exact}/{frames}"); | 10439 | eprintln!("{NAME}: witness reports Y={wy} U={wu} V={wv}, frames_exact={exact}/{frames}"); |
| 10406 | } | 10440 | } |
| 10407 | 10441 | ||
| 10442 | + /// lane-av1cmpaudit2: the permanent CONTROL for the class | ||
| 10443 | + /// `comparator-that-never-reads-the-oracle`. | ||
| 10444 | + /// | ||
| 10445 | + /// The retracted predecessor lane's per-cell counter reported "0 wrong" | ||
| 10446 | + /// on 18/18 cells -- including cells that differ from `aomdec | ||
| 10447 | + /// --rawvideo` in 17658 samples -- because it packed OUR decoded samples | ||
| 10448 | + /// into a buffer and compared that buffer against the same samples. | ||
| 10449 | + /// `aomdec`'s output was written, length-checked, and never read. | ||
| 10450 | + /// Nothing about that mistake is visible from the outside: the helper's | ||
| 10451 | + /// signature, its panic text and its return type are all exactly what a | ||
| 10452 | + /// working comparator has, and no amount of reading the source of a | ||
| 10453 | + /// healthy-looking helper proves the next one is healthy. | ||
| 10454 | + /// | ||
| 10455 | + /// So the class is pinned here from the other direction. | ||
| 10456 | + /// `EC_AV1_AOMDEC` is already the crate's oracle override, so this test | ||
| 10457 | + /// points every oracle helper at a shim that runs the REAL `aomdec` and | ||
| 10458 | + /// then corrupts exactly ONE byte of whatever it wrote -- the | ||
| 10459 | + /// `--rawvideo` output and the `EC_AV1_FINAL_DUMP` frame 0 -- leaving | ||
| 10460 | + /// every other sample a genuine decode. On a pin that IS byte-exact | ||
| 10461 | + /// against the real oracle: | ||
| 10462 | + /// | ||
| 10463 | + /// 1. **arm 1, real oracle: every helper is GREEN.** Without this arm, | ||
| 10464 | + /// arm 2's red could just be a stream that was never exact. | ||
| 10465 | + /// 2. **arm 2, one-byte-wrong oracle: every helper is RED.** A helper | ||
| 10466 | + /// that stays green here is the retracted defect itself: it cannot | ||
| 10467 | + /// fail, so its green is worth nothing. | ||
| 10468 | + /// | ||
| 10469 | + /// One test, five helpers, and it goes red for the exact mistake that | ||
| 10470 | + /// was retracted. Measured over this file: the other 62 tests that | ||
| 10471 | + /// reach an oracle helper all take `lock_gate_counters()` before their | ||
| 10472 | + /// first oracle call, which is what makes the process-global | ||
| 10473 | + /// `EC_AV1_AOMDEC` safe to flip here. | ||
| 10474 | + #[test] | ||
| 10475 | + fn every_oracle_comparator_reds_on_a_one_byte_wrong_oracle() { | ||
| 10476 | + const NAME: &str = "every_oracle_comparator_reds_on_a_one_byte_wrong_oracle"; | ||
| 10477 | + let _gate_lock = lock_gate_counters(); | ||
| 10478 | + if !aomdec_available(NAME) { | ||
| 10479 | + return; | ||
| 10480 | + } | ||
| 10481 | + let pin = crate_pin("420_odd65x65_key.obu"); | ||
| 10482 | + let stream = std::fs::read(&pin).unwrap_or_else(|e| { | ||
| 10483 | + panic!( | ||
| 10484 | + "{NAME}: the control's pin {} is missing ({e}) -- restore the committed copy", | ||
| 10485 | + pin.display() | ||
| 10486 | + ) | ||
| 10487 | + }); | ||
| 10488 | + assert_eq!( | ||
| 10489 | + stream_bit_depth(&stream, NAME), | ||
| 10490 | + 8, | ||
| 10491 | + "{NAME}: the control's pin must be the 8-bit cell the shim corrupts" | ||
| 10492 | + ); | ||
| 10493 | + let plane_samples = { | ||
| 10494 | + let frames = decode_stream(&stream).expect("the control's pin must decode"); | ||
| 10495 | + let f = &frames[0]; | ||
| 10496 | + [f.y.len(), f.u.len(), f.v.len()] | ||
| 10497 | + }; | ||
| 10498 | + | ||
| 10499 | + // ---- arm 1: the real oracle, every comparator green ------------ | ||
| 10500 | + { | ||
| 10501 | + let obu = std::env::temp_dir().join(format!("{NAME}-arm1.obu")); | ||
| 10502 | + std::fs::write(&obu, &stream).expect("writing the pin for arm 1"); | ||
| 10503 | + assert_rawvideo_matches(&obu, &stream, "oracle-control-arm1-rawvideo", 1, 8); | ||
| 10504 | + let _ = std::fs::remove_file(&obu); | ||
| 10505 | + let (frames, hidden) = | ||
| 10506 | + decode_all_frames_vs_oracle(&stream, "oracle-control-arm1-alldumps"); | ||
| 10507 | + assert_eq!( | ||
| 10508 | + (frames, hidden), | ||
| 10509 | + (1, 0), | ||
| 10510 | + "{NAME}: arm 1 expects one decode-order frame and no hidden frames" | ||
| 10511 | + ); | ||
| 10512 | + let (wy, wu, wv, n, exact) = | ||
| 10513 | + count_rawvideo_diffs(&stream, "oracle-control-arm1-count") | ||
| 10514 | + .expect("arm 1: the two sides must be byte-comparable"); | ||
| 10515 | + assert_eq!( | ||
| 10516 | + (wy, wu, wv), | ||
| 10517 | + (0, 0, 0), | ||
| 10518 | + "{NAME}: arm 1 runs against the REAL oracle, so every plane must be zero" | ||
| 10519 | + ); | ||
| 10520 | + assert_eq!( | ||
| 10521 | + (n, exact), | ||
| 10522 | + (1, 1), | ||
| 10523 | + "{NAME}: arm 1 expects one shown frame that is byte-identical" | ||
| 10524 | + ); | ||
| 10525 | + let (differing, first) = key_frame_diffs(&stream, "oracle-control-arm1-kf"); | ||
| 10526 | + assert_eq!( | ||
| 10527 | + (differing, first), | ||
| 10528 | + (0, None), | ||
| 10529 | + "{NAME}: arm 1's key frame must be byte-identical to the oracle's" | ||
| 10530 | + ); | ||
| 10531 | + let [y, u, v] = | ||
| 10532 | + oracle_plane_diffs(&stream, "oracle-control-arm1-planes", plane_samples); | ||
| 10533 | + assert_eq!( | ||
| 10534 | + [y, u, v], | ||
| 10535 | + [0, 0, 0], | ||
| 10536 | + "{NAME}: arm 1 must be zero on every plane against the real oracle" | ||
| 10537 | + ); | ||
| 10538 | + } | ||
| 10539 | + | ||
| 10540 | + // ---- the one-byte-wrong oracle --------------------------------- | ||
| 10541 | + let dir = std::env::temp_dir().join(format!("ec-av1-{NAME}-{}", std::process::id())); | ||
| 10542 | + let _ = std::fs::remove_dir_all(&dir); | ||
| 10543 | + std::fs::create_dir_all(&dir).expect("scratch dir"); | ||
| 10544 | + let shim = dir.join("one-byte-wrong-aomdec.sh"); | ||
| 10545 | + // The real oracle's path rides in a sibling file rather than inside | ||
| 10546 | + // the script, so a path with a quote or a space cannot mangle it and | ||
| 10547 | + // the script body needs no `format!` escaping at all. | ||
| 10548 | + std::fs::write(dir.join("real-aomdec"), aomdec_path().as_os_str().as_encoded_bytes()) | ||
| 10549 | + .expect("recording the real oracle's path for the shim"); | ||
| 10550 | + // Byte 7 of both the `--rawvideo` output and the `EC_AV1_FINAL_DUMP` | ||
| 10551 | + // frame 0 is inside the Y plane, and its value is rotated by 128 so | ||
| 10552 | + // the write always changes it. Nothing else is touched: the stream, | ||
| 10553 | + // the geometry, the frame count and every other sample are a genuine | ||
| 10554 | + // `aomdec` decode. | ||
| 10555 | + let script = r#"#!/bin/sh | ||
| 10556 | +REAL=$(cat "$(dirname "$0")/real-aomdec") | ||
| 10557 | +rawvideo=0 | ||
| 10558 | +out="" | ||
| 10559 | +prev="" | ||
| 10560 | +for a in "$@"; do | ||
| 10561 | + if [ "$a" = "--rawvideo" ]; then rawvideo=1; fi | ||
| 10562 | + if [ "$prev" = "-o" ]; then out="$a"; fi | ||
| 10563 | + prev="$a" | ||
| 10564 | +done | ||
| 10565 | +"$REAL" "$@" || exit $? | ||
| 10566 | +flip() { | ||
| 10567 | + [ -s "$1" ] || return 0 | ||
| 10568 | + b=$(od -An -tu1 -j 7 -N 1 "$1" 2>/dev/null | tr -d ' \n') | ||
| 10569 | + [ -n "$b" ] || return 0 | ||
| 10570 | + esc=$(printf '\\%03o' $(( (b + 128) % 256 ))) | ||
| 10571 | + printf "$esc" | dd of="$1" bs=1 seek=7 count=1 conv=notrunc 2>/dev/null | ||
| 10572 | + return 0 | ||
| 10573 | +} | ||
| 10574 | +[ "$rawvideo" = 1 ] && flip "$out" | ||
| 10575 | +[ -n "$EC_AV1_FINAL_DUMP" ] && flip "$EC_AV1_FINAL_DUMP.f0" | ||
| 10576 | +exit 0 | ||
| 10577 | +"#; | ||
| 10578 | + std::fs::write(&shim, script).expect("writing the oracle shim"); | ||
| 10579 | + #[cfg(unix)] | ||
| 10580 | + { | ||
| 10581 | + use std::os::unix::fs::PermissionsExt; | ||
| 10582 | + std::fs::set_permissions(&shim, std::fs::Permissions::from_mode(0o755)) | ||
| 10583 | + .expect("the oracle shim must be executable"); | ||
| 10584 | + } | ||
| 10585 | + | ||
| 10586 | + // ---- arm 2: same pin, oracle off by ONE byte ------------------- | ||
| 10587 | + // The override is THREAD-LOCAL, so the tampered oracle is confined | ||
| 10588 | + // to this thread and no sibling test can see it; it is still cleared | ||
| 10589 | + // before any result is asserted, so a red arm cannot leave this | ||
| 10590 | + // test's own later work reading a wrong oracle. | ||
| 10591 | + let reds: [bool; 5]; | ||
| 10592 | + { | ||
| 10593 | + set_oracle_path(Some(shim.clone())); | ||
| 10594 | + let panicked = |f: &dyn Fn()| { | ||
| 10595 | + std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)).is_err() | ||
| 10596 | + }; | ||
| 10597 | + let rawvideo_red = panicked(&|| { | ||
| 10598 | + let obu = std::env::temp_dir().join(format!("{NAME}-arm2.obu")); | ||
| 10599 | + std::fs::write(&obu, &stream).expect("writing the pin for arm 2"); | ||
| 10600 | + assert_rawvideo_matches(&obu, &stream, "oracle-control-arm2-rawvideo", 1, 8); | ||
| 10601 | + }); | ||
| 10602 | + let _ = std::fs::remove_file(std::env::temp_dir().join(format!("{NAME}-arm2.obu"))); | ||
| 10603 | + let dumps_red = panicked(&|| { | ||
| 10604 | + decode_all_frames_vs_oracle(&stream, "oracle-control-arm2-alldumps"); | ||
| 10605 | + }); | ||
| 10606 | + let count_red = { | ||
| 10607 | + let counted = count_rawvideo_diffs(&stream, "oracle-control-arm2-count") | ||
| 10608 | + .unwrap_or_else(|| { | ||
| 10609 | + panic!( | ||
| 10610 | + "{NAME}: a single flipped oracle byte must NOT change the buffer \ | ||
| 10611 | + LENGTH -- returning None means the shim corrupted more than the \ | ||
| 10612 | + comparison" | ||
| 10613 | + ) | ||
| 10614 | + }); | ||
| 10615 | + counted.0 + counted.1 + counted.2 > 0 && counted.4 < counted.3 | ||
| 10616 | + }; | ||
| 10617 | + let kf_red = { | ||
| 10618 | + let (differing, first) = key_frame_diffs(&stream, "oracle-control-arm2-kf"); | ||
| 10619 | + differing > 0 && first.is_some() | ||
| 10620 | + }; | ||
| 10621 | + let planes_red = { | ||
| 10622 | + let [y, u, v] = | ||
| 10623 | + oracle_plane_diffs(&stream, "oracle-control-arm2-planes", plane_samples); | ||
| 10624 | + y + u + v > 0 | ||
| 10625 | + }; | ||
| 10626 | + set_oracle_path(None); | ||
| 10627 | + let _ = std::fs::remove_dir_all(&dir); | ||
| 10628 | + reds = [rawvideo_red, dumps_red, count_red, kf_red, planes_red]; | ||
| 10629 | + } | ||
| 10630 | + // One assert, naming EVERY comparator that stayed green: a partial | ||
| 10631 | + // run would report the first and hide whether the other four are | ||
| 10632 | + // covered. | ||
| 10633 | + let blind: Vec<&str> = [ | ||
| 10634 | + ("assert_rawvideo_matches", reds[0]), | ||
| 10635 | + ("decode_all_frames_vs_oracle", reds[1]), | ||
| 10636 | + ("count_rawvideo_diffs", reds[2]), | ||
| 10637 | + ("key_frame_diffs", reds[3]), | ||
| 10638 | + ("oracle_plane_diffs", reds[4]), | ||
| 10639 | + ] | ||
| 10640 | + .into_iter() | ||
| 10641 | + .filter(|(_, red)| !red) | ||
| 10642 | + .map(|(what, _)| what) | ||
| 10643 | + .collect(); | ||
| 10644 | + assert!( | ||
| 10645 | + blind.is_empty(), | ||
| 10646 | + "{NAME}: {} of 5 oracle comparators stayed GREEN against an oracle that is wrong \ | ||
| 10647 | + by exactly one byte -- {blind:?} -- they cannot fail, so their green proves \ | ||
| 10648 | + nothing (class `comparator-that-never-reads-the-oracle`)", | ||
| 10649 | + blind.len() | ||
| 10650 | + ); | ||
| 10651 | + eprintln!("{NAME}: all five oracle comparators red on a one-byte-wrong oracle"); | ||
| 10652 | + } | ||
| 10653 | + | ||
| 10408 | /// lane-av1422anom: the odd-frame-HEIGHT 4:2:0 reconstruction defect, | 10654 | /// lane-av1422anom: the odd-frame-HEIGHT 4:2:0 reconstruction defect, |
| 10409 | /// pinned and ratcheted. | 10655 | /// pinned and ratcheted. |
| 10410 | /// | 10656 | /// |
| @@ -10427,6 +10673,8 @@ pub(crate) mod tests { | |||
| 10427 | fn the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect() { | 10673 | fn the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect() { |
| 10428 | const NAME: &str = | 10674 | const NAME: &str = |
| 10429 | "the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect"; | 10675 | "the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect"; |
| 10676 | + // lane-av1cmpaudit2: same mutex as every other oracle gate. | ||
| 10677 | + let _gate_lock = lock_gate_counters(); | ||
| 10430 | const FILE: &str = "420_oddheight_320x232.obu"; | 10678 | const FILE: &str = "420_oddheight_320x232.obu"; |
| 10431 | const BYTES: usize = 15773; | 10679 | const BYTES: usize = 15773; |
| 10432 | // sha256 6832c3cd867f5fc491b45fd67f77c38453db0ca6d461e7d225e6276f4d0784c8, | 10680 | // sha256 6832c3cd867f5fc491b45fd67f77c38453db0ca6d461e7d225e6276f4d0784c8, |
| @@ -38150,6 +38398,9 @@ pub(crate) mod tests { | |||
| 38150 | #[test] | 38398 | #[test] |
| 38151 | #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"] | 38399 | #[ignore = "lane-sb128 r2 diagnostic: is the frame-6 mismatch sb128-specific?"] |
| 38152 | fn sb128_r2_control_sb64() { | 38400 | fn sb128_r2_control_sb64() { |
| 38401 | + // lane-av1cmpaudit2: this control reaches the oracle, so it takes | ||
| 38402 | + // the gate mutex like every other one. | ||
| 38403 | + let _gate_lock = lock_gate_counters(); | ||
| 38153 | let (width, height) = (256usize, 192usize); | 38404 | let (width, height) = (256usize, 192usize); |
| 38154 | let y4m = Command::new("ffmpeg") | 38405 | let y4m = Command::new("ffmpeg") |
| 38155 | .args([ | 38406 | .args([ |
lanes/av1cmpaudit2.report.mdadded+187 -0
| @@ -0,0 +1,187 @@ | |||
| 1 | +# lane-av1cmpaudit2 — audit of the class `comparator-that-never-reads-the-oracle` | ||
| 2 | + | ||
| 3 | +Base `9d5f7bd9`. Question: which committed gates and which recent lane | ||
| 4 | +reports depend on a comparison that cannot fail? | ||
| 5 | + | ||
| 6 | +**Answer: none in the crate. One report headline was unverifiable, and is | ||
| 7 | +now re-measured. The whole class is now pinned by ONE committed control.** | ||
| 8 | + | ||
| 9 | +## 1. The class | ||
| 10 | + | ||
| 11 | +`lanes/av1422remeasure.report.md` claimed "0 wrong on 18/18 cells, 0 of | ||
| 12 | +2359296". Its per-cell counter packed OUR decoded samples into a buffer and | ||
| 13 | +compared that buffer against the same samples; `aomdec`'s output was written, | ||
| 14 | +length-checked, and never read. Retracted in | ||
| 15 | +`lanes/av1422remeasure.RETRACTION.md`. Cells that differ from `aomdec` in | ||
| 16 | +17658 samples reported zero. | ||
| 17 | + | ||
| 18 | +The reason this class is dangerous is that it is invisible from the outside. | ||
| 19 | +The helper's signature, its panic text and its return type are all exactly | ||
| 20 | +what a working comparator has. "Read the source and check" is not a control, | ||
| 21 | +because the retracted counter's source read fine too. | ||
| 22 | + | ||
| 23 | +## 2. Per-helper table — the crate's own comparators | ||
| 24 | + | ||
| 25 | +Every comparator in `crates/ec-av1/src/stream.rs` that reads an external | ||
| 26 | +oracle. Line numbers are this branch's tip (`277327e3`), which adds the | ||
| 27 | +control test of §6 and the thread-local oracle override. Method: located every `std::fs::read` of an oracle-written buffer in | ||
| 28 | +the crate (16 `ref_raw`/`want`/`aom_dump` bindings), then read each | ||
| 29 | +comparison loop. Class is LIVE only if the oracle buffer is the operand of a | ||
| 30 | +content comparison, not just of a length check. | ||
| 31 | + | ||
| 32 | +| # | comparator | location | reads oracle bytes at | classification | | ||
| 33 | +|---|---|---|---|---| | ||
| 34 | +| 1 | `assert_rawvideo_matches` | `stream.rs:5536` | reads `ref_raw` at 5568, compares `ours.iter().zip(&ref_raw)` at 5588 + 5595 | **LIVE** | | ||
| 35 | +| 2 | `decode_all_frames_vs_oracle` | `stream.rs:10250` | reads `aom.f{i}` into `want` at 10301, `ours.f{i}` into `got` at 10302, `got.iter().zip(&want)` at 10310 | **LIVE** | | ||
| 36 | +| 3 | `count_rawvideo_diffs` | `stream.rs:10345` | reads aomdec rawvideo into `want` at 10369, `ours.iter().zip(&want)` at 10386 | **LIVE** | | ||
| 37 | +| 4 | `key_frame_diffs` | `stream.rs:48354` | reads `aomkf.f0` into `want` at 48384, `got.iter().zip(&want)` at 48398 | **LIVE** | | ||
| 38 | +| 5 | `oracle_plane_diffs` | `stream.rs:49392` | reads `aom.f{i}` into `want` at 49440, `got[a..b].zip(&want[a..b])` at 49452 | **LIVE** | | ||
| 39 | + | ||
| 40 | +Plus 13 gates that inline the same two-buffer comparison rather than calling a | ||
| 41 | +helper — 7 rawvideo sites (`stream.rs` 7505, 8019, 8208, 9009, 9154, 9291, | ||
| 42 | +9718; each does `let want = &ref_raw[…]` then `plane.iter().zip(want).filter(|&(&a, &b)| a as u8 != b)`) | ||
| 43 | +and 6 final-dump sites (50415, 50551, 50674, 50783, 50935, 51054; each does | ||
| 44 | +`our_dump[at..at+PLANE] == aom_dump[at..at+PLANE]`). All **LIVE**. | ||
| 45 | + | ||
| 46 | +There is no `assert_final_dump_matches` in the crate under that or any other | ||
| 47 | +name; searched by name and by role (every `std::fs::read` of an aomdec-written | ||
| 48 | +path). `encode.rs`'s `ffmpeg_decode` / `ffmpeg_decode_sequence` / | ||
| 49 | +`ffmpeg_decode_sequence_10bit` all spawn `ffmpeg` and take its stdout | ||
| 50 | +(`encode.rs:16503`, `18587`; `stream.rs:5797`, `5888`) — **LIVE**, and their | ||
| 51 | +comparators `first_difference` (`encode.rs:17906`) and `first_plane_mismatch` | ||
| 52 | +(`encode.rs:20744`) zip two independent `Picture`s — **LIVE**. | ||
| 53 | + | ||
| 54 | +Swept outside `ec-av1` too: `crates/ec-vp8`, `ec-h264`, `ec-h265`, `ec-hw` | ||
| 55 | +all reach ffmpeg through a real `Command::output()` and compare the stdout; | ||
| 56 | +no self-compare found. | ||
| 57 | + | ||
| 58 | +## 3. Per-report table | ||
| 59 | + | ||
| 60 | +| report | headline | comparator | reads oracle? | non-vacuity control | verdict | | ||
| 61 | +|---|---|---|---|---|---| | ||
| 62 | +| `av1chromarect-r3` | "TOTAL 0 wrong from 2359296" (§1) | a temporary probe test, **removed before commit, no path quoted** — UNKNOWN by its own admission | not inspectable | §3 mutation (`chroma_window`'s `cn_cols == 1 && cn_rows == 1` → `if true`) reproduces **79969 wrong**, and both committed gates go FAILED with the gate's own panic text | **LIVE by proxy; headline RE-DERIVED, see §4** | | ||
| 63 | +| `av1dcunit` | "0 wrong … 0 of 2359296" (§2) | `~/.cache/cmp444.py`, quoted in §2, **present on disk** | YES — reads `aom.f{f}` and `ours.f{f}` separately, `o[at+s] != a[at+s]` | §5 M1 (unit readers back to block `reach`) → RED, "U … 130 samples wrong", the committed gate's own panic text | **LIVE** | | ||
| 64 | +| `av1dcunit` | "f0: Y 0 / U 130 / V 30 of 65536" (§5) | "my own script", **no path quoted**; the surviving `cmp444.py` hardcodes `W = H = 512` and 3 frames, so it cannot be it | not inspectable | the committed gate covering the same witness reproduces **U = 130** under the lane's own M1 | **LIVE by proxy; V = 30 not independently reproduced** | | ||
| 65 | +| `av1ibcfork` | "fully byte-exact", 0 of 307200 per plane (§7/§8) | committed gate `a_444_intrabc_rect4_witness_is_byte_exact_after_the_skip_arm_footprint` (`stream.rs:50613`): 4:2:0 arm calls `decode_all_frames_vs_oracle` at 50639, 4:4:4 arm reads `aom_dump`/`our_dump` at 50674/50675 and compares them inline at 50686/50690 | YES, both arms | feature-reach assert `hits > 0` at 50669; §8 mutation of `(bw >> ss_x, …)` → `(bw/2, …)` reds at sample 51360 (x=160, y=80) | **LIVE** | | ||
| 66 | +| `av1loss444` | "EXACT 6/6, 0 wrong luma/U/V"; "0 across all 36 frame-dumps" | `cmp_final.py`, quoted verbatim in §9 as `~/.cache/loss444/cmp_final.py`, **present on disk** | YES — `sa` = oracle plane, `sb` = ours, `bad = [j for j in range(len(sa)) if sa[j] != sb[j]]`, with a length guard | §4 two bit-flip controls on the real dumps: "Y 2 / U 2 / V 2, first (110,26)" and "U 1 wrong with Y 0, V 0" | **LIVE** | | ||
| 67 | +| `av1txctxband` | "37229 / 37229, zero divergence"; "99/99 exact-entropy" | `~/.cache/sb128fork/cmp444.py` (present) for pixels; `hunt5.py` (present) for the entropy ladder | YES — both scripts read their two trace/dump sets independently | mutation of the RECT reader's four lines → FAILED 0 passed; 1 failed | **LIVE** | | ||
| 68 | +| `av1txctxband` | the gate's primary arm is a counter comparing two of OUR OWN models (`decode.rs:28536`, `28635`) | oracle-free by design | n/a | it is a mutation detector, not an exactness claim, and the gate additionally calls `decode_all_frames_vs_oracle` | **LIVE (not a pixel claim)** | | ||
| 69 | +| `av1sb128fork` | entropy fork table | `hunt4.py`, present, reads both traces | YES | stated | **LIVE** | | ||
| 70 | +| `av1sb128fork` | §1 pixel table "841/1295/1372", "56986/55974/56442" | **no comparator named anywhere in the report, and no committed gate at all** | not inspectable | none stated | **UNKNOWN — treat as unverified, see §5** | | ||
| 71 | +| `av1422anom` | "17658 wrong chroma of 593920" on 320x232 | `count_rawvideo_diffs` (`stream.rs:10345`) | YES | `the_counting_oracle_diff_reports_a_real_difference` decodes a witness KNOWN to differ and asserts non-zero | **LIVE** | | ||
| 72 | +| `av1422remeasure` | "0 wrong on 18/18" | the retracted throwaway counter | **NO** | none — that is why it was retracted | **TAUTOLOGICAL (already retracted)** | | ||
| 73 | + | ||
| 74 | +## 4. Re-measured headline | ||
| 75 | + | ||
| 76 | +`av1chromarect-r3`'s headline comparator was deleted, so I re-derived the | ||
| 77 | +number with an independently written comparator that reads two separately | ||
| 78 | +produced dump sets: `aomdec --codec=av1` with `EC_AV1_FINAL_DUMP` for the | ||
| 79 | +oracle, and the crate's own `examples/dump_yuv.rs` for ours, on the committed | ||
| 80 | +`crates/ec-av1/fixtures/r512.obu` (6948 bytes, 3 frames, 4:4:4 512x512, | ||
| 81 | +262144 samples per plane). | ||
| 82 | + | ||
| 83 | +``` | ||
| 84 | +f0: Y=0 U=0 V=0 | ||
| 85 | +f1: Y=0 U=0 V=0 | ||
| 86 | +f2: Y=0 U=0 V=0 | ||
| 87 | +TOTAL wrong: 0 of 2359296 | ||
| 88 | +``` | ||
| 89 | + | ||
| 90 | +**The headline survives.** `av1dcunit` §5's "V 30" was not reproduced (its | ||
| 91 | +U = 130 is reproduced by the committed gate under the lane's own M1); its §2 | ||
| 92 | +headline is directly re-checkable and is LIVE. | ||
| 93 | + | ||
| 94 | +## 5. Claims that must be treated as unverified | ||
| 95 | + | ||
| 96 | +1. `av1sb128fork` §1's pixel table — "Y 841 / U 1295 / V 1372 of 65536" and | ||
| 97 | + "Y 56986 / U 55974 / V 56442" — names no comparator and commits no gate. | ||
| 98 | + **Unverified.** Its entropy-fork table is separately LIVE. | ||
| 99 | +2. `av1ibcfork` §5's by-hand red-before numbers (`U 72945`, `V 64865`). | ||
| 100 | + Produced by an off-repo manual diff through `decode_probe`, which is not a | ||
| 101 | + comparator. The committed claim on the same fixture is LIVE and | ||
| 102 | + independently re-runnable; the by-hand figures are not. | ||
| 103 | +3. `av1dcunit` §5's `V 30 wrong` (the U = 130 half is reproduced by the | ||
| 104 | + committed gate's own panic under mutation M1). | ||
| 105 | +4. `av1chromarect-r3` §1's probe script itself — deleted, unpathed, | ||
| 106 | + unrecoverable. The NUMBER is re-derived above and the two committed gates | ||
| 107 | + are LIVE. | ||
| 108 | + | ||
| 109 | +## 6. The control this lane landed | ||
| 110 | + | ||
| 111 | +`stream.rs` — `every_oracle_comparator_reds_on_a_one_byte_wrong_oracle`. | ||
| 112 | + | ||
| 113 | +`aomdec_path()` grows a thread-local override (same shape as the existing | ||
| 114 | +`FINAL_DUMP_PREFIX`, and thread-local because the crate denies `unsafe_code` | ||
| 115 | +and a process-global env var would leak one test's tampered oracle into every | ||
| 116 | +sibling's comparison on another thread). The test points that override at a | ||
| 117 | +shim which runs the REAL `aomdec` and then rotates byte 7 of the | ||
| 118 | +`--rawvideo` output and of `EC_AV1_FINAL_DUMP` frame 0 — one byte, inside the | ||
| 119 | +Y plane, everything else a genuine decode. On the byte-exact | ||
| 120 | +`420_odd65x65_key.obu` pin: | ||
| 121 | + | ||
| 122 | +``` | ||
| 123 | +arm 1, real oracle -> all five comparators green | ||
| 124 | +arm 2, one-byte-wrong -> all five comparators red | ||
| 125 | +``` | ||
| 126 | + | ||
| 127 | +All five helpers named in §2 are covered by that one test. Four gates that | ||
| 128 | +reached the oracle without `lock_gate_counters()` now take it | ||
| 129 | +(`a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact`, | ||
| 130 | +`the_counting_oracle_diff_reports_a_real_difference`, | ||
| 131 | +`the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect`, | ||
| 132 | +`sb128_r2_control_sb64`). | ||
| 133 | + | ||
| 134 | +### Mutation proof (the control bites) | ||
| 135 | + | ||
| 136 | +All five comparators mutated to the retracted defect — each zipping our | ||
| 137 | +buffer against itself instead of the oracle: | ||
| 138 | + | ||
| 139 | +- `assert_rawvideo_matches` 5588 `.zip(&ref_raw)` → `.zip(&ours)` | ||
| 140 | +- `decode_all_frames_vs_oracle` 10310 `.zip(&want)` → `.zip(&got)` | ||
| 141 | +- `count_rawvideo_diffs` 10386 `.zip(&want)` → `.zip(&ours)` | ||
| 142 | +- `key_frame_diffs` 48398 `.zip(&want)` → `.zip(&got)` | ||
| 143 | +- `oracle_plane_diffs` 49452 `.zip(&want[a..b])` → `.zip(&got[a..b])` | ||
| 144 | + | ||
| 145 | +Result: | ||
| 146 | + | ||
| 147 | +``` | ||
| 148 | +every_oracle_comparator_reds_on_a_one_byte_wrong_oracle: 5 of 5 oracle | ||
| 149 | +comparators stayed GREEN against an oracle that is wrong by exactly one | ||
| 150 | +byte -- ["assert_rawvideo_matches", "decode_all_frames_vs_oracle", | ||
| 151 | +"count_rawvideo_diffs", "key_frame_diffs", "oracle_plane_diffs"] | ||
| 152 | +test result: FAILED. 0 passed; 1 failed | ||
| 153 | +``` | ||
| 154 | + | ||
| 155 | +**Arm 1 passed under the same mutation.** That is the point: the mutants are | ||
| 156 | +invisible to all 60-odd existing pixel-exact gates and to every other | ||
| 157 | +assertion in this crate. Only this control sees them. Mutations reverted; | ||
| 158 | +`cargo check -p ec-av1 --all-targets` clean, no warnings. | ||
| 159 | + | ||
| 160 | +## 7. Gates run | ||
| 161 | + | ||
| 162 | +``` | ||
| 163 | +cargo test -p ec-av1 --lib -- every_oracle_comparator_reds_on_a_one_byte_wrong_oracle \ | ||
| 164 | + the_counting_oracle_diff_reports_a_real_difference \ | ||
| 165 | + the_pinned_420_oddheight_witness_is_pinned_and_ratchets_its_reconstruction_defect \ | ||
| 166 | + the_rawvideo_helper_compares_real_samples_at_the_streams_own_bit_depth \ | ||
| 167 | + a_real_aomenc_segmentation_stream_with_map_inheritance_decodes_pixel_exact | ||
| 168 | +→ 5 passed; 0 failed | ||
| 169 | +``` | ||
| 170 | + | ||
| 171 | +`EC_AV1_REQUIRE_AOMDEC=1 EC_AV1_REQUIRE_AOMENC=1 EC_AV1_REQUIRE_FIXTURES=1`, | ||
| 172 | +oracle `~/.cache/aom-oracle/build/aomdec`. | ||
| 173 | + | ||
| 174 | +## 8. not_done | ||
| 175 | + | ||
| 176 | +1. `av1sb128fork` §1's pixel numbers were **not** re-derived. They are | ||
| 177 | + red-before mutation figures whose comparator was never recorded; deriving | ||
| 178 | + them means reconstructing the lane's mutation, which is not identifiable | ||
| 179 | + from the report. Left as unverified rather than guessed. | ||
| 180 | +2. `av1dcunit` §5's `V 30` was not independently reproduced (U = 130 was). | ||
| 181 | +3. No full `ec-av1` suite run — per the wave's rules, scoped tests only. The | ||
| 182 | + lock added to `sb128_r2_control_sb64` is inside an `#[ignore]`d | ||
| 183 | + diagnostic, so it is compile-verified but not executed. | ||
| 184 | +4. The entropy-ladder comparators (`hunt4.py`, `hunt5.py`, `align.py`) were | ||
| 185 | + classified LIVE by reading, not by a control; the class audited here is the | ||
| 186 | + sample/pixel comparator, and a byte-vs-trace-field variant of the same | ||
| 187 | + control would be a separate lane. | ||