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

**What happened:** A person reading two pull requests on a web app asked whether CoderHelm's approvals and resolved comments could go away after a while, because "it becomes too much". On the first, CoderHelm's "Approved with notes" review from four days earlier still stood in full: the file table, the "Why approved" line, a risk block, an FYI list, Verification, Tests, "Earlier comments" and the rating footer. A person's "Address the review" commit and a second review just as long sat under it. On the second, an inline thread of CoderHelm's from 18 hours earlier was still open: "Blocking (failing check): Lint & Type Check and Deploy Preview are red on this head … I could not read the logs". It was about an older head whose checks had passed since. CoderHelm only cleaned up its earlier reviews when it posted a new one. A push, checks going green, code leaving the diff and a merge all left everything as it was.

**The guarantee:** CoderHelm's own reviews and threads are tidied on a push, when checks finish, on a merge or a close, and on the review sweep. A review body for an older commit than the head becomes one line, for example "✅ Approved `abc1234` (superseded by later commits)". The exception is a request for changes, which still holds the merge and keeps its reasons until the next review. On a merge or a close every body becomes one line and CoderHelm's resolved threads are hidden. A thread about failing checks resolves once the head's checks pass, and so does a thread whose file or lines left the diff (a required-rule thread is not resolved just because its lines moved). CoderHelm's comments in those threads are hidden. A new review keeps only its verdict, its reason and what holds the merge in sight; the overview, file table, risk, FYI, verification, tests and earlier comments go under one collapsed block. A person's review, a thread a person opened and an unanswered reply are never touched, and nothing is posted to announce the cleanup.

**Where it's enforced:** `common::review_supersede` (`tidy`, `settled`, `checks_pass`, `fold`), carried out by `worker::passes::review_tidy` (the `review_tidy` message and the review sweep) and queued by `gateway::routes::github_webhook` (`queue_review_tidy` on `synchronize`, `closed` and `check_suite` `completed`). The body is folded in `review_pr`.
1 change: 1 addition & 0 deletions services/common/contract/worker_messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"lesson": {"type":"lesson","team_id":"TEAM#team-a","installation_id":1,"run_id":"r1","repo_owner":"acme","repo_name":"widgets","pr_number":2,"trigger":"pr_closed"},
"reward_outcome": {"type":"reward_outcome","team_id":"TEAM#team-a","installation_id":1,"run_id":"r1","repo_owner":"acme","repo_name":"widgets","pr_number":2},
"stale_prs_preview": {"type":"stale_prs_preview","team_id":"TEAM#team-a","repo":"acme/widgets"},
"review_tidy": {"type":"review_tidy","team_id":"TEAM#team-a","installation_id":1,"repo_owner":"acme","repo_name":"widgets","pr_number":2,"reason":"push"},
"security_event": {"type":"security_event","team_id":"TEAM#team-a","installation_id":1,"kind":"dependabot_alert","repo":"acme/widgets","action":"created","alert_number":88,"ghsa_id":"GHSA-q9fx-2w5c-8m4r"},
"review_lesson": {"type":"review_lesson","team_id":"TEAM#team-a","installation_id":1,"repo_owner":"acme","repo_name":"widgets","pr_number":2,"trigger":"reply","event_at":1},
"jira_comment": {"type":"jira_comment","team_id":"TEAM#team-a","installation_id":1,"ticket_id":"T-1","title":"t","run_id":"r1","run_status":"completed","pr_number":2,"repo_owner":"acme","repo_name":"widgets","author":"someone","comment":"c","context_hash":"h","action":{"type":"resume","team_id":"TEAM#team-a","run_id":"r1","installation_id":1}},
Expand Down
2 changes: 2 additions & 0 deletions services/common/src/dlq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub const WORKER_MESSAGE_TYPES: &[&str] = &[
"review",
"review_reminder",
"review_sweep",
// CoderHelm's own reviews and threads on one pull request tidied.
"review_tidy",
"stale_prs_preview",
"setup_analyze",
// Security fixes: an alert, an advisory, a push or a check now.
Expand Down
20 changes: 20 additions & 0 deletions services/common/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ pub enum WorkerMessage {
/// review that didn't finish (a service error) for the PR's current head.
#[serde(rename = "review_sweep")]
ReviewSweep,
/// CoderHelm's own reviews and threads on one pull request tidied now
/// (`worker::passes::review_tidy`): sent on a push, on checks finishing
/// and on a merge or a close; the review sweep covers the rest.
#[serde(rename = "review_tidy")]
ReviewTidy(ReviewTidyMessage),
/// Work out one repository's stale pull request plan now, without
/// changing anything (the dashboard's "Preview"). The scheduled cleanup
/// rides on the review-reminder tick.
Expand Down Expand Up @@ -427,6 +432,7 @@ impl WorkerMessage {
| WorkerMessage::ReviewLesson(_)
| WorkerMessage::ReviewReminder
| WorkerMessage::ReviewSweep
| WorkerMessage::ReviewTidy(_)
| WorkerMessage::StalePrsPreview(_) => f::REVIEW,
WorkerMessage::SecurityEvent(_) => f::SECURITY,
WorkerMessage::SkillSync(_) => f::SKILL_SYNC,
Expand Down Expand Up @@ -494,6 +500,7 @@ impl WorkerMessage {
| WorkerMessage::Review(_)
| WorkerMessage::ReviewReminder
| WorkerMessage::ReviewSweep
| WorkerMessage::ReviewTidy(_)
| WorkerMessage::StalePrsPreview(_)
| WorkerMessage::SetupAnalyze(_)
| WorkerMessage::SecurityEvent(_)
Expand Down Expand Up @@ -634,6 +641,19 @@ pub struct SecurityEventMessage {
pub ticket: String,
}

/// One pull request whose CoderHelm reviews and threads are tidied
/// (`crate::review_supersede::tidy`).
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq)]
pub struct ReviewTidyMessage {
pub team_id: String,
pub installation_id: u64,
pub repo_owner: String,
pub repo_name: String,
pub pr_number: u64,
/// What sent it: `push`, `checks`, `merged`, `closed`.
pub reason: String,
}

/// One repository's stale pull request preview (`common::stale_prs`).
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct StalePrsPreviewMessage {
Expand Down
Loading
Loading