Validate gated Google retrieval and record unchanged localization quality

This commit is contained in:
karl committed 2026-10-13 13:49:23 +02:00
1 parent af04cec27c
commit 59908adfa6
5 files changed
+267 -5

No files matched your search

+25 -3
View File
@@ -13,6 +13,7 @@ use std::{
const FIXTURE_SHA: &str = "b4e465a0eb9582b826eebd2a20797e1680e4907e336d02d0ef2194e2ba0af393";
const ASSETS: [&str; 5] = ["clip04", "music01", "music02", "sound01", "sound02"];
mod gated;
const POLICY: &str = "primary-audio-range-v3;aresample16000-before-atrim;samplecoverage-1ms;nonoverlapping30s;independent-process-per-window;auto-language;segment-times";
fn digest(path: &Path) -> Result<String> {
@@ -90,7 +91,7 @@ fn eligible(asr: &Value, fixture: &Value) -> Result<(Vec<Value>, Vec<Value>)> {
ensure!(
asr["complete"] == true
&& asr["fixture_sha256"] == FIXTURE_SHA
&& asr["policy"] == POLICY
&& matches!(asr["policy"].as_str(), Some(POLICY) | Some(gated::POLICY))
&& asr["backend"] == "forced CPU"
&& asr["threads"] == 1,
"Incomplete, stale, or unrecognized ASR report"
@@ -104,6 +105,7 @@ fn eligible(asr: &Value, fixture: &Value) -> Result<(Vec<Value>, Vec<Value>)> {
] {
ensure!(asr[field].as_str().is_some_and(|hash| hash.len() == 64 && hash.bytes().all(|b| b.is_ascii_hexdigit())), "Missing ASR provenance");
}
let vad = gated::verified_report(asr)?;
let rows = asr["rows"].as_array().context("Missing ASR rows")?;
ensure!(rows.len() == 5, "All five competing assets required");
let mut seen = BTreeSet::new();
@@ -133,12 +135,23 @@ fn eligible(asr: &Value, fixture: &Value) -> Result<(Vec<Value>, Vec<Value>)> {
);
let windows = row["windows"].as_array().context("Missing windows")?;
ensure!(windows.len() <= 20, "Oversized window list");
let planned = vad
.as_ref()
.map(|vad| gated::planned_windows(vad, row, asset))
.transpose()?;
if let Some(planned) = &planned {
gated::verify_windows(windows, planned)?;
}
let mut next = start;
for (window_index, window) in windows.iter().enumerate() {
let offset = number(&window["offset_ms"])?;
let duration = number(&window["duration_ms"])?;
ensure!(
offset == next && duration == (end - offset).min(30000) && duration > 0,
if let Some(planned) = &planned {
gated::matches_plan(window, &planned[window_index])
} else {
offset == next && duration == (end - offset).min(30000) && duration > 0
},
"Missing, overlapping or truncated source windows"
);
next = offset.checked_add(duration).context("Window overflow")?;
@@ -183,7 +196,10 @@ fn eligible(asr: &Value, fixture: &Value) -> Result<(Vec<Value>, Vec<Value>)> {
ensure!(segments.len() <= 5000, "Too many recognized segments");
}
}
ensure!(next == end, "Incomplete source-window coverage");
ensure!(
planned.is_some() || next == end,
"Incomplete source-window coverage"
);
}
ensure!(
asr["quality_failed"] == !excluded.is_empty(),
@@ -197,6 +213,12 @@ fn eligible(asr: &Value, fixture: &Value) -> Result<(Vec<Value>, Vec<Value>)> {
== excluded.len(),
"ASR validation failure count inconsistent"
);
if vad.is_some() {
ensure!(
asr["comparison_eligible"] == excluded.is_empty(),
"Gated comparison status inconsistent"
);
}
Ok((segments, excluded))
}