From 4304b0f336ddba7b4ec6780795059ff2066d105b Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 17:33:17 +0000 Subject: comments: keep only what the code cannot show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stripped every comment that described what an item does, documented its arguments or fields, or cited the design docs (§n, I-n, m-n, decision n). 2247 comments down to 83. What survives: the section dividers that segment the large modules, the secret-handling warnings, the agent wire-frame directions, and the few notes without which the code they attach to reads as redundant, reorderable, or unsound. --- src/ops.rs | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) (limited to 'src/ops.rs') diff --git a/src/ops.rs b/src/ops.rs index 612db78..a40a326 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -5,7 +5,6 @@ use crate::db::{self, Db}; use crate::error::Result; use crate::time; -/// Default number of versions kept per pkgbase (§11 `retention_versions`). pub const DEFAULT_KEEP: usize = 3; #[derive(Debug, Default, Clone)] @@ -17,17 +16,12 @@ pub struct RetentionReport { pub staging_swept: usize, } -/// Everything a metrics scrape reports, computed in one pass over the database. -/// -/// Kept as a struct rather than a string builder so the HTTP handler, the CLI and -/// the tests read the same numbers from the same source. #[derive(Debug, Default, Clone)] pub struct Metrics { pub builds: Vec<(String, i64)>, pub queue_depth: i64, pub oldest_queued_age_secs: i64, pub pending_review: i64, - /// Age of pending candidates in seconds, already sorted, for bucketing. pub review_ages: Vec, pub succeeded: i64, pub failed: i64, @@ -49,9 +43,6 @@ pub struct Metrics { } impl Metrics { - /// Share of recorded builds that published. Reported as 1.0 when nothing has - /// run yet: an alert rule reading 0% success on an empty system pages someone - /// for no reason. pub fn build_success_rate(&self) -> f64 { match self.succeeded + self.failed { 0 => 1.0, @@ -59,9 +50,6 @@ impl Metrics { } } - /// Render in Prometheus text exposition format. Every family is declared with - /// `# HELP` and `# TYPE`, because a scrape that fails validation drops the - /// whole payload. pub fn to_prometheus(&self) -> String { let mut o = String::new(); @@ -79,7 +67,6 @@ impl Metrics { o.push_str(&header("aurbuild_pending_review_candidates", "Reviews waiting on a human — the review debt.")); o.push_str(&format!("aurbuild_pending_review_candidates {}\n", self.pending_review)); - // Not how many reviews are pending, but how stale the pending ones are. o.push_str("# HELP aurbuild_pending_review_age_seconds Histogram of how long pending reviews have waited.\n# TYPE aurbuild_pending_review_age_seconds histogram\n"); for le in [3600i64, 21600, 86400, 259200, 604800] { let n = self.review_ages.iter().filter(|a| **a <= le).count(); @@ -152,7 +139,6 @@ impl Metrics { } } -/// Compute every metric from live state. pub fn metrics(cfg: &Config, db: &Db) -> Result { let mut m = Metrics::default(); let now = time::now(); @@ -195,7 +181,6 @@ pub fn metrics(cfg: &Config, db: &Db) -> Result { Ok(m) } -/// A Prometheus family header. fn header(name: &str, help: &str) -> String { format!("# HELP {name} {help}\n# TYPE {name} gauge\n") } @@ -204,7 +189,6 @@ fn file_len(p: &Path) -> u64 { std::fs::metadata(p).map(|m| m.len()).unwrap_or(0) } -/// `(dir count, total bytes)` under a directory, tolerating concurrent removal. fn staging_usage(root: &Path) -> (usize, u64) { let mut dirs = 0; let mut bytes = 0; @@ -232,9 +216,6 @@ fn dir_bytes(path: &Path) -> u64 { total } -/// Which releases of a pkgbase keep their files, and which lose them. -/// -/// The rule is "newest N, plus anything that would be a lie to evict". pub fn plan_retention(db: &Db, keep: usize) -> Result<(Vec, Vec)> { let keep = keep.max(1); let pkgbases = db::pkgbase_release_pointers(db)?; @@ -243,7 +224,6 @@ pub fn plan_retention(db: &Db, keep: usize) -> Result<(Vec, Vec) let mut evict = Vec::new(); for (pb_id, accepted) in pkgbases { let releases = db::published_release_ids(db, pb_id)?; - // Still in the index? Then it is being served, whatever its age. let serving = db::serving_release_ids(db, pb_id)?; let mut keep_set: std::collections::BTreeSet = serving.iter().cloned().collect(); @@ -269,16 +249,10 @@ pub struct EvictPlan { pub release_id: i64, } -/// Run retention: evict files for releases beyond the keep window, then sweep -/// abandoned staging directories. -/// -/// Files are only removed when no *retained* release still references them: the store -/// is content-addressed. pub fn retention(cfg: &Config, db: &Db, keep: Option) -> Result { let keep = keep.unwrap_or_else(|| db::setting_i64(db, "retention_versions", DEFAULT_KEEP as i64) as usize); let (kept, evict) = plan_retention(db, keep)?; - // Everything still held by a kept release, so we do not evict a shared file. let mut retained_files: std::collections::BTreeSet = std::collections::BTreeSet::new(); for id in &kept { for f in release_files(cfg, db, *id)? { @@ -297,7 +271,6 @@ pub fn retention(cfg: &Config, db: &Db, keep: Option) -> Result) -> Result Result> { let mut out = Vec::new(); for (path, sig, log) in db::release_artifact_paths(db, release_id)? { @@ -350,8 +316,6 @@ pub fn release_files(cfg: &Config, db: &Db, release_id: i64) -> Result Result Result<(usize, u64)> { let root = cfg.staging_dir(); let Ok(entries) = std::fs::read_dir(&root) else { return Ok((0, 0)) }; @@ -385,8 +345,6 @@ pub fn sweep_staging(cfg: &Config, db: &Db, grace_secs: i64) -> Result<(usize, u }; let state = db::builds::get(db, &build_id)?.map(|b| b.state); let abandonable = match &state { - // No build row: staging left over from a crash before the row was - // written. None => true, Some(s) => matches!(s.as_str(), "succeeded" | "failed" | "cancelled"), }; @@ -426,11 +384,6 @@ fn record_run(db: &Db, r: &RetentionReport) -> Result<()> { ) } -/// A consistent snapshot of the database, written to `dest`. -/// -/// `VACUUM INTO` runs on the writer connection so the snapshot cannot interleave with -/// a write, and produces a compacted single file with no WAL. A `cp` of a live WAL -/// database gives a main file and a sidecar log that may not belong to it. pub fn backup(db: &Db, dest: &Path) -> Result { let dest = dest.to_path_buf(); if dest.exists() { @@ -445,8 +398,6 @@ pub fn backup(db: &Db, dest: &Path) -> Result { } } db::backup_to(&db.writer, &dest)?; - // The snapshot must be readable on its own: if it does not open and report - // the same schema version, the backup is a file, not a backup. let version = db::schema_version(&dest) .map_err(|e| crate::error::Error::db(format!("backup unreadable: {e}")))?; if version <= 0 { -- cgit v1.2.3