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
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ jobs:
# review histories replayed through the real decision code, no model.
- run: cargo test --workspace

# Every run failure that reached a person, replayed through the pipeline's
# decision code with fakes only at the edges (docs/incidents.md).
incidents:
name: Incident regressions
runs-on: ubuntu-latest
defaults:
run:
working-directory: services
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
workspaces: services
cache-on-failure: true
- run: cargo test -p worker 'incidents::'

lambda-tests:
name: Lambda (Python)
runs-on: ubuntu-latest
Expand Down
53 changes: 53 additions & 0 deletions docs/incidents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Incident regression suite

Every run failure that reached a person is a case in
`services/worker/src/passes/incidents/`, so it can't come back without a
failing test. CI runs the suite as its own job, **Incident regressions**
(`cargo test -p worker incidents::`), on every pull request.

Each case replays the failure on one invented monorepo:

- `apps/studio`: the CMS studio, its schema, and a `typegen` script. The
script writes `apps/studio/schema.json`, and writes the site's types
through a `../web/...` path.
- `apps/web`: the site.
- `e2e/`: end-to-end specs, with a map of which spec tests which page.

The case runs the pipeline's own decision code. Only the edges are faked:

- GitHub: branches, compares and pull requests, in the shapes GitHub returns.
- The model: recorded judge replies, read by the real parser.
- The sandbox: a real tar.gz archive and a CodeBuild-shaped log, read by the
real `codegen_outcome`.
- DynamoDB: run records as the table holds them.

Each case checks three things: the run's final status, the pull request and
notes the run leaves, and that the old failure message never appears. When a
decision is made inside the pipeline itself, the case also checks that the
pipeline still calls it there.

## Cases

| Case | What happened | The guarantee |
|---|---|---|
| a. `a_whole_branch` | The plan check said 5 of 7 tasks were done. The last step wrote nothing, and the run ended "I ran but produced no file changes". | A step that writes nothing is judged on the whole branch. Work on the branch goes on to the checks and the pull request. With nothing on the branch, the run names the planned tasks that weren't built and never asks generic questions. |
| b. `b_open_pr_retry` | A retry started over on a branch whose earlier run was still fixing CI. | A retry continues the earlier run's open pull request and opens no other. While the earlier run still works on the branch, the retry stops before writing anything and says why. That covers a run that is running, waiting on CI, holding a writer slot, or has a round under way or parked. |
| c. `c_codegen_egress` | The sandbox's network allowlist refused the CMS host. The run blamed the change: "its generated files were not regenerated". | Builds that run a generator may reach the hosts it needs. A host that is still refused is a tooling failure that names the host. |
| d. `d_echoed_markers` | The echoed buildspec holds the upload markers, so every build read as "could not be uploaded". | A marker counts only on a line of its own. The exit code is the last one printed. A failed generator's reason quotes what the generator printed, not the echoed buildspec. |
| e. `e_large_generated_output` | A types file over 5 MB, written through `../`, was dropped silently. The run said "regenerated 1 file(s)" and opened no pull request. | Every changed file is committed, or named as a tooling failure. Paths have one spelling. A generated task its generator settled counts as done in the plan check and the proof check. |
| f. `f_steps` | The generator check ran out of time and the run failed "not enough time left". | A gate that lacks time continues in a fresh step at that gate, as a new queue message. A run that keeps making progress continues past 20 steps. Two steps in a row without progress stop it, and it says where it was stuck. |
| g. `g_large_plan` | A 40-file ticket was capped and narrowed. | A plan holds every file the ticket needs. Nothing caps or narrows it, and every later round is told every task. |
| h. `h_pr_updates` | A PR updated over several runs went stale. Its description was out of date, a ticket comment was posted twice, a question was asked on every update, an e2e test skipped itself when content was missing, and a note said "could not look up" content that was readable. | Each one is caught by its own check. The description is rewritten when a round lands. A notice is posted once per ticket, and so is a question. A spec that skips on missing content fails the checklist. A note that didn't look, when it could have, goes back to the planner. |
| i. `i_finished_work_pr` | A run with one planned task left ended with no pull request. Later the run opened a draft but left the work to a person. | Finished work always ends with a pull request. Planned work that is still open puts a draft PR up with a "Not finished" section. CoderHelm then keeps working those tasks in rounds on the PR and marks it ready when the section is empty. It stops only after two rounds in a row without progress. It then names the tasks and why, and sets the run to `needs_input`, never `completed`. |

## Adding a case

When a fix lands for a new failure:

1. Add `services/worker/src/passes/incidents/<letter>_<name>.rs`. Start it with
what happened and the guarantee, in plain words, with no customer names.
2. Build the scenario on the fixture monorepo (`fixture.rs`). Add any new edge
to the fixture as a fake, never as a mock of the pipeline's own code.
3. Check the final status, what the run leaves, and that the old message never
appears (`Ending::never_says`).
4. Add a row to the table above.
3 changes: 2 additions & 1 deletion lambda/stuck-run-cleanup/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"feedback": "feedback round",
"security_fix": "security fix round",
"conflict_fix": "conflict round",
"planned_work": "planned-work round",
}

_dynamodb = None
Expand Down Expand Up @@ -167,7 +168,7 @@ def round_kind(run, pass_name):
return "ci_fix"
if p == "feedback":
return "feedback"
if p in ("security_fix", "conflict_fix"):
if p in ("security_fix", "conflict_fix", "planned_work"):
return p
return "review_fix"

Expand Down
32 changes: 32 additions & 0 deletions services/common/src/run_round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ pub enum Kind {
/// it: CoderHelm merges the base into its own pull request's branch,
/// once (`await_merge`).
Conflict,
/// Planned work the check before the pull request still found not done
/// after its fix round: the pull request opened as a draft with it
/// listed under "Not finished", and CoderHelm keeps working it in
/// rounds of its own while each round makes progress.
PlannedWork,
}

impl Kind {
Expand All @@ -92,6 +97,7 @@ impl Kind {
Kind::Feedback => "feedback",
Kind::SecurityFix => "security_fix",
Kind::Conflict => "conflict_fix",
Kind::PlannedWork => "planned_work",
}
}

Expand All @@ -102,6 +108,7 @@ impl Kind {
"feedback" => Some(Kind::Feedback),
"security_fix" => Some(Kind::SecurityFix),
"conflict_fix" => Some(Kind::Conflict),
"planned_work" => Some(Kind::PlannedWork),
_ => None,
}
}
Expand All @@ -114,6 +121,7 @@ impl Kind {
"feedback" => Kind::Feedback,
"security_fix" => Kind::SecurityFix,
"conflict_fix" => Kind::Conflict,
"planned_work" => Kind::PlannedWork,
_ => Kind::ReviewFix,
}
}
Expand All @@ -126,6 +134,7 @@ impl Kind {
Kind::Feedback => "feedback round",
Kind::SecurityFix => "security fix round",
Kind::Conflict => "conflict round",
Kind::PlannedWork => "planned-work round",
}
}
}
Expand Down Expand Up @@ -171,6 +180,9 @@ pub struct Round {
/// The branch the round writes its checkpoints to (empty until it
/// starts working).
pub wip_branch: String,
/// Planned-work rounds in a row, before this one, that made no progress
/// (no task finished and nothing pushed). Two stop the work.
pub stalled: u32,
}

/// The branch a round on `pr_branch` keeps its checkpoints on: a branch of
Expand Down Expand Up @@ -227,6 +239,7 @@ impl Round {
feedback: cut(feedback, MAX_FEEDBACK_CHARS),
scoped,
wip_branch: String::new(),
stalled: 0,
}
}

Expand Down Expand Up @@ -267,6 +280,7 @@ impl Round {
("feedback".to_string(), s(&self.feedback)),
("scoped".to_string(), AttributeValue::Bool(self.scoped)),
("wip_branch".to_string(), s(&self.wip_branch)),
("stalled".to_string(), n(self.stalled)),
]))
}

Expand All @@ -291,6 +305,7 @@ impl Round {
.copied()
.unwrap_or(true),
wip_branch: get_s(m, "wip_branch"),
stalled: get_n(m, "stalled"),
})
}

Expand Down Expand Up @@ -678,11 +693,14 @@ mod tests {
assert_eq!(Kind::of_pass("feedback"), Kind::Feedback);
assert_eq!(Kind::of_pass("implement"), Kind::ReviewFix);
assert_eq!(Kind::of_pass("security_fix:1"), Kind::SecurityFix);
assert_eq!(Kind::of_pass("planned_work:2"), Kind::PlannedWork);
for k in [
Kind::CiFix,
Kind::ReviewFix,
Kind::Feedback,
Kind::SecurityFix,
Kind::Conflict,
Kind::PlannedWork,
] {
assert_eq!(Kind::parse(k.as_str()), Some(k));
}
Expand All @@ -702,5 +720,19 @@ mod tests {
assert!(sweep.contains(&format!("ROUND_SWEEP_GRACE_SECONDS = {SWEEP_GRACE_SECS}")));
assert!(sweep.contains(&format!("ROUND_BUDGET_SECONDS = {BUDGET_SECS}")));
assert!(sweep.contains("Pull request open; the last fix round didn't finish"));
for k in [
Kind::CiFix,
Kind::ReviewFix,
Kind::Feedback,
Kind::SecurityFix,
Kind::Conflict,
Kind::PlannedWork,
] {
assert!(
sweep.contains(&format!("\"{}\": \"{}\"", k.as_str(), k.label())),
"the sweep names the {}",
k.label()
);
}
}
}
Loading
Loading