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
5 changes: 5 additions & 0 deletions docs/incidents/xx_waits_never_outlive_their_event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# xx. `xx_waits_never_outlive_their_event`

**What happened:** Two waits went on after what they waited for had happened. A run stopped because the change it built on closed without merging was told that reopening the change takes it back to waiting by itself. The change was reopened, and the run kept waiting on a person until the 15-minute sweep: the reopen webhook went on to the review triggers and returned, and the check a pull request event sent read only the runs still waiting for a merge, not the runs that change's close had stopped. On an alert route that waits out a quiet window before posting the recovery, the run waiting on a person for that alert stayed waiting after the recovery posted. Only a recovery posted at once closed it; the later post, made by the worker's episode check, never reached the run.

**The guarantee:** A pull request closed or reopened sends the team's change check before any return a reopen reaches, and the check names that change. It reads the runs still waiting for a merge and the runs stopped by that change's close, so a reopen takes the stopped run back to waiting at once and a merge sends it on. The 15-minute sweep stays the backstop for every team. A recovery closes its waiting run through one path, `common::run_wake::alert_cleared`, whether it posts at once (the gateway's `alert_delivery`) or after the quiet window (the worker's episode check).
5 changes: 5 additions & 0 deletions docs/incidents/xz_org_overview_facts_only.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# xz. `xz_org_overview_facts_only`

**What happened:** A leader opened the pull requests page to understand the state of the org's pull requests and found only a list: nothing said what was stuck, on whom, or whether that was usual for the org. The overview above the list answers that, and it is the one place a page could rank people, print a number nothing computed, or mix two teams' pull requests.

**The guarantee:** `GET /api/prs/overview` (`common::pr_overview::build`) covers every pull request in the team's repositories, people's, CoderHelm's and other bots', and returns computed facts only. No per-person ranking, count or duration is ever returned; a GitHub login appears only as the owner of one item under "Needs attention". Every number in the summary is the value of a fact in `facts`, and the words between them carry no numbers of their own. Thresholds are percentiles of the scope's own history (a repo's own from 30 merges in 90 days, else the org's), no rate is shown on fewer than 10 events, and what CoderHelm doesn't store yet is `null` and named in `missing`, never estimated. The Stale tile and the Stale panel's headline are one number. An org with no CoderHelm pull requests gets the whole overview. Every read is keyed by the session's team, and the short cache by the installation, the team and the scope, listed in `bm_teams_never_cross`.
34 changes: 34 additions & 0 deletions services/common/src/change_wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,20 @@ pub fn waits_on_close(action: &str) -> bool {
a.starts_with("Reopen ") && a.contains(CLOSED_ASK)
}

/// Whether the pull request `pr` of `repo` that moved (a merge, a close, a
/// reopen as GitHub reports it) is the change `dep` waits on. An empty repo
/// or no number (the sweep) reads every dependency.
pub fn moved_is(dep: &Dependency, repo: &str, pr: u64) -> bool {
repo.is_empty() || pr == 0 || (dep.pr == pr && dep.repo.eq_ignore_ascii_case(repo))
}

/// Whether a pull request event `action` asks the team's waiting runs to
/// read their change again: a close (merged or not) settles a wait, and a
/// reopen takes a run stopped by that close back to waiting at once.
pub fn event_moves_change(action: &str) -> bool {
matches!(action, "closed" | "reopened")
}

/// The reason a run stops when its dependency closed without merging.
pub fn closed_reason(dep: &Dependency) -> String {
format!(
Expand Down Expand Up @@ -328,6 +342,26 @@ mod after_close_tests {
assert_eq!(crate::rendered::person_text(&a), None, "{a}");
}

#[test]
fn a_reopen_or_close_reaches_only_the_runs_of_that_change() {
assert!(event_moves_change("reopened"));
assert!(event_moves_change("closed"));
for other in ["opened", "synchronize", "edited", "labeled", ""] {
assert!(!event_moves_change(other), "{other}");
}
let dep = Dependency {
ticket: "WEB-7".into(),
repo: "acme/bookstore-web".into(),
pr: 12,
..Default::default()
};
assert!(moved_is(&dep, "Acme/Bookstore-Web", 12));
assert!(!moved_is(&dep, "acme/bookstore-web", 13));
assert!(!moved_is(&dep, "acme/other", 12));
// The sweep names no change: every dependency is read.
assert!(moved_is(&dep, "", 0));
}

#[test]
fn only_the_closed_change_stop_is_read_as_its_change_closing() {
let dep = Dependency {
Expand Down
1 change: 1 addition & 0 deletions services/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ pub mod pr_layout;
pub mod pr_needs;
/// What happened to a PR CoderHelm opened, read from GitHub.
pub mod pr_outcome;
pub mod pr_overview;
/// The last read of a description before it is saved, verified.
pub mod pr_reader;
pub mod pr_record;
Expand Down
14 changes: 11 additions & 3 deletions services/common/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,11 @@ pub enum WorkerMessage {
/// sends one too).
#[serde(rename = "role_reads_wait")]
RoleReadsWait(RoleReadsWaitMessage),
/// A pull request of the team merged or closed: its runs waiting for
/// another change (`awaiting_change`, `crate::change_wait`) read their
/// dependency again (the self-heal sweep checks every 15 minutes too).
/// A pull request of the team merged, closed or reopened: its runs
/// waiting for another change (`awaiting_change`, `crate::change_wait`)
/// read their dependency again, and a run stopped because that change
/// closed waits for it again (the self-heal sweep checks every 15
/// minutes too).
#[serde(rename = "change_wait_check")]
ChangeWaitCheck(ChangeWaitCheckMessage),
/// Read a team's open pull requests into their records
Expand Down Expand Up @@ -965,6 +967,12 @@ pub struct PrRecordsSyncMessage {
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq)]
pub struct ChangeWaitCheckMessage {
pub team_id: String,
/// `owner/repo` of the pull request that moved (empty: any).
#[serde(default, skip_serializing_if = "String::is_empty")]
pub repo: String,
/// The pull request that moved (0: any).
#[serde(default)]
pub pr: u64,
}

/// Re-check the role of a run waiting for the install's "AWS role reads"
Expand Down
Loading