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 @@ -75,6 +75,7 @@ pipeline still calls it there.
| as. `as_infra_closed_pr_keeps_record` | The same gap as `ap` in the other store. An infrastructure finding keeps its own record and nothing released it: after a person closed its fix pull request the record stayed `pr_open`, so the Infrastructure tab kept the closed pull request and never offered "Open fix PR" again; a cancelled or failed fix run left the record `fixing` for good; a reopened pull request was never noticed. | Infrastructure records go through the same reconciliation as dependency findings (one `reconcile` over `common::security_release::Claim`, not a copy): the same reads of GitHub and the run records, events, sweep bounds, person-closed record, holds and Retry. What is this store's own stays: a merge never closes a finding (only a read of the account does), a pull request the replacement guard made a draft is not closed and is left as it is, a finding on its runbook stays there until its code or target changes, a pull request is recorded only after the guard read it, and a fix round that ends without settling its pull request becomes the guard's second step (a draft), never a ready pull request. |
| at. `at_round_scope` | A feature run opened its draft pull request and the proof check found three gaps. The fix round went to edit the existing file that builds a page's metadata, which the pull request had not touched yet: two edits were "rejected: outside the ticket's files" and a third failed. The guard held every fix round to the files the pull request already changed and gave way after two refusals of one path, so the round started for work the branch had not done was refused the file that work lives in. A planned task stayed not done, planned-work rounds went on for about an hour on a pull request whose checks passed, and one that hit GitHub's hourly limit was read as "it met an error": its work branch was deleted during the limit, an attempt was spent and the next try started five seconds later. | A round may edit what it was started for (`write_guard`): the pull request's files, the plan's task files (done or not) and listed dependents, and the files its gap, finding or failing check names; a check's output names the files that fail, never the ones it only warns about. Any other existing file is refused every time, however often it is tried, with one message that says how to justify the edit (`outside_plan`, one sentence); a justified edit is made and listed on the pull request under "Changed outside the plan's files". A round that ends with an edit refused and no task finished made no progress whatever it pushed: the next round is told what was refused, and a second one stops and names the file once. GitHub's limit inside a round on the pull request is a wait: the round is parked as it stands (its work branch, its attempt) and goes on after the reset. |
| au. `au_upgrade_decided_and_proven` | An outside reviewer checked a dependency security pull request of about fifty packages, four across a major version. The code was sound and the account of it was not: its count of advisories left was CoderHelm's own and disagreed with the package manager's production audit of the same head; one package of a framework was raised while its siblings from the same source repository stayed behind; no type check was recorded, because the repository's CI has none and CoderHelm's checks mirrored CI; it said "contract unchanged" although a validation library's major changed the 400 error bodies of an endpoint; and each override across a major lacked why it is safe. | A dependency update is decided and proven by the pipeline (`common::upgrade_quality`). Packages released together are found from the registry's source repository and the base branch's lockfile, move as one bump, and a lockfile that splits them fails the set like any check. The set a dependency change is verified with (frozen install with the manifest's package manager version and the deployment image's, type check when the project is typed, build, lint, tests, production audit) is found in the project whatever CI runs, budgeted to the sandbox's time, compared with the base branch, and recorded against the head; the settle stage cites the record, so "check not run" never stays open for a check of the set. Advisories are counted once: the base branch and the head read the same way and laid beside the package manager's audit, each disagreement with its cause, each remaining advisory with its package, whether the change touches it and why it stays. Each major carries its dependency paths, where they run, whether the repository uses it, the reachability verdict with its limit, and how it is fixed (a parent release that declares the fixed range before an override). A major the repository calls is probed through its call sites on the base branch's build and the head's; a changed answer is a known behaviour change, and a sentence that calls the contract or the behaviour unchanged without a probe that shows it is taken out. The record is of one commit, and a head that has moved since is said to have. |
| av. `av_description_from_facts` | An outside reviewer found a dependency security pull request's code sound and its description wrong in five places (a package row "not moved on the head" that the lockfile resolves at the patched version, an open item saying the lockfile was out of sync when a frozen install passes, a fixed advisory listed as not fixed, a wrong count of high advisories left, the package still listed as open). The title read `fix(deps): ...` where every merged pull request reads a ticket key and a summary, commits carried the prefix `KEY-1:` (a sample key CoderHelm had learned from its own description), a sentence said "contract unchanged" with nothing behind it, no major version jump said why it was safe, and CoderHelm's own review thread about the description stayed open. A second pull request, a three-file feature, carried a page about its outside steps that nobody could act on: a raw 403 with its JSON body twice, "needs access" beside "owner: CoderHelm", "after the pull request opens" long after it had opened, and found facts and a query already run listed as items with owners. | A description is a view of the facts recorded for its head. Every sentence a person or a model wrote is held against them on every rebuild of every kind of run, and one they do not bear out is rewritten from them or removed; what a model writes is checked before it is saved. What a reader sees first is rendered from the facts (the change, how to check it, the risk, what they have to do or that nothing is needed, anything out of the ordinary with its evidence) within a budget; everything else is collapsed. A step outside the code has one owner and one state, generated every build; a check CoderHelm can make is made and reported as a result; a raw error is said as a cause with what lifts it. Titles and commits follow the form detected in the repository with a real key or none. A lesson that holds a placeholder is refused when learned and removed when found. A rebuild resolves CoderHelm's own thread that said the description was behind. The quality eval (`description_eval`) keeps both pull requests as cases. |
| aw. `aw_quarantine_dead_end` | Sixteen end-to-end tests of one team sat in quarantine, some for over three weeks, each with one button (release) and nothing happening. The week's two automatic fixes went to whichever flaky test a default-branch run listed first and only to tests that cost CI time that week, which a quarantined test never does; a test whose fix failed once was never looked at again; a person's "Fix this test" was dropped by the worker as a duplicate of the gateway's own mark, and refused for a quarantined test whose health had gone back to healthy. One test had failed three times and then passed about thirty-five runs in a row on several pull requests; it stayed quarantined under a cause sentence its history had disproved. | A quarantined test always shows where it stands and what happens next (`common::e2e::quarantine`): its fix pull request with its state, the run that is working, or the actions (fix, remove) with the one reason nothing happened by itself. A test that proved healthy (20 clean passes in a row, on more than one pull request or branch, over two hours) leaves by itself with the evidence and its ticket is closed; one that bounces back twice in 30 days is called unstable and needs a quiet week. A cause the runs disprove is marked out of date and worked out again on the next failure. Automatic fixes go to the longest quarantined first, a fix that did not hold is tried again after a week, and the weekly number is said with the day it starts again; a person's request is never counted and never dropped. A removal is a pull request for the team with why it is reasonable: CoderHelm proposes one only when the test was quarantined 30 days, two fixes did not hold and another healthy test covers it, and never merges it. |
| ax. `ax_github_budget` | An installation used up GitHub's hourly request budget: sweeps on timers spent it beside the runs. A review fix round that had worked for two hours met the limit, the next step logged `Resume failed: RateLimited`, the run read "the last fix round didn't finish" and its review's findings were deferred to a person; three sweeps failed on the same limit, one warning per item. | A rate limit is a wait, everywhere: the resume is sent for the reset as the same run and round (no attempt spent, nothing unfinished, nothing deferred) and the run page says "Waiting for GitHub's hourly limit; continues by itself at <time>". Once the limit is met nothing is sent until the reset. Every request is counted by caller; sweeps spend only above the share kept for runs and within their own hourly caps, and say a skip once. A round a limit ended is run again by the sweep once the budget allows. |
| ba. `ba_verdict_on_old_commit` | A run finished as Done with its pull request ready while its own reviewer stood at "Changes requested" on a commit older than the head, and the run page said a person was needed and that merging was the team's call. The last fix was pushed, and the wake-up that found CI green with no event to read completed the run through an ending that skips the review step, so the new head was never reviewed. | Every completion and the sweep look at the finished run's pull request (`pr_watch`): no reviewer verdict on the head asks for the review of that commit, once per head; changes requested on the head get their fix round, and when the run's rounds are over the findings are deferred on the pull request with the reason. The run page names the one true reason the pull request is where it is (`common::merge_standing`) and names a person only for the team's own rule, with where it is set. |
Expand Down
17 changes: 17 additions & 0 deletions services/common/src/git_conventions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,23 @@ fn stand_in_number(number: &str) -> bool {
number.chars().all(|c| c == '0') || counting || number.chars().all(|c| c == '9')
}

/// Whether a key-shaped token (`KEY-1`, `ABC-XXXX`, `OPS-0000`) is an
/// example rather than a ticket: a stand-in project or a stand-in number.
pub fn is_stand_in_key(key: &str) -> bool {
let Some((project, number)) = key.split_once('-') else {
return false;
};
stand_in_number(number)
|| STAND_IN_PROJECTS
.iter()
.any(|p| project.eq_ignore_ascii_case(p))
}

/// Whether a word in braces or angle brackets stands for the ticket.
pub fn is_stand_in_word(word: &str) -> bool {
STAND_IN_WORDS.iter().any(|w| word.eq_ignore_ascii_case(w))
}

/// The key (or stand-in) a commit subject starts with, if any. `run_key` is
/// the run's real key: an exact match is never a stand-in.
fn lead(subject: &str, run_key: Option<&str>) -> Option<Lead> {
Expand Down
50 changes: 49 additions & 1 deletion services/common/src/github_grants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ pub fn record(installation: u64, permissions: &Value) {
.collect();
with(|all| {
let k = all.entry(installation).or_default();
k.refused.retain(|p| !map.contains_key(p));
k.refused.retain(|p| match p.split_once(":write") {
Some((name, _)) => !map
.get(name)
.is_some_and(|l| matches!(l.as_str(), "write" | "admin")),
None => !map.contains_key(p),
});
k.token = Some(map);
});
}
Expand All @@ -73,6 +78,32 @@ pub fn grant(installation: u64, permission: &str) -> Grant {
})
}

/// Whether `installation` may write with `permission` (start a workflow
/// needs `actions: write`; reading its runs only `read`).
pub fn write_grant(installation: u64, permission: &str) -> Grant {
with(|all| {
let Some(k) = all.get(&installation) else {
return Grant::Unknown;
};
if k.refused.contains(&format!("{permission}:write")) {
return Grant::Missing;
}
match &k.token {
Some(t) => match t.get(permission).map(String::as_str) {
Some("write" | "admin") => Grant::Granted,
_ => Grant::Missing,
},
None => Grant::Unknown,
}
})
}

/// Remembers that GitHub refused a write with `permission`. True the first
/// time, so the caller says it once.
pub fn refused_write(installation: u64, permission: &str) -> bool {
refused(installation, &format!("{permission}:write"))
}

/// True when the installation is known to lack the permission: the read is
/// skipped.
pub fn lacks(installation: u64, permission: &str) -> bool {
Expand Down Expand Up @@ -132,6 +163,23 @@ mod tests {
use super::*;
use serde_json::json;

#[test]
fn a_write_is_known_before_it_is_tried() {
let i = 990_001;
assert_eq!(write_grant(i, "actions"), Grant::Unknown);
record(i, &json!({"actions": "read", "contents": "write"}));
assert_eq!(grant(i, "actions"), Grant::Granted);
assert_eq!(write_grant(i, "actions"), Grant::Missing);
assert_eq!(write_grant(i, "contents"), Grant::Granted);
// A refusal is remembered once, and a newer token clears it.
let j = 990_002;
assert!(refused_write(j, "actions"));
assert!(!refused_write(j, "actions"));
assert_eq!(write_grant(j, "actions"), Grant::Missing);
record(j, &json!({"actions": "write"}));
assert_eq!(write_grant(j, "actions"), Grant::Granted);
}

#[test]
fn unknown_until_a_token_or_a_refusal_says() {
assert_eq!(grant(9_000_001, "statuses"), Grant::Unknown);
Expand Down
17 changes: 17 additions & 0 deletions services/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,27 @@ mod model_call_sites;
pub mod own_pr;
/// Paginated DynamoDB lookups (follow LastEvaluatedKey to a match).
pub mod paged;
/// Placeholder tokens: never learned, never written into a commit or title.
pub mod placeholders;
/// Every body CoderHelm sends GitHub fits GitHub's limit.
pub mod pr_body_fit;
/// 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
/// from it.
pub mod pr_conventions;
/// A dependency pull request's facts, from what the pipeline records.
pub mod pr_dependency;
pub mod pr_facts;
/// Where each part of a description goes, and how a reader would judge it.
pub mod pr_layout;
/// What happened to a PR Coderhelm opened, read from GitHub.
pub mod pr_outcome;
/// The last read of a description before it is saved, verified.
pub mod pr_reader;
/// The work around a pull request that is not in its diff, each step with
/// one owner and one state.
pub mod pr_steps;
pub mod run_prs;
// review_stats: time-ordered review records for analytics
pub mod decision_log;
Expand Down
Loading
Loading