diff --git a/services/common/src/description_lint.rs b/services/common/src/description_lint.rs new file mode 100644 index 000000000..2da4fe2ec --- /dev/null +++ b/services/common/src/description_lint.rs @@ -0,0 +1,198 @@ +//! The last check on a pull request description before it is written. +//! +//! A web pull request's description carried "History of the touched files" +//! three times, one section per fix round, and a list of deploy workflows +//! for services the change never touched. Whatever section writer produced +//! it, the description is held here at the one place it is written +//! (`GitHubClient::create_pull_request` and `update_pr_body`): +//! +//! - a section said twice keeps only its newest (last) copy; +//! - a line that lists several deploy workflows (a deploy map) goes: the +//! release section names only the deploy the change waits on; +//! - "who this affects" with no use found goes: a search that found nothing +//! tells a reviewer nothing. +//! +//! [`defects`] is the check; [`clean`] applies it. + +/// A section heading: `## X`, `### X`, or a line that is only a bold label +/// (`**History of the touched files**`). +fn heading(l: &str) -> Option { + let t = l.trim(); + let name = if let Some(h) = t.strip_prefix("### ").or_else(|| t.strip_prefix("## ")) { + h + } else if t.starts_with("**") + && t.ends_with("**") + && t.len() > 4 + && !t[2..t.len() - 2].contains("**") + { + &t[2..t.len() - 2] + } else { + return None; + }; + let level = t.chars().take_while(|c| *c == '#').count(); + let n = name.trim().trim_end_matches(':').trim().to_lowercase(); + (!n.is_empty()).then(|| { + if level == 0 { + n + } else { + format!("{} {n}", "#".repeat(level)) + } + }) +} + +/// A line that ends a section without being one (a collapsed block's +/// edge, a hidden marker). +fn boundary(l: &str) -> bool { + let t = l.trim_start(); + t.starts_with("\n"; + assert_eq!(clean(body), body); + assert!(defects(body).is_empty()); + } +} diff --git a/services/common/src/git_conventions.rs b/services/common/src/git_conventions.rs index 52d6a193e..a015891ea 100644 --- a/services/common/src/git_conventions.rs +++ b/services/common/src/git_conventions.rs @@ -369,6 +369,127 @@ pub fn subject_key(subject: &str) -> Option { .map(|l| l.key) } +/// Commits a pull request may carry when it is marked ready; more is fix +/// round churn, squashed first (a dependency pull request once had 50). +pub const MAX_READY_COMMITS: usize = 5; + +/// Whether `commits` on a pull request are churn to squash before ready. +pub fn churn(commits: usize) -> bool { + commits > MAX_READY_COMMITS +} + +/// One commit of a branch, oldest first, as the final squash reads it. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct CommitInfo { + pub sha: String, + pub subject: String, +} + +/// A commit the final squash writes: its message and the commit whose tree +/// it takes (the last one of its run of commits). +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Group { + pub message: String, + pub last_sha: String, + pub count: usize, +} + +/// Commits a squashed pull request keeps, at most. +pub const MAX_GROUPS: usize = 4; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum Round { + Review, + Checks, + Other, +} + +fn round_of(subject: &str) -> Round { + let l = subject.to_lowercase(); + let has = |ws: &[&str]| { + l.split(|c: char| !c.is_ascii_alphanumeric()) + .any(|w| ws.contains(&w)) + }; + if has(&[ + "review", + "feedback", + "address", + "comment", + "comments", + "suggestion", + ]) { + Round::Review + } else if has(&[ + "test", + "tests", + "ci", + "lint", + "format", + "fmt", + "lockfile", + "build", + "types", + "typecheck", + "clippy", + "e2e", + ]) { + Round::Checks + } else { + Round::Other + } +} + +fn round_words(r: Round) -> &'static str { + match r { + Round::Review => "Address review feedback", + Round::Checks => "Fix failing checks", + Round::Other => "Follow-up changes", + } +} + +/// The final squash's commits: the first commit (the implementation) under +/// `first` (its own subject, normalized to the run's key), then one commit +/// per run of fix-round commits of one kind (review feedback, failing +/// checks, other follow-ups), at most [`MAX_GROUPS`] in all. Runs stay in +/// order, so each commit takes the tree of its run's last commit and the +/// result is exactly the branch's code. Every message carries the run's +/// real `key` or none. +pub fn squash_groups(commits: &[CommitInfo], first: &str, key: Option<&str>) -> Vec { + let Some((head, rest)) = commits.split_first() else { + return Vec::new(); + }; + let mut runs: Vec<(Option, String, usize)> = vec![(None, head.sha.clone(), 1)]; + for c in rest { + let r = round_of(&c.subject); + match runs.last_mut() { + Some((Some(k), last, n)) if *k == r => { + *last = c.sha.clone(); + *n += 1; + } + _ => runs.push((Some(r), c.sha.clone(), 1)), + } + } + // Too many runs: the follow-ups after the first fold into one. + while runs.len() > MAX_GROUPS { + let tail = runs.split_off(MAX_GROUPS - 1); + let last = tail.last().map(|t| t.1.clone()).unwrap_or_default(); + let n: usize = tail.iter().map(|t| t.2).sum(); + let kind = tail[0].0.filter(|k| tail.iter().all(|t| t.0 == Some(*k))); + runs.push((kind.or(Some(Round::Other)), last, n)); + } + let msg = |text: &str| normalize_message(&normalize_subject(text, key, key.is_some()), key); + runs.into_iter() + .map(|(kind, last_sha, count)| Group { + message: match kind { + None => normalize_message(first, key), + Some(k) => msg(round_words(k)), + }, + last_sha, + count, + }) + .collect() +} + /// A whole commit message with its subject normalized as in /// [`normalize_subject`] (no key added), its body kept. pub fn normalize_message(message: &str, key: Option<&str>) -> String { @@ -691,6 +812,48 @@ pub fn validate(kind: Kind, template: &str) -> Result<(), String> { #[cfg(test)] mod tests { + fn c(sha: &str, subject: &str) -> super::CommitInfo { + super::CommitInfo { + sha: sha.into(), + subject: subject.into(), + } + } + + #[test] + fn churn_squashes_into_a_few_logical_commits_with_the_runs_key() { + let commits = vec![ + c("a1", "KEY-1: add the export retry"), + c("a2", "fix lint"), + c("a3", "fix failing test"), + c("a4", "address review feedback on naming"), + c("a5", "address review comment"), + c("a6", "fix ci"), + c("a7", "tidy the docs"), + ]; + let g = super::squash_groups(&commits, "OPS-41: Add the export retry", Some("OPS-41")); + assert!(g.len() <= super::MAX_GROUPS, "{g:?}"); + assert_eq!(g[0].message, "OPS-41: Add the export retry"); + assert_eq!(g[0].last_sha, "a1"); + assert_eq!(g[1].message, "OPS-41: Fix failing checks"); + assert_eq!(g[1].last_sha, "a3"); + assert_eq!(g[2].message, "OPS-41: Address review feedback"); + // The rest folds into one, ending at the branch's tip. + assert_eq!(g.last().unwrap().last_sha, "a7"); + assert_eq!(g.iter().map(|x| x.count).sum::(), 7); + // No stand-in key reaches a message. + assert!(g.iter().all(|x| !x.message.contains("KEY-1")), "{g:?}"); + // Without a key, none is added. + let g = super::squash_groups(&commits[..2], "Add the export retry", None); + assert_eq!(g[1].message, "Fix failing checks"); + } + + #[test] + fn fifty_commits_are_churn_to_squash_and_a_few_are_not() { + assert!(!super::churn(1)); + assert!(!super::churn(super::MAX_READY_COMMITS)); + assert!(super::churn(50)); + } + use super::*; fn tokens() -> Tokens { diff --git a/services/common/src/lib.rs b/services/common/src/lib.rs index 42463647e..9f3be266b 100644 --- a/services/common/src/lib.rs +++ b/services/common/src/lib.rs @@ -158,6 +158,9 @@ pub mod knowledge; pub mod repo_read; // The test that every model call site is a metered helper pub mod ci_cover; +/// The last check on a pull request description: no section twice, no +/// deploy maps, no empty "who this affects". +pub mod description_lint; #[cfg(test)] mod model_call_sites; /// Which pull requests CoderHelm may push to, edit or close: its own. diff --git a/services/common/src/pr_body.rs b/services/common/src/pr_body.rs index d7b398710..bbb8fb417 100644 --- a/services/common/src/pr_body.rs +++ b/services/common/src/pr_body.rs @@ -33,6 +33,8 @@ pub const WORD_BUDGET: usize = 200; /// Words in sight past which the body fails. pub const WORD_HARD: usize = 300; pub const SUMMARY_WORDS: usize = 60; +/// Words the Problem line holds. +pub const PROBLEM_WORDS: usize = 45; pub const ITEM_WORDS: usize = 30; pub const FOCUS_WORDS: usize = 25; pub const MAX_ITEMS: usize = 3; @@ -259,10 +261,17 @@ impl Ticket { } } -/// Everything one description shows. +/// Everything one description shows, laid out as Problem, Changes, Risk +/// and Verification (and Needed from you only when a person must act), +/// two or three lines each. #[derive(Debug, Clone, Default)] pub struct Body { pub ticket: Option, + /// Why the change exists, in a sentence or two (the ticket's ask, the + /// advisories a dependency update fixes). + pub problem: String, + /// The one command or step that checks the change by hand. + pub how_to_check: String, /// The head's short sha. pub head: String, /// The head the results are of, when the description could not be @@ -804,6 +813,11 @@ fn screens_markdown(s: &Screens) -> String { struct Blocks { header: String, alert: String, + /// With its `### Problem` heading. + problem: String, + /// With its `### Changes` heading: the summary, the review question and + /// what to read first. + changes: String, summary: String, /// With its `### Needed from you` heading. needed: String, @@ -818,22 +832,24 @@ struct Blocks { } impl Blocks { + /// `### Risk` with its Risk and Rollback lines. + fn risk_section(&self) -> String { + format!("### Risk\n\n{}\n\n{}", self.risk, self.rollback) + } + /// The blocks in the fixed order. - fn in_order(&self) -> Vec<&str> { + fn in_order(&self) -> Vec { [ &self.alert, - &self.summary, + &self.problem, + &self.changes, &self.needed, - &self.focus, - &self.deps, - &self.risk, - &self.rollback, + &self.risk_section(), &self.verification, - &self.screens, ] .into_iter() - .map(String::as_str) .filter(|b| !b.is_empty()) + .cloned() .collect() } } @@ -846,6 +862,24 @@ fn under_heading(block: &str) -> String { } } +/// The Problem line: why the change exists, the ticket linked in it. +fn problem_line(b: &Body, ticket: Option<&Ticket>) -> String { + let link = ticket + .map(|t| format!(" ({})", t.link())) + .unwrap_or_default(); + let p = part(&fit_words(&part(&b.problem), PROBLEM_WORDS)); + if p.is_empty() { + // Nothing recorded why: the ticket, or that there is none (what + // the change does is in Changes, never said twice). + match ticket { + Some(t) => format!("Asked for in {}.", t.link()), + None => "No ticket or finding says why.".to_string(), + } + } else { + format!("{}{link}.", upper_first(&p)) + } +} + fn blocks(b: &Body) -> Blocks { let mut out = Blocks::default(); let mut v: Vec = Vec::new(); @@ -872,14 +906,13 @@ fn blocks(b: &Body) -> Blocks { } else { String::new() }; - let waiting = one_line(&b.waiting); - out.alert = match (waiting.is_empty(), alert.is_empty()) { - (true, true) => String::new(), - (true, false) => format!("> [!IMPORTANT]\n> {alert}."), - (false, true) => format!("> [!NOTE]\n> {waiting}"), - (false, false) => format!("> [!IMPORTANT]\n> {waiting} {alert}."), - }; + // The alert is only for what breaks on merge; what the pull request + // waits on is the first line of Verification. + if !alert.is_empty() { + out.alert = format!("> [!IMPORTANT]\n> {alert}."); + } out.summary = summary_paragraph(&b.summary, ticket, &b.outside); + out.problem = format!("### Problem\n\n{}", problem_line(b, ticket)); if !b.needed.is_empty() { let mut s = String::from("### Needed from you\n\n"); let items: Vec = b @@ -931,6 +964,24 @@ fn blocks(b: &Body) -> Blocks { upper_first(&rollback) }; out.rollback = format!("**Rollback:** {rollback}."); + // Changes: what the change does (the ticket is linked in Problem), then + // the review question with CoderHelm's conclusion and what to read + // first; where to see it is in Verification. + let mut changes = format!( + "### Changes\n\n{}", + summary_paragraph(&b.summary, None, &b.outside) + ); + let no_see = Focus { + see_it: String::new(), + ..b.focus.clone() + }; + for f in focus_markdown(&no_see).into_iter().take(2) { + changes.push_str(&format!("\n- {f}")); + } + if !out.deps.is_empty() { + changes.push_str(&format!("\n\n{}", out.deps)); + } + out.changes = changes; let lead_in = if !b.results_of.is_empty() && b.results_of != b.head { format!( "Results below are for {}; the head is now {}.", @@ -942,7 +993,12 @@ fn blocks(b: &Body) -> Blocks { format!("On {} (head of this PR):", b.head) }; let rows = table_rows(&b.rows); - let mut verification = format!("### Verification\n\n{lead_in}\n\n"); + let mut verification = String::from("### Verification\n\n"); + let waiting = one_line(&b.waiting); + if !waiting.is_empty() { + verification.push_str(&format!("{waiting}\n\n")); + } + verification.push_str(&format!("{lead_in}\n\n")); verification.push_str(&table( &["Check", "Result"], &rows @@ -950,10 +1006,19 @@ fn blocks(b: &Body) -> Blocks { .map(|r| vec![one_line(&r.check), r.result()]) .collect::>(), )); - out.verification = verification; + let see = part(&b.focus.see_it); + if !see.is_empty() { + verification.push_str(&format!("\n\nSee it: {see}.")); + } + let how = part(&b.how_to_check); + if !how.is_empty() { + verification.push_str(&format!("\n\nHow to check: {how}.")); + } if let Some(s) = &b.screens { out.screens = screens_markdown(s); + verification.push_str(&format!("\n\n{}", out.screens)); } + out.verification = verification; out } @@ -1224,16 +1289,17 @@ pub fn defects(body: &str, head: &str) -> Vec { let mut d: Vec = Vec::new(); let seen = in_sight(body); let lines: Vec<&str> = seen.lines().filter(|l| !l.trim().is_empty()).collect(); - // The first block is the Summary, or one alert and then the Summary. + let templated = body.contains(crate::pr_template::MARK); + // The first block is Problem, or one alert and then Problem. match lines.first().map(|l| l.trim()) { Some(l) if l.starts_with("> [!") => { let after = lines.iter().find(|l| !l.trim().starts_with('>')); - if after.is_none_or(|l| is_block_start(l.trim())) { - d.push("an alert is not followed by the Summary".into()); + if !templated && after.is_none_or(|l| l.trim() != "### Problem") { + d.push("an alert is not followed by the Problem".into()); } } - Some(l) if is_block_start(l) => { - d.push(format!("the body does not open with the Summary: {l}")) + Some(l) if !templated && l != "### Problem" => { + d.push(format!("the body does not open with the Problem: {l}")) } None => d.push("nothing is in sight".into()), _ => {} @@ -1241,10 +1307,15 @@ pub fn defects(body: &str, head: &str) -> Vec { if seen.matches("> [!").count() > 1 { d.push("more than one alert".into()); } - // Headings: only these three, in this order; a body laid into the + // Headings: only these, in this order; a body laid into the // repository's template has the template's headings. - let templated = body.contains(crate::pr_template::MARK); - let allowed = ["Needed from you", "Review focus", "Verification"]; + let allowed = [ + "Problem", + "Changes", + "Needed from you", + "Risk", + "Verification", + ]; let mut last = 0usize; for l in lines.iter().filter(|_| !templated) { let t = l.trim(); @@ -1256,7 +1327,7 @@ pub fn defects(body: &str, head: &str) -> Vec { } } } - for h in ["Review focus", "Verification"] + for h in ["Problem", "Changes", "Risk", "Verification"] .iter() .filter(|_| !templated) { @@ -1264,14 +1335,57 @@ pub fn defects(body: &str, head: &str) -> Vec { d.push(format!("no {h} section")); } } - // The Summary. - if let Some(p) = lines - .iter() - .find(|l| !is_block_start(l.trim()) && !l.trim().starts_with('>')) - { - let n = words(p); - if n > SUMMARY_WORDS { - d.push(format!("the Summary has {n} words")); + // No section twice, no deploy map, no empty "who this affects". + d.extend(crate::description_lint::defects(&seen)); + // Each section is short: two or three lines of prose (Verification + // holds the waiting line, the head and how to check, and its tables). + if !templated { + let mut prose: Vec<(String, usize)> = Vec::new(); + for l in seen.lines() { + let t = l.trim(); + if let Some(h) = t.strip_prefix("### ") { + prose.push((h.to_string(), 0)); + continue; + } + let counted = !t.is_empty() + && !t.starts_with('|') + && !t.starts_with("- [") + && !t.starts_with('>') + && !t.starts_with("```") + && !t.starts_with("<") + && !l.starts_with(" ") + && !t.starts_with("Opened by CoderHelm"); + if counted { + if let Some(last) = prose.last_mut() { + last.1 += 1; + } + } + } + for (h, n) in prose { + let max = match h.as_str() { + "Verification" => 4, + "Needed from you" => MAX_ITEMS, + _ => 3, + }; + if n > max { + d.push(format!("{h} has {n} lines")); + } + } + } + // The summary sentence that opens Changes. + let mut in_changes = false; + for l in seen.lines() { + let t = l.trim(); + if t.starts_with("### ") { + in_changes = t == "### Changes"; + continue; + } + if in_changes && !t.is_empty() { + let n = words(t); + if n > SUMMARY_WORDS { + d.push(format!("the summary has {n} words")); + } + break; } } // Needed from you. @@ -1323,34 +1437,6 @@ pub fn defects(body: &str, head: &str) -> Vec { ticks.next(); } } - // Review focus. - let focus: Vec<&str> = section("Review focus") - .into_iter() - .filter(|l| l.starts_with("- ")) - .collect(); - if !(1..=3).contains(&focus.len()) { - d.push(format!("Review focus has {} bullets", focus.len())); - } - if let Some(first) = focus.first() { - let kinds = [ - "approach", - "naming", - "copy", - "security", - "performance", - "correctness", - ]; - let lower = first.to_lowercase(); - if !first.trim_end().ends_with('?') && !kinds.iter().any(|k| lower.contains(k)) { - d.push(format!("the first focus bullet names no feedback: {first}")); - } - } - for f in &focus { - let n = words(f); - if n > FOCUS_WORDS + 12 { - d.push(format!("a focus bullet has {n} words")); - } - } // Risk and Rollback. let risk = lines.iter().find(|l| l.starts_with("**Risk:** ")); match risk { @@ -1379,14 +1465,16 @@ pub fn defects(body: &str, head: &str) -> Vec { } // Verification. let ver = section("Verification"); - let lead_in = ver.iter().find(|l| !l.trim().is_empty()); + let lead_in = ver + .iter() + .find(|l| l.starts_with("On ") || l.starts_with("Results below are for ")); match lead_in { - Some(l) if l.starts_with("On ") || l.starts_with("Results below are for ") => { + Some(l) => { if !head.is_empty() && !l.contains(head) { d.push(format!("the lead-in does not name the head {head}: {l}")); } } - _ => d.push("Verification has no lead-in with the head".into()), + None => d.push("Verification has no lead-in with the head".into()), } if !head.is_empty() { let n = readable(&seen).matches(head).count(); @@ -1394,11 +1482,14 @@ pub fn defects(body: &str, head: &str) -> Vec { d.push(format!("the short sha is in sight {n} times")); } } + // The checks table: from its header to the first line that is not a row. let rows: Vec<&str> = ver .iter() .copied() - .filter(|l| l.starts_with('|') && !l.starts_with("|---") && !l.starts_with("| Check |")) - .take_while(|l| !l.starts_with("| Before |")) + .skip_while(|l| !l.starts_with("| Check |")) + .skip(1) + .take_while(|l| l.starts_with('|')) + .filter(|l| !l.starts_with("|---")) .collect(); if rows.len() > MAX_ROWS { d.push(format!("Verification has {} rows", rows.len())); @@ -1495,16 +1586,6 @@ pub fn defects(body: &str, head: &str) -> Vec { d } -fn is_block_start(t: &str) -> bool { - t.starts_with('#') - || t.starts_with("- ") - || t.starts_with('|') - || t.starts_with("**") - || t.starts_with('<') - || t.starts_with("```") - || t.chars().next().is_some_and(|c| c.is_ascii_digit()) && t.contains(". ") -} - fn is_uuid(w: &str) -> bool { let parts: Vec<&str> = w.split('-').collect(); parts.len() == 5 @@ -1674,8 +1755,8 @@ mod tests { let bad = "**Check:** `cd apps/studio && npm run deploy:staging`; 6 recorded checks passed on d78bb24.\n**Risk:** Low.\n**Needed from you:**\n1. Deploy it (a person on the team)\n **Review:** decide whether this is right.\n **Look at first:**\n- `Deploy to Production` did not run on `d78bb24`.\n\n
More\n*em*\n
\n"; let found = defects(bad, "d78bb24"); for want in [ - "does not open with the Summary", - "no Review focus section", + "does not open with the Problem", + "no Changes section", "no Rollback line", "in sight: did not run", "in sight: (a person", @@ -1733,4 +1814,76 @@ mod tests { ); assert_eq!(defects(&body, "d78bb24"), Vec::::new(), "{body}"); } + + /// The layout: Problem, Changes, (Needed from you), Risk, Verification, + /// two or three lines each; the preview's link, its screenshots, what + /// the pull request waits on and how to check are in Verification. + #[test] + fn the_body_is_problem_changes_risk_verification() { + let b = Body { + ticket: Some(Ticket { + key: "KEY-123".into(), + url: "https://tracker.example.com/browse/KEY-123".into(), + }), + problem: "The sign-up page loses the form when the session expires".into(), + how_to_check: "open `/sign-up`, wait out the session, submit".into(), + head: "d78bb24".into(), + waiting: "Waiting on the preview's end-to-end run.".into(), + summary: "Keeps the form's values across a session refresh.".into(), + focus: Focus { + question: "Approach: is keeping the values what KEY-123 asks for?".into(), + see_it: "[the preview](https://preview.example.com/sign-up)".into(), + ..Default::default() + }, + level: Level::Low, + risk: "one page's form state only".into(), + rollback: "revert this PR".into(), + rows: vec![Row { + check: "Unit tests (CI)".into(), + outcome: Outcome::Passed, + detail: String::new(), + }], + screens: Some(Screens::Pages(vec![( + "/sign-up".into(), + "https://img.example.com/d.png".into(), + "https://img.example.com/p.png".into(), + )])), + run_url: "https://app.example.com/runs/1".into(), + ..Default::default() + }; + let r = render(&b); + let v = &r.visible; + let at = |h: &str| v.find(h).unwrap_or_else(|| panic!("{h}: {v}")); + assert!(at("### Problem") < at("### Changes")); + assert!(at("### Changes") < at("### Risk")); + assert!(at("### Risk") < at("### Verification")); + assert!( + !v.contains("### Review focus") && !v.contains("> [!"), + "{v}" + ); + let ver = &v[at("### Verification")..]; + for want in [ + "Waiting on the preview's end-to-end run.", + "See it: [the preview](https://preview.example.com/sign-up).", + "How to check: open `/sign-up`, wait out the session, submit.", + "| Page | Desktop | Phone |", + ] { + assert!(ver.contains(want), "{want}: {ver}"); + } + assert!(v.contains( + "The sign-up page loses the form when the session expires ([KEY-123](https://tracker.example.com/browse/KEY-123))." + )); + let body = format!("{v}\n\n{}", r.footer); + assert_eq!(defects(&body, "d78bb24"), Vec::::new(), "{body}"); + // A section of more than three lines, or one said twice, is a defect. + let long = body.replace("### Risk\n\n", "### Risk\n\nOne.\n\nTwo.\n\nThree.\n\n"); + assert!( + defects(&long, "d78bb24") + .iter() + .any(|d| d.contains("Risk has")), + "{long}" + ); + let twice = format!("{body}\n\n### Risk\n\n**Risk:** Low. Again here."); + assert!(!defects(&twice, "d78bb24").is_empty()); + } } diff --git a/services/common/src/pr_facts.rs b/services/common/src/pr_facts.rs index 5fe640ceb..ef504703e 100644 --- a/services/common/src/pr_facts.rs +++ b/services/common/src/pr_facts.rs @@ -1268,8 +1268,42 @@ pub fn preview_gaps(f: &Facts) -> Vec { .collect() } +/// The facts without what the head already settles: an open item or an +/// unverified claim about a kind of check (the lockfile, the tests, the +/// build) whose checks of that kind all passed on the head, and an item +/// the pull request's CI closes once every check on the head passed. The +/// evidence decides, never the item's wording: a fixed "lockfile out of +/// sync" goes because the install check passed on this head. +pub fn settled(f: &Facts) -> Facts { + let passed_family = |fam: Family| { + let of: Vec<&CheckFact> = f + .checks + .iter() + .filter(|c| Family::of(&c.name).contains(&fam)) + .collect(); + !of.is_empty() && of.iter().all(|c| c.outcome == Outcome::Passed) + }; + let settled_by_checks = |text: &str| { + let fams = Family::of(text); + !fams.is_empty() && fams.into_iter().all(passed_family) + }; + let all_passed = f.checks_read + && !f.checks.is_empty() + && f.checks + .iter() + .all(|c| matches!(c.outcome, Outcome::Passed | Outcome::DidNotRun)) + && f.checks.iter().any(|c| c.outcome == Outcome::Passed); + let mut out = f.clone(); + out.open + .retain(|o| !(o.closer == Closer::Ci && all_passed) && !settled_by_checks(&o.text)); + out.unverified.retain(|u| !settled_by_checks(&u.what)); + out +} + pub fn body_of(f: &Facts, ticked: &[String]) -> crate::pr_body::Body { use crate::pr_body::{Body, Focus, Level, ReadFirst, Screens, Ticket}; + let settled_facts = settled(f); + let f = &settled_facts; let head = f.short_head().to_string(); let ticket = f.why.as_ref().filter(|w| !w.reference.is_empty()).map(|w| { let url = if !w.url.is_empty() { @@ -1446,10 +1480,6 @@ pub fn body_of(f: &Facts, ticked: &[String]) -> crate::pr_body::Body { }; // The full list of checks, and how to check by hand. let mut evidence: Vec = Vec::new(); - let how = one_line(&f.how_to_check); - if !how.is_empty() { - evidence.push(format!("How to check: {how}.")); - } if let Some(p) = &f.preview { if p.url.starts_with("https://") { evidence.push(format!("Preview: {}", p.url)); @@ -1512,8 +1542,27 @@ pub fn body_of(f: &Facts, ticked: &[String]) -> crate::pr_body::Body { } _ => (String::new(), String::new()), }; + // Why: the ticket's or finding's own words; for a dependency update + // without one, the advisories it is about. + let problem = match (f.why.as_ref().map(|w| one_line(&w.title)), &f.dependency) { + (Some(t), _) if !t.is_empty() => t, + (_, Some(d)) => { + let n = d.advisories.fixed.len() + d.advisories.remaining.len(); + if n > 0 { + format!( + "{} in the dependency lines this updates", + plural(n, "known security advisory", "known security advisories") + ) + } else { + "Dependency lines behind their current releases".to_string() + } + } + _ => String::new(), + }; Body { ticket, + problem, + how_to_check: one_line(&f.how_to_check), head, results_of: String::new(), alert: String::new(), @@ -1627,10 +1676,13 @@ mod tests { out, "\n\ \n\ - Retries the export poller three times before it gives up (OPS-41).\n\n\ - ### Review focus\n\n\ + ### Problem\n\n\ + Export poller gives up on the first timeout (OPS-41).\n\n\ + ### Changes\n\n\ + Retries the export poller three times before it gives up.\n\ - Approach: decide whether this does what OPS-41 asks. CoderHelm's conclusion: all checks on this head passed.\n\ - Read first: [`src/export/poller.rs`](https://github.com/acme/site/blob/abc1234/src/export/poller.rs) (the retry loop decides when a poll is abandoned).\n\n\ + ### Risk\n\n\ **Risk:** Low. One module.\n\n\ **Rollback:** Revert this pull request.\n\n\ ### Verification\n\n\ @@ -1639,6 +1691,7 @@ mod tests { |---|---|\n\ | unit tests (CI) | Passed |\n\ | lint (CI) | Passed |\n\n\ + How to check: `cargo test -p export`.\n\n\ " ); assert_eq!( @@ -1647,6 +1700,54 @@ mod tests { ); } + /// What the head's checks settle leaves the description: a fixed + /// "lockfile out of sync" goes once the install check passes on the + /// head, whatever the item's wording; one the head doesn't settle stays. + #[test] + fn items_the_head_settles_are_removed_from_the_evidence() { + let mut f = ticket_facts(); + f.open = vec![ + OpenItem { + text: "The lockfile is out of sync with the manifest".into(), + closer: Closer::CoderHelm, + }, + OpenItem { + text: "Wait for CI to pass on this head".into(), + closer: Closer::Ci, + }, + OpenItem { + text: "Confirm the vendor's rate limit".into(), + closer: Closer::Person, + }, + ]; + f.unverified = vec![Unverified { + what: "the build was not run".into(), + why: "no runner".into(), + }]; + // Before the fix: the install check failed on the head. + f.checks = vec![ + check("install (frozen lockfile)", Outcome::Failed), + check("unit tests", Outcome::Passed), + ]; + let before = settled(&f); + assert_eq!(before.open.len(), 3, "{:?}", before.open); + assert_eq!(before.unverified.len(), 1); + // On the next head both passed, and a build ran. + f.checks = vec![ + check("install (frozen lockfile)", Outcome::Passed), + check("unit tests", Outcome::Passed), + check("build", Outcome::Passed), + ]; + let after = settled(&f); + let left: Vec<&str> = after.open.iter().map(|o| o.text.as_str()).collect(); + assert_eq!(left, vec!["Confirm the vendor's rate limit"]); + assert!(after.unverified.is_empty(), "{:?}", after.unverified); + // The rendered description no longer shows them. + let out = lead(&f); + assert!(!out.contains("out of sync"), "{out}"); + assert!(!out.contains("build was not run"), "{out}"); + } + #[test] fn nothing_is_called_checked_that_no_record_backs() { let mut f = ticket_facts(); @@ -1683,9 +1784,14 @@ mod tests { out.contains("| the export against the live bucket | Not run: the sandbox has no credentials for it |"), "{out}" ); - // What a person must do comes right after the Summary. + // What a person must do comes right after Changes, before Risk. assert!( - out.contains("\n\n### Needed from you\n\n- [ ] **Person who holds the credential**, before merge: Set the staging secret. Why a person: it needs a credential only a person can provide."), + out.find("### Changes") < out.find("### Needed from you") + && out.find("### Needed from you") < out.find("### Risk"), + "{out}" + ); + assert!( + out.contains("\n\n### Needed from you\n\n- [ ] **Person who holds the credential**, before merge: Set the staging secret. Why a person: it needs a credential only a person can provide."), "{out}" ); assert!(!out.contains("(a person)"), "{out}"); @@ -1743,10 +1849,7 @@ mod tests { "{out}" ); assert!(!out.contains("Feedback wanted"), "{out}"); - assert!( - out.contains("Updates 2 packages: 2 major (OPS-41)."), - "{out}" - ); + assert!(out.contains("Updates 2 packages: 2 major."), "{out}"); } #[test] diff --git a/services/common/src/pr_layout.rs b/services/common/src/pr_layout.rs index d6e5c2f69..8021d5fbc 100644 --- a/services/common/src/pr_layout.rs +++ b/services/common/src/pr_layout.rs @@ -582,7 +582,7 @@ mod tests { use super::*; use crate::pr_body::{FOOTER_END, FOOTER_START}; - const LEAD: &str = "\n\nRetries the export poller three times before it gives up (OPS-41).\n\n### Review focus\n\n- Approach: does this do what OPS-41 asks?\n\n**Risk:** Low. One module changes.\n\n**Rollback:** Revert this pull request.\n\n### Verification\n\nOn abc1234 (head of this PR):\n\n| Check | Result |\n|---|---|\n| lint (CI) | Passed |\n\n"; + const LEAD: &str = "\n\n### Problem\n\nThe export poller gives up on the first timeout (OPS-41).\n\n### Changes\n\nRetries the export poller three times before it gives up.\n- Approach: does this do what OPS-41 asks?\n\n### Risk\n\n**Risk:** Low. One module changes.\n\n**Rollback:** Revert this pull request.\n\n### Verification\n\nOn abc1234 (head of this PR):\n\n| Check | Result |\n|---|---|\n| lint (CI) | Passed |\n\n"; fn body() -> String { format!( @@ -596,7 +596,7 @@ mod tests { assert!(out.starts_with(LEAD), "{out}"); let seen = visible(&out); assert!(seen.contains("**Draft:** CI is still running."), "{seen}"); - for gone in ["## Changes", "Open items", "Source ticket", "Consulted"] { + for gone in ["\n## Changes", "Open items", "Source ticket", "Consulted"] { assert!(!seen.contains(gone), "{gone}: {seen}"); } let labels: Vec<&str> = out @@ -754,7 +754,7 @@ mod tests { assert!( flaws .iter() - .any(|f| matches!(f, Flaw::Layout(d) if d.contains("no Review focus"))), + .any(|f| matches!(f, Flaw::Layout(d) if d.contains("no Problem"))), "{flaws:?}" ); // Folded away, the same machinery is evidence, not a flaw. diff --git a/services/worker/src/clients/github.rs b/services/worker/src/clients/github.rs index 63de6246a..4fdb2cbed 100644 --- a/services/worker/src/clients/github.rs +++ b/services/worker/src/clients/github.rs @@ -2495,20 +2495,84 @@ impl GitHubClient { if base_tree.as_deref() == Some(tree_sha.as_str()) { return Ok(()); // no net change } - let new_commit = self - .post( - &format!("{API_BASE}/repos/{owner}/{repo}/git/commits"), - &serde_json::json!({ - "message": message, - "tree": tree_sha, - "parents": [base_sha], - }), - ) - .await?; - let new_sha = new_commit - .get("sha") + // A linear history of the app's own commits is squashed into a few + // logical commits (`git_conventions::squash_groups`) on the commit + // it started from, each taking its run's last tree; anything else + // (a merge of the base in it) becomes one commit on the base. + let listed: Vec = self + .get(&format!( + "{API_BASE}/repos/{owner}/{repo}/compare/{base_sha}...{branch_sha}" + )) + .await? + .get("commits") + .and_then(|c| c.as_array()) + .cloned() + .unwrap_or_default(); + let linear = !listed.is_empty() + && listed.iter().all(|c| { + c.get("parents") + .and_then(|p| p.as_array()) + .is_some_and(|p| p.len() == 1) + }); + let infos: Vec = listed + .iter() + .map(|c| common::git_conventions::CommitInfo { + sha: c["sha"].as_str().unwrap_or("").to_string(), + subject: c["commit"]["message"] + .as_str() + .unwrap_or("") + .lines() + .next() + .unwrap_or("") + .to_string(), + }) + .collect(); + let key = common::git_conventions::subject_key(message); + let groups = common::git_conventions::squash_groups(&infos, message, key.as_deref()); + let start = listed + .first() + .and_then(|c| c.pointer("/parents/0/sha")) .and_then(|v| v.as_str()) - .ok_or("Missing sha in squash commit")?; + .map(String::from); + let new_sha = match (linear && groups.len() > 1, start) { + (true, Some(mut parent)) => { + for g in &groups { + let (tree, _) = self.commit_tree_parents(owner, repo, &g.last_sha).await?; + parent = self + .put_commit( + owner, + repo, + &g.message, + &tree, + std::slice::from_ref(&parent), + ) + .await?; + } + parent + } + _ => { + let new_commit = self + .post( + &format!("{API_BASE}/repos/{owner}/{repo}/git/commits"), + &serde_json::json!({ + "message": message, + "tree": tree_sha, + "parents": [base_sha], + }), + ) + .await?; + new_commit + .get("sha") + .and_then(|v| v.as_str()) + .ok_or("Missing sha in squash commit")? + .to_string() + } + }; + // Someone pushed since this was read: nothing is rewritten. + if self.get_ref(owner, repo, branch).await? != branch_sha { + return Ok(()); + } + let new_sha = new_sha.as_str(); // Force-update: intentional history rewrite (single-writer context). let ref_url = format!("{API_BASE}/repos/{owner}/{repo}/git/refs/heads/{branch}"); self.patch( @@ -4150,7 +4214,7 @@ impl GitHubClient { ) -> Result> { 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); + let body = common::description_lint::clean(&crate::passes::outcome::guard_body(body)); self.post( &url, &serde_json::json!({ @@ -5324,7 +5388,7 @@ impl GitHubClient { body: &str, ) -> Result<(), Box> { let url = format!("{API_BASE}/repos/{owner}/{repo}/pulls/{pr_number}"); - let body = crate::passes::outcome::guard_body(body); + let body = common::description_lint::clean(&crate::passes::outcome::guard_body(body)); self.patch(&url, &serde_json::json!({"body": body})).await?; Ok(()) } diff --git a/services/worker/src/passes/conventions.rs b/services/worker/src/passes/conventions.rs index c178c32b2..f650241ac 100644 --- a/services/worker/src/passes/conventions.rs +++ b/services/worker/src/passes/conventions.rs @@ -65,6 +65,14 @@ impl ForRun { /// `was` (a commit message) with its subject in the repository's form /// and its body kept. pub fn commit(&self, was: &str) -> String { + // A stand-in key (`KEY-1:`) an agent wrote never reaches a commit: + // the run's real key or none. + let real = match &self.key { + Key::Real(k) => Some(k.as_str()), + Key::None(_) => None, + }; + let was = common::git_conventions::normalize_message(was, real); + let was = was.as_str(); match was.split_once('\n') { Some((first, body)) => { format!( diff --git a/services/worker/src/passes/description_eval.rs b/services/worker/src/passes/description_eval.rs index fae86e9ec..ee9372991 100644 --- a/services/worker/src/passes/description_eval.rs +++ b/services/worker/src/passes/description_eval.rs @@ -378,7 +378,7 @@ pub fn feature_case() -> Case { "### Needed from you\n- [ ] **Repository admin**, after merge: Grant CoderHelm's GitHub App permission to start the deploy workflow or run the command below once. Why a person: a permission only a person grants.", " ```sh\n cd apps/studio && npm run deploy:staging\n ```", // A look belongs to the merge decision, never a separate chore. - "- See it: Studio: the page document, the title field.", + "See it: Studio: the page document, the title field.", "| Test Suite (CI) | Passed |", ], collapsed: vec![ @@ -453,13 +453,14 @@ pub fn ticket_case() -> Case { "**Roll back:**", ], in_sight: vec![ - "Retries a timed-out export poll three times before giving up (OPS-41).", + "Retries a timed-out export poll three times before giving up.", "| unit tests (CI) | Failed: [log](https://ci.example.com/unit-tests) |", "On abc1234 (head of this PR):", + // How to check is part of Verification. + "How to check: `cargo test -p export`.", ], collapsed: vec![ "* `src/export/poller.rs`: the retry loop and its limit.", - "How to check: `cargo test -p export`.", "Source ticket: OPS-41", ], } @@ -1014,18 +1015,24 @@ pub fn rendered_defects(body: &str) -> Vec { visible = visible.replacen(f, "", 1); } let start = visible.trim_start(); - let opens_with_summary = start.starts_with("

") + let opens_with_problem = start.starts_with("

Problem

") || (start.starts_with("
") && start .split_once("
") - .is_some_and(|(_, rest)| rest.trim_start().starts_with("

"))); - if !opens_with_summary { + .is_some_and(|(_, rest)| rest.trim_start().starts_with("

Problem

"))); + if !opens_with_problem { d.push(format!( - "the first block is not the Summary: {}", + "the first block is not the Problem: {}", common::truncate_str(start, 80) )); } - let allowed = ["Needed from you", "Review focus", "Verification"]; + let allowed = [ + "Problem", + "Changes", + "Needed from you", + "Risk", + "Verification", + ]; for h in ["h1", "h2", "h3"] { for e in elements(&visible, h) { let text = e @@ -1233,7 +1240,7 @@ mod tests { "in sight: did not run", "in sight: (a person", "in sight: **Check:**", - "no Review focus section", + "no Problem section", "the risk has no level and reason", "short sha is in sight", ] { diff --git a/services/worker/src/passes/description_facts.rs b/services/worker/src/passes/description_facts.rs index 79623c156..bf7d5d1a4 100644 --- a/services/worker/src/passes/description_facts.rs +++ b/services/worker/src/passes/description_facts.rs @@ -812,8 +812,12 @@ mod tests { assert!(!s.body.contains("contract unchanged"), "{}", s.body); let seen = common::pr_layout::visible(&s.body); assert!( - seen.starts_with( - "The export poller retries a timed-out poll three times before it gives up (OPS-41)." + seen.starts_with("### Problem\nExport poller gives up on the first timeout (OPS-41)."), + "{seen}" + ); + assert!( + seen.contains( + "### Changes\nThe export poller retries a timed-out poll three times before it gives up." ), "{seen}" ); @@ -827,12 +831,13 @@ mod tests { assert!(seen.contains("**Risk:** Low. "), "{seen}"); // Nothing is needed: the section is not there. assert!(!seen.contains("Needed from you"), "{seen}"); - // The ticket line, the walkthrough and the command are below. - for below in [ - "Source ticket: OPS-41", - "the retry loop", - "How to check: `cargo test -p export`.", - ] { + // How to check is in Verification; the ticket line and the + // walkthrough are below. + assert!( + seen.contains("How to check: `cargo test -p export`."), + "{seen}" + ); + for below in ["Source ticket: OPS-41", "the retry loop"] { assert!( s.body.contains(below) && !seen.contains(below), "{below}: {}", @@ -910,7 +915,7 @@ mod tests { let s = shape(BODY, "t", f.clone(), Some(reply)); assert!( s.body.contains( - "\nRetries a timed-out export poll three times (OPS-41).\n" + "\nRetries a timed-out export poll three times.\n" ), "{}", s.body diff --git a/services/worker/src/passes/description_goldens/before_rewritten.md b/services/worker/src/passes/description_goldens/before_rewritten.md index 51fe6538e..9cc4e498e 100644 --- a/services/worker/src/passes/description_goldens/before_rewritten.md +++ b/services/worker/src/passes/description_goldens/before_rewritten.md @@ -1,6 +1,14 @@ -Adds a Studio warning when a Hero (Default) subtitle is longer than 160 characters, so editors fix long subtitles before they break the hero layout ([KEY-123](https://tracker.example.com/browse/KEY-123)). Editors can still publish. Done outside the diff: post the 23 documents already over the limit on KEY-123. +### Problem + +Hero subtitle character limit ([KEY-123](https://tracker.example.com/browse/KEY-123)). + +### Changes + +Adds a Studio warning when a Hero (Default) subtitle is longer than 160 characters, so editors fix long subtitles before they break the hero layout. Editors can still publish. Done outside the diff: post the 23 documents already over the limit on KEY-123. +- Approach: decide whether this does what KEY-123 asks. CoderHelm's conclusion: all checks on this head passed. +- Read first: [`apps/studio/schemaTypes/blocks/hero-block-validation.ts`](https://github.com/acme/site/blob/d78bb24/apps/studio/schemaTypes/blocks/hero-block-validation.ts) (the rule, +21 lines); then the other 2 files. ### Needed from you @@ -10,11 +18,7 @@ Adds a Studio warning when a Hero (Default) subtitle is longer than 160 characte cd apps/studio && npm run deploy:staging ``` -### Review focus - -- Approach: decide whether this does what KEY-123 asks. CoderHelm's conclusion: all checks on this head passed. -- Read first: [`apps/studio/schemaTypes/blocks/hero-block-validation.ts`](https://github.com/acme/site/blob/d78bb24/apps/studio/schemaTypes/blocks/hero-block-validation.ts) (the rule, +21 lines); then the other 2 files. -- See it: document `/private-events/weddings`, Hero, Sub Title field. +### Risk **Risk:** Low. Warning-level validation only; no schema, data, or publish-flow change. @@ -31,6 +35,10 @@ On d78bb24 (head of this PR): | Studio build (CI) | Passed | | Studio in local dev, manual (CoderHelm) | Passed; warning shows at 161 characters; Publish stays enabled | +See it: document `/private-events/weddings`, Hero, Sub Title field. + +How to check: `npm test -- hero-block-validation`. + No screenshot: CoderHelm had no runnable preview to capture for this run. @@ -50,8 +58,6 @@ Adds the warning rule. Full test evidence -How to check: `npm test -- hero-block-validation`. - Every check on this head: - [`Lint and typecheck`](https://ci.example.com/Lint-and-typecheck): passed - [`Unit tests`](https://ci.example.com/Unit-tests): passed diff --git a/services/worker/src/passes/description_goldens/dependency_48.md b/services/worker/src/passes/description_goldens/dependency_48.md index 2dcc8eb46..e9f54b537 100644 --- a/services/worker/src/passes/description_goldens/dependency_48.md +++ b/services/worker/src/passes/description_goldens/dependency_48.md @@ -1,10 +1,13 @@ -Updates 48 npm packages: 3 major, 9 minor, 36 patch ([KEY-456](https://tracker.example.com/browse/KEY-456)). Fixes 2 security advisories. +### Problem -### Review focus +Monthly dependency maintenance ([KEY-456](https://tracker.example.com/browse/KEY-456)). +### Changes + +Updates 48 npm packages: 3 major, 9 minor, 36 patch. Fixes 2 security advisories. - Approach: decide whether to merge 48 dependency updates. CoderHelm's conclusion: all 3 major version jumps are safe for this code, each by the usages, checks and probes recorded beside it; all checks on this head passed. - Read first: [`next.config.ts`](https://github.com/acme/site/blob/4be19a0/next.config.ts) (caching defaults changed in Next 15); then the other 4 files; skip `package-lock.json`, which is generated. @@ -16,6 +19,8 @@ Updates 48 npm packages: 3 major, 9 minor, 36 patch ([KEY-456](https://tracker.e | `cookie-jar` | 0.6.0 to 0.7.2 | Security: GHSA-aaaa-bbbb-0001 | | `route-match` | 6.2.2 to 6.3.0 | Security: GHSA-aaaa-bbbb-0002 | +### Risk + **Risk:** Medium. Next 15 changes request caching across all pages; a missed caching default would surface as stale or uncached data, not a crash. **Rollback:** Revert this PR; the lockfile restores every version. No data or config outside the repo changes. diff --git a/services/worker/src/passes/description_goldens/ui_change.md b/services/worker/src/passes/description_goldens/ui_change.md index 68cf9b25f..32b9abfae 100644 --- a/services/worker/src/passes/description_goldens/ui_change.md +++ b/services/worker/src/passes/description_goldens/ui_change.md @@ -1,6 +1,14 @@ -Adds a Studio warning when a Hero (Default) subtitle is longer than 160 characters, so editors fix long subtitles before they break the hero layout ([KEY-123](https://tracker.example.com/browse/KEY-123)). Editors can still publish. Done outside the diff: post the 23 documents already over the limit on KEY-123. +### Problem + +Hero subtitle character limit ([KEY-123](https://tracker.example.com/browse/KEY-123)). + +### Changes + +Adds a Studio warning when a Hero (Default) subtitle is longer than 160 characters, so editors fix long subtitles before they break the hero layout. Editors can still publish. Done outside the diff: post the 23 documents already over the limit on KEY-123. +- Approach: is a non-blocking warning what KEY-123 asks for, or should over-limit subtitles block publishing? CoderHelm's conclusion: all checks on this head passed. +- Read first: [`apps/studio/schemaTypes/blocks/hero-block-validation.ts`](https://github.com/acme/site/blob/d78bb24/apps/studio/schemaTypes/blocks/hero-block-validation.ts) (the rule, +21 lines); then the other 2 files. ### Needed from you @@ -10,11 +18,7 @@ Adds a Studio warning when a Hero (Default) subtitle is longer than 160 characte cd apps/studio && npm run deploy:staging ``` -### Review focus - -- Approach: is a non-blocking warning what KEY-123 asks for, or should over-limit subtitles block publishing? CoderHelm's conclusion: all checks on this head passed. -- Read first: [`apps/studio/schemaTypes/blocks/hero-block-validation.ts`](https://github.com/acme/site/blob/d78bb24/apps/studio/schemaTypes/blocks/hero-block-validation.ts) (the rule, +21 lines); then the other 2 files. -- See it: [the preview](https://preview.example.com/studio), document `/private-events/weddings`, Hero, Sub Title field. +### Risk **Risk:** Low. Warning-level validation only; no schema, data, or publish-flow change. @@ -31,6 +35,10 @@ On d78bb24 (head of this PR): | Studio build (CI) | Passed | | Studio in local dev, manual (CoderHelm) | Passed; warning shows at 161 characters; Publish stays enabled | +See it: [the preview](https://preview.example.com/studio), document `/private-events/weddings`, Hero, Sub Title field. + +How to check: `npm test -- hero-block-validation`. + | Before | After | |---|---| | Sub Title field with a 190-character subtitle and no warning | Same field showing the warning 'Over 160 characters (190)' | @@ -50,8 +58,6 @@ On d78bb24 (head of this PR): Full test evidence -How to check: `npm test -- hero-block-validation`. - Every check on this head: - [`Lint and typecheck`](https://ci.example.com/Lint-and-typecheck): passed - [`Unit tests`](https://ci.example.com/Unit-tests): passed diff --git a/services/worker/src/passes/habits_check.rs b/services/worker/src/passes/habits_check.rs index 9ae18da7e..2bbe26d8b 100644 --- a/services/worker/src/passes/habits_check.rs +++ b/services/worker/src/passes/habits_check.rs @@ -676,6 +676,8 @@ pub fn section(plan: &PlanResult, f: &PrFacts) -> String { } out.push('\n'); } + // Only uses a search found: one that found nothing tells a reviewer + // nothing, so it is not written. let affected: Vec<&habits::Affected> = h .affected .iter() @@ -703,11 +705,6 @@ pub fn section(plan: &PlanResult, f: &PrFacts) -> String { out.push_str(&format!("- `{}`{uses}: {state}\n", a.where_.trim())); } out.push('\n'); - } else if !h.no_outside_use.trim().is_empty() { - out.push_str(&format!( - "**Who this affects:** nothing outside this repository ({}).\n\n", - h.no_outside_use.trim().trim_end_matches('.') - )); } } if !f.outside_plan.is_empty() { diff --git a/services/worker/src/passes/incidents/bf_owns_the_work.rs b/services/worker/src/passes/incidents/bf_owns_the_work.rs index dab378f1a..3d385f95b 100644 --- a/services/worker/src/passes/incidents/bf_owns_the_work.rs +++ b/services/worker/src/passes/incidents/bf_owns_the_work.rs @@ -286,10 +286,10 @@ fn the_second_pull_requests_three_items() { ..Default::default() }; let lead = pr_facts::lead(&f); - // The look is part of the review: shown under Review focus, never a + // The look is part of the review: shown in Verification, never a // chore under "Needed from you". assert!( - lead.contains("- See it: Studio: the landing document, hero Sub Title field."), + lead.contains("See it: Studio: the landing document, hero Sub Title field."), "{lead}" ); assert!(!lead.contains("judgement only a person"), "{lead}"); diff --git a/services/worker/src/passes/ready.rs b/services/worker/src/passes/ready.rs index ba0e17208..9d582d6a3 100644 --- a/services/worker/src/passes/ready.rs +++ b/services/worker/src/passes/ready.rs @@ -1656,9 +1656,21 @@ async fn make_ready(ctx: &Ctx<'_>, f: &Facts) -> Result<(), Refused> { super::round::fold_churn(gh, ctx.owner, ctx.repo, head).await; } // Final squash: the run's whole history (the implementation and every - // fix round) as one clean commit, best-effort. + // fix round) as one clean commit, best-effort. A path that didn't ask + // for it still squashes fix-round churn (more than + // `common::git_conventions::MAX_READY_COMMITS` commits); `squash_branch` + // never rewrites a branch holding a person's commits. + let squash = match ctx.squash_keep_first { + Some(k) => Some(k), + None => gh + .list_pr_commits(ctx.owner, ctx.repo, ctx.pr) + .await + .ok() + .filter(|c| common::git_conventions::churn(c.len())) + .map(|_| false), + }; if let (Some(keep_first), Some(head), Some(base)) = ( - ctx.squash_keep_first, + squash, pr["head"]["ref"].as_str(), pr["base"]["ref"].as_str(), ) {