summaryrefslogtreecommitdiffstats
path: root/tests/production_surface.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-18 17:25:41 +0000
committeraur-build <aur-build@localhost>2026-11-18 17:25:41 +0000
commitf3e4c1496d2ddcdae535132427fdb499181f1695 (patch)
treeca1c9cb5e66caa7b9542aebb38811725b98c6f46 /tests/production_surface.rs
parent8bb76cb266a2fef5d5fe43c0f9643101f59112aa (diff)
downloadaur-build-f3e4c1496d2ddcdae535132427fdb499181f1695.tar.gz
aur-build-f3e4c1496d2ddcdae535132427fdb499181f1695.zip
review: one host rule, one body rule, one audit constructor
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.
Diffstat (limited to 'tests/production_surface.rs')
-rw-r--r--tests/production_surface.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/production_surface.rs b/tests/production_surface.rs
index 26f50ea..e978a2c 100644
--- a/tests/production_surface.rs
+++ b/tests/production_surface.rs
@@ -159,3 +159,33 @@ fn a_default_config_has_no_hooks_attached() {
let json = serde_json::to_string(&cfg).unwrap();
assert!(!json.contains("publish_fault"), "hooks leaked into the serialized config: {json}");
}
+
+#[test]
+fn the_review_modules_do_not_keep_private_copies_of_the_rules() {
+ // §6 m-2: `hosts` existed twice, verbatim, and the "did the executable part
+ // of the recipe change" rule existed twice with *different* semantics — the
+ // diff panel compared function header lines, the risk scorer compared the
+ // bodies. One question, one answer, in the module that owns the subject.
+ for (file, forbidden) in [
+ ("src/review/diff.rs", ["fn hosts(", "fn body_changed("]),
+ ("src/review/risk.rs", ["fn hosts(", "fn body_changed("]),
+ ] {
+ let src = read(file);
+ for f in forbidden {
+ assert!(!src.contains(f), "{file} still defines {f} — use recipe::bodies_changed / urlutil::hosts");
+ }
+ }
+ assert!(read("src/review/diff.rs").contains("urlutil::hosts"));
+ assert!(read("src/review/risk.rs").contains("urlutil::hosts"));
+ assert!(read("src/review/diff.rs").contains("recipe::bodies_changed"));
+ assert!(read("src/review/risk.rs").contains("recipe::bodies_changed"));
+}
+
+#[test]
+fn audit_rows_are_built_by_the_constructors_not_by_hand() {
+ // §6 m-4: three review sites hand-built `AuditEntry` literals, each with its
+ // own `detail` shape and its own spelling of `actor_kind`.
+ let src = read("src/review/approve.rs");
+ assert!(!src.contains("db::AuditEntry {"), "audit rows must be built by AuditEntry::human/system");
+ assert_eq!(src.matches("AuditEntry::human(").count(), 3, "approve, reject and withdraw");
+}