From b325c38f3133a18133bde73b1bb623aad21fb58c Mon Sep 17 00:00:00 2001 From: Sam & Claude Date: Wed, 27 May 2026 12:44:52 +0200 Subject: [PATCH] Fix platform-matrix watchdog check: exact manifest suffix match (Sam & Claude) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit read_manifest used a loose `filename.contains(manifest_type)` substring match, so for host=osa type=watchdog-host-status it nondeterministically grabbed either `…watchdog-host-status.json` (correct, has `.status`) or its sibling `…watchdog-host-status-run-manifest.json` (no `.status`). When the run-manifest won the read_dir race, source/mode read as "unknown" and the FreeBSD watchdog-socket-read row failed (11/12). Match the exact `-.json` suffix and pick the lexically greatest (most-recent dated) filename, so selection is deterministic and the run-manifest sibling is excluded. The underlying watchdog data was always correct; this was a false failure from loose fixture matching. cargo test --workspace: all green. cargo clippy --all-targets -D warnings: clean. Co-Authored-By: Claude Opus 4.7 --- tests/platform-matrix.rs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/platform-matrix.rs b/tests/platform-matrix.rs index 1f9f1cf..400e9e7 100644 --- a/tests/platform-matrix.rs +++ b/tests/platform-matrix.rs @@ -18,21 +18,22 @@ struct PlatformTest { fn read_manifest(host: &str, manifest_type: &str) -> Option { let manifest_dir = Path::new("manifests"); - // Find the most recent matching manifest - if let Ok(entries) = fs::read_dir(manifest_dir) { - for entry in entries.flatten() { - if let Ok(filename) = entry.file_name().into_string() { - if filename.contains(host) && filename.contains(manifest_type) { - if let Ok(content) = fs::read_to_string(entry.path()) { - if let Ok(json) = serde_json::from_str::(&content) { - return Some(json); - } - } - } - } - } - } - None + // Match the exact `-.json` suffix so a loose substring + // does not also grab a sibling like `…watchdog-host-status-run-manifest.json` + // (which has no `.status`). Collect all matches and pick the lexically + // greatest filename — dated `YYYY-MM-DD-` prefixes sort to "most recent" — + // so the result is deterministic regardless of `read_dir` ordering. + let suffix = format!("{}-{}.json", host, manifest_type); + let mut matches: Vec<_> = fs::read_dir(manifest_dir) + .ok()? + .flatten() + .filter_map(|entry| entry.file_name().into_string().ok().map(|n| (n, entry.path()))) + .filter(|(name, _)| name.ends_with(&suffix)) + .collect(); + matches.sort_by(|a, b| a.0.cmp(&b.0)); + let (_, path) = matches.last()?; + let content = fs::read_to_string(path).ok()?; + serde_json::from_str::(&content).ok() } fn test_deepseek_cache_probe(platform: &str, host: &str) -> PlatformTest {