From 1feddfcdc81f0cbdc13dcb3176cb656f12adc1dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 1 Oct 2026 17:09:56 +0300 Subject: [PATCH] lane-av1unwritten r10: the AB-arm tracker, once more, plus the number corrections 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.rs | 59 +++++++++++++++++++++++------ lanes/av1unwritten.report.md | 72 +++++++++++++++++++++++++++++------- 2 files changed, 105 insertions(+), 26 deletions(-) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index dd6a40d8..88070864 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -56618,10 +56618,15 @@ mod tests { /// a symbol's RESOLUTION and every dispatch of it. /// /// So the invariant is stated over the dispatch structure, not over a list. - /// Today the file has **10 partition-symbol resolutions** and **13 - /// `refuse_invalid_subsize((` call sites**, of which 9 are guards at 9 - /// resolutions (the extra 4 are the definition, the doc comment and the test's - /// own example strings). What is asserted, exactly: + /// Counts in the tree this was written against, re-derived per line rather + /// than grepped: `refuse_invalid_subsize((` occurs **18 times** in this file — + /// **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 + /// string literals and comparisons, **2** in doc comments; the definition's + /// signature line does not match `((` at all. The scan finds **10 resolutions**: + /// the eleventh guard is the inter-frame 128 one, whose resolution lives in + /// the shared `read_sb128_root`, so a guard has no resolution of its own here. + /// What is asserted, exactly: /// /// * every `partition_w[` level in the file appears among the resolutions /// this scan finds -- a new level cannot be added without a guard check; @@ -56634,8 +56639,12 @@ mod tests { /// * no guard sits inside a `PARTITION_HORZ_A..=PARTITION_VERT_B` arm. /// /// It does NOT prove a guard is at the exact dispatch point: the window is a - /// window. That limit is why the AB-arm invariant exists separately, and why - /// `EC_AV1_SUBSIZE_GUARD_TRACE` records what each site really sees. + /// window. And the two cross-checks are weaker than they look — 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, + /// which is a window and not a dispatch bound. That limit is why the AB-arm + /// invariant exists separately, and why `EC_AV1_SUBSIZE_GUARD_TRACE` records + /// what each site really sees over the corpus. #[test] fn every_partition_symbol_resolution_is_guarded_before_it_dispatches() { let src = include_str!("decode.rs"); @@ -56699,14 +56708,34 @@ mod tests { let level: usize = digits.parse().expect("digits"); // The bound variable is the token after `let `, looked for in the two // lines the binding can occupy (r9: it may be the line above). + // r10: scan BACKWARDS from the closest line and take the nearest `let` + // whose binding is the one followed by this symbol read -- taking the + // first `let` upward named an unrelated binding above it. let mut var = None; - for cand in [lo, n] { + for cand in (lo..=n).rev() { let ct = lines[cand].trim_start(); - if let Some(v) = ct.strip_prefix("let ") { - var = v - .split(|c: char| !(c.is_alphanumeric() || c == '_')) - .next() - .map(str::to_string); + if ct.starts_with("//") { + continue; + } + let Some(v) = ct.strip_prefix("let ") else { + continue; + }; + let name = v + .split(|c: char| !(c.is_alphanumeric() || c == '_')) + .next() + .unwrap_or("") + .to_string(); + if name.is_empty() { + continue; + } + // This binding is followed by the symbol read if the SAME line + // completes `let = dec.symbol(`, or if the next line starts + // the call. That is what separates `let part8 =` from an unrelated + // `let ec_dbg_pre =` two lines above it. + let next = lines.get(cand + 1).copied().unwrap_or(""); + let binds_here = ct.contains("= dec.symbol") || next.contains("dec.symbol("); + if binds_here || cand == n { + var = Some(name); break; } } @@ -56822,6 +56851,12 @@ mod tests { // been inside it. if line.contains("PARTITION_HORZ_A..=PARTITION_VERT_B") { ab_arm = Some((ind + 4, false)); + } else if t == "{" { + // r10: the arm's own brace carries the OPENER's indent, not the + // body's, so treating it as "backed out" cleared the arm before a + // single body statement was seen -- which is why the mutation that + // moves a guard INSIDE an arm stayed GREEN at r8 AND r9. A lone `{` + // never changes the state. } else if let Some((body, entered)) = ab_arm { if !entered { if ind >= body { diff --git a/lanes/av1unwritten.report.md b/lanes/av1unwritten.report.md index a61372da..b90ace20 100644 --- a/lanes/av1unwritten.report.md +++ b/lanes/av1unwritten.report.md @@ -619,7 +619,11 @@ reachable at ss (1,0) today. Guarded anyway. adds the exact guard-vs-resolution count. 3. **`sites.len() >= 9` was a floor the tree already satisfied with 10.** Replaced with a count derived from the scan: the decode body has **11 guard sites** and - the scan finds **11 resolutions**. + the scan finds **10 resolutions** — 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 here. That is exactly the redundancy the `>=` + exists to allow, so the counts are reported as 11 guards against 10 + resolutions and the reason is named. Plus the one the refutation demonstrated green: the AB-arm tracker **self-cleared 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 ### 11.3 The occurrence count, re-derived per line -`refuse_invalid_subsize((` appears **18 times in `decode.rs`**: **11** guard call -sites in the decode body (one per resolution), **4** in this test's own string -literals and comparisons, **2** in doc comments, and **1** — the definition's own -signer line does not match `((` at all. Main's line-grep count of 13 was taken at -r7, before the two r9 guards; the refutation's 15 was likewise pre-r9. Eleven is -what the tree carries now, counted by call shape (`l.trim_start().starts_with(…)`) -so a multi-line assert string mentioning the function is not counted. +`refuse_invalid_subsize((` appears **18 times in `decode.rs`**, and the breakdown +that sums is **11 + 5 + 2**: + +* **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 string literals and comparisons — the four named in the + assertions plus the multi-line assert string at 56835; +* **2** in doc comments. + +The definition's own signature line does not match `((` at all. Main's line-grep +count of 13 was taken at r7 and the refutation's 15 at r9, both before the r9 kf-w8 +guards; 18 is what the tree carries now, counted by call shape +(`l.trim_start().starts_with(…)`) so a multi-line assert string mentioning the +function is not counted. The scan finds **10** resolutions against those **11** +guards — the inter-128 guard at 53985 has no resolution of its own because +`read_sb128_root` is shared. ### 11.4 What is still not claimed -The guard-vs-resolution cross-check is `>=`, not `==`: the scan sees 11 and 11 -today, but a hard equality between two numbers the scan itself computes is a claim -about the scanner, not about coverage. What reds is a resolution with no guard — -on its own line, naming the variable — and a guard sitting inside an AB arm. A -redundant guard with no resolution behind it is harmless and is not treated as a -defect. +The guard-vs-resolution cross-check is `>=`, not `==`: the scan sees 10 resolutions +against 11 guards today, and a hard equality between two numbers the scan itself +computes is a claim about the scanner, not about coverage. What reds is a +resolution with no guard — on its own line, naming the variable — and a guard +sitting inside an AB arm. A redundant guard with no resolution behind it is +harmless and is not treated as a defect. + +**And the two cross-checks are weaker than they look.** 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** — which is +a window, not a dispatch bound. Stated rather than left for a reader to infer. + +### 11.5 r10: the AB-arm tracker, again + +r9's 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 `{` — at the **opener's** indent 44, not the body's — hit +`ind < body` and cleared it. Every statement in the arm body was invisible, and +the mutation that moves a guard INSIDE an arm stayed GREEN at r8 *and* r9. r10 +skips a line whose trimmed text is exactly `{` when deciding to enter or clear. +The mutation now reds with the r5 diagnostic: + +``` +$ # move the kf-16 guard inside a PARTITION_HORZ_A..=PARTITION_VERT_B arm +decode.rs:36539 puts a refuse_invalid_subsize inside a +PARTITION_HORZ_A..=PARTITION_VERT_B arm (values 4..=7 only); the offending +values are PARTITION_VERT (2) and PARTITION_VERT_4 (9), which that arm can +never observe -- r5's defect +``` + +Also in r10: the bound-variable lookup 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, which could name an unrelated binding (`ec_dbg_pre`) instead +of the partition symbol. + +**No decode-path change in r10** — the four passes found no defect in it. +