summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordev <dev@example.com>2026-11-21 19:27:26 +0000
committerdev <dev@example.com>2026-11-21 19:27:26 +0000
commit0f18ebddc1c138c531e3e331786c7fa917d9186f (patch)
treeb99428e80e267d8a1b4665b46aa67212fb42f154
parent533835c6b49111d5520ccd7a7bdd008a428b560f (diff)
downloadaur-build-0f18ebddc1c138c531e3e331786c7fa917d9186f.tar.gz
aur-build-0f18ebddc1c138c531e3e331786c7fa917d9186f.zip
http: ten request and response helpers were never crate-internal, just unmarked
`http` declares 81 `pub(crate)` items, the densest cluster in the tree, and the census called every one of them the good state. Ten of them are not crate-internal at all: `State`, `Req`, `Res`, `logout`, and the five accessors on `Req` and constructors on `Res` are named only from `http/mod.rs`, the file that declares them. The router dispatches through them in the same file; the `pub(crate)` was describing an outside caller that does not exist. `cookie` is the one worth naming: it is the auth-cookie helper, it looked used from `http/routes/mod.rs`, and what is used there is a *field* named `cookie` on `Req`. A word-match census cannot tell those apart, which is the whole reason this pass was done by stripping markers and compiling rather than by reading the census output. priv 159 -> 149 (http 81 -> 71), overwide 22 -> 21. `cargo check` clean under both profiles, no new warnings; tests/http.rs, surfaces.rs, notices.rs and invariants.rs all pass (43 tests).
-rw-r--r--src/http/mod.rs18
-rw-r--r--src/http/routes/mod.rs2
-rw-r--r--tests/architecture-budget.json14
-rw-r--r--tools/test-surface.md10
4 files changed, 22 insertions, 22 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs
index c95cd16..f10d4e2 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -9,12 +9,12 @@ use std::sync::Arc;
use crate::config::Config;
use crate::db::Db;
-pub(crate) struct State {
+struct State {
pub cfg: Config,
pub db: Db,
}
-pub(crate) struct Req {
+struct Req {
pub method: String,
pub path: String,
pub cookies: Vec<(String, String)>,
@@ -25,13 +25,13 @@ pub(crate) struct Req {
impl Req {
/// Read by the route handlers, which are in this module; the word `form` in a test is a local parameter.
- pub(crate) fn form(&self) -> &[(String, String)] {
+ fn form(&self) -> &[(String, String)] {
&self.form_pairs
}
- pub(crate) fn form_get(&self, key: &str) -> Option<String> {
+ fn form_get(&self, key: &str) -> Option<String> {
self.form_pairs.iter().find(|(k, _)| k == key).map(|(_, v)| v.clone())
}
- pub(crate) fn query_get(&self, key: &str) -> Option<String> {
+ fn query_get(&self, key: &str) -> Option<String> {
self.query_pairs.iter().find(|(k, _)| k == key).map(|(_, v)| v.clone())
}
/// Reading a cookie off a request is internal plumbing; the auth tests need it in order to forge one.
@@ -44,7 +44,7 @@ impl Req {
}
#[cfg(not(feature = "test-support"))]
- pub(crate) fn cookie(&self, name: &str) -> Option<String> {
+ fn cookie(&self, name: &str) -> Option<String> {
Self::cookie_impl(self, name)
}
@@ -53,7 +53,7 @@ impl Req {
}
}
-pub(crate) struct Res {
+struct Res {
pub status: u16,
pub content_type: String,
pub body: Vec<u8>,
@@ -64,7 +64,7 @@ pub(crate) struct Res {
impl Res {
/// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
- pub(crate) fn html(status: u16, body: String) -> Self {
+ fn html(status: u16, body: String) -> Self {
Self { status, content_type: "text/html; charset=utf-8".into(), body: body.into_bytes(), headers: Vec::new(), stream: None, stream_len: None }
}
pub fn text(status: u16, body: String) -> Self {
@@ -81,7 +81,7 @@ impl Res {
}
}
/// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
- pub(crate) fn redirect(location: &str) -> Self {
+ fn redirect(location: &str) -> Self {
Self {
status: 303,
content_type: "text/plain".into(),
diff --git a/src/http/routes/mod.rs b/src/http/routes/mod.rs
index 0ffecb0..2b9ebb9 100644
--- a/src/http/routes/mod.rs
+++ b/src/http/routes/mod.rs
@@ -34,7 +34,7 @@ pub(crate) fn login_form(state: &State, req: &Req) -> Res {
}
/// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
-pub(crate) fn logout(req: &Req) -> Res {
+fn logout(req: &Req) -> Res {
if let Some(sid) = req.cookie("sid") {
auth::drop_session(&sid);
}
diff --git a/tests/architecture-budget.json b/tests/architecture-budget.json
index 18e33c5..d600d39 100644
--- a/tests/architecture-budget.json
+++ b/tests/architecture-budget.json
@@ -215,8 +215,8 @@
"largest": 565,
"largest_file": "src/http/routes/pages.rs",
"lines": 2035,
- "overwide": 1,
- "priv": 81,
+ "overwide": 0,
+ "priv": 71,
"pub": 17,
"test": 5
},
@@ -414,7 +414,7 @@
"fetch": 0,
"git": 0,
"hash": 0,
- "http": 1,
+ "http": 0,
"lib": 0,
"main": 0,
"ops": 0,
@@ -432,9 +432,9 @@
}
},
"test_surface": {
- "already-gated": 21,
+ "already-gated": 22,
"interface": 1,
- "narrowed": 14,
+ "narrowed": 13,
"total": 36
},
"totals": {
@@ -445,8 +445,8 @@
"largest": 699,
"largest_file": "src/config.rs",
"lines": 15671,
- "overwide": 22,
- "priv": 159,
+ "overwide": 21,
+ "priv": 149,
"pub": 448,
"test": 49
}
diff --git a/tools/test-surface.md b/tools/test-surface.md
index 16f931f..3d69623 100644
--- a/tools/test-surface.md
+++ b/tools/test-surface.md
@@ -70,12 +70,11 @@ reaches the test tier also reaches a release build.
|---|---|---|---|---|---|
| `db` | `Writer` | `src/db/mod.rs:191` | `architecture.rs` | `src/db/audit.rs:10`, `src/db/audit.rs:74`, `src/db/mod.rs:329` +15 | `Db` has a `pub writer: Writer` field and pipeline, ops, review, watch and usecase all call `db.writer.tx(..)`. A field cannot be `pub` with a `pub(crate)` type — the compiler rejects it — so `Writer` is public because the public interface of `Db` requires it, not because a test asked. `tools/release-surface-probe.py` confirms it is reachable in a release build; that reachability is load-bearing, not residue. |
-## Feature-conditional visibility — production uses it, only from inside its module — 14 items
+## Feature-conditional visibility — production uses it, only from inside its module — 13 items
| module | item | declared at | test files | in-module call sites | why |
|---|---|---|---|---|---|
| `db` | `MIGRATIONS` | `src/db/migrations.rs:344` | `db.rs` | `src/db/mod.rs:157` | `db::migrate` iterates it to apply pending migrations; tests/db.rs asserts the list is ordered and complete. |
-| `http` | `cookie` | `src/http/mod.rs:42` | `common/mod.rs`, `http.rs` | `src/http/mod.rs:224`, `src/http/routes/mod.rs:38`, `src/http/routes/mod.rs:64` +2 ⚑ | the auth cookie helper; the tests that use it build no fixture, so they move into the module and it narrows. |
| `http` | `login` | `src/http/routes/mod.rs:51` | `common/mod.rs`, `http.rs` | `src/http/mod.rs:218` | the login route handler; same — its tests are harness-free and move with it. |
| `pipeline` | `admissible` | `src/pipeline/dispatch.rs:130` | `dispatch.rs` | `src/pipeline/dispatch.rs:111` | the dispatch filter, called at dispatch.rs:86; tests/dispatch.rs pins which builds it admits. |
| `pipeline` | `dispatch_once` | `src/pipeline/dispatch.rs:87` | `dispatch.rs` | `src/pipeline/dispatch.rs:71` | one tick of the dispatcher, called by the scheduler loop at dispatch.rs:60; tests/dispatch.rs drives single ticks. |
@@ -89,7 +88,7 @@ reaches the test tier also reaches a release build.
| `watch` | `probe` | `src/watch/upstream.rs:45` | `architecture.rs`, `ops.rs`, `vcs.rs` | `src/watch/detect.rs:96` | the upstream probe, called by detect.rs:95; tests/ops.rs and tests/vcs.rs both need a fixture. |
| `watch` | `sync_mirror` | `src/watch/mirror.rs:22` | `detect.rs` | `src/watch/detect.rs:41` | the mirror sync, called by detect.rs:40; tests/detect.rs drives a real sync. |
-## Already gated — 21 items
+## Already gated — 22 items
| module | item | declared at | test files | in-module call sites | why |
|---|---|---|---|---|---|
@@ -103,6 +102,7 @@ reaches the test tier also reaches a release build.
| `db` | `tx_for_tests` | `src/db/mod.rs:284` | `approve.rs`, `common/mod.rs`, `db.rs`, `invariants.rs` … | — | already gated behind test-support — the pattern the rest of this table asks for. |
| `db` | `unapproved_index_entries` | `src/db/invariants.rs:15` | `db.rs`, `detect.rs`, `notices.rs`, `shims.rs` | — | an invariant query nothing runs; it needs `pub(crate)` diff internals to be useful, so it is gated rather than relocated. |
| `db` | `world_members` | `src/db/world.rs:32` | `db.rs` | — | a world-snapshot reader nothing calls; `put_world_snapshot` is the half production uses. |
+| `http` | `cookie` | `src/http/mod.rs:42` | `common/mod.rs`, `http.rs` | `src/http/mod.rs:224`, `src/http/routes/mod.rs:38`, `src/http/routes/mod.rs:64` +2 ⚑ | the auth cookie helper; the tests that use it build no fixture, so they move into the module and it narrows. |
| `ops` | `STAGING_GRACE_SECS` | `src/ops.rs:333` | `ops.rs` | `src/ops.rs:300` | the grace period the staging sweep applies at ops.rs:286; tests/ops.rs pins the value it must be. |
| `ops` | `build_success_rate` | `src/ops.rs:51` | `ops.rs` | `src/ops.rs:101` ⚑ | computed inside the maintenance report at ops.rs:87; tests/ops.rs checks the arithmetic. |
| `ops` | `sweep_staging` | `src/ops.rs:363` | `ops.rs` | `src/ops.rs:300` | called by the maintenance pass at ops.rs:286; tests/ops.rs exercises it directly. |
@@ -120,8 +120,8 @@ reaches the test tier also reaches a release build.
| disposition | count |
|---|---|
| `interface` | 1 |
-| `narrowed` | 14 |
-| `already-gated` | 21 |
+| `narrowed` | 13 |
+| `already-gated` | 22 |
| **total** | **36** |
Of these, 1 are ungated today. Gating the `gate` rows and narrowing the