diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 08:23:14 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 08:23:14 +0000 |
| commit | eefbefed9cbea6b2edef65900fbe6cb6da0b48e4 (patch) | |
| tree | 1249788a49812fc15b644687af7c1384f94ba236 /src | |
| parent | a6b652985f40cf022d6c522415c36fad13bc663d (diff) | |
| download | aur-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')
| -rw-r--r-- | src/http/render.rs | 2 | ||||
| -rw-r--r-- | src/http/routes.rs | 76 | ||||
| -rw-r--r-- | src/watch/detect.rs | 12 | ||||
| -rw-r--r-- | src/watch/staleness.rs | 42 |
4 files changed, 113 insertions, 19 deletions
diff --git a/src/http/render.rs b/src/http/render.rs index 2fad5c8..9e3d801 100644 --- a/src/http/render.rs +++ b/src/http/render.rs @@ -211,6 +211,8 @@ pub struct NoticeRow { #[derive(Debug, Clone)] pub struct StaleRow { pub pkgbase: String, + /// The dependency that moved (or `aur` for a downgrade row). + pub dependency: String, pub built_with: String, pub now: String, } diff --git a/src/http/routes.rs b/src/http/routes.rs index 784024d..ab68069 100644 --- a/src/http/routes.rs +++ b/src/http/routes.rs @@ -4,7 +4,7 @@ //! connection — and hands mutations to the writer actor. A slow client can //! therefore never hold the write lock, which is the whole point of the split. -use crate::db::{self, builds, model::*}; +use crate::db::{self, builds, model::*, Db}; use crate::review::{approve as ap, candidates, diff, risk}; use crate::{pipeline, time}; @@ -592,15 +592,19 @@ fn attention(state: &State, req: &Req) -> Res { .iter() .filter(|s| s.kind == crate::watch::staleness::Kind::Outdated) .cloned() - .map(|s| StaleRow { pkgbase: s.pkgbase, built_with: s.built_with, now: s.now }) + .map(|s| StaleRow { pkgbase: s.pkgbase, dependency: s.dependency, built_with: s.built_with, now: s.now }) .collect(); let missing: Vec<StaleRow> = stale .iter() .filter(|s| s.kind == crate::watch::staleness::Kind::Missing) .cloned() - .map(|s| StaleRow { pkgbase: s.pkgbase, built_with: s.built_with, now: s.now }) + .map(|s| StaleRow { pkgbase: s.pkgbase, dependency: s.dependency, built_with: s.built_with, now: s.now }) + .collect(); + let downgrades: Vec<StaleRow> = crate::watch::staleness::downgrades(db) + .unwrap_or_default() + .into_iter() + .map(|s| StaleRow { pkgbase: s.pkgbase, dependency: s.dependency, built_with: s.built_with, now: s.now }) .collect(); - let downgrades: Vec<StaleRow> = Vec::new(); let empty = notices.is_empty() && outdated.is_empty() && missing.is_empty() && blocked.is_empty(); page_to_res( Attention { page, empty, notices, outdated, missing, downgrades, blocked }, @@ -687,6 +691,19 @@ fn package_detail(state: &State, req: &Req, name: &str) -> Res { step: b.current_step.unwrap_or_default(), }) .collect(); + // Depends-on comes from the recipe we actually serve; needed-by comes from + // the packages whose own recipes name this one (§10.3). + let deps_in: Vec<String> = accepted + .as_ref() + .and_then(|r| db::accepted_recipe(db, r).ok().flatten()) + .map(|r| { + let mut v = crate::pkgver::dep_names(&r.depends); + v.sort(); + v.dedup(); + v + }) + .unwrap_or_default(); + let deps_out: Vec<String> = crate::watch::staleness::dependents_of(db, name).unwrap_or_default(); let stale: Vec<String> = crate::watch::staleness::stale_for(db, name) .unwrap_or_default() .into_iter() @@ -703,8 +720,8 @@ fn package_detail(state: &State, req: &Req, name: &str) -> Res { summary, can_withdraw: accepted.is_some(), stale, - deps_in: Vec::new(), - deps_out: Vec::new(), + deps_in, + deps_out, timeline, builds, }, @@ -746,6 +763,22 @@ fn package_withdraw(state: &State, req: &Req, name: &str) -> Res { // --------------------------------------------------------------- builds -- +/// The version a build is about. A build points at a candidate, or — for a +/// manual rebuild of something already published — at a release. +fn build_version(db: &Db, b: &builds::BuildRow) -> String { + if let Some(cid) = b.candidate_id { + if let Some(c) = candidates::candidate_by_id(db, cid).ok().flatten() { + return c.version(); + } + } + if let Some(rid) = b.release_id { + if let Some(r) = db::release_by_id(db, rid).ok().flatten() { + return r.version(); + } + } + String::new() +} + fn build_rows(state: &State) -> Vec<BuildRow> { builds::list( &state.db, @@ -760,11 +793,12 @@ fn build_rows(state: &State) -> Vec<BuildRow> { .flatten() .map(|p| p.name) .unwrap_or_default(); + let version = build_version(&state.db, &b); BuildRow { id_short: short(&b.id), id: b.id, pkgbase, - version: String::new(), + version, kind: b.kind, state: b.state, step: b.current_step.unwrap_or_default(), @@ -785,17 +819,21 @@ fn builds_with(state: &State, _req: &Req, page: Page) -> Res { let recent: Vec<BuildRow> = builds::list(&state.db, &[build_state::FAILED, build_state::SUCCEEDED], 10) .unwrap_or_default() .into_iter() - .map(|b| BuildRow { - id_short: short(&b.id), - id: b.id, - pkgbase: db::get_pkgbase_by_id(&state.db, b.pkgbase_id).ok().flatten().map(|p| p.name).unwrap_or_default(), - version: String::new(), - kind: b.kind, - state: b.state, - step: b.current_step.unwrap_or_default(), - lease: String::new(), - cancel: b.cancel_requested, - error: b.error.unwrap_or_default(), + .map(|b| { + let pkgbase = db::get_pkgbase_by_id(&state.db, b.pkgbase_id).ok().flatten().map(|p| p.name).unwrap_or_default(); + let version = build_version(&state.db, &b); + BuildRow { + id_short: short(&b.id), + id: b.id, + pkgbase, + version, + kind: b.kind, + state: b.state, + step: b.current_step.unwrap_or_default(), + lease: String::new(), + cancel: b.cancel_requested, + error: b.error.unwrap_or_default(), + } }) .collect(); page_to_res(Builds { page, rows: build_rows(state), recent }, 200) @@ -834,7 +872,7 @@ fn build_detail(state: &State, req: &Req, id: &str) -> Res { id: id.to_string(), id_short: short(id), pkgbase, - version: String::new(), + version: build_version(db, &b), kind: b.kind, state: b.state, error: b.error.clone().unwrap_or_default(), diff --git a/src/watch/detect.rs b/src/watch/detect.rs index 084052f..55b7543 100644 --- a/src/watch/detect.rs +++ b/src/watch/detect.rs @@ -20,6 +20,8 @@ use crate::watch::mirror::{read_tree, sync_mirror, Sync}; pub enum Outcome { /// Nothing moved at all. NoChange, + /// The subscription is paused: we look at nothing and change nothing. + Paused, /// A new review was opened. Candidate { id: i64, kind: String }, /// The open review was updated in place (I7). @@ -47,6 +49,16 @@ pub struct CheckReport { pub fn check_pkgbase(cfg: &Config, db: &Db, name: &str) -> Result<CheckReport> { let pb = get_pkgbase(db, name)? .ok_or_else(|| crate::error::Error::not_found(format!("pkgbase {name}")))?; + // A paused subscription is not observed at all. Pausing because a package is + // broken must not keep opening reviews nobody is going to act on, and it + // must not keep polling AUR either. The pause lives on the subscription, so + // that is what we consult. + let paused = db::get_subscription(db, name)? + .map(|s| s.state == subscription_state::PAUSED) + .unwrap_or(false); + if paused { + return Ok(CheckReport { pkgbase: name.into(), head: String::new(), outcome: Outcome::Paused }); + } let sync = sync_mirror(cfg, db, name, &pb.aur_url)?; let head = match &sync { Sync::Gone => { 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. |
