summaryrefslogtreecommitdiffstats
path: root/src/error.rs
Commit message (Collapse)AuthorAgeFilesLines
* rustfmt,lints: pin the formatting, adopt the idiom lints, pay them offaur-build9 days1-9/+11
| | | | | | | | | | | | | | | rustfmt.toml fixes the shape the tree is written in (120 columns, small items kept on one line) and one canonical pass makes it the truth. [lints.clippy] names the idiom lints worth enforcing and leaves out the two that would add doc-comment boilerplate rather than remove it. The tree pays them off here: write!/writeln! instead of push_str(&format!()), let-else instead of match-on-Option, borrows where a thread entry point only reads what it owns, no `&self` on a Copy state and no `self` nobody reads. ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and value are now emitted by the same call instead of three.
* error,tools: a variant nothing constructed, and three tool constructs ↵aur-build10 days1-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | nothing read `Missing::Snapshot` was declared, rendered by the `Display` arm, and constructed by nothing: `From<&str> for Missing` routes a bare sentence to `Missing::Other`, and the test that mentions a snapshot asserts `Other(_)`. The variant and its formatting arm are gone. A variant scan that counted *mentions* could not see it, because the formatting arm is a mention; the scan now ignores a line that only renders the variant, and what it reports afterwards is `Error::Json` and `Error::Sqlite`, both of which the compiler proves live — deleting either breaks the hundred-odd `?` sites that reach them through `#[from]`. Three survivors in `tools/`, none of them caught by the audit that claimed the axis was empty, because that audit looked at module-level constants and function parameters and never at local bindings: - `test-surface.py` opened `render()` with `out = [...] if False else []`, a literal dead branch whose binding was then never read. Both gone. - `test-surface.py` computed a `collisions` set that nothing consulted; the rule it narrated had moved into `mentioned` as `sole_owner`. The set is deleted and the explanation now sits in the docstring of the function that applies it. - `release-surface-probe.py` built `decl_line` and used `decl_no` instead. `a, b = item.split(" as ", 1)` became `_, b = ..` for the same reason. The scans now cover locals and constant conditions as well, and report nothing: no unread binding, no `if False`, no unreachable statement after a terminator, no unused import, constant, parameter, or unread argparse option across the five tools.
* error: give the six variants behavior carries a shape, not a sentencedev11 days1-19/+325
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Error::NotFound("no repo row; run `aur-build init`")` and `Error::NotFound("pkgbase linux")` were the same variant. One is "the install was never initialised, every page is wrong"; the other is "that page does not exist, answer 404". The difference lived inside a string, so the only way to act on it was to re-parse text the same process had written moments earlier. Six variants now carry structure: Missing pkgbase / candidate / release / build / snapshot / mirror path / repo row Refused IllegalTransition / WrongState / PointerMoved / Other Guard HashMismatch / DigestMismatch / Invariant WorldGap MissingPin / Other PoolFull Backend{backend} / Other TransientCause Upstream / Command / Other `Refused` distinguishes the three refusals that were indistinguishable: a transition no edge permits (caller bug), a row in the wrong state (stale view), and the accepted pointer moving under a build (a lost race, and the one a client may safely retry). `PoolFull::Backend` names which pool, because a kata quota needs an operator and a local cap clears when a build exits. `is_transient` and `is_pool_exhausted` already matched on variants rather than strings, so they are unchanged — the typing is what lets the *next* branch be a match instead of a `contains`. No test assertion was edited. Where a message is load-bearing the Display was written to reproduce it: `recipe_hash mismatch: approved X, materialized Y`, `no release 4`, `illegal candidate transition approved → rejected`, `sandbox world is missing plain-make-1.0-1 after installing the lease set` and kata's `never dialed in` all come out of the new types byte-identical. Five messages did change wording, none asserted anywhere: release N is X, not published: nothing to withdraw -> release N is X, not published (Refused::WrongState's shape) illegal candidate transition a → b for review 7 -> ... for candidate 7 (it is a candidate id; "review" was misleading) no candidate 7 to resolve -> candidate 7 (Missing::Candidate's shape) lease artifact n-v: store bytes hash to A but the index says B -> source n-v hashed to A but the candidate recorded B (shares Guard::DigestMismatch with the source-cache check) vcs_cache clone URL: err -> upstream: vcs_cache clone URL: err (TransientCause::Upstream tag) error.pub 15->21 is the six payload enums, which is the point of the task rather than a widening to apologise for. watch.dead/test each rose by one for a subtler reason: `watch::upstream::resolve` looked live only because an unrelated db message ended "... to resolve", and rewording that string removed the phantom mention. The census now documents that a clean count is not always an answer, since mentions are matched over raw source including string literals. 281 passed / 0 failed (277 plus four new typing tests in src/error.rs), clippy -D warnings clean, release build clean.
* comments: keep only what the code cannot showaur-build12 days1-16/+0
| | | | | | | | | | | 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.
* comments: say why, not whataur-build12 days1-27/+12
| | | | | | | | | | | | | | 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.
* sandbox: failure-mode tier — a FakeBackend that breaks on purposeaur-build12 days1-0/+31
| | | | | | | | | | | | | | | | | | | The recovery paths a remote pool makes newly reachable are now executed, not described. A decorator over the loopback backend injects the four faults that matter: a sandbox that vanishes mid-run (the step fails, the lease expires, the reaper requeues, a healthy pool finishes from the checkpoints — I5 across the sandbox boundary); a TTL that bites mid-build (a failed step, not a retry-burned one); a pool at quota (the build blocks on sandbox-pool using the same blocked machinery as missing deps, rather than failing on an infrastructure fact); and a sandbox whose pacman -Q lies about the installed world (provisioning refuses with a dedicated world-mismatch class, so 'the sandbox lied' never reads as 'the sandbox broke'). Two error classes carry that vocabulary: PoolExhausted — capacity, so wait, never retry — and WorldMismatch — fail-closed, never retried. The remote and kata acquire timeouts now speak the first, which is what makes a full pool a queue fact instead of a build failure.
* pipeline, db: the correctness minors — fsync, withdrawal, orphans, retry classaur-build13 days1-3/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | m-7. `fsync_file` and `fsync_dir` opened, ignored every error, and returned Ok, in the module whose entire guarantee is "fsync, then rename". A filesystem that refused the sync — full, read-only, a network mount that had dropped — still produced a successful publish whose database might not be on disk. They propagate now, with the path and the cause. m-10. `withdraw_release_in` set `state='withdrawn'` unconditionally, so withdrawing twice reported success the second time while changing nothing, and withdrawing a release that had never been live did the same. The write is a compare-and-swap on `state='published'`, and a refusal names the state that was actually there ("release 1 is withdrawn, not published: nothing to withdraw"). m-16. Artifacts are copied into the served tree before the DB commit, and when the commit refused they stayed: files no index names, sitting in the directory consumers download from. `publish` now tracks which files it created (a file that already existed belongs to the release still being served and is never touched) and removes them if the publish does not land. m-14. `is_transient` treated every `Error::Io` as retryable, which made ENOSPC and EACCES — plain `Io` — into three identical failures and a silent build. Only the kinds that mean "ask again in a moment" retry now. This turned a test that had been asserting the bug: it simulated a transient failure by pointing `makechrootpkg` at a nonexistent path, which is a missing binary, not a flaky network. That test now asserts the opposite (one attempt, no retries), and a new one produces a genuinely transient failure the way production does — a `SKIP` source whose bytes go unreachable after detection, cache dropped, so the `sources` step fails over the fetch path and retries to the cap. m-13. `random_hex` read `/dev/urandom` into a zeroed buffer, ignored every error, and hashed it anyway. Since C-1 the session id is the whole credential, so a failed read is now a refusal: `new_session()` returns `Option`, and the two call sites answer 500 rather than mint a token derivable from the clock and a counter. m-9. The row-error policy is decided and applied: a row that cannot be read fails the query instead of vanishing from the result (six `filter_map(|r| r.ok())` sites, including the reaper's and the claimer's), and `setting_i64` documents its own policy — absent means default, nonsense means default *and a complaint*, because a typo that silently does nothing is worse than a knob that refuses to apply.
* watch: two-stage VCS watcher — ls-remote probe, pkgver() resolution, pin ↵aur-build13 days1-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | capture (§5.2) Stage A probes every VCS source in source=() with git ls-remote, respecting #commit/#tag/#branch fragments, and returns one UpstreamPin per source. If the tip set equals the accepted release's pins, nothing can have changed and Stage B never runs — the common case costs one round trip per source and no clone. svn/hg have no cheap universal probe, so they are reported as unprobed and force Stage B rather than being silently treated as unchanged. Stage B runs only on movement: it fetches into a persistent vcs_cache (rather than re-cloning a multi-gigabyte upstream daily), runs makepkg --vercheck, and captures the pins from the clone it already has. Results are cached on (pkgbase, recipe_hash, upstream_tip) with a per-pkgbase cooldown, and a process-wide slot cap bounds concurrent resolutions. The resolved epoch:pkgver-pkgrel plus the pins go into identity_hash, so a different commit is a different thing to approve. Also fixes a misclassification the new path exposed: a VCS source's digest is its pin, so upstream movement showed up as an integrity_alert. Integrity events are now restricted to fixed downloads; VCS movement under a frozen pkgver is pin_drift, as §5.2 specifies. New fixtures git-multi (two upstreams) and git-tagged (#tag pin). 10 tests in tests/vcs.rs.
* feat: SQLite schema, migrations, single writer actoraur-build14 days1-0/+70
The §11 data model as four migrations, plus the §11a concurrency model: one writer thread owning the write connection (mutations arrive as closures over a crossbeam channel, so SQLITE_BUSY is not part of the design) and thread-local read-only connections under WAL. Invariants that are database guarantees rather than conventions: I7 partial unique index -> at most one pending_review per pkgbase I3 UNIQUE(pkgbase_id, identity_hash) -> no duplicate candidates I10 audit table rejects UPDATE and DELETE by trigger §16 current_accepted_release_id moves only by compare-and-swap Also: vercmp + dependency-string parsing (ALPM algorithm, no libalpm), hash helpers including recipe_hash over the whole AUR tree, the clock helper that stamps every write, and the config/root layout. Part of P0 (DESIGN.md §17).