forge
Explore
Log in

Don't you dare go Hollow

lane-av1unwritten r10: the AB-arm tracker, once more, plus the number corrections

Browse files at this commit

1feddfcdc81f0cbdc13dcb3176cb656f12adc1ddAhmet Kaan GümüşParent: 4ac9e12
No decode-path change -- the fourth pass found no defect in it. Test and report
only.

1. The AB-arm tracker was open for exactly one line. Armed at the condition
(indent 44, body 48), the wrapped `.contains(&part16)` at indent 48 set
entered = true, and then the arm's own `{` -- which carries the OPENER's indent,
not the body's -- hit ind < body and cleared it. Every statement in the arm body
was invisible, so the mutation that moves a guard INSIDE an arm stayed GREEN at
r8 and r9. r10 skips a line whose trimmed text is exactly `{`. That mutation now
reds with the r5 diagnostic:
  "decode.rs:36539 puts a refuse_invalid_subsize inside a
   PARTITION_HORZ_A..=PARTITION_VERT_B arm ... -- r5's defect"

2. The doc comment was stale r7 text. Re-derived per line: 18 occurrences in
decode.rs = 11 guard call sites in the decode body (35588, 36278, 36406, 36472,
36882, 37132, 53985, 54222, 54606, 54752, 55164) + 5 in this test's own strings
and comparisons + 2 in doc comments. The definition's signature does not match
"(( " at all.

3. The scan finds 10 resolutions, not 11. The eleventh guard is the inter-frame 128
one at 53985, whose resolution lives in the shared read_sb128_root and so has no
resolution of its own -- the redundancy the >= exists to allow. The report says
11 guards against 10 resolutions and names why.

4. The bound-variable lookup now scans BACKWARDS and takes the nearest `let`
whose binding is the one followed by the symbol read; it used to take the first
`let` upward and could name an unrelated binding (ec_dbg_pre).

5. The non-claim is now explicit rather than inferable: cross-check 1 is level
PRESENCE only, cross-check 2 is >=, so a SECOND unguarded site at an
already-covered level is caught only by the per-site 220-line window -- a window,
not a dispatch bound.
crates/ec-av1/src/decode.rsmodified+47 -12
@@ -56618,10 +56618,15 @@ mod tests {
5661856618 /// a symbol's RESOLUTION and every dispatch of it.
5661956619 ///
5662056620 /// So the invariant is stated over the dispatch structure, not over a list.
56621- /// Today the file has **10 partition-symbol resolutions** and **13
56622- /// `refuse_invalid_subsize((` call sites**, of which 9 are guards at 9
56623- /// resolutions (the extra 4 are the definition, the doc comment and the test's
56624- /// own example strings). What is asserted, exactly:
56621+ /// Counts in the tree this was written against, re-derived per line rather
56622+ /// than grepped: `refuse_invalid_subsize((` occurs **18 times** in this file —
56623+ /// **11 guard call sites** in the decode body (35588, 36278, 36406, 36472,
56624+ /// 36882, 37132, 53985, 54222, 54606, 54752, 55164), **5** in this test's own
56625+ /// string literals and comparisons, **2** in doc comments; the definition's
56626+ /// signature line does not match `((` at all. The scan finds **10 resolutions**:
56627+ /// the eleventh guard is the inter-frame 128 one, whose resolution lives in
56628+ /// the shared `read_sb128_root`, so a guard has no resolution of its own here.
56629+ /// What is asserted, exactly:
5662556630 ///
5662656631 /// * every `partition_w<N>[` level in the file appears among the resolutions
5662756632 /// this scan finds -- a new level cannot be added without a guard check;
@@ -56634,8 +56639,12 @@ mod tests {
5663456639 /// * no guard sits inside a `PARTITION_HORZ_A..=PARTITION_VERT_B` arm.
5663556640 ///
5663656641 /// It does NOT prove a guard is at the exact dispatch point: the window is a
56637- /// window. That limit is why the AB-arm invariant exists separately, and why
56638- /// `EC_AV1_SUBSIZE_GUARD_TRACE` records what each site really sees.
56642+ /// window. And the two cross-checks are weaker than they look — cross-check 1
56643+ /// is level PRESENCE only, cross-check 2 is `>=` — so a SECOND unguarded site
56644+ /// at an already-covered level is caught ONLY by the per-site 220-line window,
56645+ /// which is a window and not a dispatch bound. That limit is why the AB-arm
56646+ /// invariant exists separately, and why `EC_AV1_SUBSIZE_GUARD_TRACE` records
56647+ /// what each site really sees over the corpus.
5663956648 #[test]
5664056649 fn every_partition_symbol_resolution_is_guarded_before_it_dispatches() {
5664156650 let src = include_str!("decode.rs");
@@ -56699,14 +56708,34 @@ mod tests {
5669956708 let level: usize = digits.parse().expect("digits");
5670056709 // The bound variable is the token after `let `, looked for in the two
5670156710 // lines the binding can occupy (r9: it may be the line above).
56711+ // r10: scan BACKWARDS from the closest line and take the nearest `let`
56712+ // whose binding is the one followed by this symbol read -- taking the
56713+ // first `let` upward named an unrelated binding above it.
5670256714 let mut var = None;
56703- for cand in [lo, n] {
56715+ for cand in (lo..=n).rev() {
5670456716 let ct = lines[cand].trim_start();
56705- if let Some(v) = ct.strip_prefix("let ") {
56706- var = v
56707- .split(|c: char| !(c.is_alphanumeric() || c == '_'))
56708- .next()
56709- .map(str::to_string);
56717+ if ct.starts_with("//") {
56718+ continue;
56719+ }
56720+ let Some(v) = ct.strip_prefix("let ") else {
56721+ continue;
56722+ };
56723+ let name = v
56724+ .split(|c: char| !(c.is_alphanumeric() || c == '_'))
56725+ .next()
56726+ .unwrap_or("")
56727+ .to_string();
56728+ if name.is_empty() {
56729+ continue;
56730+ }
56731+ // This binding is followed by the symbol read if the SAME line
56732+ // completes `let <name> = dec.symbol(`, or if the next line starts
56733+ // the call. That is what separates `let part8 =` from an unrelated
56734+ // `let ec_dbg_pre =` two lines above it.
56735+ let next = lines.get(cand + 1).copied().unwrap_or("");
56736+ let binds_here = ct.contains("= dec.symbol") || next.contains("dec.symbol(");
56737+ if binds_here || cand == n {
56738+ var = Some(name);
5671056739 break;
5671156740 }
5671256741 }
@@ -56822,6 +56851,12 @@ mod tests {
5682256851 // been inside it.
5682356852 if line.contains("PARTITION_HORZ_A..=PARTITION_VERT_B") {
5682456853 ab_arm = Some((ind + 4, false));
56854+ } else if t == "{" {
56855+ // r10: the arm's own brace carries the OPENER's indent, not the
56856+ // body's, so treating it as "backed out" cleared the arm before a
56857+ // single body statement was seen -- which is why the mutation that
56858+ // moves a guard INSIDE an arm stayed GREEN at r8 AND r9. A lone `{`
56859+ // never changes the state.
5682556860 } else if let Some((body, entered)) = ab_arm {
5682656861 if !entered {
5682756862 if ind >= body {
lanes/av1unwritten.report.mdmodified+58 -14
@@ -619,7 +619,11 @@ reachable at ss (1,0) today. Guarded anyway.
619619 adds the exact guard-vs-resolution count.
620620 3. **`sites.len() >= 9` was a floor the tree already satisfied with 10.** Replaced
621621 with a count derived from the scan: the decode body has **11 guard sites** and
622- the scan finds **11 resolutions**.
622+ the scan finds **10 resolutions** — the eleventh guard is the inter-frame 128
623+ one at `53985`, whose resolution lives in the shared `read_sb128_root` and so
624+ has no resolution of its own here. That is exactly the redundancy the `>=`
625+ exists to allow, so the counts are reported as 11 guards against 10
626+ resolutions and the reason is named.
623627
624628 Plus the one the refutation demonstrated green: the AB-arm tracker **self-cleared
625629 on the `{` line**, because that line carries the same indent as the `if` — moving
@@ -635,19 +639,59 @@ refuse_invalid_subsize((32, 32)) within 220 lines after it
635639
636640 ### 11.3 The occurrence count, re-derived per line
637641
638-`refuse_invalid_subsize((` appears **18 times in `decode.rs`**: **11** guard call
639-sites in the decode body (one per resolution), **4** in this test's own string
640-literals and comparisons, **2** in doc comments, and **1** — the definition's own
641-signer line does not match `((` at all. Main's line-grep count of 13 was taken at
642-r7, before the two r9 guards; the refutation's 15 was likewise pre-r9. Eleven is
643-what the tree carries now, counted by call shape (`l.trim_start().starts_with(…)`)
644-so a multi-line assert string mentioning the function is not counted.
642+`refuse_invalid_subsize((` appears **18 times in `decode.rs`**, and the breakdown
643+that sums is **11 + 5 + 2**:
644+
645+* **11 guard call sites** in the decode body — 35588, 36278, 36406, 36472, 36882,
646+ 37132, 53985, 54222, 54606, 54752, 55164;
647+* **5** in this test's own string literals and comparisons — the four named in the
648+ assertions plus the multi-line assert string at 56835;
649+* **2** in doc comments.
650+
651+The definition's own signature line does not match `((` at all. Main's line-grep
652+count of 13 was taken at r7 and the refutation's 15 at r9, both before the r9 kf-w8
653+guards; 18 is what the tree carries now, counted by call shape
654+(`l.trim_start().starts_with(…)`) so a multi-line assert string mentioning the
655+function is not counted. The scan finds **10** resolutions against those **11**
656+guards — the inter-128 guard at 53985 has no resolution of its own because
657+`read_sb128_root` is shared.
645658
646659 ### 11.4 What is still not claimed
647660
648-The guard-vs-resolution cross-check is `>=`, not `==`: the scan sees 11 and 11
649-today, but a hard equality between two numbers the scan itself computes is a claim
650-about the scanner, not about coverage. What reds is a resolution with no guard —
651-on its own line, naming the variable — and a guard sitting inside an AB arm. A
652-redundant guard with no resolution behind it is harmless and is not treated as a
653-defect.
661+The guard-vs-resolution cross-check is `>=`, not `==`: the scan sees 10 resolutions
662+against 11 guards today, and a hard equality between two numbers the scan itself
663+computes is a claim about the scanner, not about coverage. What reds is a
664+resolution with no guard — on its own line, naming the variable — and a guard
665+sitting inside an AB arm. A redundant guard with no resolution behind it is
666+harmless and is not treated as a defect.
667+
668+**And the two cross-checks are weaker than they look.** Cross-check 1 is level
669+PRESENCE only. Cross-check 2 is `>=`. So a **second unguarded site at an
670+already-covered level is caught only by the per-site 220-line window** — which is
671+a window, not a dispatch bound. Stated rather than left for a reader to infer.
672+
673+### 11.5 r10: the AB-arm tracker, again
674+
675+r9's tracker was open for exactly one line: armed at the condition (indent 44,
676+body 48), the wrapped `.contains(&part16)` at indent 48 set `entered = true`, and
677+then the arm's own `{` — at the **opener's** indent 44, not the body's — hit
678+`ind < body` and cleared it. Every statement in the arm body was invisible, and
679+the mutation that moves a guard INSIDE an arm stayed GREEN at r8 *and* r9. r10
680+skips a line whose trimmed text is exactly `{` when deciding to enter or clear.
681+The mutation now reds with the r5 diagnostic:
682+
683+```
684+$ # move the kf-16 guard inside a PARTITION_HORZ_A..=PARTITION_VERT_B arm
685+decode.rs:36539 puts a refuse_invalid_subsize inside a
686+PARTITION_HORZ_A..=PARTITION_VERT_B arm (values 4..=7 only); the offending
687+values are PARTITION_VERT (2) and PARTITION_VERT_4 (9), which that arm can
688+never observe -- r5's defect
689+```
690+
691+Also in r10: the bound-variable lookup scans **backwards** and takes the nearest
692+`let` whose binding is the one followed by the symbol read. It used to take the
693+first `let` upward, which could name an unrelated binding (`ec_dbg_pre`) instead
694+of the partition symbol.
695+
696+**No decode-path change in r10** — the four passes found no defect in it.
697+