From c295510e2bb0ee61234536c832dad87a45977fc8 Mon Sep 17 00:00:00 2001 From: aur-build Date: Fri, 20 Nov 2026 23:38:01 +0000 Subject: sandbox: keep `Exit` out of the release build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `Exit` is the result of running a command in a sandbox. `pipeline` consumes it through `Sandbox::run` — `.success()`, `.stderr` — without ever writing the name, which is why the census called it dead outside `sandbox`. The type now lives in a private `mod exit` and reaches the world through an alias that is `pub` only under `test-support` and `pub(crate)` otherwise. A `pub` definition inside a private module is not a nameable path from outside, but it is visible enough to appear in a public trait signature, which is what makes this possible where a plain `pub(crate) struct` is not. Verified with an external crate: naming `aur_build::sandbox::Exit` in a release build is `error[E0603]: struct Exit is private`; with `test-support` it compiles. --- src/ops.rs | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src/ops.rs') diff --git a/src/ops.rs b/src/ops.rs index a40a326..fd3fb42 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -43,7 +43,21 @@ pub struct Metrics { } impl Metrics { + /// The metrics report computes it internally; a test checks the arithmetic. + /// + /// Module-internal in a production build, `pub` only under `test-support`: + /// one body behind two visibility declarations, exactly one of which compiles. + #[cfg(feature = "test-support")] pub fn build_success_rate(&self) -> f64 { + Self::build_success_rate_impl(self) + } + + #[cfg(not(feature = "test-support"))] + pub(crate) fn build_success_rate(&self) -> f64 { + Self::build_success_rate_impl(self) + } + + fn build_success_rate_impl(&self) -> f64 { match self.succeeded + self.failed { 0 => 1.0, n => self.succeeded as f64 / n as f64, @@ -307,7 +321,19 @@ pub fn retention(cfg: &Config, db: &Db, keep: Option) -> Result Result> { let mut out = Vec::new(); @@ -329,7 +355,21 @@ pub fn release_files(cfg: &Config, db: &Db, release_id: i64) -> Result Result<(usize, u64)> { + sweep_staging_impl(cfg, db, grace_secs) +} + +#[cfg(not(feature = "test-support"))] +pub(crate) fn sweep_staging(cfg: &Config, db: &Db, grace_secs: i64) -> Result<(usize, u64)> { + sweep_staging_impl(cfg, db, grace_secs) +} + +fn sweep_staging_impl(cfg: &Config, db: &Db, grace_secs: i64) -> Result<(usize, u64)> { let root = cfg.staging_dir(); let Ok(entries) = std::fs::read_dir(&root) else { return Ok((0, 0)) }; let now = time::now(); -- cgit v1.2.3