From f3e4c1496d2ddcdae535132427fdb499181f1695 Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 17:25:41 +0000 Subject: review: one host rule, one body rule, one audit constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit m-2. `hosts` existed twice, verbatim, in `review::diff` and `review::risk`. The duplication that matters is the other one: "did the executable part of the recipe change" also existed twice, with *different* semantics. The risk scorer compared everything from the first function definition onward; the diff panel compared only the lines that name a function, so a `build()` rewritten to `curl … | sh` under the same function names told the risk scorer "code changed, high" and told the reviewer nothing at all — the one reader who could have caught it. Both questions now have one answer: `urlutil::hosts` (which also strips the `git@` from ssh URLs, so a scheme change stops crying "new source host" wolf) and `recipe::bodies_changed`, in the module that owns the recipe. m-4. The three review decisions each hand-built an `AuditEntry` literal, and their `detail` shapes drifted: approve recorded the identity hash, reject recorded only the note, withdraw only the reason — so for two of the three the log cannot answer which candidate bytes the decision was about. `AuditEntry` is built by `::human` / `::system` now, and reject records the identity hash it rejected. m-3, the four-times-copied 21-column candidate `SELECT`, was already gone: the `CANDIDATE_COLS` constant came with moving the candidate SQL into `db/` in an earlier commit. Tests: the body rule is pinned at the unit level with the exact drift case (same function names, different body), `tests/production_surface.rs` fails if either module grows a private copy again or if an audit row is hand-built, and the reject test reads its own audit row back and requires the identity in it. --- src/review/diff.rs | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) (limited to 'src/review/diff.rs') diff --git a/src/review/diff.rs b/src/review/diff.rs index 1196406..629258c 100644 --- a/src/review/diff.rs +++ b/src/review/diff.rs @@ -89,8 +89,8 @@ fn source_delta(old: &Recipe, new: &Recipe) -> Panel { body.push_str(&format!("- {s}\n")); } } - let old_hosts = hosts(&old.source); - let new_hosts = hosts(&new.source); + let old_hosts = crate::urlutil::hosts(&old.source); + let new_hosts = crate::urlutil::hosts(&new.source); for h in new_hosts.difference(&old_hosts) { body.push_str(&format!("! new source host: {h}\n")); } @@ -190,40 +190,15 @@ fn install_delta(old: &Recipe, new: &Recipe) -> Panel { (Some(a), Some(b)) if a != b => body.push_str(&format!("! install script changed: {a} -> {b}\n")), _ => {} } - if old.pkgbuild != new.pkgbuild { - // The recipe diff shows the text; here we call out only whether the - // executable part moved, which is what actually runs. - let f = |t: &str| { - t.lines() - .filter(|l| { - let l = l.trim_start(); - l.starts_with("build()") - || l.starts_with("package") - || l.starts_with("prepare()") - || l.starts_with("check()") - }) - .collect::>() - .join("\n") - }; - if f(&old.pkgbuild) != f(&new.pkgbuild) { - body.push_str("! build()/package() bodies changed — this is code that runs here and on every installer\n"); - } + if crate::recipe::bodies_changed(&old.pkgbuild, &new.pkgbuild) { + // The recipe diff shows the text; this panel calls out that the + // executable part moved, which is what actually runs — on this machine + // and on every machine that installs the result. + body.push_str("! build()/package() bodies changed — this is code that runs here and on every installer\n"); } Panel { name: "install", title: "Install-script delta", body } } -fn hosts(sources: &[String]) -> std::collections::BTreeSet { - sources - .iter() - .filter_map(|s| { - let s = s.rsplit("::").next().unwrap_or(s); - let s = s.rsplit('+').next().unwrap_or(s); - let rest = s.split("://").nth(1)?; - rest.split('/').next().map(|h| h.to_string()) - }) - .collect() -} - fn version_delta(base: Option<&ReleaseRow>, c: &CandidateRow) -> Panel { let mut body = String::new(); match base { -- cgit v1.2.3