From 8ef57372c78983328a342c6fe34f9255db0b8898 Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Mon, 30 Nov 2026 20:48:41 -0500 Subject: [PATCH] The proof's repeat count is chosen in one place, and its routes report runs that never reached the page apart proof_routes::repeat_count takes the count measured from the test's failure rate when the run has one, else the review's; Plan::tally gives the runs that passed or failed on the page and the routes that never reached it, which are never failures. This is the seam the evidence-led test fix wires into. --- services/common/src/e2e/proof_routes.rs | 65 +++++++++++++++++++++++++ services/worker/src/passes/pr_watch.rs | 7 ++- services/worker/src/passes/test_fix.rs | 2 +- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/services/common/src/e2e/proof_routes.rs b/services/common/src/e2e/proof_routes.rs index 0251e0c3..fbc47644 100644 --- a/services/common/src/e2e/proof_routes.rs +++ b/services/common/src/e2e/proof_routes.rs @@ -280,6 +280,46 @@ impl Plan { } } +/// Most repeat runs one proof asks for. +pub const MAX_REPEAT: u32 = 300; + +/// How many runs the proof asks for: the count measured from the test's +/// own failure rate when the run has one (`e2e::fix_evidence`'s +/// `repeats_for`, which floors and caps it), else what the review asked +/// (`asked`). The one place the plan's count is chosen, so the measured +/// count and the routes never disagree. +pub fn repeat_count(asked: u32, measured: Option) -> u32 { + measured.unwrap_or(asked).clamp(1, MAX_REPEAT) +} + +/// The plan's runs as counts for the test's evidence: runs that passed or +/// failed on the page, and routes that never reached it (refused by the +/// network, no address, no start script), which are never failures. +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct Tally { + pub passed: u32, + pub failed: u32, + pub not_reached: u32, +} + +impl Plan { + pub fn tally(&self) -> Tally { + let mut t = Tally::default(); + for a in &self.attempts { + match &a.outcome { + Outcome::Passed { runs } => t.passed += runs, + Outcome::Failed { passed, failed, .. } => { + t.passed += passed; + t.failed += failed; + } + Outcome::Unavailable { .. } => t.not_reached += 1, + Outcome::Started { .. } => {} + } + } + t + } +} + /// A sandbox route's output as an outcome: refused by the network or never /// started is the route being unavailable; counts are a result. pub fn outcome_of(output: &str, repeat: u32) -> Outcome { @@ -864,6 +904,31 @@ mod tests { assert!(pre.contains("npm run 'dev'") && pre.contains("127.0.0.1:4000")); } + #[test] + fn the_measured_count_wins_and_routes_that_never_reached_the_page_are_not_failures() { + assert_eq!(repeat_count(20, None), 20); + assert_eq!(repeat_count(20, Some(45)), 45); + assert_eq!(repeat_count(20, Some(5000)), MAX_REPEAT); + let mut p = Plan::new("abc1234def", &[TEST.to_string()], 20); + p.record( + Route::Preview, + outcome_of( + "CODERHELM_EGRESS_BLOCKED pr-7.preview-web.acme-books.example\n 20 failed\n", + 20, + ), + "t", + ); + p.record(Route::Staging, outcome_of(" 20 passed (40s)\n", 20), "t"); + assert_eq!( + p.tally(), + Tally { + passed: 20, + failed: 0, + not_reached: 1 + } + ); + } + #[test] fn the_repeat_asked_is_read_from_the_finding() { assert_eq!( diff --git a/services/worker/src/passes/pr_watch.rs b/services/worker/src/passes/pr_watch.rs index 43daa03c..a018e778 100644 --- a/services/worker/src/passes/pr_watch.rs +++ b/services/worker/src/passes/pr_watch.rs @@ -991,7 +991,12 @@ async fn prove_owed( return Performed::Settled; } let tests = owed_tests(state, c, &items).await; - let repeat = routes::repeat_asked(&items.join(" "), common::e2e::test_package::REPEAT_RUNS); + // The review's count; a count measured from the test's own failure + // rate goes in as `measured` (`routes::repeat_count`). + let repeat = routes::repeat_count( + routes::repeat_asked(&items.join(" "), common::e2e::test_package::REPEAT_RUNS), + None, + ); let target = super::ci_repro::Target { team_id: &c.team_id, run_id: &c.run_id, diff --git a/services/worker/src/passes/test_fix.rs b/services/worker/src/passes/test_fix.rs index 579425d6..bd24c952 100644 --- a/services/worker/src/passes/test_fix.rs +++ b/services/worker/src/passes/test_fix.rs @@ -2919,7 +2919,7 @@ pub async fn ready_gate( head: &sha, }, &tests, - test_package::REPEAT_RUNS, + common::e2e::proof_routes::repeat_count(test_package::REPEAT_RUNS, None), ) .await; repeat_ok = match plan.verdict() {