From 4304b0f336ddba7b4ec6780795059ff2066d105b Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 17:33:17 +0000 Subject: comments: keep only what the code cannot show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stripped every comment that described what an item does, documented its arguments or fields, or cited the design docs (§n, I-n, m-n, decision n). 2247 comments down to 83. What survives: the section dividers that segment the large modules, the secret-handling warnings, the agent wire-frame directions, and the few notes without which the code they attach to reads as redundant, reorderable, or unsound. --- src/review/approve.rs | 40 +--------------------------------------- src/review/candidates.rs | 13 ------------- src/review/diff.rs | 22 ---------------------- src/review/risk.rs | 23 ----------------------- 4 files changed, 1 insertion(+), 97 deletions(-) (limited to 'src/review') diff --git a/src/review/approve.rs b/src/review/approve.rs index c8cd99d..23afee3 100644 --- a/src/review/approve.rs +++ b/src/review/approve.rs @@ -2,8 +2,6 @@ use crate::db::{self, approvals, candidates, CandidateState, *}; use crate::error::{Error, Result}; use crate::time; -/// Why an approval was refused (§7.1a). Rendered as HTTP 409 with the current -/// diff, plus a CLI message. #[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] pub enum Stale { #[error("review is no longer pending (state: {state})")] @@ -12,7 +10,6 @@ pub enum Stale { Identity { expected: String, actual: String }, #[error("the diff changed while you were looking (shown {expected}, now {actual})")] Diff { expected: String, actual: String }, - /// The base moved: a newer version was accepted while the review was open. #[error("a newer version was accepted since this review was opened")] Base { expected: Option, actual: Option }, } @@ -27,24 +24,14 @@ pub struct Approval { pub identity_hash: String, } -/// Why a decision did not happen (§7.1a, §6 M-3). -/// -/// Two families, and the difference is the whole point: `Stale` means the -/// reviewer's screen no longer matches the database, so the answer is to look -/// again; `System` means the database itself refused, and looking again changes -/// nothing. #[derive(Debug, thiserror::Error)] pub enum ApproveError { - /// What is stored is not what was displayed. #[error(transparent)] Stale(#[from] Stale), - /// The write itself failed; nothing about the review is at fault. #[error("the decision could not be recorded: {0}")] System(#[from] Error), } -/// Approve a candidate. Returns the approval row on success, or the reason the -/// approval was refused. pub fn approve( db: &Db, actor: &str, @@ -75,7 +62,6 @@ pub fn approve( if subject.diff_digest != dd { return Ok(Err(ApproveError::Stale(Stale::Diff { expected: dd.clone(), actual: subject.diff_digest }))); } - // Base is still the accepted release (I2, end to end). if base != current_base { return Ok(Err(ApproveError::Stale(Stale::Base { expected: base, actual: current_base }))); } @@ -114,12 +100,9 @@ pub fn approve( identity_hash: ih, })) }) - // A failed transaction is a system failure, never a stale review. .map_err(ApproveError::System)? } -/// Reject a candidate. Rejection is remembered per identity so the watcher stops -/// nagging about the same version (§7.1), and can be re-opened later. pub fn reject(db: &Db, actor: &str, candidate_id: i64, note: &str) -> Result<()> { let actor = actor.to_string(); let note = note.to_string(); @@ -149,11 +132,8 @@ pub fn reject(db: &Db, actor: &str, candidate_id: i64, note: &str) -> Result<()> }) } -/// One item of a bulk decision, and what happened to it (§7.4). #[derive(Debug)] pub struct BulkItem { - /// `None` when the id matched nothing — which a caller must be able to - /// report, so the row cannot be the key. pub candidate: Option, pub outcome: BulkOutcome, } @@ -164,47 +144,31 @@ impl BulkItem { } } -/// What a bulk decision did with one item (§7.4). #[derive(Debug)] pub enum BulkOutcome { - /// Approved; the approval row is here so the caller can queue the build. Approved(Approval), - /// A rejection records no approval, so there is no row to hand back. Rejected, - /// Not decided, and why. Refused(BulkRefusal), } -/// Why a bulk decision skipped one of its items (§7.4). Each reason is its own -/// variant because they are different answers to give a human. #[derive(Debug, thiserror::Error)] pub enum BulkRefusal { - /// High-risk items need their own confirmation, per item (§7.4). #[error("high risk: confirm it individually")] HighRiskUnconfirmed, - /// The form said neither approve nor reject. #[error("unknown decision `{0}`")] UnknownDecision(String), - /// The review is gone — deleted, or never existed. #[error("no such review")] NotFound, - /// The review no longer matches what was displayed. #[error(transparent)] Stale(Stale), - /// The write itself failed. #[error("{0}")] System(Error), } -/// §7.4 bulk decision. High-risk items are refused unless confirmed -/// individually, and one refused item never rolls back the ones that were -/// decided. `items` carries the identity and diff each review was displayed -/// with, so the approval-echo rule applies to bulk exactly as to a single -/// approval. pub fn bulk( db: &Db, actor: &str, - items: &[(i64, String, String)], // (candidate_id, identity_hash, diff_digest) + items: &[(i64, String, String)], decision: &str, confirmed: &[i64], ) -> Result> { @@ -240,8 +204,6 @@ pub fn approval_for(db: &Db, candidate_id: i64) -> Result> approvals::for_candidate(db, candidate_id) } -/// Withdraw a published release (§9 `repo-remove` path, decision 23: warns, -/// does not block). pub fn withdraw(db: &Db, actor: &str, release_id: i64, reason: &str) -> Result<()> { let actor = actor.to_string(); let reason = reason.to_string(); diff --git a/src/review/candidates.rs b/src/review/candidates.rs index d4c49e8..53361fe 100644 --- a/src/review/candidates.rs +++ b/src/review/candidates.rs @@ -8,23 +8,13 @@ pub use crate::db::candidates::{ #[derive(Debug, Clone, PartialEq, Eq)] pub enum Upsert { - /// A new review row was opened. Created { id: i64, kind: String }, - /// The open review was updated in place; no new row, `base` untouched (I7). Collapsed { id: i64, revision: i64 }, - /// A human had already seen the old diff, so it was frozen as `superseded` - /// and a fresh review opened (decision 8). Superseded { old: i64, new: i64 }, - /// This exact identity was rejected before; do not nag (§7.1). PreviouslyRejected, - /// Nothing changed relative to what is already recorded. Unchanged, } -/// Insert-or-collapse a candidate for `pb`. -/// -/// `accepted` is the pkgbase's current accepted release, or `None` when this is -/// a first introduction (§7.1b). pub fn upsert_candidate(db: &Db, pb: &Pkgbase, accepted: Option<&ReleaseRow>, nc: &NewCandidate) -> Result { let kind = if accepted.is_some() { db::candidate_kind::NEW_VERSION } else { db::candidate_kind::FIRST_INTRODUCTION }; let base = accepted.map(|a| a.id); @@ -40,14 +30,11 @@ pub fn upsert_candidate(db: &Db, pb: &Pkgbase, accepted: Option<&ReleaseRow>, nc let revision = sql::collapse_in(tx, &open, &nc)?; return Ok(Upsert::Collapsed { id: open.id, revision }); } - // A human saw the old diff: freeze it for the audit trail and open - // a fresh review against the same base. sql::supersede_in(tx, open.id)?; let new_id = sql::insert_in(tx, pkgbase_id, base, kind, &nc)?; return Ok(Upsert::Superseded { old: open.id, new: new_id }); } - // A previously rejected identity must not be re-raised. if sql::rejected_before_in(tx, pkgbase_id, &nc.identity_hash)? { return Ok(Upsert::PreviouslyRejected); } diff --git a/src/review/diff.rs b/src/review/diff.rs index 519d9ae..42467f0 100644 --- a/src/review/diff.rs +++ b/src/review/diff.rs @@ -7,11 +7,9 @@ use crate::git; pub struct Panel { pub name: &'static str, pub title: &'static str, - /// Unified-diff text, or a readable rendering for panels that are not diffs. pub body: String, } -/// Everything a reviewer needs for one candidate. pub fn panels(cfg: &Config, db: &Db, c: &CandidateRow, base: Option<&ReleaseRow>) -> Result> { let mut out = Vec::new(); let snap = db::snapshot_by_id(db, c.snapshot_id)?; @@ -44,8 +42,6 @@ pub fn panels(cfg: &Config, db: &Db, c: &CandidateRow, base: Option<&ReleaseRow> out.push(install_delta(old, new)); } } else { - // §7.1b first_introduction: no diff pane. The full recipe is rendered - // readably instead, by the template. out.push(Panel { name: "recipe_full", title: "Full recipe", @@ -57,7 +53,6 @@ pub fn panels(cfg: &Config, db: &Db, c: &CandidateRow, base: Option<&ReleaseRow> Ok(out) } -/// The recipe a candidate recorded, if we kept the snapshot. fn recipe_of(db: &Db, snapshot_id: Option) -> Option { let id = snapshot_id?; let snap = db::snapshot_by_id(db, id).ok().flatten()?; @@ -68,8 +63,6 @@ fn candidate_snapshot_id(db: &Db, candidate_id: i64) -> Option { db::candidate_snapshot_id(db, candidate_id).ok().flatten() } -/// `source=()` entries added, removed, or moved to a different host (§6). A new -/// host is the classic supply-chain shape and must be impossible to miss. fn source_delta(old: &Recipe, new: &Recipe) -> Panel { let mut body = String::new(); for s in &new.source { @@ -90,7 +83,6 @@ fn source_delta(old: &Recipe, new: &Recipe) -> Panel { for h in old_hosts.difference(&new_hosts) { body.push_str(&format!("! source host gone: {h}\n")); } - // A declared checksum that became SKIP is a weakening, not a change. for (i, sum) in new.sha256sums.iter().enumerate() { if sum.eq_ignore_ascii_case("SKIP") { match old.sha256sums.get(i) { @@ -110,8 +102,6 @@ fn source_delta(old: &Recipe, new: &Recipe) -> Panel { Panel { name: "sources", title: "Source delta", body } } -/// Dependency changes, resolved against our own index where we can say what it -/// means: "this will pull in a package we have never published". fn dependency_delta(old: &Recipe, new: &Recipe) -> Panel { let mut body = String::new(); for (label, o, n) in [ @@ -137,7 +127,6 @@ fn dependency_delta(old: &Recipe, new: &Recipe) -> Panel { Panel { name: "deps", title: "Dependency delta", body } } -/// Everything that changes *how* it is built rather than what is built. fn build_env_delta(old: &Recipe, new: &Recipe) -> Panel { let mut body = String::new(); for o in &new.options { @@ -174,7 +163,6 @@ fn build_env_delta(old: &Recipe, new: &Recipe) -> Panel { Panel { name: "buildenv", title: "Build-env delta", body } } -/// `.install` hooks are arbitrary code that runs on every consumer machine. fn install_delta(old: &Recipe, new: &Recipe) -> Panel { let mut body = String::new(); match (&old.install, &new.install) { @@ -184,9 +172,6 @@ fn install_delta(old: &Recipe, new: &Recipe) -> Panel { _ => {} } 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 } @@ -269,7 +254,6 @@ fn short(s: &str) -> String { if s.len() > 12 { s[..12].to_string() } else { s.to_string() } } -/// Flatten the rendered panels into one canonical string. pub fn render_text(ps: &[Panel]) -> String { let mut s = String::new(); for p in ps { @@ -278,12 +262,10 @@ pub fn render_text(ps: &[Panel]) -> String { s } -/// `diff_digest`: hash of the exact rendered diff the human was shown (§7.2). pub fn diff_digest(ps: &[Panel]) -> String { crate::hash::hex_str(&render_text(ps)) } -/// The recipe text a reviewer reads for a first introduction (§7.1b). pub fn full_recipe_text(db: &Db, c: &CandidateRow) -> Result { let snap = db::snapshot_by_id(db, c.snapshot_id)?; let snap = snap.ok_or_else(|| crate::error::Error::not_found("snapshot missing"))?; @@ -291,9 +273,6 @@ pub fn full_recipe_text(db: &Db, c: &CandidateRow) -> Result { Ok(r.pkgbuild) } -/// Render the panels, store the resulting `diff_digest` on the candidate, and -/// hand it back. The approve POST must echo this value, which is what makes -/// "we build exactly what was displayed" checkable (§7.1a). pub fn render_and_store(db: &Db, cfg: &Config, c: &CandidateRow) -> Result { let base = match c.base_release_id { Some(id) => db::release_by_id(db, id)?, @@ -305,7 +284,6 @@ pub fn render_and_store(db: &Db, cfg: &Config, c: &CandidateRow) -> Result Result<(String, String)> { let base = match c.base_release_id { Some(id) => db::release_by_id(db, id)?, diff --git a/src/review/risk.rs b/src/review/risk.rs index 3b483cf..f33f9e0 100644 --- a/src/review/risk.rs +++ b/src/review/risk.rs @@ -8,12 +8,8 @@ pub mod level { pub const HIGH: &str = "high"; } -/// A build tool in `makedepends` means the build can fetch and compile anything -/// (§16: we do not sandbox the network in v0, so the reviewer should see it). const FETCHING_BUILD_TOOLS: &[&str] = &["cargo", "npm", "go", "pip", "python", "ruby", "deno", "rust", "nodejs"]; -/// Files whose presence in an upstream commit range means the build itself -/// changed, not just the code. const BUILD_SYSTEM_FILES: &[&str] = &[ "Cargo.toml", "Cargo.lock", "package.json", "setup.py", "pyproject.toml", "Makefile", "CMakeLists.txt", "meson.build", "go.mod", "Gemfile", "build.gradle", @@ -31,8 +27,6 @@ impl Assessment { } } -/// Score a candidate against the release it would replace. `None` accepted -/// means a first introduction, which is its own kind of review (§7.1b). pub fn assess( db: &Db, cfg: &crate::config::Config, @@ -54,7 +48,6 @@ pub fn assess( } } - // Things only visible from the recipe itself. if new.skipgpcheck { s.add("skippgpcheck", level::HIGH); } @@ -67,8 +60,6 @@ pub fn assess( } } if new.install.is_some() { - // An `.install` script is arbitrary code that runs on every consumer - // machine at install time. s.add("install-script", level::HIGH); } for opt in &new.options { @@ -77,8 +68,6 @@ pub fn assess( } } - // Upstream movement that touches the build system (§6): the diff is in a - // language ecosystem we cannot inspect, so say so. if let Some(a) = accepted { for pin in accepted_pins(accepted) { if let Some(old_pin) = a.pins().into_iter().find(|p| p.index == pin.index) { @@ -101,7 +90,6 @@ fn accepted_pins(accepted: Option<&ReleaseRow>) -> Vec { } fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) { - // Version deltas. if new.epoch != old.epoch && pkgver::vercmp(&new.epoch, &old.epoch) == std::cmp::Ordering::Greater { s.add("epoch-bump", level::MEDIUM); } @@ -111,7 +99,6 @@ fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) { if pkgver::is_downgrade(&old.pkgver, &new.pkgver) { s.add("downgrade", level::MEDIUM); } - // Sources: added/removed entries and host changes. let old_hosts = crate::urlutil::hosts(&old.source); let new_hosts = crate::urlutil::hosts(&new.source); for h in &new_hosts { @@ -122,7 +109,6 @@ fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) { if new.source.len() != old.source.len() { s.add("source-set-changed", level::MEDIUM); } - // Checksums weakening: a sum that existed and is now SKIP. for (i, sum) in new.sha256sums.iter().enumerate() { if sum.eq_ignore_ascii_case("SKIP") { match old.sha256sums.get(i) { @@ -136,7 +122,6 @@ fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) { if !old.validpgpkeys.is_empty() && new.validpgpkeys.is_empty() { s.add("validpgpkeys-removed", level::HIGH); } - // Dependencies. let old_md: std::collections::BTreeSet = pkgver::dep_names(&old.makedepends).into_iter().collect(); for md in pkgver::dep_names(&new.makedepends) { if !old_md.contains(&md) { @@ -146,10 +131,8 @@ fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) { let old_cd: std::collections::BTreeSet = pkgver::dep_names(&old.checkdepends).into_iter().collect(); let new_cd: std::collections::BTreeSet = pkgver::dep_names(&new.checkdepends).into_iter().collect(); if !old_cd.is_empty() && new_cd.is_empty() { - // Tests silently stopped running. s.add("checkdepends-removed", level::MEDIUM); } - // Did the executable part of the recipe change, or only metadata? if crate::recipe::bodies_changed(&old.pkgbuild, &new.pkgbuild) { s.add("recipe-code-changed", level::HIGH); } @@ -158,9 +141,6 @@ fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) { } } -/// Digest comparison. Drift with no version change is an `integrity_alert` -/// (§5.3) and never reaches here as a review, so anything that *does* show up -/// alongside a version change is still worth saying. fn compare_digests( _old: &Recipe, _new: &Recipe, @@ -178,9 +158,7 @@ fn compare_digests( } } - fn upstream_touches_build_system(cfg: &crate::config::Config, from: &str, to: &str) -> bool { - // Best-effort: if we have the upstream clone cached we can ask it directly. let cache = cfg.vcs_cache_dir(); if !cache.exists() { return false; @@ -197,7 +175,6 @@ fn upstream_touches_build_system(cfg: &crate::config::Config, from: &str, to: &s false } -/// Accumulator that keeps the highest level seen and de-duplicates signals. #[derive(Debug, Default)] struct SignalSet { level: String, -- cgit v1.2.3