Skip to content
Closed
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/xy_merge_keeps_both_sides_and_parses.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
- Only a hunk both sides changed differently goes to the model, alone with its ancestor, ours and theirs and a few unchanged lines around it. Its reply must be that hunk's lines: prose, markdown fences and conflict markers are stripped where they wrap it and refused inside it, it can't be longer than both sides together, and every identifier either side added must still be there.
- The merged file is checked before anything is committed (`merge3::check_merged`): no conflict markers or prose, a line count within both sides' changes together, both sides' added identifiers present, and it parses for its language as well as the sides do (TypeScript, TSX, JavaScript, Python and Rust by their parsers; JSON, YAML and TOML must parse; other code by the bracket scan).
- A merge that fails is tried once more with smaller hunks. Failing again, nothing is pushed and the branch stays as it was. The failure is CoderHelm's own problem: an internal alert, a line on the run page, and the reason as the stop reason.
- A conflict round on CoderHelm's own pull request that meets a refused merge runs again in a fresh step against the base's newest head, while the base moves between tries and under the round's step ceiling. Out of tries, a person is asked only when both sides changed the same lines with incompatible intent and the model's merge of them was refused on both tries. That is a typed product decision with one question showing the two versions: keep A, keep B, or combine them. Anything else stops as CoderHelm's own problem, and no person is asked to "resolve the conflict".

The case replays it with invented content: a TSX file where the base changed many lines and the branch added two merges mechanically without asking the model, the result that was pushed fails every check, and a model reply of prose plus a rewritten file for a real overlapping hunk pushes nothing.
5 changes: 5 additions & 0 deletions docs/incidents/ya_overview_signals_recorded.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ya. `ya_overview_signals_recorded`

**What happened:** The org overview said "not recorded yet" for eight signals: how long main was red and which pull requests it blocked, how long jobs waited for a runner, what became of CoderHelm's findings, how its runs ended, what they cost, which paths one reviewer covers, which merges touched a sensitive path, and open security alerts with no pull request. The weekly digest and the per-pull-request nudges didn't exist.

**The guarantee:** Each signal is recorded where it happens, for every pull request and repository. Default-branch check runs, statuses and job waits go from the webhook into one record per repository (`pr_ci`), with red episodes and runner waits. Each stored review records its findings and moves earlier ones on (`pr_findings`); only the reviewer finding a concern gone at a later head counts as verified. A pull request's runs end in exactly one of six states with their cost, written when it closes and again nightly (`pr_runs`). Closed pull requests keep their files, for single-reviewer paths and sensitive-path merges against each repository's list (`pr_settings`, defaulting to auth, payments, secrets, infra and migrations). Open Dependabot alerts with no pull request are counted; code scanning says it needs the security events permission. The digest and nudges stay off until a team turns them on; a digest goes only to the team's members or its own channels, and a nudge goes privately to the person whose turn it is, three times a stage at most, then never.
15 changes: 13 additions & 2 deletions docs/pull-requests/api_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,20 @@ On the history row (`History`):
- `bypass`: the rule a merge went past ("merged before the required review", "merged with changes requested", "merged with required checks failing: ...", "merged while the branch's rules blocked it") or null; `merged_by_type` (`person` | `coderhelm` | `bot`), so CoderHelm's own bypasses show.
- `follow_ups[] {repo, number, at, reason}`: suspects, never cause, each with its reason; `reverted_by` is the certain link.
- `category`, `severity`, `flaky_checks[]`, `drift_behind`, `drift_overlap`.
- `run_outcome` (the last run's status) and `stop_reason` (its hand-off code when a person had to act).
- `run_outcome`: one of `first_try`, `after_fixes`, `rerun_only`, `gave_up`, `blocked`, `stopped` (`common::pr_runs::outcome`, from the run's recorded ending), and `stop_reason`, its ending code. Written when the pull request closes and again by the nightly reconcile for a run that ends later.
- `cost_micro_usd`: the pull request's runs' recorded cost together; `files[]` (up to 300), for single-reviewer paths and sensitive-path merges.

Not stored yet (follow-ups): CODEOWNERS file versions and sensitive-path lists (so `non_owner_on_owned` reads only GitHub's review decision today), policy events from the rule-suites API and audit log, Dependabot and code-scanning alerts with KEV and EPSS, default-branch CI episodes, a nightly flaky-check index, review comment counts and comments followed by a change, run cost and findings per pull request, the event feed, and the SLA and working-agreement settings.
## Recorded at the source (`ya_overview_signals_recorded`)
- Default-branch CI `PRMAINCI#owner/repo` (`pr_ci::MainCi`), one per repository, from every `check_run`, `status` and `workflow_job` webhook on the default branch: the current head's checks, red `episodes[] {from, to, sha, checks, fixed_sha}` (newest 500, 400 days) and runner waits `queue[] {at, secs, label}` (`started_at` minus `created_at`, newest 2,000). A pull request is blocked by main when a check failing on it is failing on main now (`pr_ci::blocked_by_main`).
- Findings `PRFINDINGS#owner/repo#000318` (`pr_findings::PrFindings`), written by the reviewer each time it stores a review: each finding's tier (p0 blocking, p1 high, p2 other), when it was raised, acknowledged by a person, followed by a change to its lines, verified fixed (the reviewer found it gone at a later head), or dismissed (answered without a change).
- Settings `PRSETTINGS` (`pr_settings::PrSettings`), `GET`/`PUT /api/prs/settings` (changing needs agent settings): sensitive path patterns per repository (default `**/auth/**`, `**/payments/**`, `**/secrets/**`, `**/infra/**`, `**/migrations/**`), the SLA days, `digest {enabled, channel: slack|teams|email, to[]}` and `nudges {enabled}`, both off by default.
- Security alerts: open Dependabot findings with no pull request, from the security findings CoderHelm already keeps (`SECFINDING#`). Code scanning reads as `needs_permission` until the app holds the security events permission.

## Digest and nudges (`worker::passes::pr_notify`, both opt-in)
- Weekly digest: Monday from 13:00 UTC, once per ISO week (`PRDIGEST#<week>` claim), the overview read through the same `pr_overview_read::read` the page uses. Slack or Teams go to the team's update channels; email only to listed addresses that belong to team members.
- Nudges: a private email to the member whose GitHub login holds the turn, at the stage's p85 (the latest repository snapshot), then two and four working days later, then never again for that stage (`PRNUDGE#owner/repo#000318`); skipped when a person acted in the last working day.

Not stored yet (follow-ups): CODEOWNERS file versions (so `non_owner_on_owned` reads only GitHub's review decision today), policy events from the rule-suites API and audit log, KEV and EPSS beyond what security findings carry, a nightly flaky-check index, and review comment counts.

## Ordering and freshness (since the review of #985)
- `PrRecord.head_repo`: the head branch's repository. Stack links join head and base inside the same repository only, so a fork's branch never stacks the repository's pull requests.
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 @@ -265,6 +265,7 @@ pub mod plan_sync;
/// Every body CoderHelm sends GitHub fits GitHub's limit.
pub mod pr_body;
pub mod pr_body_fit;
pub mod pr_ci;
/// A description checked against the recorded facts, sentence by sentence.
pub mod pr_claims;
/// What is recorded about a pull request at one head, and the lead rendered
Expand All @@ -273,18 +274,23 @@ pub mod pr_conventions;
/// A dependency pull request's facts, from what the pipeline records.
pub mod pr_dependency;
pub mod pr_facts;
pub mod pr_findings;
pub mod pr_history;
/// Where each part of a description goes, and how a reader would judge it.
pub mod pr_layout;
pub mod pr_needs;
pub mod pr_notify;
/// What happened to a PR CoderHelm opened, read from GitHub.
pub mod pr_outcome;
pub mod pr_overview;
pub mod pr_overview_read;
/// The last read of a description before it is saved, verified.
pub mod pr_reader;
pub mod pr_record;
/// The final read of a description before it is posted.
pub mod pr_review;
pub mod pr_runs;
pub mod pr_settings;
/// The work around a pull request that is not in its diff, each step with
/// one owner and one state.
pub mod pr_steps;
Expand Down
Loading