summaryrefslogtreecommitdiffstats
path: root/src/watch/detect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/watch/detect.rs')
-rw-r--r--src/watch/detect.rs52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/watch/detect.rs b/src/watch/detect.rs
index de1285e..800c157 100644
--- a/src/watch/detect.rs
+++ b/src/watch/detect.rs
@@ -8,28 +8,16 @@ use crate::time;
use crate::watch::digests::resolve_sources;
use crate::watch::mirror::{read_tree, sync_mirror, Sync};
-/// What one check of one pkgbase resulted in.
-///
-/// Four variants mirror [`Upsert`] deliberately (n-2): `Upsert` answers the storage
-/// question, `Outcome` the watcher's. `outcome_of` is the only place that knows both.
#[derive(Debug, Clone)]
pub enum Outcome {
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).
Collapsed { id: i64, revision: i64 },
- /// The seen-but-unresolved review was frozen and a new one opened.
Superseded { old: i64, new: i64 },
- /// Identical to something a human already rejected.
PreviouslyRejected,
- /// Something changed but nothing is publishable (I11).
Notice { kind: String, detail: serde_json::Value },
- /// The package vanished from AUR.
Gone,
- /// Detection could not complete; the watcher will back off.
Blocked(String),
}
@@ -40,12 +28,9 @@ pub struct CheckReport {
pub outcome: Outcome,
}
-/// One full detection pass for a subscribed pkgbase.
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 must not keep opening
- // reviews nobody will act on, nor keep polling AUR.
let sub = db::get_subscription(db, name)?;;
let paused = sub.as_ref().map(|s| s.state == SubscriptionState::Paused).unwrap_or(false);
if paused {
@@ -64,8 +49,6 @@ pub fn check_pkgbase(cfg: &Config, db: &Db, name: &str) -> Result<CheckReport> {
db::set_subscription_state(&db.writer, name, SubscriptionState::Orphaned)?;
return Ok(CheckReport { pkgbase: name.into(), head: String::new(), outcome: Outcome::Gone });
}
- // The cheap poll saved a fetch, but we still have to look: a source can
- // change its bytes without the recipe moving (§5.3).
Sync::Unchanged { head } => head.clone(),
Sync::Fetched { head, .. } | Sync::Cloned { head } => head.clone(),
};
@@ -74,24 +57,16 @@ pub fn check_pkgbase(cfg: &Config, db: &Db, name: &str) -> Result<CheckReport> {
r
}
-/// When to look at this pkgbase again: its own interval if the subscription
-/// carries one, otherwise the global default. The interval is an argument because
-/// the caller already read the subscription row (m-11).
fn schedule_next(db: &Db, name: &str, poll_interval: Option<i64>) {
let interval = poll_interval.unwrap_or_else(|| crate::db::setting_i64(db, "poll_interval", 86400));
let next = time::secs_ahead(interval);
- // Best-effort: a missed stamp means the scheduler looks again a tick early,
- // not that a change goes unnoticed.
let _ = db::note_check(&db.writer, name, &next, None);
}
-/// Everything after the mirror is up to date.
fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckReport> {
let mirror = cfg.mirror_path(&pb.name);
let report = |outcome: Outcome| CheckReport { pkgbase: pb.name.clone(), head: head.to_string(), outcome };
- // §16 mirror divergence: if the accepted pin has vanished from our own
- // mirror, hard-fail this pkgbase rather than silently re-pinning.
let accepted = crate::review::candidates::accepted_for(db, pb)?;
if let Some(a) = &accepted {
if !crate::git::has_commit(&mirror, &a.aur_commit) {
@@ -113,12 +88,8 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
let recipe = recipe_from_tree(&tree.files)?;
let recipe_hash = tree.recipe_hash();
- // §5.2, the two-stage funnel. Stage A is one `ls-remote` per VCS source and
- // costs no clone; if the tip set is what the accepted release was built from,
- // nothing can have changed and Stage B never runs.
let has_vcs = recipe.source_entries.iter().any(|e| e.is_vcs());
let accepted_pins: Vec<UpstreamPin> = accepted.as_ref().map(|a| a.pins()).unwrap_or_default();
- // A recipe with no VCS sources states its own version.
let stage_a = if has_vcs {
Some(crate::watch::upstream::probe(&recipe, &accepted_pins)?)
} else {
@@ -129,8 +100,6 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
} else if stage_a.as_ref().unwrap().needs_stage_b() {
crate::watch::upstream::resolve(cfg, db, pb, &recipe, &recipe_hash, stage_a.as_ref().unwrap())?
} else {
- // Upstream has not moved; reusing the accepted pins keeps the next pass
- // cheap too.
accepted.as_ref().map(|a| crate::watch::upstream::StageB {
epoch: a.epoch.clone(),
pkgver: a.pkgver.clone(),
@@ -139,8 +108,6 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
cached: true,
})
};
- // For a VCS package the literal `pkgver=` is frozen; the resolved one is the
- // only version a consumer could install.
let (epoch, pkgver, pkgrel, pins) = match &resolved {
Some(r) => (r.epoch.clone(), r.pkgver.clone(), r.pkgrel.clone(), r.pins.clone()),
None => (recipe.epoch.clone(), recipe.pkgver.clone(), recipe.pkgrel.clone(), Vec::new()),
@@ -176,13 +143,11 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
};
let Some(base) = accepted else {
- // §7.1b: nothing to diff against — this is a first introduction.
let up = upsert_candidate(db, pb, None, &nc)?;
score(db, cfg, pb, &recipe, &digests, None, candidate_id_of(&up));
return Ok(report(outcome_of(up)));
};
- // Same identity as what we already serve: nothing happened.
if base.aur_commit == head
&& base.epoch == nc.epoch
&& base.pkgver == nc.pkgver
@@ -197,8 +162,6 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
let publishable = pkgver::vercmp(&base.version(), &new_version) != std::cmp::Ordering::Equal;
if !publishable {
- // §5.2 / §5.3: nothing pacman could offer as an upgrade. Record it
- // loudly instead of inventing a pkgrel bump.
return Ok(report(non_publishable(db, pb, &base, &nc, &recipe)?));
}
@@ -224,8 +187,6 @@ fn candidate_id_of(up: &Upsert) -> Option<i64> {
}
}
-/// Advisory risk scoring (§6). Best-effort: a scoring failure must never lose a
-/// candidate, so this logs rather than propagates.
fn score(
db: &Db,
cfg: &Config,
@@ -239,13 +200,10 @@ fn score(
if let Ok(a) = crate::review::risk::assess(db, cfg, recipe, digests, accepted) {
let _ = crate::review::candidates::set_risk(db, id, &a.level, &a.signals);
}
- // Record now what would block the build later, using the same rule the plan
- // step uses, so a reviewer sees it before approving (§10.4).
let missing = missing_deps(db, pb, recipe);
let _ = crate::review::candidates::set_missing_deps(db, id, &missing);
}
-/// Dependencies that are ours to publish but are not in the index yet.
fn missing_deps(db: &Db, pb: &Pkgbase, recipe: &Recipe) -> Vec<String> {
let ours = match db::our_package_names(db) {
Ok(o) => o,
@@ -278,8 +236,6 @@ fn outcome_of(up: Upsert) -> Outcome {
}
}
-/// The version string did not move, so there is no review to open — but the change
-/// is recorded, because a silently drifting tarball must not be invisible (§5.3).
fn non_publishable(
db: &Db,
pb: &Pkgbase,
@@ -289,9 +245,6 @@ fn non_publishable(
) -> Result<Outcome> {
let old_digests: Vec<SourceDigest> = base.digests();
let new_digests: Vec<SourceDigest> = serde_json::from_str(&nc.source_digests_json).unwrap_or_default();
- // A local source is part of the recipe: when its bytes move, that *is* the
- // recipe drift. A VCS source's digest is its pin, so upstream moving shows up
- // there too, but that is ordinary drift (§5.3).
let vcs_indices: std::collections::BTreeSet<usize> = recipe
.source_entries
.iter()
@@ -312,9 +265,6 @@ fn non_publishable(
let pins_changed = old_pins != new_pins;
if digest_changed {
- // The single most valuable detection in the system: the artifact in the
- // index was built from bytes upstream no longer serves, and the version is
- // unchanged. An approval would be useless, so this is an alert.
let changed: Vec<serde_json::Value> = changed_remote
.iter()
.map(|n| {
@@ -350,8 +300,6 @@ fn non_publishable(
)?;
return Ok(Outcome::Notice { kind: notice_kind::PIN_DRIFT.into(), detail: serde_json::json!({}) });
}
- // The recipe drifted under a static version: the maintainer probably forgot
- // to bump pkgrel, and the user should know.
db::put_notice_once(
&db.writer,
pb.id,