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/approve.rs | 54 +++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/review/approve.rs') diff --git a/src/review/approve.rs b/src/review/approve.rs index 208e8e2..e5f446f 100644 --- a/src/review/approve.rs +++ b/src/review/approve.rs @@ -110,15 +110,14 @@ pub fn approve( candidates::resolve_in(tx, id, CandidateState::Approved, &at)?; db::audit_in( tx, - &db::AuditEntry { - at: &at, - actor_kind: "human", - actor: &actor, - action: "approve", - entity: "candidate", - entity_id: &id.to_string(), - detail: serde_json::json!({"approval": approval_id, "identity": ih, "pkgbase_id": subject.pkgbase_id}), - }, + &db::AuditEntry::human( + &at, + &actor, + "approve", + "candidate", + &id.to_string(), + serde_json::json!({"approval": approval_id, "identity": ih, "pkgbase_id": subject.pkgbase_id}), + ), )?; Ok(Ok(Approval { id: approval_id, @@ -151,15 +150,17 @@ pub fn reject(db: &Db, actor: &str, candidate_id: i64, note: &str) -> Result<()> candidates::resolve_in(tx, candidate_id, CandidateState::Rejected, &at)?; db::audit_in( tx, - &db::AuditEntry { - at: &at, - actor_kind: "human", - actor: &actor, - action: "reject", - entity: "candidate", - entity_id: &candidate_id.to_string(), - detail: serde_json::json!({"note": note}), - }, + &db::AuditEntry::human( + &at, + &actor, + "reject", + "candidate", + &candidate_id.to_string(), + // The identity hash, not only the note: "why was this rejected" + // is unanswerable if the row does not say which bytes were on + // screen (§11). + serde_json::json!({"identity": identity, "note": note}), + ), )?; Ok(()) }) @@ -276,15 +277,14 @@ pub fn withdraw(db: &Db, actor: &str, release_id: i64, reason: &str) -> Result<( db::withdraw_release_in(tx, release_id)?; db::audit_in( tx, - &db::AuditEntry { - at: &at, - actor_kind: "human", - actor: &actor, - action: "withdraw", - entity: "release", - entity_id: &release_id.to_string(), - detail: serde_json::json!({"reason": reason}), - }, + &db::AuditEntry::human( + &at, + &actor, + "withdraw", + "release", + &release_id.to_string(), + serde_json::json!({"release": release_id, "reason": reason}), + ), )?; Ok(()) }) -- cgit v1.2.3