diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 07:29:07 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 07:29:07 +0000 |
| commit | 04b40812f3366c71bf1c99779f880cc74b7f9efa (patch) | |
| tree | 79586843b34b5a1cf703e18f2b5a35dd6814e9d6 /src/watch/detect.rs | |
| parent | 0b3cb443e70b46ec61455255c3ddfc2a26997613 (diff) | |
| download | aur-build-04b40812f3366c71bf1c99779f880cc74b7f9efa.tar.gz aur-build-04b40812f3366c71bf1c99779f880cc74b7f9efa.zip | |
review: advisory risk scoring and non-publishable change handling (§6, §5.3, I11)
Every candidate is scored against the recipe the accepted release was
actually built from (release -> candidate -> snapshot), never against
'last seen'. Signals: SKIP on a non-VCS source, a sum changed to SKIP,
new source host, --skippgpcheck, removed validpgpkeys, new makedepends
and fetching build tools (cargo/npm/go/pip), .install scripts, weakened
options, removed checkdepends, pkgrel reset, epoch bump, downgrade, a
diff touching build()/package() bodies rather than metadata, upstream
ranges that touch a build-system file, and first introduction. Advisory
only — there is no auto-approval, so a wrong score costs attention and
never safety (§7.3).
Fixes a fixture bug the new tests exposed: digest-drift and
skip-checksum declared bare paths as sources, which parse as local
recipe files rather than remote downloads, so the drift path never
fired. They now use file:// URLs like a real remote would.
tests/notices.rs: integrity_alert is high severity and leaves no
candidate, pin_drift is informational, recipe drift under a static
version is a warning, SKIP-on-non-VCS is a high risk signal, repeated
polling of one drift is one notice, and an I11 sweep over twelve
fixtures proving a change is never silently dropped.
Diffstat (limited to 'src/watch/detect.rs')
| -rw-r--r-- | src/watch/detect.rs | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/watch/detect.rs b/src/watch/detect.rs index d5f5c46..084052f 100644 --- a/src/watch/detect.rs +++ b/src/watch/detect.rs @@ -184,10 +184,9 @@ 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. - return match upsert_candidate(db, pb, None, &nc)? { - Upsert::Created { id, kind } => Ok(report(Outcome::Candidate { id, kind })), - other => Ok(report(outcome_of(other))), - }; + 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. @@ -221,9 +220,34 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor } let up = upsert_candidate(db, pb, Some(&base), &nc)?; + score(db, cfg, pb, &recipe, &digests, Some(&base), candidate_id_of(&up)); Ok(report(outcome_of(up))) } +fn candidate_id_of(up: &Upsert) -> Option<i64> { + match up { + Upsert::Created { id, .. } | Upsert::Collapsed { id, .. } | Upsert::Superseded { new: id, .. } => Some(*id), + Upsert::PreviouslyRejected | Upsert::Unchanged => None, + } +} + +/// 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, + pb: &Pkgbase, + recipe: &Recipe, + digests: &[SourceDigest], + accepted: Option<&ReleaseRow>, + candidate_id: Option<i64>, +) { + let Some(id) = candidate_id else { return }; + if let Ok(a) = crate::review::risk::assess(db, cfg, pb, recipe, digests, accepted) { + let _ = crate::review::candidates::set_risk(db, id, &a.level, &a.signals); + } +} + fn outcome_of(up: Upsert) -> Outcome { match up { Upsert::Created { id, kind } => Outcome::Candidate { id, kind }, |
