Verify unseen music stress inputs against production decoding
This commit is contained in:
1 parent
d27be302c8
commit
cbf07b0575
4 files changed
+90
-28
No files matched your search
@@ -98,7 +98,7 @@ fn main() -> Result<()> {
|
||||
if candidate["kind"] == "audio" {
|
||||
let actual = probe(&tools, &path, &limits)?;
|
||||
ensure!(
|
||||
serde_json::to_value(&actual.tags)? == candidate["actual_tags"],
|
||||
fields(&serde_json::to_value(&actual.tags)?) == fields(&candidate["actual_tags"]),
|
||||
"Actual tags differ"
|
||||
);
|
||||
let window = audio_windows(&actual, &limits)?
|
||||
@@ -215,4 +215,54 @@ mod tests {
|
||||
assert!(dot(&[0.0], &[0.0]).is_err());
|
||||
assert!(dot(&vec![f32::NAN; 768], &vec![0.0; 768]).is_err());
|
||||
}
|
||||
#[test]
|
||||
#[ignore = "Requires the real prepared containers and CPU FFmpeg; no model inference"]
|
||||
fn prepared_pcm_and_tags_match_production_decoder() -> Result<()> {
|
||||
let plan_path = std::env::var_os("SEARCHI_METADATA_VALIDATION_PLAN")
|
||||
.context("Set SEARCHI_METADATA_VALIDATION_PLAN")?;
|
||||
let plan: Value = serde_json::from_slice(&fs::read(plan_path)?)?;
|
||||
let tools = FfmpegTools::new(
|
||||
PathBuf::from(
|
||||
std::env::var_os("SEARCHI_TEST_FFMPEG").context("Set SEARCHI_TEST_FFMPEG")?,
|
||||
),
|
||||
PathBuf::from(
|
||||
std::env::var_os("SEARCHI_TEST_FFPROBE").context("Set SEARCHI_TEST_FFPROBE")?,
|
||||
),
|
||||
)?;
|
||||
let limits = MediaLimits::default();
|
||||
let mut families = BTreeMap::new();
|
||||
let mut verified = 0;
|
||||
for candidate in plan["candidates"].as_array().context("Candidates absent")? {
|
||||
if candidate.get("pcm_sha256").is_none() {
|
||||
continue;
|
||||
}
|
||||
let path = PathBuf::from(candidate["path"].as_str().context("Path missing")?);
|
||||
ensure!(
|
||||
sha(&fs::read(&path)?) == candidate["sha256"],
|
||||
"Container changed"
|
||||
);
|
||||
let actual = probe(&tools, &path, &limits)?;
|
||||
ensure!(
|
||||
fields(&serde_json::to_value(&actual.tags)?) == fields(&candidate["actual_tags"]),
|
||||
"Tag evidence differs"
|
||||
);
|
||||
let window = audio_windows(&actual, &limits)?
|
||||
.into_iter()
|
||||
.next()
|
||||
.context("Audio absent")?;
|
||||
let pcm = decode_audio(&tools, &path, window, &limits)?;
|
||||
let bytes: Vec<_> = pcm.iter().flat_map(|value| value.to_le_bytes()).collect();
|
||||
let hash = sha(&bytes);
|
||||
ensure!(hash == candidate["pcm_sha256"], "Production PCM differs");
|
||||
if let Some(previous) = families.insert(candidate["id"].to_string(), hash.clone()) {
|
||||
ensure!(previous == hash, "Variant audio differs");
|
||||
}
|
||||
verified += 1;
|
||||
}
|
||||
ensure!(
|
||||
verified == 18 && families.len() == 6,
|
||||
"Expected six real three-variant families"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user