| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
writer stops handing out connections
Twelve modules outside `db/` contained hand-rolled SQL — 22 statements in
`ops.rs`, 17 in `approve.rs`, 15 in `candidates.rs`, 11 in `publish.rs`, and a
dozen more scattered through `watch`, `pipeline`, `http` — which meant the
blast radius of a schema change was "any module", and `db/` was a directory
rather than a boundary. The audit trail alone was defined in four places with
three different detail payloads.
Every statement now lives in `db/`. New modules `db::candidates` and
`db::approvals` own their tables (including the 21-column candidate select,
spelled once as `CANDIDATE_COLS` instead of four times); `db::queries` gains
the metrics reads, the retention reads and writes, the publish writes
(`insert_release_in`, `cas_accepted_release_in`, `remove_index_packages_in`),
the staleness reads and the source-cache lookups; `db::builds` gains
`set_release_in`. Where a mutation is a *decision* — the collapse rules, the
approval gate, the publish compare-and-swap — the decision stays where it was
and the statements are called through the transaction handle, so the atomicity
is unchanged and only the SQL moved.
`audit_in` is the in-transaction audit append, and `audit` is now a wrapper
over it: a decision and its audit row commit together or not at all, which is
what I10 actually claims.
Enforcement is two-layered, because one layer is a lie. `Writer::call`, `tx`
and `send` are `pub(crate)`, which keeps the crate's *users* out — the
integration tests and the shim binaries — but `pub(crate)` is crate-wide, so
on its own it would not stop `approve.rs` from writing SQL tomorrow. The layer
that does is `tests/schema_ownership.rs`: it walks `src/` and fails the build
if a statement literal or a rusqlite statement call appears outside `src/db/`.
It was checked against a deliberate violation. The test harness still needs to
construct states no typed API reaches, so the raw door exists but only under
the `test-support` feature, which nothing but this crate's own dev-dependency
enables; a production binary cannot see it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The gate asked whether the request carried `Cookie: auth=1`, and login did
nothing but set that literal value, so the password protected the login form
and nothing else: anyone could read the reviews, the audit log, the settings
and the build logs by typing the cookie themselves, and the CSRF step then
happily minted them a session to POST with. The random sid machinery was
already there and already unguessable; it was just never bound to the flag
that said "someone authenticated".
A session now carries that flag. `auth.rs` holds a map of live sids to
whether they passed the password gate; `authenticate` can only flip a sid this
process minted, so a login attempt cannot mint a session as a side effect.
`gate` asks `is_authenticated(sid)` and nothing else, and the `auth` cookie is
gone from both the login response and the logout one. Login rotates the sid
rather than promoting the anonymous one, so the session that existed before
the password was typed is never the one that carries the privilege after it;
logout drops the sid, which invalidates its derived CSRF token with it.
Two tests, both over a bare socket because a client that follows redirects
turns "you are not signed in" into the login page's 200 and hides the whole
point: `a_forged_auth_cookie_is_not_a_session` (the exact forgery, on every
sensitive surface, GET and POST) and `login_rotates_the_session_and_logout_ends_it`
(rotation, dead pre-login sid, dead logged-out sid). The audit actor is
honest now too: with a password set, only an authenticated session is "web".
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(I6)
Attention, the package page and the builds page now answer real questions
instead of rendering empty tables:
- Attention lists outdated dependencies derived from the recorded world
snapshots, naming the dependency that moved, what the artifact was built
against and what the index holds now; also missing dependencies and
downgrades (AUR offering a lower version than we serve), which is an
announcement for a human, not a build request.
- The package page shows depends-on from the recipe we actually serve and
needed-by from the packages whose recipes name it, plus staleness and the
aur_commit timeline, each release linking into cgit at that exact commit.
- Builds rows carry the version they are about, in both the live and the
recently-finished table.
- A manual rebuild reuses the approved source identity and mints no approval
(I6); the test asserts the approval count is unchanged before and after the
rebuild runs.
- A paused subscription is not observed at all: detection returns Paused
without polling, so pausing a broken package stops it opening reviews.
- Staleness stays computed on read (§10.2). Nothing stores a stale flag, so
nothing can serve a stale lie.
Also: dep-client fixture added for dependency pairs.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
|
|
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).
|