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
26 changes: 23 additions & 3 deletions docs/api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4662,7 +4662,7 @@
]
},
"waiting_line": {
"description": "What the run's pull request waits on, in one plain line, and\nwhether it is ready for review: \"Waiting on: an approving review from\na person on #12 (this repo requires one before CoderHelm merges).\nReady for review: checks passed, preview checked.\" Built from\n`merge_standing`, `draft_hold` and `preview`. Null before the run\nhas a pull request.",
"description": "What the run's pull request waits on, in one plain line, and\nwhether it is ready for review: \"Needs 1 approval from a person\n(repo rule) on #12. Ready for review: checks passed, preview\nchecked.\" Built from\n`merge_standing`, `draft_hold` and `preview`. Null before the run\nhas a pull request.",
"examples": [
null
],
Expand Down Expand Up @@ -5189,6 +5189,13 @@
],
"type": "string"
},
"needs_person": {
"description": "A person must act: a reason only a person has (a typed hand-off).\nFalse for every hold CoderHelm settles itself.",
"examples": [
true
],
"type": "boolean"
},
"pr_number": {
"description": "The pull request.",
"examples": [
Expand Down Expand Up @@ -5227,7 +5234,8 @@
"kind",
"summary",
"reasons",
"pr_number"
"pr_number",
"needs_person"
],
"type": "object"
},
Expand Down Expand Up @@ -5286,8 +5294,20 @@
"RunMergeStanding": {
"description": "Where a run's pull request stands on its way to merge.",
"properties": {
"approvals": {
"description": "Approving reviews from people the repository's rule requires\n(`needs_person_approval`, `repo_requires_person_review`). Null when\nnot known.",
"examples": [
1
],
"format": "int32",
"minimum": 0,
"type": [
"integer",
"null"
]
},
"code": {
"description": "Stable code: `merged`, `closed`, `reviewing`, `fixing_review`,\n`review_changes_requested`, `checks_running`, `checks_failing`,\n`conflict`, `draft`, `auto_merge_off`, `needs_person_approval`,\n`repo_requires_person_review` or `merging`.",
"description": "Stable code: `merged`, `closed`, `reviewing`, `fixing_review`,\n`review_changes_requested`, `checks_running`, `checks_failing`,\n`conflict`, `draft`, `auto_merge_off`, `needs_person_approval`,\n`repo_requires_person_review`, `building_plan`, `plan_needs_access`\nor `merging`.",
"examples": [
"auto_merge_off"
],
Expand Down
12 changes: 12 additions & 0 deletions docs/incidents/xj_plan_builds_every_repo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# xj. `xj_plan_builds_every_repo`

**What happened:** A ticket's plan spanned two repositories: an infrastructure repository (the module for a scheduled function) and an API repository (the function's code, its tests, a migration and its deploy workflow). The run opened a pull request in the infrastructure repository only, and its function was a placeholder file. The API repository's plan check said the plan was unfinished, and the multi-repository loop read that as "this repository failed" and moved on, so the run went on with one pull request and most of the API tasks still to do. CoderHelm's own review then asked for changes on the infrastructure pull request: an acceptance line the change doesn't deliver. The fix round worked for hours on a branch where that fix could not live, listed the findings as deferred, and the run ended "Done". Its page said "Waiting on: a person, CoderHelm's review asks for changes it could not make" next to "Nothing needed from you", and the review's additional findings showed an empty place: "💬 `` — An acceptance line…".

**The invariants, enforced in code:**

1. **A run never ends while its own plan has undone tasks in a repository it can write to.** The run keeps its plan repository by repository (`common::plan_repos`) and the count it still owes (`plan_owed`). Every done or waiting ending goes through the one ending gate (`common::run_ending`), which writes it only under `PLAN_GATE`: the count is 0. A source scan fails when a new ending path is written outside that gate. The multi-repository loop keeps an unfinished repository as owed and takes a fresh step for it, and the plan sweep (`plan_continue::sweep`, on deploy and every 15 minutes) picks up runs that still owe one, including runs from before the record kept the plan.
2. **A pull request is never offered for review while it ships a placeholder in place of what its ticket needs, or while another part of the plan is unbuilt.** `common::stub_check` reads the diff for placeholder files, empty handlers, "not implemented" errors and TODOs where the implementation goes. The ready decision (`ready::offer_blocked`) waits on them, the coder replaces them in a round of its own, and the one call that marks a pull request ready checks again right before GitHub is asked. The parts of a plan are linked: each pull request names itself "part 1 of 2" or "part 2 of 2" and the order they merge in.
3. **"Deferred" is only for a typed person-only reason.** A finding whose fix the run's own plan or routes can make is never deferred: the rest of the plan is built first (`plan_continue::continue_if_owed`, before any fix round or deferral), and only a reason that types as `PersonOnly` defers (`own_review_ledger::typed_settle`). CoderHelm's own limits are an internal alert and a typed stop that names what its review still asks for. They are never "Done", never deferred and never a person's wait.
4. **Every "waiting on a person" goes through #930's `PersonOnly`.** The merge standing (`Standing::person_only`), the draft hold (`DraftHold::person_only`) and the run page's line (`waiting_line`) name a person only through it. The page's "Needs a person" badge and its top line are read from that one state, so they can't disagree. When the only wait left is the repository's required approval, the line says exactly "Needs 1 approval from a person (repo rule)" with the pull request. A source scan fails when a new text claims a person is needed without the type.

The empty place in a finding is gone. A finding on no file is listed by its title, and the text guard (`rendered::person_text`) fails on an empty code span or an empty name.
17 changes: 16 additions & 1 deletion services/common/src/draft_hold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,22 @@ impl DraftHold {
/// anything else, and GitHub refusing to mark it ready, are CoderHelm's
/// to finish.
pub fn needs_person(&self) -> bool {
self.kind == Kind::Held && self.reasons.iter().any(|r| r.human_only().is_some())
self.person_only().is_some()
}

/// The typed hand-off a held pull request waits on
/// (`person_only::PersonOnly`, #930's one type for a person's to-do):
/// a reason on the human-only list whose words name nothing CoderHelm
/// owns. `None` for every other hold: it is CoderHelm's to finish.
pub fn person_only(&self) -> Option<crate::person_only::PersonOnly> {
if self.kind != Kind::Held {
return None;
}
self.reasons.iter().find_map(|r| {
let why = r.human_only()?;
let need = format!("{} {}", r.what, r.todo);
crate::person_only::of_human_only(why, need.trim()).ok()
})
}

fn pr_words(&self) -> String {
Expand Down
6 changes: 6 additions & 0 deletions services/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ pub mod paged;
pub mod placeholders;
/// Which waiting plan tasks a merged run releases.
pub mod plan_dependents;
/// A run's plan, repository by repository: what each part built and what
/// the run still owes before it finishes.
pub mod plan_repos;
pub mod plan_state;
pub mod plan_sync;
/// Every body CoderHelm sends GitHub fits GitHub's limit.
Expand Down Expand Up @@ -282,6 +285,9 @@ pub mod run_prs;
/// Scope decided once at plan time, held in every round and in the
/// description.
pub mod scope_ledger;
/// A pull request never ships a placeholder in place of what its ticket
/// asks for: the diff check before it is offered for review.
pub mod stub_check;
pub mod waiting_line;
// review_stats: time-ordered review records for analytics
/// A run waiting for another ticket's change to merge, and what it does
Expand Down
Loading