summaryrefslogtreecommitdiffstats
path: root/tests/invariants.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:33:17 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:33:17 +0000
commit4304b0f336ddba7b4ec6780795059ff2066d105b (patch)
tree10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /tests/invariants.rs
parente757979f1a2afdbe7146066345bb9acd19d3b151 (diff)
downloadaur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz
aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip
comments: keep only what the code cannot show
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.
Diffstat (limited to 'tests/invariants.rs')
-rw-r--r--tests/invariants.rs51
1 files changed, 0 insertions, 51 deletions
diff --git a/tests/invariants.rs b/tests/invariants.rs
index 35f5b1a..d5b3758 100644
--- a/tests/invariants.rs
+++ b/tests/invariants.rs
@@ -6,7 +6,6 @@ use aur_build::review::approve::approve as do_approve;
use aur_build::review::{candidates, diff};
use common::*;
-/// subscribe → detect → render → approve → build → publish, in one call.
fn full_run(env: &Env, name: &str) -> CandidateRow {
aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, name).unwrap();
let c = candidates::pending_candidates(&env.db).unwrap().remove(0);
@@ -35,14 +34,11 @@ fn count(env: &Env, sql: &str) -> i64 {
.unwrap()
}
-/// **I1 — no artifact without an approval.** After a real publish, every entry
-/// in the served index traces back through a release to an approval row.
#[test]
fn i1_every_index_entry_traces_back_to_an_approval() {
let (env, _fx) = env_with_fixture("plain-make");
full_run(&env, "plain-make");
- // The §2 query, verbatim in spirit: index entry → release → approval.
assert_eq!(
count(
&env,
@@ -53,7 +49,6 @@ fn i1_every_index_entry_traces_back_to_an_approval() {
0,
"I1: an index entry exists that no human approved"
);
- // And the reverse direction: nothing was approved and then quietly dropped.
assert_eq!(
count(&env, "SELECT count(*) FROM approval WHERE decision='approved'"),
1
@@ -61,9 +56,6 @@ fn i1_every_index_entry_traces_back_to_an_approval() {
assert_eq!(count(&env, "SELECT count(*) FROM release WHERE approval_id IS NULL"), 0);
}
-/// **I2 — the diff base is the last accepted version, never the last seen one.**
-/// Many detections arrive while nobody is looking; the review still compares against
-/// the accepted release.
#[test]
fn i2_base_is_the_last_accepted_version_after_many_detections() {
let (env, fx) = env_with_fixture("plain-make");
@@ -71,7 +63,6 @@ fn i2_base_is_the_last_accepted_version_after_many_detections() {
let accepted = db::accepted_release(&env.db, "plain-make").unwrap().unwrap();
assert_eq!(accepted.pkgver, "1.0");
- // Five upstream moves with nobody reviewing.
for v in ["1.1", "1.2", "1.3", "1.4", "1.5"] {
fx.bump(&[("pkgver", v)]);
aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap();
@@ -85,7 +76,6 @@ fn i2_base_is_the_last_accepted_version_after_many_detections() {
"I2: the diff base must be the accepted release ({}), not the last seen commit",
accepted.id
);
- // And the rendered diff really compares against it.
let panels = diff::panels(&env.cfg, &env.db, &open[0], Some(&accepted)).unwrap();
let text = diff::render_text(&panels);
assert!(text.contains("1.0"), "diff should show the accepted version: {text}");
@@ -93,8 +83,6 @@ fn i2_base_is_the_last_accepted_version_after_many_detections() {
let _ = c;
}
-/// **I4 — publishing is atomic.** Kill the process mid-publish: the consumer-
-/// visible index is either entirely the old one or entirely the new one.
#[test]
fn i4_kill_mid_publish_leaves_the_old_index_byte_identical() {
let (mut env, fx) = env_with_fixture("plain-make");
@@ -108,7 +96,6 @@ fn i4_kill_mid_publish_leaves_the_old_index_byte_identical() {
let dd = diff::render_and_store(&env.db, &env.cfg, &c).unwrap();
do_approve(&env.db, "tester", c.id, &c.identity_hash, &dd, None).unwrap();
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
- // Die after the new database is rendered to .tmp but before the rename.
env.set_publish_fault("before-rename");
assert!(matches!(
pipeline::run(&env.cfg, &env.db, &id).unwrap(),
@@ -124,13 +111,10 @@ fn i4_kill_mid_publish_leaves_the_old_index_byte_identical() {
query_pairs(&env, "SELECT name, version FROM package WHERE state='in_index'"),
vec![("plain-make".to_string(), "1.0-1".to_string())]
);
- // Recovery re-materializes the index from the DB; it invents nothing.
assert!(publish::reconcile(&env.cfg, &env.db).unwrap() >= 1);
assert_eq!(std::fs::read(&db_file).unwrap(), old_bytes);
}
-/// **I5 — a build resumes at the next incomplete step.** A worker that dies
-/// mid-pipeline does not repeat the expensive work or double-publish.
#[test]
fn i5_resume_after_a_crash_repeats_no_completed_step() {
let (mut env, fx) = env_with_fixture("plain-make");
@@ -152,7 +136,6 @@ fn i5_resume_after_a_crash_repeats_no_completed_step() {
let builds_before = aur_build::shims::called_with(&shim, "makepkg", "");
assert_eq!(builds_before, 2, "one build per attempted publish");
- // "Restart" the worker on the same build row.
env.clear_publish_fault();
match pipeline::run(&env.cfg, &env.db, &id).unwrap() {
pipeline::Outcome::Succeeded { release_id } => assert!(release_id > 0),
@@ -163,16 +146,12 @@ fn i5_resume_after_a_crash_repeats_no_completed_step() {
builds_before,
"I5: resuming re-ran the build step"
);
- // No duplicate side effects: one release row for the version, one artifact.
assert_eq!(count(&env, "SELECT count(*) FROM release WHERE pkgver='2.0'"), 1);
- // Artifacts are content-addressed; what must not happen is the same bytes
- // recorded twice.
assert_eq!(
count(&env, "SELECT count(*) FROM artifact"),
count(&env, "SELECT count(DISTINCT digest) FROM artifact"),
"I5: the resume recorded a duplicate artifact"
);
- // Every step is checkpointed as succeeded or explicitly skipped.
let bad = env
.db
.read(|c| {
@@ -186,8 +165,6 @@ fn i5_resume_after_a_crash_repeats_no_completed_step() {
assert_eq!(bad, 0, "every step reached a terminal state");
}
-/// **I7 — at most one open review per pkgbase.** Enforced by the partial unique
-/// index, not by application politeness.
#[test]
fn i7_the_schema_refuses_a_second_open_review() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -213,8 +190,6 @@ fn i7_the_schema_refuses_a_second_open_review() {
assert_eq!(candidates::pending_candidates(&env.db).unwrap().len(), 1);
}
-/// **I8 — the served index is exactly the set of accepted pointers.** Not a
-/// superset and not a subset. Checked against the files on disk as well as the rows.
#[test]
fn i8_index_equals_the_accepted_pointers() {
let (env, fx) = env_with_fixture("plain-make");
@@ -237,19 +212,15 @@ fn i8_index_equals_the_accepted_pointers() {
assert!(!pointers.is_empty());
assert_eq!(index, pointers, "I8: index and accepted pointers diverge");
- // The superseded version is really gone, not merely hidden.
assert_eq!(
count(&env, "SELECT count(*) FROM package WHERE state='in_index' AND version='1.0-1'"),
0
);
- // And the database file on disk lists the same set.
let db_file = env.cfg.repo_arch_dir().join("aur-build.db.tar.gz");
let names = index_db_names(&db_file);
assert_eq!(names, vec!["plain-make".to_string()]);
}
-/// **I3 — the recipe is pinned to a commit.** Materializing anything other than
-/// the approved tree fails closed before a build runs.
#[test]
fn i3_materialization_fails_closed_on_the_recipe_pin() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -272,7 +243,6 @@ fn i3_materialization_fails_closed_on_the_recipe_pin() {
assert_eq!(count(&env, "SELECT count(*) FROM release"), 0);
}
-/// **I6 — a rebuild never needs a new approval.**
#[test]
fn i6_manual_rebuild_publishes_the_same_version_without_a_new_approval() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -290,10 +260,6 @@ fn i6_manual_rebuild_publishes_the_same_version_without_a_new_approval() {
);
}
-/// n-5: a manual rebuild's identity used to be a hand-rolled
-/// `format!("{commit}|{hash}|manual}")` — a second, incompatible format for the
-/// same concept, with a delimiter that can occur inside the values. It is now
-/// derived through the same canonical-JSON hash as every other identity.
#[test]
fn a_manual_rebuild_is_deterministic_and_its_own_build() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -312,7 +278,6 @@ fn a_manual_rebuild_is_deterministic_and_its_own_build() {
);
}
-/// **I10 — the audit log is append-only**, and every consequential action is in it.
#[test]
fn i10_audit_is_append_only_and_records_the_decisions() {
let (env, _fx) = env_with_fixture("plain-make");
@@ -348,7 +313,6 @@ fn i10_audit_is_append_only_and_records_the_decisions() {
}
}
-/// **I12 — every build records the world it was built against.**
#[test]
fn i12_every_build_records_a_world_snapshot() {
let (env, fx) = env_with_fixture("plain-make");
@@ -383,12 +347,6 @@ fn i12_every_build_records_a_world_snapshot() {
assert!(!members.contains("glibc"), "foreign packages must be filtered out (§10.1)");
}
-// I9 (build isolation) is exercised by the chroot step and the real-chroot tier;
-// I11 (non-publishable change becomes a notice, never a silent drop) is covered
-// by `recipe_drift_under_a_static_version_is_a_notice_not_a_candidate` in
-// tests/detect.rs and gets its full treatment with P1's upstream probes.
-
-/// Read the package names out of a pacman-style database file (gzipped tar).
fn index_db_names(path: &std::path::Path) -> Vec<String> {
let file = std::fs::File::open(path).unwrap();
let mut ar = tar::Archive::new(flate2::read::GzDecoder::new(file));
@@ -406,12 +364,6 @@ fn index_db_names(path: &std::path::Path) -> Vec<String> {
names
}
-/// I9: build hosts are treated as untrusted — a malicious PKGBUILD must not reach
-/// the control plane's data or smuggle foreign bytes into what we publish.
-///
-/// `collect` scans the srcdir for `*.pkg.tar.zst` and `ingest` copies whatever those
-/// paths point at into the store, from where the bytes are served and signed. So the
-/// pipeline refuses symlinks and anything outside the build's own staging directory.
#[test]
fn i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir() {
let (mut env, _fx) = env_with_fixture("plain-make");
@@ -423,7 +375,6 @@ fn i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir() {
let c = candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap();
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
- // Something a build must never get to publish: our own database file.
let secret = env.cfg.db_path();
let store_before = dir_listing(&env.cfg.store_dir());
env.cfg.hooks.shim_plant_link = Some(secret.display().to_string());
@@ -440,7 +391,6 @@ fn i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir() {
"the failure should say why it refused: {err}"
);
- // The refused bytes never reached the store, and nothing was published.
assert_eq!(
dir_listing(&env.cfg.store_dir()),
store_before,
@@ -448,7 +398,6 @@ fn i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir() {
);
assert_eq!(builds::get(&env.db, &id).unwrap().unwrap().state, BuildState::Failed);
assert!(db::index_version(&env.db, "plain-make").unwrap().is_none(), "nothing publishes from a failed build");
- // And the database itself is intact — the build read it, it did not become it.
assert!(secret.exists());
}