forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1422seed r2: the flip control is PROVEN to bite (324/324) and the merged fix re-measured independently

Browse files at this commit

10be7f55c68549055f1ac43b62fc1734c80963ffAhmet Kaan GümüşParent: 2b46317358ec13
The comparator this family's numbers rest on is now proven live, and the root cause of the missing proof is
itself the interesting part: the census's own `flipctl.py` never ran because it was BROKEN -- it re-derived the
decode->display mapping by luma identity inside every compare() call, so flipping a sample destroyed the mapping
key and the call aborted. It was never "unrun". The committed control `scripts/flipctl-422.py` maps ONCE, pins
that mapping across every arm, exercises EVERY decode->display solution (so an ambiguous mapping cannot hide a
failure), and flips in BOTH directions -- the oracle arm and the ours arm, which is the direction every sweep
number is read in. Result on the merged tree: **324 arms, 324 PASS, 0 FAIL** across five s422 targets, the
luma-wrong cell, two 4:2:0 and two 4:4:4 cells, both depths, two shown frames and three samples per plane per
cell, all baselines 0/0/0 so every arm is a +1-off-zero test.

It also re-measured the merged fix rather than inheriting it: the five family cells 0/0/0 (from 0/22003/21625,
0/7810/5531, 0/3437/2222, 0/4653/3777, 0/5740/4348), 4:2:0 and 4:4:4 controls 5/5 exact (so the new `own422`
predicate leaves the 4:2:0 pair arm and the 4:4:4 `own444` arm untouched), luma 0 on every shown frame of every
cell, and `s422_384x240` unchanged at 0/1780/1871 -- correctly NOT attributed to this arm.

Trap worth keeping, recorded in the report and in skill `oracle-comparator-liveness-control`: its first
re-measurement ran against a STALE `main` ref (`0c77bad5`, cached before the merge) and reproduced the pre-fix
numbers exactly -- nothing in the output distinguished "the fix does not work" from "the branch pointer is old".
Re-resolving main first turned the same command into 0/0/0. Same class as a stale binary, on the ref instead.

Honest residue, stated rather than implied: the POST-fix sentinel census was NOT re-run (the scan is still the
temporary uncommitted edit; §3's census is the PRE-fix one and stands as written); coverage on the merged tree is
ARGUED rather than censused (an unwritten sample would hold 0xDEAD = 57005, unreachable at either depth, so
per-plane exactness cannot coexist with one -- labelled an inference); and no gate was added, because a 4:2:2
byte-exact gate is unreachable while the sequence header still refuses the format.
lanes/av1422seed.report.mdmodified+95 -0
@@ -457,3 +457,98 @@ python3 scripts/shape422-diff.py s422_320x246 sweep/s422_320x246.obu
457457 `cells.json` entries are `{"name": ..., "path": ...}`. The comparator derives
458458 geometry from the sequence header itself and needs no other argument; it raises
459459 rather than reporting a count it cannot justify.
460+
461+---
462+
463+## 9. Round 2 addendum — independent re-verification of the merged fix, and the flip control §1.1/§7 could not run
464+
465+This lane lands **no decoder change**. `lane/av1422luma` `459e425d` (merged to
466+main as `298be661`) closed the arm this report localised, and this round's job
467+was to check that claim rather than restate it. Two things came out of that,
468+one of them new to the tree.
469+
470+### 9.1 The merged tree, measured here, not read off the sibling's report
471+
472+`main` = `298be661`, my read-only branch rebased onto it, the local-only 4:2:2
473+probe bypass applied to `stream.rs:1803` for the run and reverted after (the
474+refusal is intact in the committed tree — `git diff main -- crates/` is empty).
475+Same comparator, same binary, same ffmpeg 8.1.3:
476+
477+| cell | round 1 (pre-fix) | merged `298be661` |
478+|---|---|---|
479+| `s422_322x240` | 0 / 22003 / 21625 | **0 / 0 / 0** |
480+| `s422_320x246` | 0 / 7810 / 5531 | **0 / 0 / 0** |
481+| `s422_322x246` | 0 / 3437 / 2222 | **0 / 0 / 0** |
482+| `s422_352x242_10b` | 0 / 4653 / 3777 | **0 / 0 / 0** |
483+| `s422_416x242_10b` | 0 / 5740 / 4348 | **0 / 0 / 0** |
484+
485+Controls on the same binary: `s420_320x240`, `s420_320x246`,
486+`s420_352x242_10b`, `s444_320x240`, `s444_320x242_10b` — **5/5 BYTE-EXACT**,
487+so the 4:2:0 pair arm and the 4:4:4 `own444` arm are untouched by the new
488+`own422` predicate. The whole `s422_*` sweep reads 17/18 byte-exact, with
489+`s422_384x240` unchanged at 0/1780/1871 — the separate frame-1 altref residual
490+`lane/av1422late` owns, correctly NOT attributed to this arm.
491+
492+**A stale-ref trap worth recording.** My first re-measurement of this round ran
493+against `0c77bad5`, a `main` ref my worktree had cached *before* the fix
494+merged, and reproduced the pre-fix numbers exactly (0/7810/5531 on
495+`s422_320x246`) — the kind of result that reads as "the fix does not work" and
496+is entirely an artefact of the branch pointer. `git log -1 main` at the time
497+already disagreed with the merge that had actually landed. Re-resolving
498+`main` first is what turned the same command into `0/0/0`. Class:
499+`stale-binary-false-readings`, on the ref rather than the binary.
500+
501+### 9.2 The flip control: now run, and committed as `scripts/flipctl-422.py`
502+
503+§1.1 and §7 both recorded this as NOT DONE, and the whole corpus verdict rests
504+on it: nothing above distinguishes "our planes match ffmpeg's" from "this
505+comparator never looked at ffmpeg". It is now run.
506+
507+`scripts/flipctl-422.py` flips **one sample** and requires the count to move by
508+**exactly +1 in that plane and 0 in every other plane**, in two independent
509+directions:
510+
511+* **oracle arm** — flip one ffmpeg sample. On a `0/0/0` cell this is the only
512+ thing that can move, so a surviving zero means the comparator is not reading
513+ the oracle.
514+* **ours arm** — flip one of our samples, oracle untouched. This is the
515+ direction every number in this report is read in.
516+
517+It maps decode→display **once** and pins the mapping across the flip: the
518+census's own `flipctl.py` re-derives that mapping from LUMA identity inside
519+every `compare` call, so a flipped sample destroys the very key it maps on and
520+the control aborts instead of measuring (that is why it never ran — the script
521+was broken, not unrun). Every decode→display *solution* is exercised, so an
522+ambiguous mapping cannot hide a failure behind the one that got picked.
523+Two shown display frames per cell (first and middle), three sample indices
524+per plane (first, middle, last), both depths.
525+
526+**324 arms, 324 PASS, 0 FAIL** over five 4:2:2 target cells, `s422_416x250_10b`,
527+two 4:2:0 cells and two 4:4:4 cells — including the 2-solution mapping class
528+(`s420_352x242_10b`, 72 arms, hidden frame 16), which is where a comparator
529+that quietly picks one assignment would show up. All baselines were `0/0/0`,
530+so every arm is a `+1`-off-zero test: the strongest form of this control.
531+
532+```sh
533+python3 scripts/flipctl-422.py cells.json
534+```
535+
536+### 9.3 Still not measured, stated rather than hidden
537+
538+* **The post-fix `EC_AV1_PLANE_SENTINEL=1` unwritten-sample census was not
539+ re-run this round.** §3's census is the PRE-fix one (a 4×8 unwritten hole per
540+ chroma plane at row 128, cols 144..151) and it stands as recorded; the scan
541+ itself is still the temporary four-line edit §8 step 3 describes and is
542+ still not committed. What the merged tree does establish instead is
543+ *implied* coverage, not measured census: a sample that reconstruction never
544+ wrote still holds `PLANE_SENTINEL` = `0xDEAD` = 57005, which is above the
545+ 10-bit maximum and unreachable by ffmpeg at either depth, so a per-plane
546+ byte-exact count on every shown frame of all five cells *cannot* coexist
547+ with an unwritten sample in those planes. That is an inference from the
548+ sentinel's value, not a census run — a lane that wants the direct artifact
549+ should land the scan as a committed env-gated pass, which this lane did not
550+ do because the arm it was measuring is already merged.
551+* No gate was added. `INTRABC_RECT4_OWN_CHROMA422_HITS` on the merged tree is
552+ the route counter the sibling lane describes, and 4:2:2 still refuses at the
553+ sequence header, so a committed byte-exact gate on a 4:2:2 cell is not
554+ reachable without the probe bypass.
scripts/flipctl-422.pyadded+141 -0
@@ -0,0 +1,141 @@
1+#!/usr/bin/env python3
2+"""Flip control: prove the ffmpeg comparator BITES, before any verdict.
3+
4+[`cmp422-ffmpeg`][c] re-derives the decode->display assignment from LUMA
5+identity on every call, so a flipped oracle sample can never be re-mapped --
6+the identity it keys on is exactly what the flip breaks. This control
7+therefore maps ONCE from the untouched streams and then flips one SAMPLE per
8+arm with the mapping PINNED, which is the only way to ask "does one wrong
9+sample move the count by exactly one?".
10+
11+Two independent directions, both required to pass:
12+
13+* **oracle arm** -- flip one ffmpeg sample. The plane that owns it must move by
14+ EXACTLY +1, every other plane by exactly 0. On a byte-exact cell this is the
15+ only thing that can move, so a `0/0/0` that survives a flip is a comparator
16+ that is not reading the oracle.
17+* **ours arm** -- flip one of OUR samples with the oracle untouched. Same
18+ delta. This is the direction the whole corpus verdict rests on, and on a
19+ `0/0/0` cell it is what separates "we agree" from "we never looked".
20+
21+Every decode->display SOLUTION is exercised, so an ambiguous mapping cannot
22+hide a failure behind the one that was picked.
23+
24+Usage:
25+ python3 scripts/flipctl-422.py cells.json
26+
27+`cells.json` entries: `{"name", "path", "prefix"}`, `prefix` being our
28+`EC_AV1_FINAL_DUMP` prefix. Exit status 0 only if every arm passes.
29+"""
30+import importlib.util
31+import json
32+import os
33+import sys
34+
35+_HERE = os.path.dirname(os.path.abspath(__file__))
36+_spec = importlib.util.spec_from_file_location(
37+ "cmp422_ffmpeg", os.path.join(_HERE, "cmp422-ffmpeg.py"))
38+C = importlib.util.module_from_spec(_spec)
39+_spec.loader.exec_module(C)
40+
41+
42+def plane_counts(ours, disp, mapping, hidden, sizes, bps):
43+ """The comparator's own accounting (`cmp422-ffmpeg.compare`'s `measure`),
44+ with the decode->display assignment PINNED so a flipped sample cannot
45+ re-map."""
46+ tot = [0, 0, 0]
47+ for oi, a in enumerate(ours):
48+ if oi in hidden:
49+ continue
50+ b = disp[mapping[oi]]
51+ off = 0
52+ for pi, sz in enumerate(sizes):
53+ for i in range(sz):
54+ s = off + i * bps
55+ if a[s:s + bps] != b[s:s + bps]:
56+ tot[pi] += 1
57+ off += sz * bps
58+ return tot
59+
60+
61+def flip_sample(buf, sample_index, bps):
62+ """Flip bit 0 of one SAMPLE's low byte: exactly +1 wrong sample at both
63+ depths (2**bitdepth < 2**16, so nothing carries out of the container)."""
64+ out = bytearray(buf)
65+ out[sample_index * bps] ^= 1
66+ return bytes(out)
67+
68+
69+def arms_for(sizes):
70+ """(plane, sample_index) per plane: the first, the middle and the last."""
71+ out = []
72+ for pi, sz in enumerate(sizes):
73+ out += [(pi, 0), (pi, sz // 2), (pi, sz - 1)]
74+ return out
75+
76+
77+def one_cell(cell, path, prefix):
78+ w, h, ssx, ssy, depth, pix = C.probe_geometry(path)
79+ bps = 1 if depth <= 8 else 2
80+ sizes, fsz = C.plane_spans(w, h, ssx, ssy, bps)
81+ disp = C.split(C.ffmpeg_frames(path, pix), sizes, fsz, cell)
82+ ours = [open(p, "rb").read() for p in C.frame_files(prefix)]
83+ if not ours:
84+ raise SystemExit(f"{cell}: no EC_AV1_FINAL_DUMP frames -- vacuous")
85+ for i, o in enumerate(ours):
86+ if len(o) != fsz:
87+ raise SystemExit(f"{cell}: our frame {i} is {len(o)} B, "
88+ f"geometry {w}x{h} ss={ssx}{ssy} depth={depth} implies {fsz} B")
89+ sols = C.map_decode_to_display(ours, disp, sizes, bps, cell)
90+ shown = set()
91+ for mapping, hidden in sols:
92+ shown |= {d for oi, d in enumerate(mapping) if oi not in hidden}
93+ shown = sorted(shown)
94+ # Two shown display frames per cell -- the first and one in the middle --
95+ # so the arm is not confined to frame 0.
96+ ks = sorted({shown[0], shown[len(shown) // 2]})
97+ results, arms = [], 0
98+ base0 = plane_counts(ours, disp, sols[0][0], sols[0][1], sizes, bps)
99+ for k in ks:
100+ for sol_i, (mapping, hidden) in enumerate(sols):
101+ dmap = {d: oi for oi, d in enumerate(mapping) if oi not in hidden}
102+ if k not in dmap:
103+ continue
104+ oi = dmap[k]
105+ base = plane_counts(ours, disp, mapping, hidden, sizes, bps)
106+ for pi, si in arms_for(sizes):
107+ off = sum(sizes[:pi]) + si # sample index inside the frame
108+ want = [0, 0, 0]
109+ want[pi] = 1
110+ for side in ("oracle", "ours"):
111+ if side == "oracle":
112+ f = list(disp)
113+ f[k] = flip_sample(disp[k], off, bps)
114+ got = plane_counts(ours, f, mapping, hidden, sizes, bps)
115+ else:
116+ f = list(ours)
117+ f[oi] = flip_sample(ours[oi], off, bps)
118+ got = plane_counts(f, disp, mapping, hidden, sizes, bps)
119+ delta = [got[i] - base[i] for i in range(3)]
120+ ok = delta == want
121+ results.append(ok)
122+ arms += 1
123+ if not ok:
124+ print(f" FAIL {side:6s} disp f{k} plane {'YUV'[pi]} "
125+ f"sample {si} sol{sol_i}: {base} -> {got} "
126+ f"delta {delta} want {want}")
127+ print(f"{cell}: baseline {base0} {len(ours)} decode / {len(disp)} shown, "
128+ f"hidden {sols[0][1]}, {len(sols)} mapping solution(s), {arms} arms")
129+ return results
130+
131+
132+def main(spec_path):
133+ rows = []
134+ for c in json.load(open(spec_path)):
135+ rows += one_cell(c["name"], c["path"], c["prefix"])
136+ print(f"\n{sum(rows)} PASS, {len(rows) - sum(rows)} FAIL of {len(rows)} flip arms")
137+ return 0 if all(rows) else 1
138+
139+
140+if __name__ == "__main__":
141+ sys.exit(main(sys.argv[1]))
\ No newline at end of file