Lane-realworld r2 charter -- verify bd61617, gate cdef_idx, then delta q/lf
Browse files at this commit09db2270fa074ef711b200f7542211d7022488a1Parent: 7fc9065- docs
- lane-realworld r2 charter -- verify bd61617, gate cdef_idx, then delta q/lf
1 changed file +93 -0
lanes/realworld-r2.charter.mdadded+93 -0
| @@ -0,0 +1,93 @@ | |||
| 1 | +# lane-realworld r2 — verify cdef_idx, gate it, then delta_q / delta_lf | ||
| 2 | + | ||
| 3 | +Worktree `/home/user/Documents/Code/Rust/edith_codecs-realworld`, branch | ||
| 4 | +`lane-realworld`, at bd61617. | ||
| 5 | + | ||
| 6 | +## State handed to you (r1's own words; nothing here is verified) | ||
| 7 | +bd61617 is r1's work, committed verbatim by the orchestrator when r1 hit its | ||
| 8 | +turn cap. It compiles (`cargo build -p ec-av1 --release` was clean). Its | ||
| 9 | +**suite status is UNKNOWN** — the test run was launched and the cap hit before | ||
| 10 | +it returned. There is **no gate test at all** yet. | ||
| 11 | + | ||
| 12 | +What it contains — CDEF index only, `delta_q`/`delta_lf` entirely unstarted: | ||
| 13 | +- `crates/ec-av1/src/decode.rs`: thread-locals `CDEF_BITS`, `CDEF_TRANSMITTED`, | ||
| 14 | + `CDEF_SB_COLS`, `CDEF_IDX_GRID`, `CDEF_IDX_HITS` + a `cdef_idx_hits()` | ||
| 15 | + accessor, mirroring the existing `*_HITS` pattern. | ||
| 16 | +- `maybe_read_cdef_idx(dec, mi_r, mi_c, skip)` — the spec 5.11.56 `read_cdef` | ||
| 17 | + port. No-op when `cdef.bits == 0` or `skip`; reads once per superblock (this | ||
| 18 | + decoder's SB is the CDEF unit — no 128x128 support, so no 4-way index). | ||
| 19 | +- Wired at all five sites where `skip` is decoded: `read_intra_mode` (shared by | ||
| 20 | + `decode_block` and `decode_leaf8`, given new `mi_r`/`mi_c` params), | ||
| 21 | + `read_intra_mode_rect` / `decode_block_rect`, `decode_inter_block` (~6462), | ||
| 22 | + `decode_inter_block8` (~8189). | ||
| 23 | +- Both tile functions (`decode_key_frame_tile_with_cdfs`, | ||
| 24 | + `decode_inter_frame_tile_with_cdfs`) set `CDEF_BITS` / `CDEF_SB_COLS` and init | ||
| 25 | + `CDEF_IDX_GRID` before the SB loop, and reset `CDEF_TRANSMITTED = false` at | ||
| 26 | + the top of each SB. | ||
| 27 | +- `apply_cdef` looks up a per-superblock `sidx` through a | ||
| 28 | + `strength_idx(mi_r, mi_c)` closure over `CDEF_IDX_GRID`, replacing every | ||
| 29 | + hardcoded `[0]` strength index. | ||
| 30 | +- `crates/ec-av1/src/stream.rs`: the `header.cdef.bits != 0` refusal in | ||
| 31 | + `decode_stream` was REMOVED. | ||
| 32 | + | ||
| 33 | +**Risk r1 flagged:** `apply_cdef`'s early-return guard became | ||
| 34 | +`cdef.bits == 0 && <all index-0 strengths zero>`, so a `bits > 0` stream now | ||
| 35 | +always walks the full filter loop even when every strength is zero. Believed | ||
| 36 | +correct, never checked against a real decode. | ||
| 37 | + | ||
| 38 | +## Do these in order — COMMIT AFTER EVERY GREEN STEP, never batch | ||
| 39 | +1. `export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-realworld` then | ||
| 40 | + `EC_AV1_REQUIRE_AOMENC=1 nice -n 19 cargo test -p ec-av1 --lib -j4`. | ||
| 41 | + Report the pass count against the 232 passed / 0 failed baseline. If it is | ||
| 42 | + red, fixing bd61617 is the whole job until it is green. | ||
| 43 | +2. **The CDEF gate.** Copy the structure of | ||
| 44 | + `a_real_aomenc_stream_with_masked_compound_decodes_pixel_exact` | ||
| 45 | + (stream.rs around 4447-4657) but keep `--enable-cdef=1` (drop that gate's | ||
| 46 | + `--enable-cdef=0`) and disable the unrelated features (masked-comp, | ||
| 47 | + interintra, obmc, warp, restoration, palette, intrabc) exactly as that gate | ||
| 48 | + does. Hard-assert `crate::decode::cdef_idx_hits() > 0` — the accessor | ||
| 49 | + already exists. Bound the ffmpeg generate with `-t <seconds>`; build the | ||
| 50 | + fixture through `gradients_source(seed, w, h, tail)`; aomenc | ||
| 51 | + `--threads=1 --row-mt=0`. Flat gradients may not make aomenc's RD choose | ||
| 52 | + `cdef_bits > 0` — if the counter stays 0 across attempts, switch the source | ||
| 53 | + to `mandelbrot` the way the masked-compound gate does (bounded with `-t`). | ||
| 54 | + A gate that cannot prove cdef_idx fired is vacuous (class | ||
| 55 | + `gate-blind-to-feature`), and a firing count is a HARD assert, never a | ||
| 56 | + warning. COMMIT. | ||
| 57 | +3. **Then** `delta_q` / `delta_lf` (spec 5.11.15 `read_delta_qindex`, 5.11.16 | ||
| 58 | + `read_delta_lflevel`; libaom `av1/decoder/decodemv.c` `read_delta_qindex` / | ||
| 59 | + `read_delta_lflevel`). This needs new ADAPTING CDFs — four wiring sites: | ||
| 60 | + struct field, defaults array, save/restore, per-frame counter reset (see | ||
| 61 | + `cdf_state.rs:590+`; in this codebase reset2/reset3 are length-generic and | ||
| 62 | + save/restore is a whole-struct Clone, so the defaults array is the one that | ||
| 63 | + needs hand-checking, but verify the counter reset covers the new tables — | ||
| 64 | + class `cdf-counter-not-reset`: a table missing from the reset gives right | ||
| 65 | + values at the wrong adaptation rate). It also needs the running | ||
| 66 | + quantizer/loop-filter-delta state threaded through block decode, and the | ||
| 67 | + deltas are read once per superblock at the first non-skip block. | ||
| 68 | + Its own gate, its own firing counter, its own commit. | ||
| 69 | + | ||
| 70 | +## Method | ||
| 71 | +CLASS `compare-range-not-tell`: compare msac RANGE against the oracle, never | ||
| 72 | +`tell()`. Oracle `~/.cache/aom-oracle`; rungs `EC_TRACE=1` (partitions), | ||
| 73 | +`EC_TRACE_COEFF=1`, `EC_TRACE_MODE=1` (inter + intra mode info), | ||
| 74 | +`EC_AV1_PREFILT_DUMP=<prefix>` (pre-filter recon — the right rung for | ||
| 75 | +separating a CDEF filter bug from a symbol bug). Add a rung with | ||
| 76 | +`scripts/instrument-aom-oracle.sh` + `scripts/build-aom-oracle.sh` in the | ||
| 77 | +existing shape (env-gated, silent when unset, idempotent) if you need one. | ||
| 78 | +CLASS `equal-range-means-unread`: reference range unchanged where ours moves = | ||
| 79 | +we read a symbol it never wrote; theirs moves and ours does not = we skipped one. | ||
| 80 | + | ||
| 81 | +## Hard rules | ||
| 82 | +- Foreground builds, `nice -n 19 cargo ... -j4`, own `CARGO_TARGET_DIR` as | ||
| 83 | + above. Sibling worktrees (edith_codecs, -chroma, -lr, -superres, -tiles) have | ||
| 84 | + live agents — never build in or edit them. | ||
| 85 | +- NEVER push, never merge, never touch `main`. Commit on `lane-realworld` only. | ||
| 86 | +- 75-turn cap. Two agents have now burned a cap on this lane. Do not re-read | ||
| 87 | + what this charter already told you (class `worker-cap-spent-reading`), and | ||
| 88 | + commit at every green step. | ||
| 89 | +- Refuse-by-name rather than desync. Never write a refusal string claiming the | ||
| 90 | + encoder cannot emit a case unless you proved it. | ||
| 91 | +- End with `lanes/realworld-r2.report.md`, VERDICT on the first line: what | ||
| 92 | + landed, gate names + firing counts, remaining refusal strings verbatim, and | ||
| 93 | + the next lever. | ||