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 @@ -57,6 +57,7 @@ pipeline still calls it there.
| z. `z_run_facts` | A run's plan check found 3 of 3 tasks done; a later fix round wrote 1 file and its task tracker, built from the plan's unchecked copy, saved 1 of 3 over the plan check's checklist. The same runs showed no changed files: `files_modified` was written only by a completion step nothing called. | A round's coder starts from the checklist as saved and only adds ticks; only the plan check unchecks a task. `files_modified` is the branch's work against its base, without the plan files, written when the pull request opens and after every round that records the run's status, capped at 500 paths. |
| aa. `aa_promised_round` | A ticket run's own review requested changes. The run took review fix rounds until its automatic fix budget was spent, handed its pull request over with two of its own review's findings still listed, and finished. The draft was then held every hour for three days on "CoderHelm fixes them in its review rounds", and no round ever ran after the run was done. | A hold never promises CoderHelm work that isn't queued. A finished run's draft held on its own review's findings queues one review fix round for them, once per head, while the run has rounds left (its own review rounds, its automatic fix pushes and its fix cycles), and waits for it ("CoderHelm is fixing N findings from its review"), a wait bounded like every other. With no round left, after the run stopped its rounds itself, or once a round ran on the head and the findings are still there, the hold names what a person does and promises nothing. The security and planned work holds name a person's action too, since nothing runs those again once the run is over. A review of a finished run's pull request leaves its findings to that decision, so they are never fixed twice or outside the run's budget. |
| ab. `ab_label_prefix` | A failing-test fix's staging deploy and staging end-to-end checks were skipped on its draft. The reading of why went through the staging workflow line by line and kept every quoted string next to a label test as a label name, so a prefix test (`startsWith(github.event.label.name, 'E2E:')`) became a label named `E2E:`, and a condition that needs the staging label *and* `CI:E2E` read as either one. The staging label was refused, the team's `E2E:*` family let the bare `E2E:` through, and CoderHelm added `CI:E2E` and `E2E:`. Adding a missing label creates it, so the repository got an `E2E:` label that matches no area, and `CI:E2E` alone could never run the job. | A job's `if:` is read as an expression (multi-line blocks included) into the label combinations that run it, with those of the jobs it needs. A prefix or substring test is a pattern, never a label: CoderHelm adds only an existing repository label that satisfies it, the one the team's settings name when several do, and nothing when that isn't one certain label; a family allows `E2E:nav`, never `E2E:`. A label is added only when it alone runs the check, the settings allow it, it isn't a deploy, staging or production label and none is on the pull request; otherwise the hold names the exact real label for a person to add. Labels the old reading added that were a bare prefix or couldn't run their check alone come off when CoderHelm itself put them on, and a bare-prefix repository label GitHub made for that add is deleted when nothing else carries it. |
| ac. `ac_partial_and_red_ci` | A Jira run stopped after two steps that changed nothing (the coder twice said the last planned file needed no change, in words the plan check did not know) and a separate salvage path opened "⚠️ Partial", "Closes #0", "ran out of time" and marked it completed; another run's CI fix changed nothing and the run was completed with its pull request marked ready while every check was red. | One path opens a stopped run's pull request (`stop_pr`: ticket line, Not finished with done and left tasks and the recorded reason); no body names issue `#0` (client guard); a planned file the coder says needs no change settles and stays settled across steps; a step after a stalled one takes one task with a different approach; a CI fix that changes nothing tries again with fresh evidence (reporter comments, annotations, rerun on infrastructure failures), then holds the draft with what fails and the run needs a person; `ready::decide` never marks a pull request ready with a failing or running check; a source scan allows `create_pull_request` and `mark_pr_ready` only in their one place each. |

## Adding a case

Expand Down
66 changes: 66 additions & 0 deletions services/gateway/src/routes/analytics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,47 @@ pub fn ci_outcomes(runs: &[&RunRow]) -> Value {
"running": c("running"),
},
"gave_up_reasons": gave_up_reasons,
// Runs that ended wrong (should be zero): see [`ended_wrong`].
"ended_wrong": ended_wrong(runs),
})
}

/// Runs that ended in a state CoderHelm must never leave, counted so a
/// regression shows the day it happens: `completed` with this change's CI
/// still red, and `completed` after a stop mid-work (the old "partial"
/// salvage). Both must be zero; each lists its newest runs.
pub fn ended_wrong(runs: &[&RunRow]) -> Value {
let done = |r: &RunRow| matches!(r.status.as_str(), "completed" | "success");
let completed_red: Vec<&RunRow> = runs
.iter()
.copied()
.filter(|r| done(r) && r.ci_went_red() && matches!(r.ci_end_state(), CiEnd::GaveUp(_)))
.collect();
let completed_stopped: Vec<&RunRow> = runs
.iter()
.copied()
.filter(|r| {
done(r)
&& (r.error_message.starts_with("Stopped:")
|| r.error_message.starts_with("Partial implementation"))
})
.collect();
let newest = |v: &[&RunRow]| -> Vec<String> {
let mut ids: Vec<(&str, &str)> = v
.iter()
.map(|r| (r.created_at.as_str(), r.run_id.as_str()))
.collect();
ids.sort_by(|a, b| b.0.cmp(a.0));
ids.into_iter()
.take(5)
.map(|(_, id)| id.to_string())
.collect()
};
json!({
"completed_with_red_ci": completed_red.len(),
"completed_red_runs": newest(&completed_red),
"completed_after_stop": completed_stopped.len(),
"completed_after_stop_runs": newest(&completed_stopped),
})
}

Expand Down Expand Up @@ -3444,6 +3485,10 @@ mod tests {
];
let refs: Vec<&RunRow> = runs.iter().collect();
let ci = ci_outcomes(&refs);
// The two that gave up were left "completed" with red CI: counted
// as runs that ended wrong.
assert_eq!(ci["ended_wrong"]["completed_with_red_ci"], 2);
assert_eq!(ci["ended_wrong"]["completed_after_stop"], 0);
assert_eq!(ci["runs_with_red_ci"], 6);
assert_eq!(ci["red_on_base_runs"], 1);
let o = &ci["outcomes"];
Expand Down Expand Up @@ -3890,4 +3935,25 @@ mod tests {
.to_string();
assert!(lo < inside && inside < hi);
}

/// The salvaged run: completed after a stop mid-work. A run that needs a
/// person instead isn't counted.
#[test]
fn a_run_completed_after_a_stop_is_counted_as_ended_wrong() {
let runs = [
RunRow {
error_message: "Partial implementation — agent timed out".into(),
..run("1", 2, "completed")
},
RunRow {
error_message: "Stopped: steps 2 and 3 made no progress.".into(),
..run("2", 2, "needs_input")
},
];
let refs: Vec<&RunRow> = runs.iter().collect();
let w = ended_wrong(&refs);
assert_eq!(w["completed_after_stop"], 1);
assert_eq!(w["completed_after_stop_runs"][0], "1");
assert_eq!(w["completed_with_red_ci"], 0);
}
}
3 changes: 3 additions & 0 deletions services/worker/src/clients/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3252,6 +3252,8 @@ impl GitHubClient {
draft: bool,
) -> Result<serde_json::Value, Box<dyn std::error::Error + Send + Sync>> {
let url = format!("{API_BASE}/repos/{owner}/{repo}/pulls");
// No body reaches GitHub naming issue #0 (`passes::outcome`).
let body = crate::passes::outcome::guard_body(body);
self.post(
&url,
&serde_json::json!({
Expand Down Expand Up @@ -4316,6 +4318,7 @@ impl GitHubClient {
body: &str,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let url = format!("{API_BASE}/repos/{owner}/{repo}/pulls/{pr_number}");
let body = crate::passes::outcome::guard_body(body);
self.patch(&url, &serde_json::json!({"body": body})).await?;
Ok(())
}
Expand Down
Loading
Loading