diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 18:34:16 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 18:34:16 +0000 |
| commit | 1abce8ba992353bca3d7b64b2633a15136e9303b (patch) | |
| tree | c265088f9968e1e540402a155d08a5b16c59fac0 /src/pipeline | |
| parent | fdd004c50de6131be193044ae40424d691425a81 (diff) | |
| download | aur-build-1abce8ba992353bca3d7b64b2633a15136e9303b.tar.gz aur-build-1abce8ba992353bca3d7b64b2633a15136e9303b.zip | |
pipeline, watch: a source identity that is complete when it exists
n-1. `SourceIdentity::from_candidate` returned a value with `aur_commit` and
`recipe_hash` set to empty strings, which `Ctx::new` overwrote afterwards if it
found the snapshot row. So the type had two meanings for "" — not filled in yet,
and genuinely absent — and the second half of the construction was a convention
rather than a requirement: a new call site could produce a build that recorded
empty provenance and never noticed. The snapshot is an argument now, a candidate
without its snapshot is an error rather than a quieter build, and the field
`identity_hash`, which nothing ever read, is gone.
n-2. `detect::Outcome` mirrors four of `candidates::Upsert`'s variants. Kept,
with the reason in the code: `Upsert` answers "what did the candidate write do"
and `Outcome` answers "what should the watcher do next", including the outcomes
that never reach the candidate table (paused, gone, blocked, notice). Merging
them would move watcher concerns into the review module and put storage
vocabulary in the scheduler's matches. The converter is total and
compiler-checked, which is what makes the mirror safe.
Diffstat (limited to 'src/pipeline')
| -rw-r--r-- | src/pipeline/mod.rs | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs index 20648c0..bd37258 100644 --- a/src/pipeline/mod.rs +++ b/src/pipeline/mod.rs @@ -14,6 +14,7 @@ use std::path::PathBuf; use crate::config::Config; use crate::db::{self, builds, Db, Pkgbase}; use crate::db::model::*; +use crate::db::SnapshotRow; use crate::error::{Error, Result}; /// The approved source identity a build must reproduce. @@ -30,20 +31,27 @@ pub struct SourceIdentity { pub epoch: String, pub pkgver: String, pub pkgrel: String, - pub identity_hash: String, } impl SourceIdentity { - pub fn from_candidate(c: &CandidateRow) -> Self { + /// The identity of a build's source, complete on construction (n-1). + /// + /// This used to return a value with `aur_commit` and `recipe_hash` left + /// empty, which `Ctx::new` filled in afterwards if it happened to find the + /// snapshot row — so a `SourceIdentity` was a type whose empty strings could + /// mean either "not filled in yet" or "genuinely unknown", and a new call + /// site that forgot the second half produced a build that silently recorded + /// an empty provenance. The snapshot is an argument now: you cannot build one + /// without it. + pub fn from_candidate(c: &CandidateRow, snapshot: &SnapshotRow) -> Self { Self { - aur_commit: String::new(), - recipe_hash: String::new(), + aur_commit: snapshot.aur_commit.clone(), + recipe_hash: snapshot.recipe_hash.clone(), upstream_pins_json: c.upstream_pins_json.clone(), source_digests_json: c.source_digests_json.clone(), epoch: c.epoch.clone(), pkgver: c.pkgver.clone(), pkgrel: c.pkgrel.clone(), - identity_hash: c.identity_hash.clone(), } } pub fn from_release(r: &ReleaseRow) -> Self { @@ -55,7 +63,6 @@ impl SourceIdentity { epoch: r.epoch.clone(), pkgver: r.pkgver.clone(), pkgrel: r.pkgrel.clone(), - identity_hash: String::new(), } } pub fn version(&self) -> String { @@ -125,12 +132,12 @@ impl Ctx { Some(cid) => { let c = crate::review::candidates::candidate_by_id(db, cid)? .ok_or_else(|| Error::not_found("candidate for build"))?; - let mut si = SourceIdentity::from_candidate(&c); - if let Some(s) = db::snapshot_by_id(db, c.snapshot_id)? { - si.aur_commit = s.aur_commit; - si.recipe_hash = s.recipe_hash; - } - si + // A candidate without its snapshot is a broken row, not a + // candidate with less provenance: say so rather than build + // against an empty commit and hash. + let snap = db::snapshot_by_id(db, c.snapshot_id)? + .ok_or_else(|| Error::not_found("snapshot for candidate"))?; + SourceIdentity::from_candidate(&c, &snap) } None => { let rid = build |
