Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/incidents.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pipeline still calls it there.
| ap. `ap_closed_pr_keeps_findings` | An admin closed CoderHelm's dependency fix pull request for a repository to start again and cancelled its fix run. On the Security page every checkbox for that repository was off, the header's too, with nothing to say why: 274 findings still read "in a pull request" a day later. The pull request webhook recorded the close on the run and never told the findings, cancelling a run wrote only the run, and the one comparison with GitHub was the last step of the scheduled sweep, behind the time every team's sources and triage left, reading a failed request as "still open". | A finding is `pr_open` only while its pull request is open and `fixing` only while its run works (`common::security_release`). A pull request closed unmerged gives its findings back with who closed it and when, a cancelled or closed run releases what it claimed, a reopened pull request takes its findings back, and a merge fixes them: on the webhook or the person's action, and again on every sweep, first for each team and on a clock of its own, bounded and in turn, so a missed webhook and records stale from before heal within a sweep. A person asking for a fix always gets one; automatic fixes wait a week after a person said no. Retry on the run is a new request from the findings as they are now and opens a new pull request. GitHub not answering is never read as open, closed or merged. |
| ar. `ar_description_stamped_to_the_head` | A dependency run's pull request was described from a head, and the head then moved on without it. A feedback round changed an override in the manifest and the description was rebuilt on that commit, where the lockfile still resolved the old version ("not moved on the head"); the lockfile was regenerated in the commits after it and the run completed. The description still said not moved, still counted the advisory as not fixed, still listed the package under open findings and "the lockfile is out of sync" under Open items, and CoderHelm's own review of the final head left that as a note. The checks step on an open pull request never rebuilt the computed sections, a regenerated lockfile was pushed with nothing after it, a review wrote its findings into the copy of the description it had read when it started (undoing a rebuild made meanwhile), and nits on CoderHelm's own pull request ended the loop. | The description names the head it was built for, and whenever that is not the pull request's head it is rebuilt: after every message in which CoderHelm moved the branch (seen in the one place every request leaves the GitHub client), in the checks and settle step, before a review of its own pull request, in the pull request watch, and at the end of the run, which never completes while the two differ. A review writes on the description as it is now and only for the head it reviewed. An item that says a lockfile is out of sync is checked on the head, never carried. A finding that the description is behind the code is settled by the rebuild, and every finding on CoderHelm's own pull request that is not pure style is its own to act on. |
| at. `at_round_scope` | A feature run opened its draft pull request and the proof check found three gaps. The fix round went to edit the existing file that builds a page's metadata, which the pull request had not touched yet: two edits were "rejected: outside the ticket's files" and a third failed. The guard held every fix round to the files the pull request already changed and gave way after two refusals of one path, so the round started for work the branch had not done was refused the file that work lives in. A planned task stayed not done, planned-work rounds went on for about an hour on a pull request whose checks passed, and one that hit GitHub's hourly limit was read as "it met an error": its work branch was deleted during the limit, an attempt was spent and the next try started five seconds later. | A round may edit what it was started for (`write_guard`): the pull request's files, the plan's task files (done or not) and listed dependents, and the files its gap, finding or failing check names; a check's output names the files that fail, never the ones it only warns about. Any other existing file is refused every time, however often it is tried, with one message that says how to justify the edit (`outside_plan`, one sentence); a justified edit is made and listed on the pull request under "Changed outside the plan's files". A round that ends with an edit refused and no task finished made no progress whatever it pushed: the next round is told what was refused, and a second one stops and names the file once. GitHub's limit inside a round on the pull request is a wait: the round is parked as it stands (its work branch, its attempt) and goes on after the reset. |
| aw. `aw_quarantine_dead_end` | Sixteen end-to-end tests of one team sat in quarantine, some for over three weeks, each with one button (release) and nothing happening. The week's two automatic fixes went to whichever flaky test a default-branch run listed first and only to tests that cost CI time that week, which a quarantined test never does; a test whose fix failed once was never looked at again; a person's "Fix this test" was dropped by the worker as a duplicate of the gateway's own mark, and refused for a quarantined test whose health had gone back to healthy. One test had failed three times and then passed about thirty-five runs in a row on several pull requests; it stayed quarantined under a cause sentence its history had disproved. | A quarantined test always shows where it stands and what happens next (`common::e2e::quarantine`): its fix pull request with its state, the run that is working, or the actions (fix, remove) with the one reason nothing happened by itself. A test that proved healthy (20 clean passes in a row, on more than one pull request or branch, over two hours) leaves by itself with the evidence and its ticket is closed; one that bounces back twice in 30 days is called unstable and needs a quiet week. A cause the runs disprove is marked out of date and worked out again on the next failure. Automatic fixes go to the longest quarantined first, a fix that did not hold is tried again after a week, and the weekly number is said with the day it starts again; a person's request is never counted and never dropped. A removal is a pull request for the team with why it is reasonable: CoderHelm proposes one only when the test was quarantined 30 days, two fixes did not hold and another healthy test covers it, and never merges it. |
| ba. `ba_verdict_on_old_commit` | A run finished as Done with its pull request ready while its own reviewer stood at "Changes requested" on a commit older than the head, and the run page said a person was needed and that merging was the team's call. The last fix was pushed, and the wake-up that found CI green with no event to read completed the run through an ending that skips the review step, so the new head was never reviewed. | Every completion and the sweep look at the finished run's pull request (`pr_watch`): no reviewer verdict on the head asks for the review of that commit, once per head; changes requested on the head get their fix round, and when the run's rounds are over the findings are deferred on the pull request with the reason. The run page names the one true reason the pull request is where it is (`common::merge_standing`) and names a person only for the team's own rule, with where it is set. |
| bb. `bb_flaky_not_broken` | An end-to-end workflow failed on a timeout in a spec the change never touched, as it had on unrelated pull requests that week. The run spent fix rounds editing the spec's timeout and a retry helper. Where the GitHub App may not write Actions, the re-run tried first was refused and the same fix round followed. | Before a CI fix round the failure is judged (`common::flaky_checks`): a failure naming a changed file is the change's; a check with a record of failing and then passing on one commit of other pull requests, naming no changed file, is re-run once and no code changes for it, and the pull request says which check, the evidence and what was done. A refused re-run is said with the permission by name and still changes no code. The record is per repository and learns only from a commit that failed and then passed unchanged. |
| bc. `bc_stays_through_merge_and_deploy` | Pull requests were left as they were after their runs finished: one conflicted after its base moved, one went red a day later on a commit status no event carries, and one merged by a person had its production deploy fail with nothing watching. | A finished run's pull request is looked at on completion and by the sweep: a conflict starts the conflict round once per base commit, red checks not red on the base go to the fix loop once per head, and a merge by anyone gets its merge commit's deploy watched once. A deploy of CoderHelm's own change that fails on checks passing before the merge gets a revert pull request with the failing jobs as evidence, ready for the team's approval and never merged by CoderHelm; files changed again since are never overwritten. |
Expand Down
83 changes: 74 additions & 9 deletions services/common/src/e2e/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//! | Bad run | More than 20% of a job's tests fail together (at least 3), or the job died. Those failures count against the run, not the tests |
//! | Back to healthy | No flip for 7 days or 100 runs |
//! | Fixed | 30 days with no flake after a fix merged |
//! | Out of quarantine | By itself once it has proven healthy (see [`super::quarantine`]); what it did before that no longer counts against it |
//!
//! Broken outranks flaky, and a broken test is never quarantined: it is a real
//! regression, not noise.
Expand Down Expand Up @@ -244,12 +245,16 @@ pub fn decide(r: &TestRecord, now: DateTime<Utc>, default_branch: &str) -> Optio
)
});
}
let recent_flips = flips(&r.history, now - Duration::days(FLIP_WINDOW_DAYS));
let (runs, fails) = main_rate(
&r.history,
default_branch,
now - Duration::days(RATE_WINDOW_DAYS),
);
// A test that left quarantine by proving itself is judged from then on:
// the flips that put it there would otherwise quarantine it again on its
// next run.
let proven = r.care.release.as_ref().and_then(|rel| at(&rel.at));
let since = |days: i64| {
let window = now - Duration::days(days);
proven.map_or(window, |p| p.max(window))
};
let recent_flips = flips(&r.history, since(FLIP_WINDOW_DAYS));
let (runs, fails) = main_rate(&r.history, default_branch, since(RATE_WINDOW_DAYS));
let rate_flaky = runs >= RATE_MIN_RUNS
&& fails > 0
&& prob_rate_above(fails, runs, RATE_THRESHOLD) >= RATE_CONFIDENCE;
Expand Down Expand Up @@ -321,6 +326,10 @@ pub struct Applied {
pub events: Vec<StateEvent>,
pub became_flaky: bool,
pub became_broken: bool,
/// It left quarantine by itself on this run, with the evidence.
pub released: Option<super::model::Release>,
/// Its recorded cause was marked out of date on this run.
pub cause_went_stale: bool,
}

/// Adds a run to a test's history and updates its health and quarantine.
Expand Down Expand Up @@ -377,9 +386,7 @@ pub fn apply_run(
});
}
if out.became_flaky && auto_quarantine && !r.quarantined && !r.never_quarantine {
r.quarantined = true;
r.quarantined_since = Some(now_s.clone());
r.quarantined_by = Some("auto".into());
super::quarantine::enter(r, now, "auto");
out.events.push(StateEvent {
at: now_s,
from: "flaky".into(),
Expand All @@ -388,6 +395,12 @@ pub fn apply_run(
actor: "coderhelm".into(),
});
}
// The record against its own history: a merged fix that failed again, a
// cause the runs disprove, a quarantine it has earned its way out of.
let settled = super::quarantine::settle(r, now);
out.events.extend(settled.events);
out.released = settled.released;
out.cause_went_stale = settled.cause_went_stale;
r.events.extend(out.events.iter().cloned());
if r.events.len() > 100 {
let drop = r.events.len() - 100;
Expand Down Expand Up @@ -437,6 +450,7 @@ mod tests {
fix_branch: None,
fix_phase_at: None,
workflow_path: None,
care: Default::default(),
last_seen: String::new(),
history: vec![],
events: vec![],
Expand Down Expand Up @@ -672,6 +686,57 @@ mod tests {
assert!(!off.quarantined);
}

#[test]
fn a_test_released_by_its_passes_is_not_quarantined_again_by_its_old_flips() {
let mut r = record();
run(&mut r, entry(1, "s1", "main", Outcome::Flaky, 0), 0, true);
run(&mut r, entry(2, "s2", "main", Outcome::Flaky, 0), 0, true);
assert!(r.quarantined);
// Twenty passes on two branches over the next day.
let mut last = Applied::default();
for i in 0..20u32 {
let mut e = entry(
10 + i,
&format!("p{i}"),
if i % 2 == 0 { "main" } else { "feature" },
Outcome::Passed,
1,
);
e.at = (day(1) + Duration::minutes(10 * i as i64)).to_rfc3339();
last = apply_run(
&mut r,
e,
day(1) + Duration::minutes(10 * i as i64 + 5),
"main",
true,
);
}
assert!(last.released.is_some(), "the twentieth pass releases it");
assert!(!r.quarantined);
assert_eq!(r.health, State::Healthy);
assert!(r.events.iter().any(|e| e.from == "quarantined"
&& e.to == "healthy"
&& e.reason
.starts_with("Left quarantine by itself: 20 passes in a row")));
// The next pass, still inside the 14 days of the two flips: it stays
// out, and stays healthy.
let a = run(
&mut r,
entry(40, "p40", "main", Outcome::Passed, 2),
2,
true,
);
assert!(!a.became_flaky);
assert!(!r.quarantined);
// It flakes twice again: quarantined again by the same rule, and
// that is counted as a bounce.
run(&mut r, entry(41, "n1", "main", Outcome::Flaky, 3), 3, true);
let a = run(&mut r, entry(42, "n2", "main", Outcome::Flaky, 3), 3, true);
assert!(a.became_flaky);
assert!(r.quarantined);
assert_eq!(r.care.bounces.len(), 1);
}

#[test]
fn fixed_after_thirty_clean_days_from_the_fix() {
let mut r = record();
Expand Down
3 changes: 3 additions & 0 deletions services/common/src/e2e/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//! - [`detect`] decides healthy, flaky, broken or fixed; pure and tested.
//! - [`coverage`] maps code to the areas tests cover.
//! - [`store`] keeps runs, tests, failure groups and recommendations.
//! - [`quarantine`] decides how a test leaves quarantine: by proving itself,
//! by a fix, or by a pull request that removes it.
//!
//! Fixing a failing or flaky test from a ticket or pull request:
//!
Expand Down Expand Up @@ -43,6 +45,7 @@ pub mod messages;
pub mod model;
pub mod owners;
pub mod parse;
pub mod quarantine;
pub mod report_source;
pub mod signature;
pub mod stats;
Expand Down
Loading
Loading