diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 15:59:10 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 15:59:10 +0000 |
| commit | e04152da00f97c5ecc9a3f6dc5217d61274c7907 (patch) | |
| tree | 7d70011f688b2dddaa98804575fc885f61876cf6 /tests/production_surface.rs | |
| parent | 062efa6583b7fea292a4f485659661d266461611 (diff) | |
| download | aur-build-e04152da00f97c5ecc9a3f6dc5217d61274c7907.tar.gz aur-build-e04152da00f97c5ecc9a3f6dc5217d61274c7907.zip | |
pipeline: one lock guards the served index, and it says so once
`publish.rs` had two static mutexes, each documented as *the* "one publish per
repo" guarantee — `PUBLISH_LOCK` taken at the top of `publish()`, `REPO_LOCK`
taken partway through and by `withdraw_package`. Either the second was
redundant or the guarantee was incomplete, and a reader could not tell which,
which is worse than either answer: the comment on `REPO_LOCK` claimed a
single-writer property that its own position in the function did not provide
(artifacts were already staged by then), and the comment on `PUBLISH_LOCK`
claimed it for a section that did not include the rename.
There is one lock now. `REPO_LOCK` is taken at the top of `publish()` and held
for the whole of it — staging, render, DB commit, rename, sign — which is the
sequence that must not interleave, and `withdraw_package` takes the same lock
for the same reason. The poison-recovery rule that belonged to both is stated
once, on the lock. `reconcile` is documented as the one rewriter that does not
take it, because it runs at startup before the dispatcher exists.
M-5 is a clarity defect rather than a live misbehaviour, so the guard is
structural: `tests/production_surface.rs` fails if `publish.rs` declares a
second serialization mutex, if `PUBLISH_LOCK` comes back, or if either index
writer stops taking the one that remains. A timing-based test would have been
the flaky kind and would not have proven anything the I4 and I8 crash tests do
not already prove.
Diffstat (limited to 'tests/production_surface.rs')
| -rw-r--r-- | tests/production_surface.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/production_surface.rs b/tests/production_surface.rs index 1fa855f..5ade95b 100644 --- a/tests/production_surface.rs +++ b/tests/production_surface.rs @@ -58,6 +58,31 @@ fn no_production_module_references_the_shim_harness() { } #[test] +fn the_served_index_has_exactly_one_serialization_lock() { + // §6 M-5: two mutexes in `publish.rs`, each documented as *the* "one publish + // per repo" guarantee, with `withdraw_package` taking only one of them, is + // worse than either answer — a reader cannot tell whether the guarantee is + // redundant or incomplete. There is one lock now, and this keeps it that way. + let src = std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("src/pipeline/publish.rs")) + .expect("read publish.rs"); + let mutexes = src + .lines() + .filter(|l| l.contains("static") && l.contains("Mutex<")) + .collect::<Vec<_>>(); + assert_eq!(mutexes.len(), 1, "publish.rs must declare exactly one serialization mutex, found {mutexes:?}"); + assert!(!src.contains("PUBLISH_LOCK"), "the second lock must stay deleted"); + // And both writers of the served index take it, not just one of them. + let acquisitions = src + .lines() + .filter(|l| l.contains("lock_repo()") && !l.trim_start().starts_with("fn ")) + .count(); + assert!( + acquisitions >= 2, + "publish and withdraw_package must both take the repo lock; found {acquisitions} acquisitions" + ); +} + +#[test] fn the_shim_binaries_are_test_only() { let manifest = std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("Cargo.toml")) .expect("read Cargo.toml"); |
