summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
Commit message (Collapse)AuthorAgeFilesLines
* ops: retention that never lies about what is on disk, metrics that cannot ↵aur-build13 days1-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | drift, and a backup that restores Three §15 features, each with a failure mode worth designing against. **Retention** evicts the files of releases beyond the keep window and never deletes a row. The artifact keeps its digest, size and provenance and gains a purged_at, so the record says 'these bytes existed and were dropped at T' instead of continuing to claim a file that is no longer there. A package, its signature, its build log and its cached sources are evicted as one unit — a package whose log is gone but whose bytes remain is the worst outcome: full price, no explanation. Shared content-addressed files are reference-checked against every *retained* release first, because two releases built from the same source share one cached archive and aging one out must not corrupt the other. The currently accepted release and anything still backing an in_index package are kept regardless of how far down the list they sit: deleting the bytes the index is pointing at is the one thing retention must never do. **Staging sweep** derives 'abandoned' rather than guessing it: the dir's build is terminal, or has no build row at all, and the dir is older than a grace period. A dir whose build is running is left alone however old it looks, because a long build is not an abandoned one. **Metrics** are computed from live state on every scrape. There are no counters incremented at event sites, because a counter maintained by every code path is a counter that quietly drifts the first time a path is added; a query cannot drift. Includes queue depth, the review-debt age histogram (not just how many reviews are pending but how stale they are), build success rate, WAL size, stale counts by reason and staging usage. A fresh install reports success rate 1.0 rather than NaN or 0%, so an empty system does not page anyone. Served at GET /metrics and by 'aur-build metrics'. **Backup** uses VACUUM INTO on the writer connection, so it cannot interleave with a write, and refuses to overwrite an existing file — a backup that silently replaces last week's backup is a way of losing the only copy on the day you need it. The snapshot is then reopened and checked for schema version and approval rows: if it does not open on its own it is a file, not a backup. New CLI: metrics, gc [--keep N] [--dry-run], backup <path>. tests/ops.rs: 9 tests. 170 tests pass, clippy clean.
* pkginfo: .PKGINFO/.BUILDINFO parsing gets a real home, and a parser bug fix ↵aur-build13 days1-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (§10.1) Ingest decides what the index claims about a package and what the world snapshot records by reading two text files out of a tar inside a zstd stream. That code was living in src/shims — the test harness — which meant production depended on the harness for its view of a package's own metadata. Moved to src/pkginfo.rs, with the shim now delegating to it so the harness and the production path cannot disagree about what a package says about itself. Still no libalpm: tar + zstd + eighty lines of key = value parsing. Unknown keys are ignored rather than rejected, because makepkg adds fields over time and a new one must not stop us publishing. **The parser had a real bug.** A .BUILDINFO installed block puts its first entry on the same line as the key: installed = glibc 2.39-1 x86_64 - gmp 6.3.0-1 x86_64 - The old code skipped the header line, so the first dependency was silently dropped from every snapshot — exactly the kind of gap that makes staleness quietly wrong. The header line is parsed now. tests/world.rs builds real .pkg.tar.zst files and asserts the fields come out of the archive: repeated keys stay lists, an archive with no .PKGINFO is refused rather than defaulted from the filename, and the world snapshot contains our own packages and none of glibc/pacman/binutils. The empty-snapshot case for a first build is asserted too — nothing of ours existed yet, and recording that honestly beats inventing a world. Split pkgbases produce one approval, one release and N index rows each with its own artifact, asserted directly here. 143 tests pass, clippy clean.
* http: the review surface — server-rendered, no JavaScript required (§12, ↵aur-build13 days1-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | §13) tiny_http, thread-per-connection, askama templates. Every §13 surface is server-rendered HTML that works with scripts switched off: Inbox, review detail with the full panel set, Builds, Attention, Index, Subscriptions, Ops/audit, Settings. The parts that are easy to get wrong: - Handlers read through thread-local READ-ONLY connections. They cannot take the write lock even by accident, so a slow page render never blocks the build pipeline's writer. tests/http.rs asserts this by trying to write through a read connection and requiring failure. - Every POST requires a CSRF token derived from the session id. Logout drops the session, which invalidates every form still open in a browser. - Approve carries identity_hash AND diff_digest (§7.1a). If either has moved, the approval is refused with 409 and the page re-renders the review AS IT IS NOW — never a silent retarget onto the newer state. - Bulk approve refuses high-risk items unless each one is individually confirmed by id. Bulk is per-item, never 'approve everything forever'. - Reject requires a note; it is re-openable, not a deletion. - Optional password gate; anonymous visitors are redirected to /login. Also: the index page states the pacman conf snippet including 'SigLevel = Required DatabaseOptional', because a repo consumers ignore the signature is a repo that gets MITM'd.
* pipeline: ten-step build machine with atomic signed publishaur-build14 days1-0/+1
| | | | | | | | | | | | | | | | | | | | | materialize -> plan -> chroot -> sources -> pkgver -> build -> collect -> verify -> ingest -> publish, each checkpointed in build_step so a worker that dies resumes at the next incomplete step without repeating the expensive one (I5). Step 0 materializes from the local mirror only and re-hashes the tree: there is no path from 'AUR moved since the review' to 'we built it anyway' (I3). Step 4 re-resolves a VCS pkgver and refuses when it no longer matches the approved identity. Publish renders the index to .tmp, fsyncs, commits release + package rows and the accepted pointer under a compare-and-swap, then renames over the served database and signs it, so a crash leaves the old index byte-for-byte intact (I4) and every index entry traces back to an approval (I1). Ingest records the world snapshot as the BUILDINFO installed set intersected with our own packages, which is what keeps staleness meaningful (I12). 17 shim-driven end-to-end tests, including kill-mid-publish and crash-resume, with no root, network, or real chroot.
* test: toolchain shims and the fake-package corpus (§16a)aur-build14 days1-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The harness that makes the rest of this developable. Six real binaries named exactly like the tools the pipeline shells out to, sharing one shim module, driven entirely by environment so no production code path is test-only: AUR_SHIM_DIR where invocations are recorded (jsonl) AUR_SHIM_MANIFEST the fixture manifest to obey AUR_SHIM_FAIL optional tool forced to fail makechrootpkg emits real .pkg.tar.zst files with .PKGINFO and .BUILDINFO (the full chroot world, which is why §10.1 filters it), makepkg answers --printsrcinfo and --vercheck for Stage B, repo-add rebuilds a gzip'd .db with %FILENAME%/%VERSION%/%SHA256SUM% DESC entries, gpg writes a detached signature, mkarchroot creates a warm root. Each one records its invocation so tests assert on what actually ran. testcorpus/ holds 17 fixtures, each a PKGBUILD plus a manifest with the scripted outcome: plain-make, with-patch, install-hooks, skip-checksum, split-pkgbase, build-fails, check-fails, missing-dep, dep-cycle, epoch-bump, pkgrel-reset, downgrade, digest-drift, pin-drift, git-sourced, git-submodules, unresolvable. The harness commits a fixture into a real git repo standing in for AUR, materialises a local upstream git repo for VCS fixtures, and swaps payload bytes for the drift cases. Config.child_env is what puts the shims on PATH for child processes, so the pipeline runs completely unmodified under test. Part of P0 (DESIGN.md §17).
* feat: AUR mirror watcher, recipe parsing, candidate creationaur-build14 days1-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The detection path (§5.1, §5.1a, §5.3, §7.1): * git helpers, all subprocess git in one auditable place. Mirrors are cloned with --mirror and polled with git ls-remote, fetching only when the tip actually moved; --no-prune keeps history we may need forever. * .SRCINFO parsing (authoritative) with a PKGBUILD fallback, and source=() parsing that keeps VCS kind, #commit/#tag/#branch refs and the filename:: form. * recipe_hash over the whole snapshot tree, so a shipped patch is part of the recipe and cannot change silently. * source digest resolution: declared checksums are trusted-as-declared (makepkg enforces them, no bandwidth), local files are hashed from the mirror, and SKIP sources are downloaded and stream-hashed into the content-addressed source cache. Detection always re-fetches SKIP sources — answering from our own cache would defeat drift detection. * candidate creation with base = current_accepted_release, collapse in place while unviewed, supersede only once a human has looked, and a previously rejected identity is not re-raised. * non-publishable change handling (I11): unchanged version string means no review, but never silence — recipe drift and pin drift become notices, and a changed digest on a remote source with an unchanged version becomes a high-severity integrity_alert. Also vercmp + dep-string parsing with the ALPM test vectors, and the approval record with optimistic concurrency (§7.1a) that the CLI and web layers will both call. 16 detection tests against real file:// git fixtures, incl. I2 across three unattended detections and I11 for all three drift kinds. Part of P0 (DESIGN.md §17).
* feat: SQLite schema, migrations, single writer actoraur-build14 days1-0/+14
| | | | | | | | | | | | | | | | | | | 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).
* chore: scaffold cargo project, toolchain shim binaries, git baselineaur-build14 days1-0/+1
Provisions rustup + devtools from the distro package set and lays down the crate skeleton: library, CLI binary, and one binary per external tool the pipeline shells out to (mkarchroot, makechrootpkg, makepkg, repo-add, gpg, pacman) so the §16a PATH shims are real executables that cargo builds and tests can locate via CARGO_BIN_EXE_*. Part of P0 (DESIGN.md §17).