summaryrefslogtreecommitdiffstats
path: root/src/watch/staleness.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-18 08:23:14 +0000
committeraur-build <aur-build@localhost>2026-11-18 08:23:14 +0000
commiteefbefed9cbea6b2edef65900fbe6cb6da0b48e4 (patch)
tree1249788a49812fc15b644687af7c1384f94ba236 /src/watch/staleness.rs
parenta6b652985f40cf022d6c522415c36fad13bc663d (diff)
downloadaur-build-eefbefed9cbea6b2edef65900fbe6cb6da0b48e4.tar.gz
aur-build-eefbefed9cbea6b2edef65900fbe6cb6da0b48e4.zip
http: surfaces driven by live state — staleness, downgrades, deps, rebuild (I6)
Attention, the package page and the builds page now answer real questions instead of rendering empty tables: - Attention lists outdated dependencies derived from the recorded world snapshots, naming the dependency that moved, what the artifact was built against and what the index holds now; also missing dependencies and downgrades (AUR offering a lower version than we serve), which is an announcement for a human, not a build request. - The package page shows depends-on from the recipe we actually serve and needed-by from the packages whose recipes name it, plus staleness and the aur_commit timeline, each release linking into cgit at that exact commit. - Builds rows carry the version they are about, in both the live and the recently-finished table. - A manual rebuild reuses the approved source identity and mints no approval (I6); the test asserts the approval count is unchanged before and after the rebuild runs. - A paused subscription is not observed at all: detection returns Paused without polling, so pausing a broken package stops it opening reviews. - Staleness stays computed on read (§10.2). Nothing stores a stale flag, so nothing can serve a stale lie. Also: dep-client fixture added for dependency pairs.
Diffstat (limited to 'src/watch/staleness.rs')
-rw-r--r--src/watch/staleness.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/watch/staleness.rs b/src/watch/staleness.rs
index 40bafeb..210632e 100644
--- a/src/watch/staleness.rs
+++ b/src/watch/staleness.rs
@@ -86,6 +86,48 @@ pub fn stale_for(db: &Db, pkgbase: &str) -> Result<Vec<Stale>> {
Ok(stale_rows(db)?.into_iter().filter(|s| s.pkgbase == pkgbase).collect())
}
+/// AUR now offers a **lower** version than we serve (§10.2). This is not a
+/// build request; it is an announcement that the mirror and the upstream have
+/// disagreed, and someone has to decide which one consumers follow.
+///
+/// Derived on read from the newest candidate per pkgbase against the accepted
+/// release, so it disappears the moment either side moves.
+pub fn downgrades(db: &Db) -> Result<Vec<Stale>> {
+ let rows: Vec<(String, String, String)> = db.read(|c| {
+ let mut st = c.prepare(
+ "SELECT p.name, r.pkgver, (
+ SELECT c.pkgver FROM candidate c
+ WHERE c.pkgbase_id = r.pkgbase_id
+ ORDER BY c.id DESC LIMIT 1)
+ FROM release r
+ JOIN pkgbase p ON p.current_accepted_release_id = r.id
+ WHERE r.state = 'published'",
+ )?;
+ let rows = st.query_map([], |r| {
+ Ok((
+ r.get::<_, String>(0)?,
+ r.get::<_, String>(1)?,
+ r.get::<_, Option<String>>(2)?.unwrap_or_default(),
+ ))
+ })?;
+ Ok(rows.filter_map(|r| r.ok()).collect::<Vec<_>>())
+ })?;
+ let mut out = Vec::new();
+ for (pkgbase, served, offered) in rows {
+ if offered.is_empty() || !crate::pkgver::is_downgrade(&served, &offered) {
+ continue;
+ }
+ out.push(Stale {
+ kind: Kind::Outdated,
+ pkgbase: pkgbase.clone(),
+ dependency: "aur".into(),
+ built_with: served,
+ now: offered,
+ });
+ }
+ Ok(out)
+}
+
/// "If I approve this, what goes stale?" — the dependents question (§10.3).
/// A package depends on `name` if `name` appears in its recorded world or in
/// its recipe dependencies.