summaryrefslogtreecommitdiffstats
path: root/src/db/candidates.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
commite757979f1a2afdbe7146066345bb9acd19d3b151 (patch)
tree30d5f5fbccd25ea7bf01c5202684af463b74e7d3 /src/db/candidates.rs
parent94c318f13264bb3c00a9f3057ba2e1aafb57c9e4 (diff)
downloadaur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.tar.gz
aur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.zip
comments: say why, not what
Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath.
Diffstat (limited to 'src/db/candidates.rs')
-rw-r--r--src/db/candidates.rs24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/db/candidates.rs b/src/db/candidates.rs
index 63c089f..631bf42 100644
--- a/src/db/candidates.rs
+++ b/src/db/candidates.rs
@@ -1,22 +1,10 @@
-//! The candidate table: its row shape, its column list, and every statement
-//! that touches it (§7.1).
-//!
-//! The *rules* about candidates — collapse into the open review, supersede once
-//! a human has looked, never re-raise a rejection — are domain logic and live
-//! in `review::candidates`. What lives here is SQL, so that the schema has one
-//! owner (§6 M-1). The `_in` functions take a transaction handle so a caller
-//! can compose several of them into one atomic decision; the decision itself
-//! stays with the caller.
-
use rusqlite::{params, OptionalExtension, Row, Transaction};
use crate::db::{CandidateRow, CandidateState, Db};
use crate::error::{Error, Result};
use crate::time;
-/// The columns `row_to_candidate` reads, spelled once. Every other table in
-/// this module already works this way; the candidate select was simply copied
-/// four times for long enough to be noticed (§6 m-3).
+/// The columns `row_to_candidate` reads, spelled once (§6 m-3).
const CANDIDATE_COLS: &str = "c.id, c.pkgbase_id, c.base_release_id, c.kind, c.snapshot_id, c.epoch, c.pkgver, \
c.pkgrel, c.upstream_pins_json, c.source_digests_json, c.identity_hash, c.diff_digest, \
c.revision, c.viewed_at, c.risk_level, c.risk_signals_json, c.missing_deps_json, c.state, \
@@ -130,10 +118,8 @@ pub fn review_subject_in(tx: &Transaction<'_>, candidate_id: i64) -> Result<Opti
/// Take a candidate out of the open state: approved, rejected or superseded.
///
-/// The write is a compare-and-swap on [`CandidateState`]: a decided review is
-/// never re-decided, so an approval racing a rejection — or a stale worker
-/// resolving a review that has since been superseded — fails instead of
-/// silently overwriting what a human did.
+/// The write is a compare-and-swap on [`CandidateState`]: a decided review is never
+/// re-decided, so an approval racing a rejection fails instead of overwriting.
pub fn resolve_in(tx: &Transaction<'_>, id: i64, to: CandidateState, at: &str) -> Result<()> {
let froms = CandidateState::predecessors(to);
let placeholders = froms.iter().map(|_| "?").collect::<Vec<_>>().join(",");
@@ -233,7 +219,7 @@ pub fn supersede_in(tx: &Transaction<'_>, id: i64) -> Result<()> {
}
/// Has this exact identity been rejected before? If so the watcher stays quiet
-/// until a human re-opens it (§7.1: "do not nag").
+/// until a human re-opens it (§7.1).
pub fn rejected_before_in(tx: &Transaction<'_>, pkgbase_id: i64, identity_hash: &str) -> Result<bool> {
Ok(tx
.query_row(
@@ -362,7 +348,7 @@ pub fn mark_viewed(db: &Db, id: i64) -> Result<()> {
})
}
-/// §7.1: a rejection can be re-opened. We retire the rejected row so it stops
+/// §7.1: a rejection can be re-opened. The rejected row is retired so it stops
/// suppressing the identity, and the next detection opens a fresh review.
pub fn reopen_rejected(db: &Db, id: i64) -> Result<()> {
let at = time::now();