summaryrefslogtreecommitdiffstats
path: root/src/watch
Commit message (Collapse)AuthorAgeFilesLines
* pipeline, watch: a source identity that is complete when it existsaur-build13 days1-0/+12
| | | | | | | | | | | | | | | | | | | n-1. `SourceIdentity::from_candidate` returned a value with `aur_commit` and `recipe_hash` set to empty strings, which `Ctx::new` overwrote afterwards if it found the snapshot row. So the type had two meanings for "" — not filled in yet, and genuinely absent — and the second half of the construction was a convention rather than a requirement: a new call site could produce a build that recorded empty provenance and never noticed. The snapshot is an argument now, a candidate without its snapshot is an error rather than a quieter build, and the field `identity_hash`, which nothing ever read, is gone. n-2. `detect::Outcome` mirrors four of `candidates::Upsert`'s variants. Kept, with the reason in the code: `Upsert` answers "what did the candidate write do" and `Outcome` answers "what should the watcher do next", including the outcomes that never reach the candidate table (paused, gone, blocked, notice). Merging them would move watcher concerns into the review module and put storage vocabulary in the scheduler's matches. The converter is total and compiler-checked, which is what makes the mirror safe.
* db, watch: two N+1s and a version rule with one owneraur-build13 days1-11/+12
| | | | | | | | | | | | | | | | | | | | | | m-17. `watch::staleness::dependents_of` walked the index and asked for each package's recipe by name — one query per package, on the path that runs after every publish, with N equal to the size of the index. `db::index_recipes` returns the whole table in one query now. While there: a recipe that fails to parse is no longer treated as "does not depend on this package". An unreadable srcinfo used to hide a dependent from staleness by returning `None` into an `unwrap_or(false)`; now it is a reason to look. `db::builds::requeue_blocked` asked "is this name in the index?" once per dependency of every blocked build, inside the dispatcher's hot loop. The set of in-index names is read once per pass and tested in memory. Same answer, one query. m-18. `approved_but_unbuilt` assembled the version a human reads with two `CASE WHEN epoch='0'` expressions in SQL — a second, independent copy of the `epoch:pkgver-pkgrel` rule that `pkgver::full_version` owns. Two copies of a formatting rule is how the Attention page ends up describing versions differently from every other page. The query returns the parts; Rust formats them. A guard test fails if version-string concatenation reappears in SQL.
* watch, review, config: the clarity minors — no-ops, dead params, one error ↵aur-build13 days3-16/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | type m-5. `mark_approved_but_unbuilt` was a function that did nothing, called from the failure path with a comment explaining that it did nothing. The mechanism is real — a failed build leaves the accepted pointer alone, and "approved, build failed, index still serving the old version" is what the derived query reads back — but a no-op in the failure path is a trap for whoever traces a build failure at 3am. Deleted; the explanation moved to the call site that needs it. m-6. The step loop extended the lease by a hardcoded 90 seconds while `Config` carried `lease_secs`, so an operator who raised the lease got leases that were silently reset to 90s after the first step. m-8. Dead parameters and `let _ =` debris: `upstream::run` took a `Db` it never used (and a `let _ = local;` after the value's only use), `risk::assess` took a `Pkgbase` it never used, `accepted_pins` took a `Db`, `detect::schedule_next` took a `Pkgbase` it discarded, `diff::version_delta` computed a `vercmp` and threw the answer away, and two HTTP handlers took arguments they ignored. All gone, with the callers following. m-11. `schedule_next` re-queried the subscription for `poll_interval_secs` that its caller had read moments earlier to decide whether the pkgbase was paused — two queries, and two chances to get different answers. The interval is now an argument, and the scheduler's own tick (which already holds the row) was already doing it the right way. m-15. `Config::load`/`save`/`ensure_dirs` returned `anyhow::Result` while the rest of the crate returns `error::Error`, which put two vocabularies on either side of one boundary and turned "there is no config yet, run init" — the one thing a caller can branch on — into an opaque string. They return the crate's error now; `main` keeps `anyhow` at the CLI edge, where it belongs. m-19. `skip_declared` was hardcoded `true` for VCS entries, so the field that means "the recipe gave us no checksum to trust" also meant "this is a git source", and a new `-git` source was rendered to a reviewer as `sha256sums=SKIP` — a warning about a recipe that had done nothing wrong. The field now means one thing everywhere, `SourceDigest::is_vcs()` says which integrity mechanism protects an entry, and the diff panel prints "pinned commit" for those. n-6. `recipe_at` was `pub` for no reason; it is `pub(crate)`.
* db: the review, step, release and subscription states are enums tooaur-build13 days1-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | M-8 named four more machines after `build_state`, and each had the same defect in miniature: `&str` constants, a writer that took any `&str`, and a rule that lived only in the caller's discipline. They are `CandidateState`, `StepState`, `ReleaseState` and `SubscriptionState` now, all parsed through one `db::state_col` at the row boundary — a column value the code cannot name fails the read rather than becoming a state it did not ask for. The one that mattered is the review machine. `resolve_in(tx, id, &str)` would move a candidate to any state from any state, so an approval racing a rejection, or a stale worker resolving a review that had already been superseded, silently overwrote what a human had decided — the direct route to breaking I2 and I3 with no symptom anywhere. It is a compare-and-swap on `CandidateState` now: a decided review is only ever frozen, never re-decided, and a refusal names both states. `supersede_in` goes through it, so the freeze cannot resurrect a superseded review either. `StepState` gives I5 teeth. `begin_step` upserted over any existing checkpoint, including one recorded `succeeded`, so a resume that asked to re-run a finished step could rewrite the very row that told it to skip; the upsert now refuses to touch a done checkpoint and `finish_step` is a CAS. The blocked path (`running → pending`) and the reaper's `running → interrupted` are unchanged, and both are in the table. Two behaviour changes, both for the better and both tested: the UI's pause button now says "orphaned: nothing to pause" instead of rewriting an orphaned subscription back to a pausable state, and a step checkpoint that is already done makes `begin_step` an error rather than a quiet overwrite. Five tests in `tests/state_machine.rs` cover the review CAS in both directions, the frozen checkpoint, the interrupted/blocked transitions, and the unknown value in a candidate and a step row.
* db, watch: two upward edges removed, and the layering is now a testaur-build13 days3-34/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | M-6. `db::stage_b_cache_get` and `db::stage_b_recent` returned `watch::upstream::StageB`, so the persistence layer could not be read without the VCS watcher, and the table's row shape was defined by whatever the watcher happened to find convenient. The row is `db::model::StageBCacheRow` now — epoch, pkgver, pkgrel, pins — and `watch::upstream` converts at its own boundary. The two types are deliberately not the same one: `StageB` carries `cached`, and "was this answer a cache hit?" is a fact about the resolution that just happened, not a column. M-7. `review::risk` called `watch::digests::skip_on_non_vcs` while `watch::detect` called into `review::candidates`, a cycle between two sibling domains. Whether a recipe declines to verify its own sources is a question about the recipe, so `skip_on_non_vcs` — with `SKIP`, `declared_sums` and `is_hex_digest`, which it needed and which the watcher had no business owning — moved to `recipe.rs`, a leaf both sides may look down at. `watch::digests` keeps its use of them for digest resolution; the re-export is gone. `tests/layers.rs` enforces the direction from now on: `src/db` names no module above itself, `src/review` does not name `watch`, `src/watch` does not name `pipeline` or `http`, and `recipe.rs` names nothing at all. Each rule failed before this commit and each failure message prints the exact file and line of the offending edge, so the next reasonable-looking commit cannot reintroduce one quietly.
* db: the schema gets an owner — every statement moves into db/, and the ↵aur-build13 days3-92/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* hash: canonical_json is canonical now, and a serialization failure is an erroraur-build13 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The function behind `Identity::hash` — the digest an approval echoes back — did two things its name promised and it did not do. It did not order anything: the doc comment conceded that callers were expected to pass "already-canonical values", which is a convention, not a property, and a struct serializes in whatever order its fields were declared. And on a serialization failure it returned `"{}"`, so every value that failed to serialize hashed to one shared digest. For a system whose whole job is provenance, "two identities that could not be serialized would look identical to the approval echo" is the worst possible failure to have available. Serialization now routes through `serde_json::Value`, whose map is a `BTreeMap`, so object keys come out sorted whatever the input's construction order — the name describes what happens. A failure propagates: `canonical_json` returns `Result`, `Identity::hash` returns `Result`, and the four call sites (detect, put_world_snapshot, the world step, both enqueue paths) pass it on. There is no path left where a digest is invented for a value that could not be rendered. `tests/hash.rs` pins all three properties: an unserializable value is an error naming itself, two same-field-different-declaration-order values render identically (and to the exact compact sorted bytes), and the identity digest changes when any element of the tuple changes.
* staleness: blocked builds wait properly, and the review answers §10.3 ↵aur-build13 days1-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | before you approve Three real defects, all found while writing the tests that pin §10 down: - **requeue_blocked requeued everything blocked.** The dispatcher sweeps it every pass, so a build waiting on a package that has not arrived was put back on the queue, claimed, blocked again, and repeated — a busy loop burning a claim and a plan step each tick. It now only requeues a build whose every blocking name is actually in the index. The old pipeline test asserted the broken behaviour and has been rewritten to assert the correct one. - **The review page could not warn about missing dependencies, because nothing ever computed them.** candidates::set_missing_deps existed and was never called; missing deps were discovered at plan time, i.e. after a human had already approved. Detection now records them with the same rule the plan step uses, so the reviewer sees 'the build will block until these are published' before deciding, and the CLI and the page agree because both read the row. - **The dependents question was unanswered.** §10.3 asks 'approving this marks N packages stale'. The review page now says exactly that and names them, from the same derivation the Attention page uses. tests/staleness.rs (6 tests) also pins the claims that were easy to fake: staleness is derived on read — a schema scan asserts no column anywhere stores it, and withdrawing a dependency flips a dependent from Outdated to Missing without a single write to the dependent; a blocked build names its blocker on Attention and is not counted as a failure; a dependency we stopped publishing reads as missing rather than outdated. dep-partner added to the corpus so blocked builds are testable end to end. 149 tests pass, clippy clean.
* http: surfaces driven by live state — staleness, downgrades, deps, rebuild ↵aur-build13 days2-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* http: the review surface — server-rendered, no JavaScript required (§12, ↵aur-build13 days2-0/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | §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.
* review: advisory risk scoring and non-publishable change handling (§6, ↵aur-build13 days1-4/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | §5.3, I11) Every candidate is scored against the recipe the accepted release was actually built from (release -> candidate -> snapshot), never against 'last seen'. Signals: SKIP on a non-VCS source, a sum changed to SKIP, new source host, --skippgpcheck, removed validpgpkeys, new makedepends and fetching build tools (cargo/npm/go/pip), .install scripts, weakened options, removed checkdepends, pkgrel reset, epoch bump, downgrade, a diff touching build()/package() bodies rather than metadata, upstream ranges that touch a build-system file, and first introduction. Advisory only — there is no auto-approval, so a wrong score costs attention and never safety (§7.3). Fixes a fixture bug the new tests exposed: digest-drift and skip-checksum declared bare paths as sources, which parse as local recipe files rather than remote downloads, so the drift path never fired. They now use file:// URLs like a real remote would. tests/notices.rs: integrity_alert is high severity and leaves no candidate, pin_drift is informational, recipe drift under a static version is a warning, SKIP-on-non-VCS is a high risk signal, repeated polling of one drift is one notice, and an I11 sweep over twelve fixtures proving a change is never silently dropped.
* watch: two-stage VCS watcher — ls-remote probe, pkgver() resolution, pin ↵aur-build13 days3-10/+346
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: AUR mirror watcher, recipe parsing, candidate creationaur-build14 days5-0/+683
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).