diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
| commit | 4304b0f336ddba7b4ec6780795059ff2066d105b (patch) | |
| tree | 10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /src/http/routes | |
| parent | e757979f1a2afdbe7146066345bb9acd19d3b151 (diff) | |
| download | aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip | |
comments: keep only what the code cannot show
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.
Diffstat (limited to 'src/http/routes')
| -rw-r--r-- | src/http/routes/mod.rs | 15 | ||||
| -rw-r--r-- | src/http/routes/mutations.rs | 17 | ||||
| -rw-r--r-- | src/http/routes/pages.rs | 21 |
3 files changed, 0 insertions, 53 deletions
diff --git a/src/http/routes/mod.rs b/src/http/routes/mod.rs index 0dfed52..ed488c8 100644 --- a/src/http/routes/mod.rs +++ b/src/http/routes/mod.rs @@ -8,9 +8,6 @@ use super::{Req, Res, State}; mod mutations; mod pages; -// The handlers live in two files by direction of travel — reads in `pages`, -// writes in `mutations` — and are pulled back into scope here so the routing -// table below still reads as one flat list of endpoints (n-4). pub(crate) use mutations::*; pub(crate) use pages::*; @@ -29,9 +26,6 @@ pub fn login_form(state: &State, req: &Req) -> Res { page_to_res(Login { page, error: String::new() }, 200) } -/// Forget the session server-side and clear the cookie. The CSRF token is -/// derived from the sid, so dropping the sid invalidates every form a browser -/// still has open — which is exactly what logout should do. pub fn logout(req: &Req) -> Res { if let Some(sid) = req.cookie("sid") { auth::drop_session(&sid); @@ -45,9 +39,6 @@ pub fn login(state: &State, req: &Req) -> Res { let given = req.form_get("password").unwrap_or_default(); let page = Page::new("Sign in", csrf(state, req)); if auth::password_ok(&state.cfg, &given) { - // Rotate rather than promote: the sid the visitor arrived with (if any) - // is dropped, so the session that existed before the password was typed - // is never the one that carries the privilege afterwards. if let Some(old) = req.cookie("sid") { auth::drop_session(&old); } @@ -57,7 +48,6 @@ pub fn login(state: &State, req: &Req) -> Res { }; auth::authenticate(&sid); let mut res = Res::redirect("/"); - // `serve` turns this into the `Set-Cookie: sid=…` header. res.header("X-New-Session", &sid); res } else { @@ -109,7 +99,6 @@ fn not_found(state: &State, req: &Req) -> Res { ) } -/// The shared chrome: counts for the nav badges and the active-tab marker. fn chrome(state: &State, req: &Req, title: &str, active: &str) -> Page { let db = &state.db; let mut page = Page::new(title, csrf(state, req)); @@ -133,7 +122,6 @@ fn csrf(_state: &State, req: &Req) -> String { req.cookie("sid").map(|s| auth::csrf_token(&s)).unwrap_or_default() } -/// A byte count a human can read at a glance. fn human_size(bytes: i64) -> String { const UNITS: [&str; 4] = ["B", "KiB", "MiB", "GiB"]; let mut v = bytes as f64; @@ -158,9 +146,6 @@ fn age(detected_at: &str) -> String { format!("{detected_at} → {now}") } -/// Who the audit trail says made a decision. With no password configured the -/// UI is open on loopback and every session is the operator's; with one, only -/// a session that passed the gate gets a name. fn actor(state: &State, req: &Req) -> &'static str { let sid = req.cookie("sid").unwrap_or_default(); if !auth::auth_required(&state.cfg) || auth::is_authenticated(&sid) { diff --git a/src/http/routes/mutations.rs b/src/http/routes/mutations.rs index 79089b2..2af8b7f 100644 --- a/src/http/routes/mutations.rs +++ b/src/http/routes/mutations.rs @@ -37,8 +37,6 @@ pub(crate) fn review_approve(state: &State, req: &Req, id: &str) -> Res { page_to_res(ReviewsPage { page, rows: review_rows(&state.db) }, 200) } Err(ap::ApproveError::System(e)) => { - // The database refused. Telling the reviewer their review went stale - // would be a lie about the one thing they cannot check themselves. let mut page = chrome(state, req, "Review failed", "nav_reviews"); page.flash = format!("the approval could not be recorded: {e}"); page.has_flash = true; @@ -46,14 +44,10 @@ pub(crate) fn review_approve(state: &State, req: &Req, id: &str) -> Res { page_to_res(ReviewsPage { page, rows: review_rows(&state.db) }, 500) } Err(ap::ApproveError::Stale(stale)) => { - // §7.1a: refuse, re-render what it is now, and say why. Never - // silently retarget the approval onto the newer state. let mut page = chrome(state, req, "Review changed", "nav_reviews"); page.flash = format!("refused: {stale}"); page.has_flash = true; page.flash_err = true; - // Show the review as it stands NOW — the frozen one the form came - // from may have collapsed or been superseded while it was open. let current = candidates::pending_candidates(db) .unwrap_or_default() .into_iter() @@ -109,8 +103,6 @@ pub(crate) fn review_reject(state: &State, req: &Req, id: &str) -> Res { } } -/// Bulk approve/reject (§7.4): per-item, never "approve everything forever", -/// and high-risk items are refused unless each was confirmed individually. pub(crate) fn reviews_bulk(state: &State, req: &Req) -> Res { let db = &state.db; let form = req.form(); @@ -136,8 +128,6 @@ pub(crate) fn reviews_bulk(state: &State, req: &Req) -> Res { page.flash_err = true; return page_to_res(ReviewsPage { page, rows: review_rows(&state.db) }, 400); } - // The rule itself lives in `review::approve::bulk`, so the page and the - // library cannot disagree about what a bulk decision means (§7.4). let items: Vec<(i64, String, String)> = ids .iter() .filter_map(|id| { @@ -200,9 +190,6 @@ pub(crate) fn sub_pause(state: &State, req: &Req) -> Res { let db = &state.db; let name = req.form_get("pkgbase").unwrap_or_default(); let cur = db::get_subscription(db, &name).ok().flatten().map(|s| s.state); - // Pause and resume are the only moves this page makes. A subscription that - // is orphaned or removed is not the reviewer's to pause, and saying so beats - // quietly rewriting its state. let next = match cur { Some(SubscriptionState::Active) => SubscriptionState::Paused, Some(SubscriptionState::Paused) => SubscriptionState::Active, @@ -223,8 +210,6 @@ pub(crate) fn sub_remove(state: &State, req: &Req) -> Res { pub(crate) fn notice_ack(state: &State, req: &Req) -> Res { let id: i64 = req.form_get("id").and_then(|s| s.parse().ok()).unwrap_or(0); let _ = db::acknowledge_notice(&state.db.writer, id); - // POST-redirect-GET: the notice vanishing from the list is its own - // confirmation, and a refresh can no longer re-POST. Res::redirect("/attention") } @@ -270,8 +255,6 @@ pub(crate) fn build_cancel(state: &State, req: &Req, id: &str) -> Res { builds_with(state, req, page) } -/// Retrying a failed build is an explicit, audited decision (§8.4), not -/// something the system does to itself. pub(crate) fn build_retry(state: &State, req: &Req, id: &str) -> Res { match builds::retry(&state.db, id) { Ok(()) => { diff --git a/src/http/routes/pages.rs b/src/http/routes/pages.rs index f1f3ef8..bb5db34 100644 --- a/src/http/routes/pages.rs +++ b/src/http/routes/pages.rs @@ -56,7 +56,6 @@ pub(crate) fn review_rows(db: &Db) -> Vec<ReviewRow> { revision: c.revision, }) .collect(); - // Risk first, then oldest — the scarcest resource gets the loudest rows. let rank = |r: &str| match r { risk::level::HIGH => 0, risk::level::MEDIUM => 1, @@ -83,8 +82,6 @@ pub(crate) fn review_detail(state: &State, req: &Req, id: &str) -> Res { let Some(c) = candidates::candidate_by_id(db, id).unwrap_or(None) else { return not_found(state, req); }; - // Opening a review freezes it: a later detection now opens a fresh review - // instead of silently changing what is on screen (§7.1). let _ = candidates::mark_viewed(db, id); let page = chrome(state, req, &format!("Review {}", c.pkgbase), "nav_reviews"); let (head, panels, recipe, srcinfo, sources_resolved, deps_resolved) = review_body(state, &c); @@ -113,7 +110,6 @@ pub(crate) fn panels_base(c: &CandidateRow) -> (String, bool) { } } -/// Build the review body: the panel set plus the first-introduction material. pub(crate) fn review_body( state: &State, c: &CandidateRow, @@ -224,7 +220,6 @@ pub(crate) fn attention(state: &State, req: &Req) -> Res { .into_iter() .map(|(id, pkgbase, blocked_on)| BlockedRow { id_short: short(&id), id, pkgbase, blocked_on }) .collect(); - // Staleness is computed on read (P4 fills the query in). let stale = crate::watch::staleness::stale_rows(db).unwrap_or_default(); let outdated: Vec<StaleRow> = stale .iter() @@ -322,8 +317,6 @@ pub(crate) fn package_detail(state: &State, req: &Req, name: &str) -> Res { step: b.current_step.unwrap_or_default(), }) .collect(); - // Depends-on comes from the recipe we actually serve; needed-by comes from - // the packages whose own recipes name this one (§10.3). let deps_in: Vec<String> = accepted .as_ref() .and_then(|r| db::accepted_recipe(db, r).ok().flatten()) @@ -375,8 +368,6 @@ pub(crate) fn package_detail(state: &State, req: &Req, name: &str) -> Res { // --------------------------------------------------------------- builds -- -/// The version a build is about. A build points at a candidate, or — for a -/// manual rebuild of something already published — at a release. pub(crate) fn build_version(db: &Db, b: &builds::BuildRow) -> String { if let Some(cid) = b.candidate_id { if let Some(c) = candidates::candidate_by_id(db, cid).ok().flatten() { @@ -424,8 +415,6 @@ pub(crate) fn build_rows(state: &State) -> Vec<BuildRow> { pub(crate) fn builds_page(state: &State, req: &Req) -> Res { let page = chrome(state, req, "Builds", "nav_builds"); - // htmx asks for the fragment; a browser with JavaScript off never does and - // gets the whole page either way (§13). if req.query_get("fragment").as_deref() == Some("1") { return page_to_res( BuildsTable { page, rows: build_rows(state), recent: recent_rows(state) }, @@ -514,17 +503,12 @@ pub(crate) fn build_log(state: &State, id: &str) -> Res { Res::text(200, body) } -/// The live tail (§13). Server-sent events from a blocking reader: the pipeline -/// appends to a file and never learns this connection exists, so a viewer that -/// hangs up, stalls or never shows up cannot slow a build. pub(crate) fn build_log_stream(state: &State, req: &Req, id: &str) -> Res { if builds::get(&state.db, id).unwrap_or(None).is_none() { return not_found(state, req); } let tail = sse::LogTail::new(&state.cfg, state.db.clone(), id); let mut res = Res::stream("text/event-stream", tail, None); - // No caching, and no proxy buffering: a buffered event stream is a log tail - // that arrives all at once, which is the thing we are trying to avoid. res.header("Cache-Control", "no-cache"); res.header("X-Accel-Buffering", "no"); res @@ -550,11 +534,6 @@ pub(crate) fn audit(state: &State, req: &Req) -> Res { page_to_res(Audit { page, rows }, 200) } -/// `GET /metrics` in Prometheus text exposition format (§12, §15). -/// -/// Everything here is computed from live state on every scrape. There are no counters -/// incremented at event sites: a counter every code path has to maintain quietly -/// drifts the first time a path is added; a query cannot drift. pub fn metrics(state: &State) -> Res { match ops::metrics(&state.cfg, &state.db) { Ok(m) => { |
