From 4c143e969dcd7b6a18e5a86f9a754c9b62979ccf Mon Sep 17 00:00:00 2001 From: aur-build Date: Mon, 23 Nov 2026 13:44:20 +0000 Subject: usecase,http,pipeline,ops: keep the contract, drop the argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A workflow's doc now says what it guarantees and stops defending its existence: `subscribe` resolves the repo row, `approve` queues what the approval buys, a per-item failure comes back as a value instead of a panic. The history of which front end used to open-code it is gone. The last census-war notes go with it — three places that explained why a name in a test string was not a caller. --- src/usecase/bootstrap.rs | 19 ++++++------------- src/usecase/builds.rs | 6 +----- src/usecase/detect.rs | 8 ++------ src/usecase/mod.rs | 21 +++------------------ src/usecase/reviews.rs | 29 +++++++++-------------------- src/usecase/subscriptions.rs | 6 +----- 6 files changed, 22 insertions(+), 67 deletions(-) (limited to 'src/usecase') diff --git a/src/usecase/bootstrap.rs b/src/usecase/bootstrap.rs index 6793076..a4e64d2 100644 --- a/src/usecase/bootstrap.rs +++ b/src/usecase/bootstrap.rs @@ -1,5 +1,4 @@ -//! Bringing a repository up, which every command does and every front end -//! used to write out for itself. +//! Bringing a repository up, which every command does. use std::sync::atomic::AtomicBool; use std::sync::Arc; @@ -10,17 +9,13 @@ use crate::error::Result; use crate::pipeline; /// Directories exist, the schema is current, and the repo row is present. -/// -/// Four calls in an order that matters — migrate before open, `ensure_repo` -/// before anything reads `repo_id` — which is precisely the kind of sequence -/// that quietly rots when it is copied. +/// Order matters: migrate before open, `ensure_repo` before anything reads +/// `repo_id`. pub fn open(cfg: &Config) -> Result { open_and_ensure(cfg).map(|(db, _)| db) } -/// `open`, plus the id of the row named by `cfg.repo_name` — which is what -/// `init` prints, and is not necessarily the lowest repo id if a root ever -/// holds more than one repo. +/// `open`, plus the id of the row named by `cfg.repo_name`. fn open_and_ensure(cfg: &Config) -> Result<(Db, i64)> { cfg.ensure_dirs()?; db::migrate(&cfg.db_path())?; @@ -44,10 +39,8 @@ pub fn init(cfg: &Config) -> Result { /// Everything `serve` does before control passes to the UI: bring the /// repository up, finish anything a previous run left half-published, and start -/// the two background loops. -/// -/// The HTTP server is deliberately not started here. This module sits below the -/// UI and must not be able to name it. +/// the two background loops. This module sits below the UI, so it cannot start +/// the HTTP server. pub fn serve(cfg: &Config) -> Result { let db = open(cfg)?; let _ = pipeline::publish::reconcile(cfg, &db); diff --git a/src/usecase/builds.rs b/src/usecase/builds.rs index 265e6cb..152959f 100644 --- a/src/usecase/builds.rs +++ b/src/usecase/builds.rs @@ -22,11 +22,7 @@ pub fn cancel(db: &Db, build_id: &str) -> Result<()> { builds::request_cancel(db, build_id) } -/// Retry a failed build, and record that someone asked. -/// -/// The audit row is part of the workflow rather than the caller's homework: a -/// retry changes what a build means, and a retry nobody asked for is exactly -/// what the audit trail is there to rule out. +/// Retry a failed build, and audit that someone asked. pub fn retry(db: &Db, actor: &str, build_id: &str) -> Result<()> { builds::retry(db, build_id)?; db::audit(&db.writer, actor, actor, "build.retry", "build", build_id, serde_json::json!({})) diff --git a/src/usecase/detect.rs b/src/usecase/detect.rs index 67cc83c..42f98d9 100644 --- a/src/usecase/detect.rs +++ b/src/usecase/detect.rs @@ -5,12 +5,8 @@ use crate::db::{self, Db, SubscriptionState}; use crate::error::Result; use crate::watch::detect::{self, Outcome}; -/// One pkgbase's detection result. -/// -/// Per-item failures are returned rather than raised: a sweep over every -/// subscription should not stop at the first pkgbase whose mirror is -/// unreachable, and the caller decides whether a failure is a line on stderr -/// or a row in a table. +/// One pkgbase's detection result. Per-item failures are returned, not raised, +/// so a sweep does not stop at the first unreachable mirror. pub struct Checked { pub pkgbase: String, pub outcome: Result, diff --git a/src/usecase/mod.rs b/src/usecase/mod.rs index 288d71d..25f745c 100644 --- a/src/usecase/mod.rs +++ b/src/usecase/mod.rs @@ -1,21 +1,6 @@ -//! The workflows themselves — the thing between a front end and the modules. -//! -//! Before this module existed, a workflow had one implementation per front end. -//! `main` opened the repository inline before its command match; `serve` opened -//! it again; the web routes wrote subscriptions and retried builds with their -//! own `db::` calls, so the CLI and the UI could drift and nothing would notice -//! until a reviewer saw one behaviour in the browser and another in the -//! terminal. -//! -//! A function here is a workflow only if more than one step has to happen in a -//! particular order. `subscribe` is a workflow because the repo row has to be -//! resolved first and a first detection may have to follow. `candidate_by_id` -//! is not, and stays where it is. -//! -//! Nothing in here formats output or knows a terminal, a form or a status code -//! exists. Results carry enough structure for each front end to say the same -//! facts in its own voice — which is why `Approved` reports the queueing -//! outcome rather than deciding whether a failed enqueue is fatal. +//! The workflows between a front end and the modules: a function belongs here +//! only when more than one step has to happen in a particular order. Nothing in +//! here formats output or knows a terminal, a form or a status code exists. mod bootstrap; mod builds; diff --git a/src/usecase/reviews.rs b/src/usecase/reviews.rs index 8cbb534..31aa859 100644 --- a/src/usecase/reviews.rs +++ b/src/usecase/reviews.rs @@ -14,11 +14,8 @@ pub struct Prepared { } /// Render the current diff and store its digest, so the approval that follows -/// can be checked against exactly what was shown rather than whatever the tree -/// looked like a moment later. -/// -/// `Ok(None)` means there is no such candidate; each front end says so in its -/// own words. +/// is checked against what was actually shown. `Ok(None)` means no such +/// candidate. pub fn prepare_review(cfg: &Config, db: &Db, candidate_id: i64) -> Result> { let Some(c) = candidates::candidate_by_id(db, candidate_id)? else { return Ok(None); @@ -28,10 +25,8 @@ pub fn prepare_review(cfg: &Config, db: &Db, candidate_id: i64) -> Result