diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:09:59 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:09:59 +0000 |
| commit | e757979f1a2afdbe7146066345bb9acd19d3b151 (patch) | |
| tree | 30d5f5fbccd25ea7bf01c5202684af463b74e7d3 /src/error.rs | |
| parent | 94c318f13264bb3c00a9f3057ba2e1aafb57c9e4 (diff) | |
| download | aur-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/error.rs')
| -rw-r--r-- | src/error.rs | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/src/error.rs b/src/error.rs index 342c628..f849f83 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,5 +1,3 @@ -//! Error type shared across the application. - use std::fmt; #[derive(Debug, thiserror::Error)] @@ -30,20 +28,17 @@ pub enum Error { Invalid(String), #[error("blocked: {0}")] Blocked(String), - /// The sandbox pool could not fit a lease right now. Not a failure and not - /// a retry: the build waits, the same way it waits for a dependency it - /// publishes (§10.4). A quota is a fact about capacity, not a bug. + /// The sandbox pool could not fit a lease right now. Not a failure and not a + /// retry: the build waits, as it waits for a dependency it publishes + /// (§10.4). A quota is a fact about capacity, not a bug. #[error("sandbox pool exhausted: {0}")] PoolExhausted(String), - /// The world inside the sandbox is not the world the plan approved: - /// a pinned dependency did not land, or the closure was incomplete. - /// Fail-closed with its own class so a test (and an operator) can tell - /// "the sandbox lied" apart from "the sandbox broke". + /// The world inside the sandbox is not the world the plan approved: a pinned + /// dependency did not land, or the closure was incomplete. Its own class so + /// a test can tell "the sandbox lied" from "the sandbox broke". #[error("world mismatch: {0}")] WorldMismatch(String), - /// A failure the outside world caused and a retry may clear: an unreachable - /// upstream, a half-written mirror. Distinct from a deterministic failure, - /// which must never be retried into a different answer (§8.4). + /// A failure the outside world caused and a retry may clear (§8.4). #[error("transient: {0}")] Transient(String), #[error("{0}")] @@ -86,25 +81,19 @@ impl Error { } /// True when the sandbox pool, not the build, is the problem: the build - /// should block and wait, not fail and not be retried into a different - /// answer. + /// blocks and waits rather than failing. pub fn is_pool_exhausted(&self) -> bool { matches!(self, Error::PoolExhausted(_)) } - /// True when a retry could plausibly help (§8.4): an unreachable upstream, a - /// mirror that 5xx'd, a connection that reset. + /// True when a retry could plausibly help (§8.4). /// - /// `Error::Io` is *not* automatically transient (m-14). `ENOSPC` and - /// `EACCES` are `Io`, and treating them as retryable meant a full disk or a - /// misconfigured root turned into three identical failures, a shrug, and a - /// build that never got the operator's attention. Only the kinds that mean - /// "the same call might work in a moment" are retried. + /// `Error::Io` is *not* automatically transient (m-14): `ENOSPC` and `EACCES` + /// are `Io`, and retrying them burns attempts while a full disk goes unnoticed. pub fn is_transient(&self) -> bool { match self { Error::Http(_) | Error::Transient(_) => true, - // A quota is capacity, not a hiccup: retrying a build that has no - // sandbox just burns attempts. It blocks instead. + // A quota is capacity, not a hiccup; the build blocks instead. Error::PoolExhausted(_) | Error::WorldMismatch(_) => false, Error::Io(e) => matches!( e.kind(), @@ -129,9 +118,6 @@ mod tests { #[test] fn a_full_disk_is_not_a_retryable_failure() { - // m-14: `Error::Io` used to mean "retry", so ENOSPC and EACCES — both - // plain `Io` — turned into three identical failures and a build that - // never announced itself as broken. let enospc = Error::Io(std::io::Error::from_raw_os_error(28)); let eacces = Error::Io(std::io::Error::from_raw_os_error(13)); assert!(!enospc.is_transient(), "a full disk does not clear itself between retries"); @@ -146,7 +132,6 @@ mod tests { assert!(Error::Http("connection reset".into()).is_transient()); assert!(!Error::invalid("recipe has no pkgbase").is_transient()); assert!(!Error::fail_closed("identity hash moved").is_transient()); - // A full pool waits; it does not retry. A lying world fails closed. assert!(!Error::pool_exhausted("at quota").is_transient()); assert!(!Error::world_mismatch("missing pinned dep").is_transient()); assert!(Error::pool_exhausted("at quota").is_pool_exhausted()); |
