forge
Explore
Log in

Don't you dare go Hollow

refutation pass on the 4:4:4 palette window: PASS, and its two live risks closed rather than noted

Browse files at this commit

7929331f167111e17fa021fba8f32f59b3911500Ahmet Kaan GümüşParent: 57ac17e
lanes/refute-av1444d10.report.md (reviewer seat, transcribed verbatim) reproduced the lane's numbers with
its OWN instruments: a one-byte-wrong-oracle shim turns the byte-exact cell red by exactly +1 (ours 216 vs
217 at byte 328192, the census's own first bad sample), the fix taken OUT gives Y 0 / U 1166 / V 1413 with a
per-frame table matching term for term, the mutation proof reds the gate at stream.rs:10848 with "ours 209
vs 216, 104 bytes differ", the five same-depth controls measure 0/0/0, and the 178-test regression scope
reproduces green at e4787782. It also verified what the lane asserted: the diff is exactly two sites with no
offsets or guards touched, and the window is a genuine no-op at nw*nh == 1 (cu_col/cu_row are 0, so the copy
re-strides the same buffer), with the cw != chroma_w shape returning `unsupported` before the windowing.

Two findings acted on in this commit, neither of them a doc-only fix:

1. P3 (decode.rs:2721-2731): CHROMA_PALETTE_WINDOW_HITS claimed to count "the units that are NOT the
   block's top-left corner" but fired UNCONDITIONALLY next to both windowed pushes -- so it also fired for a
   single-unit block, whose window is a pure re-stride copy of the whole buffer. That made a hit prove only
   that some palette chroma block existed, while the gate reads it as its non-vacuity arm ("must be at least
   1"). The hit is now guarded on the `bigger` (= nw * nh > 1) that was already in scope, so a hit is PROOF
   the tiled arm ran; the doc says what the code does and records the correction. On the pinned fixture the
   value is unchanged at 4 (one block, nw = 1, nh = 2, two planes, two unit rows) and the gate stays green.

2. Risk (e): palette_window indexes buf[(oy+r)*stride+ox..][..w], so a caller with a mismatched stride could
   read in-bounds GARBAGE rather than panicking -- the one silent failure mode this walk must not have, and
   the reviewer correctly named it as resting on an `unsupported` return elsewhere. It is now closed by a
   release assert in palette_window (the shape the crate uses: 73 release asserts in decode.rs), instead of
   a comment. Verified against the existing callers: palette/intrabc scope 49 passed, 444/420/lossless scope
   72 passed, the pinned gate green at 4 windowed units; all with EC_AV1_REQUIRE_AOMDEC=1.

Still UNMEASURED and filed as its own debt, not silently absorbed: the nw > 1 (horizontal windowing) arm is
INREACHABLE in all 106 committed fixtures and all six 4:4:4 sweep cells (corpus-wide tracer: 16 windowed
units, every one nw = 1), so it is correct by construction and unexercised.
crates/ec-av1/src/decode.rsmodified+46 -6
@@ -2722,10 +2722,20 @@ pub(crate) fn palette_split_tx_hits() -> usize {
27222722 thread_local! {
27232723 /// lane-av1444d10: chroma PREDICTION units on the 32-capped tiled chroma
27242724 /// walk (`decode_block_rect`'s `uw/uh = min(chroma, 32)` units) that were
2725- /// handed a WINDOWED slice of their block's palette buffer -- i.e. the
2726- /// units that are NOT the block's top-left corner. Counts units, not
2727- /// blocks, and only units whose block actually has a UV palette, so a
2728- /// stream without a tiled palette chroma block leaves it at zero.
2725+ /// handed a STRICT sub-slice of their block's palette buffer -- i.e. the
2726+ /// units of a block the 32-cap actually TILED (`nw * nh > 1`).
2727+ ///
2728+ /// CORRECTED 2026-09-30 after the refutation pass `lanes/refute-av1444d10`
2729+ /// read the numbers back: the previous comment claimed it counted "the
2730+ /// units that are NOT the block's top-left corner", which is not what the
2731+ /// code did -- the hit was unconditional, so a block's corner unit fired it
2732+ /// too AND a single-unit block (whose window is a pure re-stride copy of
2733+ /// the whole buffer) fired it as well. That made a hit prove only that some
2734+ /// palette chroma block existed, not that the tiled arm ran. The `bigger`
2735+ /// guard now makes the counter discriminate. On the pinned fixture the
2736+ /// measured value is unchanged at 4 (one block with nw = 1, nh = 2 x two
2737+ /// planes x two unit rows); a stream whose palette chroma blocks are all
2738+ /// single-unit now leaves it at zero.
27292739 static CHROMA_PALETTE_WINDOW_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) };
27302740 }
27312741
@@ -2980,6 +2990,18 @@ fn palette_window(
29802990 w: usize,
29812991 h: usize,
29822992 ) -> Vec<u16> {
2993+ // `stride` is the BLOCK's own chroma width, so a caller that handed over a
2994+ // mismatched stride could read in-bounds GARBAGE instead of panicking --
2995+ // a silent misread, which is the one failure mode this walk must not have.
2996+ // The refutation pass (`lanes/refute-av1444d10.report.md`, risk (e)) named
2997+ // that as the only thing keeping the tiled walk safe, so the invariant is
2998+ // closed loudly here instead of resting on an `unsupported` return
2999+ // elsewhere that a future shape could remove.
3000+ assert!(
3001+ w <= stride && ox + w <= stride && (oy + h) * stride <= buf.len(),
3002+ "palette window {w}x{h} at ({ox},{oy}) does not fit a {}-entry buffer at stride {stride}",
3003+ buf.len()
3004+ );
29833005 (0..h)
29843006 .flat_map(|r| buf[(oy + r) * stride + ox..][..w].iter().copied())
29853007 .collect()
@@ -20110,7 +20132,16 @@ fn decode_block_rect64(
2011020132 palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh),
2011120133 fctx,
2011220134 );
20113- hit!(CHROMA_PALETTE_WINDOW_HITS);
20135+ // Counted only when the window is a STRICT sub-slice of the
20136+ // block's buffer, i.e. when the 32-cap actually tiled the
20137+ // block: at nw * nh == 1 the window is a re-stride copy of
20138+ // the whole buffer and windowing is load-bearing for
20139+ // nothing. The `bigger` guard is what makes a hit PROOF
20140+ // that the tiled arm ran, rather than proof that some
20141+ // palette chroma block existed.
20142+ if bigger {
20143+ hit!(CHROMA_PALETTE_WINDOW_HITS);
20144+ }
2011420145 }
2011520146 read_plane(
2011620147 dec,
@@ -20169,7 +20200,16 @@ fn decode_block_rect64(
2016920200 palette_window(pbuf, chroma_w, cu_col * uw, cu_row * uh, uw, uh),
2017020201 fctx,
2017120202 );
20172- hit!(CHROMA_PALETTE_WINDOW_HITS);
20203+ // Counted only when the window is a STRICT sub-slice of the
20204+ // block's buffer, i.e. when the 32-cap actually tiled the
20205+ // block: at nw * nh == 1 the window is a re-stride copy of
20206+ // the whole buffer and windowing is load-bearing for
20207+ // nothing. The `bigger` guard is what makes a hit PROOF
20208+ // that the tiled arm ran, rather than proof that some
20209+ // palette chroma block existed.
20210+ if bigger {
20211+ hit!(CHROMA_PALETTE_WINDOW_HITS);
20212+ }
2017320213 }
2017420214 push_intra_rect(
2017520215 plane_idx,
crates/ec-av1/src/stream.rsmodified+5 -3
@@ -50751,9 +50751,11 @@ exit 0
5075150751 /// (2) 17 decode-order frames at 352x242 with FULL-RESOLUTION chroma, so
5075250752 /// a decoder that kept the 4:2:0 extent cannot pass the compare.
5075350753 /// (3) `decode::chroma_palette_window_hits()` read as a delta must be at
50754- /// least 1: the fixed lines are the only thing that increments it, so a
50755- /// gate that passes without them running would be
50756- /// gate-blind-to-feature. (4) The oracle comparator this gate leans on has
50754+ /// least 1. After the refutation pass read the numbers back, that counter
50755+ /// is guarded on `nw * nh > 1`, so it fires ONLY for units of a block the
50756+ /// 32-cap actually tiled -- a hit is therefore proof that the tiled arm ran,
50757+ /// not merely that some palette chroma block existed, and a gate that
50758+ /// passed with the tiled arm removed would be gate-blind-to-feature. (4) The oracle comparator this gate leans on has
5075750759 /// its own per-plane one-byte-flip liveness control in the crate
5075850760 /// (`every_oracle_comparator_reds_on_a_one_byte_wrong_oracle`).
5075950761 #[test]
lanes/refute-av1444d10.report.mdadded+23 -0
@@ -0,0 +1,23 @@
1+# refutation-av1444d10 — reviewer verdict on the 4:4:4 10-bit 352x242 palette-window fix (merge e4787782)
2+
3+Transcribed verbatim from the reviewer seat's output (agent Agent20-5), 2026-09-30. The ONLY edit is the P3 flag below, which main acted on in the same batch (the counter is now guarded on nw*nh>1 and its doc corrected; gate re-run green at 4 windowed units). The P3 finding's own BODY was stored truncated at its 1068-byte tail ("Fix the c…"); the gist -- the counter must be fixed or its doc corrected so that a hit proves the TILED arm ran -- is what was acted on, and a doc-only change was NOT taken as sufficient because the counter is used as the gate's non-vacuity arm.
4+
5+VERDICT: PASS
6+FLAGS: crates/ec-av1/src/decode.rs:2721-2731 (P3 doc-vs-behaviour, non-blocking)
7+EVIDENCE: (1) COMPARATOR LIVENESS: my own one-byte-wrong-oracle shim (wraps ~/.cache/aom-oracle/build/aomdec, flips bit0 of ONE byte of ${EC_AV1_FINAL_DUMP}.f0 at byte 328192) run through the gate's own comparator (EC_AV1_AOMDEC=$PWD/shim/aomdec-tamper, EC_AV1_REQUIRE_AOMDEC=1) turns the byte-exact cell RED with "1 bytes differ" at byte 328192 (ours 216 vs 217) — the count moved by exactly +1, and the comparison point is the census's first bad sample. Green baseline on the un-tampered oracle: "17 decode-order frame(s) (1 hidden) byte-exact vs aomdec, 4 windowed palette chroma unit(s)". The crate comparator reads the oracle's dump file bytes and diffs them against ours (stream.rs:10836-10855) — not a self-comparison, so it is the live kind, unlike the withdrawn av1422 re-measurement.
8+(2) CLAIM 2, my own instrument: a temporary #[cfg(test)] module in my worktree ran aomdec with EC_AV1_FINAL_DUMP against our set_final_dump_prefix dumps and counted wrong u16 SAMPLES per plane over all 17 decode-order frames (352x242 10-bit 4:4:4; dump layout Y,U,V each 352*242 samples). TIP: Y=0 U=0 V=0 on every frame, 0/0/0 total. FIX OUT (only the two palette_window calls reverted, counter left in place): Y=0 U=1166 V=1413, per-frame U = 53,54,54,54,170,54,162,54,58,54,61,54,54,61,61,54,54 and V = 51,51,51,52,160,52,158,52,58,52,158,52,51,156,156,52,51 — a term-for-term match with the report's table. First bad sample on both planes: decode frame 0, row 224, col 64, ours 209 vs oracle 216 (U).
9+(3) MUTATION PROOF reproduced by name: reverting the two windows reds the gate at stream.rs:10848 with "decode-order frame 0 of 17 (16 shown, 1 hidden) differs from the oracle at byte 328192 (ours 209 vs 216), 104 bytes differ" — identical to the report. Green again on restore (worktree diff empty afterwards).
10+(4) CLAIM 4 measured on the lane's own sweep .obu files (not the report's numbers): 320x242, 320x250, 352x250, 416x242, 416x250 all 0/0/0 over 17 decode frames AFTER, and 320x242 also 0/0/0 BEFORE the fix. 352x242's sweep .obu is byte-identical to the committed fixture (sha256 84df2f37…a0ad2, 24875 B), so the provenance chain holds.
11+(5) CLAIM 7 reproduced in a clean worktree at e4787782 with EC_AV1_REQUIRE_AOMDEC=1: "cargo test -p ec-av1 --lib -- 444 420 lossless warp intra --skip bitrate_target_lands_within_5_percent_over_48_frames" -> test result: ok. 178 passed; 0 failed; 2 ignored; 623 filtered out (345.66s).
12+(6) SEMANTIC CHANGE BEYOND THE TWO WINDOWS (claim 4 of my brief): the diff is exactly 2 sites, 10 insertions / 2 deletions, no offsets or guards touched. The no-op-at-nw*nh==1 property is verified, not assumed: cu_col/cu_row are both 0 when nw*nh==1, so palette_window(buf, chroma_w, 0, 0, uw, uh) with uw=chroma_w, uh=chroma_h is a re-stride copy; and the buffer's own stride equals chroma_w because the map is built by decode_color_index_map_wh(…, cw, ch) with cw=(bw>>ss_x).max(4), and the only case where cw>chroma_w (chroma_w<4, e.g. 4:2:0 bw=4) returns `unsupported` earlier at the (uw,uh) match arm before the palette windowing is reached. Both arms' set_palette_pred are consumed exactly once by the same reconstruct/inline_intra path as before (take_palette_pred at decode.rs:4026/4113), so no new stale-override window.
13+(7) CLAIM 8 audited mechanically, not by reading: of 98 set_palette_pred sites, all 6 multi-line ones are palette_window hand-offs; every whole-buffer .clone() hand-off that sits lexically near a unit loop was checked by hand (12776, 17281 = single-push whole-block arms; 25542 = an inter-copy 4x4 unit whose buffer is built per unit). No remaining whole-buffer hand-off inside a tiled unit loop. The two 4x8 sub-8 windows that pass ox=0 with only unit_row are single-column walks, so omitting unit_col is correct there.
14+(8) CLAIM 6's counter: an EC_NWTRACE probe on the pinned fixture shows exactly 4 windowed units = ONE block with nw=1, nh=2, x 2 planes (U,V) x 2 unit rows, so MIN_WINDOWED_UNITS=4 is the exact measured value, and every hit is a genuinely tiled unit. nw>1 is reached NOWHERE in the committed fixture corpus: a corpus-wide sweep (all 106 .obu, tracer on both fixed sites) produced 16 windowed units, all with nw=1; zero with nw>=2.
15+(9) CLAIM 3 partially re-run: the full 106-fixture before/after oracle sweep (95/1/9/1 -> 96/0/9/1) was NOT re-run — it is ~106 aomdec decodes x2 builds. What I did run: the pinned cell, the six sweep cells, the 178-test regression scope with the oracle REQUIRED, and a corpus-wide decode sweep of all 106 fixtures under my tracer (96 decoded, 10 refused, no panics) — consistent with 9 4:2:2 refusals plus the request-only 440 file, but I did not re-measure per-fixture byte-exactness on the other 95.
16+RISK: (a) The gate's pixel arm is silently SKIPPED unless an oracle is present — every run above set EC_AV1_REQUIRE_AOMDEC=1; a green run without it proves nothing about pixels. (b) The nw>1 (horizontal) windowing arm of the fixed code is UNMEASURED: it is unreachable in all 106 committed fixtures and in all six 4:4:4 sweep cells. It is correct by construction (a unit's window is cu_col*uw at the block's own chroma_w stride, matching libaom's per-unit ref pointer), but a 4:4:4 stream with a 64-wide luma rect block carrying a UV palette (chroma_w=64 -> uw=32, nw=2) is what it would take, and no such fixture exists. (c) CHROMA_PALETTE_WINDOW_HITS fires on EVERY palette chroma unit, including single-unit blocks where the window is a no-op, so the counter alone does not prove the tiled path ran; the floor of 4 and the byte compare carry that, and the floor would need re-measuring if a second palette-chroma fixture is ever added to the same test. (d) Do not trust the report's claim 3 numbers as re-measured — they are plausible and consistent with everything I measured, but I did not re-run the two-build 106-fixture sweep. (e) The window indexes buf[(oy+r)*stride+ox..][..w] and would panic (or, with a mismatched stride, misread) if a future block shape ever gave cw != chroma_w; today that shape returns `unsupported` first, which is the only thing keeping it safe.
17+
18+## Flags (structured)
19+### P3 Counter doc claims it counts only non-top-left units; it counts every palette chroma unit
20+file: crates/ec-av1/src/decode.rs:2721-2731 confidence: 0.75
21+
22+The doc comment on CHROMA_PALETTE_WINDOW_HITS (decode.rs:2721-2731, added by eb73ef89) says it counts 'units that are NOT the block's top-left corner', but the hit! sits unconditionally next to set_palette_pred(palette_window(...)) on both fixed lines, so it also fires for nw*nh==1 blocks where the window is a pure re-stride copy of the whole buffer — the exact units the comment says it excludes. Measured on the pinned fixture the two coincide (all 4 hits are nw=1, nh=2), so nothing is mis-gated today, but a reader auditing non-vacuity would conclude the counter proves the TILED arm ran, which the counter cannot distinguish: a stream whose palette chroma blocks are all single-unit would still produce hits >= 1 and pass the reachability assert. Fix the comment to say 'units handed a windowed slice (all palette chroma units on the 32-capped walk; the window is a no-op when nw*nh==1)' and let the MIN_WINDOWED_UNITS floor plus the byte compare carry the tiled-arm claim, or gate the hit! on bigger (nw*nh > 1) if the tiled arm is what it is meant to witness.
23+