From 22983d23554071013fb9caaa3a018ff2b649718b Mon Sep 17 00:00:00 2001 From: aur-build Date: Tue, 17 Nov 2026 22:09:13 +0000 Subject: =?UTF-8?q?cli:=20operator=20command=20line=20with=20the=20approva?= =?UTF-8?q?l=20path=20(=C2=A77.2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit aur-build init/subscribe/detect/reviews/show/approve/reject/build/run/ builds/status/packages/audit. approve renders the review and then approves with the hashes it just rendered, so the CLI cannot approve a diff it did not show you; --identity/--diff reproduce the stale case explicitly and a refusal exits 2 (the web equivalent is 409). Approvals are now immutable at the schema level: migration 0006 rejects UPDATE and DELETE on the approval table, because that row is the only proof the system has of what a human actually looked at (§7.2, I10). Publishing also refuses when no approval is reachable, including the manual-rebuild path that inherits one. 10 tests, including two that drive the compiled binary end to end against a file:// AUR fixture. --- .pi/.goals-pool-snapshot.json | 2 +- .pi/goals/.goal-ledger-checkpoint.json | 2 +- ...active_goal_2026111720432444_mwl5tehk-xhe7fk.md | 20 +- .pi/goals/goal_events.jsonl | 2 + Cargo.toml | 2 +- src/db/migrations.rs | 18 ++ src/main.rs | 311 ++++++++++++++++++++- src/pipeline/publish.rs | 18 +- src/review/candidates.rs | 20 ++ tests/approve.rs | 285 +++++++++++++++++++ tests/db.rs | 2 +- tests/pipeline.rs | 13 +- 12 files changed, 668 insertions(+), 27 deletions(-) create mode 100644 tests/approve.rs diff --git a/.pi/.goals-pool-snapshot.json b/.pi/.goals-pool-snapshot.json index 62ca13b..93584c1 100644 --- a/.pi/.goals-pool-snapshot.json +++ b/.pi/.goals-pool-snapshot.json @@ -1 +1 @@ -{"version":1,"dirMtimeMs":1794952630571.538,"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":1848360,"activeSeconds":4224},"sisyphus":false,"createdAt":"2026-11-17T20:43:24.440Z","updatedAt":"2026-11-17T21:57:10.569Z","activePath":".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md","revision":201,"scheduler":{"version":1,"owner":"01a1eb32-2e3f-757c-a79a-21ac993facc5","generation":"c7162450-1294-427e-aa34-597ba566e462","used":1,"phase":"running","repairUsed":false,"decision":{"kind":"ready","purpose":"ready"},"dispatch":{"id":"b07063cc-4112-4b45-b62f-b597761e0d52","kind":"ready","claimedAt":1794948204539}},"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":"pending","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":"pending","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."},{"id":"task-p0-build","title":"Build pipeline steps 0–9 and atomic signed publish (§8.1, §9)","status":"pending","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."},{"id":"task-p0-invariants","title":"Executable invariant tests I1/I2/I4/I5/I8","status":"pending","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)."}]},{"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-p0-build"}]} \ No newline at end of file +{"version":1,"dirMtimeMs":1794953348584.5046,"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":2043927,"activeSeconds":4924},"sisyphus":false,"createdAt":"2026-11-17T20:43:24.440Z","updatedAt":"2026-11-17T22:09:08.579Z","activePath":".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md","revision":235,"scheduler":{"version":1,"owner":"01a1eb32-2e3f-757c-a79a-21ac993facc5","generation":"c7162450-1294-427e-aa34-597ba566e462","used":1,"phase":"running","repairUsed":false,"decision":{"kind":"ready","purpose":"ready"},"dispatch":{"id":"b07063cc-4112-4b45-b62f-b597761e0d52","kind":"ready","claimedAt":1794948204539}},"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":"pending","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":"pending","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."},{"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":"pending","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)."}]},{"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-p0-approve"}]} \ No newline at end of file diff --git a/.pi/goals/.goal-ledger-checkpoint.json b/.pi/goals/.goal-ledger-checkpoint.json index b27d986..3532257 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-17T21:32:52.781Z","coveredBytes":5612,"coveredEvents":11,"acc":{"goals":[{"goalId":"mwl5tehk-xhe7fk","latestStatus":"active","latestFocus":false,"createdAt":"2026-11-17T20:43:24.440Z"}],"terminalGoals":[],"focusedGoalId":null,"focusGeneration":0,"focusGenByGoal":[]},"recentEventsByGoal":[["mwl5tehk-xhe7fk",[{"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_list_set","goalId":"mwl5tehk-xhe7fk","taskCount":7,"blockCompletion":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"}]]],"runtimeIndex":[["mwl5tehk-xhe7fk",{"recent":[{"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_list_set","goalId":"mwl5tehk-xhe7fk","taskCount":7,"blockCompletion":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"}],"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"}],"oracle":[],"lifecycle":{"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"},"lastActivityEvent":{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","at":"2026-11-17T21:32:52.768Z"}}]]} \ No newline at end of file +{"version":4,"format":"goal-ledger-checkpoint","createdAt":"2026-11-17T21:58:43.353Z","coveredBytes":6015,"coveredEvents":13,"acc":{"goals":[{"goalId":"mwl5tehk-xhe7fk","latestStatus":"active","latestFocus":false,"createdAt":"2026-11-17T20:43:24.440Z"}],"terminalGoals":[],"focusedGoalId":null,"focusGeneration":0,"focusGenByGoal":[]},"recentEventsByGoal":[["mwl5tehk-xhe7fk",[{"type":"task_list_set","goalId":"mwl5tehk-xhe7fk","taskCount":7,"blockCompletion":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"}]]],"runtimeIndex":[["mwl5tehk-xhe7fk",{"recent":[{"type":"task_list_set","goalId":"mwl5tehk-xhe7fk","taskCount":7,"blockCompletion":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"}],"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"}],"oracle":[],"lifecycle":{"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"},"lastActivityEvent":{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","at":"2026-11-17T21:58:43.315Z"}}]]} \ 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 04fdf9e..ec91fe8 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": 1848360, - "activeSeconds": 4224 + "tokensUsed": 2043927, + "activeSeconds": 4924 }, "sisyphus": false, "createdAt": "2026-11-17T20:43:24.440Z", - "updatedAt": "2026-11-17T21:57:10.569Z", + "updatedAt": "2026-11-17T22:09:08.579Z", "activePath": ".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md", - "revision": 201, + "revision": 235, "scheduler": { "version": 1, "owner": "01a1eb32-2e3f-757c-a79a-21ac993facc5", @@ -78,8 +78,10 @@ { "id": "task-p0-build", "title": "Build pipeline steps 0–9 and atomic signed publish (§8.1, §9)", - "status": "pending", - "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." + "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", @@ -211,7 +213,7 @@ "blockCompletion": true, "proposedAt": "2026-11-17T20:39:23.165Z" }, - "currentTaskId": "task-p0-build" + "currentTaskId": "task-p0-approve" } # Goal Prompt @@ -244,8 +246,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: 1h10m24s -- Tokens used: 1.8M (1,848,360) tokens +- Time spent: 1h22m04s +- Tokens used: 2M (2,043,927) tokens ## Tasks diff --git a/.pi/goals/goal_events.jsonl b/.pi/goals/goal_events.jsonl index 8bbabc3..8e5ef14 100644 --- a/.pi/goals/goal_events.jsonl +++ b/.pi/goals/goal_events.jsonl @@ -9,3 +9,5 @@ {"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"} diff --git a/Cargo.toml b/Cargo.toml index ed3b0f7..7a687f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ serde = { version = "1", features = ["derive"] } serde_json = "1" sha2 = "0.10" hex = "0.4" -clap = { version = "4", features = ["derive"] } +clap = { version = "4", features = ["derive", "env"] } chrono = { version = "0.4", features = ["serde"] } walkdir = "2" tar = "0.4" diff --git a/src/db/migrations.rs b/src/db/migrations.rs index dddb301..8ba925c 100644 --- a/src/db/migrations.rs +++ b/src/db/migrations.rs @@ -282,12 +282,30 @@ ALTER TABLE artifact ADD COLUMN build_id TEXT; CREATE INDEX artifact_by_build ON artifact (build_id); "#; +/// §7.2: the approval record is immutable. It is the only proof the system has +/// of *what a human actually looked at*, so editing it would let a later +/// attacker retarget a published artifact onto a clean review. +const M_0006_APPROVAL_IMMUTABLE: &str = r#" +CREATE TRIGGER approval_no_update +BEFORE UPDATE ON approval +BEGIN + SELECT RAISE(ABORT, 'approval records are immutable'); +END; + +CREATE TRIGGER approval_no_delete +BEFORE DELETE ON approval +BEGIN + SELECT RAISE(ABORT, 'approval records are immutable'); +END; +"#; + pub static MIGRATIONS: &[Migration] = &[ Migration { version: 1, name: "core", sql: M_0001_CORE }, Migration { version: 2, name: "build", sql: M_0002_BUILD }, Migration { version: 3, name: "notices", sql: M_0003_NOTICES }, Migration { version: 4, name: "audit-triggers", sql: M_0004_TRIGGERS }, Migration { version: 5, name: "artifact-build", sql: M_0005_ARTIFACT_BUILD }, + Migration { version: 6, name: "approval-immutable", sql: M_0006_APPROVAL_IMMUTABLE }, ]; /// Default settings seeded into `settings` (DESIGN.md §11). diff --git a/src/main.rs b/src/main.rs index 0ea8a90..75cb282 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,310 @@ -fn main() { - println!("aur-build"); +//! `aur-build` — the operator's command line (§7.2, §12). +//! +//! P0 ships the approval path as a CLI subcommand: the same code the web UI +//! will call in P2, so the invariant "we build exactly what was displayed, or +//! nothing" is enforced here too. `approve` renders the review, prints it, and +//! then approves with the hashes it just displayed — it cannot approve a diff it +//! did not show you. + +use std::path::PathBuf; + +use clap::{Parser, Subcommand}; + +use aur_build::config::Config; +use aur_build::db::{self, builds, model::*}; +use aur_build::pipeline; +use aur_build::review::{approve as ap, candidates, diff}; + +#[derive(Parser)] +#[command(name = "aur-build", version, about = "AUR build server: nothing is published that a human did not approve")] +struct Cli { + /// Server root (holds config.json, db, mirrors, repo). + #[arg(short, long, env = "AUR_BUILD_ROOT", global = true)] + root: Option, + #[command(subcommand)] + cmd: Cmd, +} + +#[derive(Subcommand)] +enum Cmd { + /// Create the root, config and database. + Init { + #[arg(long)] + repo: Option, + #[arg(long)] + signing_key: Option, + }, + /// Start watching a pkgbase. + Subscribe { + pkgbase: String, + /// Override the AUR URL; a `file://` path is fine, which is how the + /// test suite drives the real binary. + #[arg(long)] + url: Option, + }, + /// Stop watching a pkgbase. + Unsubscribe { pkgbase: String }, + /// Poll AUR now (without this, detection runs on the watcher's schedule). + Detect { pkgbase: Option }, + /// List reviews. + Reviews { + #[arg(long)] + all: bool, + }, + /// Show one review: the diff panels and the two hashes an approval must echo. + Show { candidate: i64 }, + /// Approve a review. Without --yes this only prints what would be approved. + Approve { + candidate: i64, + #[arg(long)] + yes: bool, + #[arg(long)] + note: Option, + /// Approve against hashes you were shown earlier instead of re-rendering. + #[arg(long)] + identity: Option, + #[arg(long)] + diff: Option, + }, + /// Reject a review with a reason. + Reject { + candidate: i64, + #[arg(long)] + note: String, + }, + /// Queue a build for a pending review. + Build { candidate: i64 }, + /// Queue a rebuild of the currently accepted version (no new approval, I6). + Rebuild { pkgbase: String }, + /// Run a queued build to completion in this process. + Run { build: String }, + /// List builds. + Builds, + /// Show a build's step timeline. + Status { build: String }, + /// Show the current index. + Packages, + /// Show recent audit rows. + Audit { + #[arg(long, default_value_t = 30)] + limit: i64, + }, +} + +fn main() -> anyhow::Result<()> { + let cli = Cli::parse(); + let cfg = match &cli.root { + Some(r) => Config::load(r).unwrap_or_else(|_| Config { + root: r.clone(), + ..Config::default() + }), + None => Config::load(&Config::default().root)?, + }; + let ctx = Ctx::open(&cfg)?; + match cli.cmd { + Cmd::Init { repo, signing_key } => { + let mut cfg = cfg; + if let Some(r) = repo { + cfg.repo_name = r; + } + if let Some(k) = signing_key { + cfg.signing_key_id = k; + } + cfg.save()?; + cfg.ensure_dirs()?; + db::migrate(&cfg.db_path())?; + let db = db::Db::open_migrated(&cfg.db_path())?; + let rid = db::ensure_repo( + &db.writer, + &cfg.repo_name, + &cfg.repo_arch_dir().display().to_string(), + &cfg.arch, + &cfg.signing_key_id, + )?; + println!("initialized {} (repo id {rid})", cfg.root.display()); + println!("add to pacman.conf:\n [{}]\n Server = {}/$repo/os/$arch", cfg.repo_name, cfg.base_url); + Ok(()) + } + Cmd::Subscribe { pkgbase, url } => { + let rid = db::repo_id(&ctx.db)?; + let url = url.unwrap_or_else(|| format!("https://aur.archlinux.org/{pkgbase}.git")); + db::subscribe(&ctx.db.writer, rid, &pkgbase, &url)?; + println!("subscribed {pkgbase} ({url})"); + Ok(()) + } + Cmd::Unsubscribe { pkgbase } => { + db::set_subscription_state(&ctx.db.writer, &pkgbase, subscription_state::REMOVED)?; + println!("unsubscribed {pkgbase}"); + Ok(()) + } + Cmd::Detect { pkgbase } => { + let names: Vec = match pkgbase { + Some(n) => vec![n], + None => db::list_subscriptions(&ctx.db)? + .into_iter() + .filter(|s| s.state == subscription_state::ACTIVE) + .map(|s| s.pkgbase) + .collect(), + }; + for n in names { + match aur_build::watch::detect::check_pkgbase(&cfg, &ctx.db, &n) { + Ok(r) => println!("{n}: {:?}", r.outcome), + Err(e) => eprintln!("{n}: {e}"), + } + } + Ok(()) + } + Cmd::Reviews { all } => { + let rows = if all { + candidates::all_candidates(&ctx.db)? + } else { + candidates::pending_candidates(&ctx.db)? + }; + if rows.is_empty() { + println!("nothing pending"); + } + for c in rows { + println!( + "#{:<5} {:<28} {:<16} {:<10} rev{} {}", + c.id, + c.pkgbase, + aur_build::pkgver::full_version(&c.epoch, &c.pkgver, &c.pkgrel), + c.kind, + c.revision, + c.state + ); + } + Ok(()) + } + Cmd::Show { candidate } => { + let c = need_candidate(&ctx.db, candidate)?; + let (text, digest) = diff::render_current(&ctx.db, &cfg, &c)?; + candidates::set_diff_digest(&ctx.db, c.id, &digest)?; + candidates::mark_viewed(&ctx.db, c.id)?; + println!("{text}"); + println!("---"); + println!("identity_hash: {}", c.identity_hash); + println!("diff_digest: {digest}"); + println!("approve with: aur-build approve {} --yes", c.id); + Ok(()) + } + Cmd::Approve { candidate, yes, note, identity, diff: diff_arg } => { + let c = need_candidate(&ctx.db, candidate)?; + // Render first, always. The hashes we send are the hashes of what we + // just rendered, unless the operator explicitly names older ones. + let (text, digest) = diff::render_current(&ctx.db, &cfg, &c)?; + candidates::set_diff_digest(&ctx.db, c.id, &digest)?; + let identity = identity.unwrap_or_else(|| c.identity_hash.clone()); + let diff_arg = diff_arg.unwrap_or(digest); + println!("{text}"); + println!("---"); + if !yes { + println!("not approved: re-run with --yes to approve exactly this"); + return Ok(()); + } + let who = whoami(); + match ap::approve(&ctx.db, &who, c.id, &identity, &diff_arg, note.as_deref()) { + Ok(a) => { + println!("approved #{} (approval {})", c.id, a.id); + let id = pipeline::enqueue_for_candidate(&cfg, &ctx.db, &c)?; + println!("queued build {id}"); + println!("run it with: aur-build run {id}"); + Ok(()) + } + Err(stale) => { + eprintln!("refused: {stale}"); + std::process::exit(2) + } + } + } + Cmd::Reject { candidate, note } => { + let c = need_candidate(&ctx.db, candidate)?; + let who = whoami(); + ap::reject(&ctx.db, &who, c.id, ¬e)?; + println!("rejected #{}", c.id); + Ok(()) + } + Cmd::Build { candidate } => { + let c = need_candidate(&ctx.db, candidate)?; + let id = pipeline::enqueue_for_candidate(&cfg, &ctx.db, &c)?; + println!("queued build {id}"); + Ok(()) + } + Cmd::Rebuild { pkgbase } => { + let id = pipeline::enqueue_manual_rebuild(&cfg, &ctx.db, &pkgbase)?; + println!("queued rebuild {id}"); + Ok(()) + } + Cmd::Run { build } => match pipeline::run(&cfg, &ctx.db, &build)? { + pipeline::Outcome::Succeeded { release_id } => { + println!("succeeded (release {release_id})"); + Ok(()) + } + pipeline::Outcome::Blocked { on } => { + println!("blocked on: {}", on.join(", ")); + std::process::exit(3) + } + pipeline::Outcome::Cancelled => { + println!("cancelled"); + std::process::exit(0) + } + pipeline::Outcome::Failed { step, error, .. } => { + eprintln!("failed at {step}: {error}"); + std::process::exit(1) + } + }, + Cmd::Builds => { + for b in builds::list(&ctx.db, &[build_state::QUEUED, build_state::RUNNING, build_state::LEASED, build_state::BLOCKED_MISSING_DEP], 50)? { + println!("{:<66} {:<20} {}", b.id, b.state, b.current_step.unwrap_or_default()); + } + Ok(()) + } + Cmd::Status { build } => { + for s in builds::steps(&ctx.db, &build)? { + println!("{:<12} {:<12} {}", s.step, s.status, s.error.unwrap_or_default()); + } + Ok(()) + } + Cmd::Packages => { + for p in db::index_packages(&ctx.db)? { + println!("{:<28} {:<16} {}", p.name, p.version, p.arch); + } + Ok(()) + } + Cmd::Audit { limit } => { + for a in db::list_audit(&ctx.db, limit)? { + println!("{} [{}] {} {} {} {}", a.at, a.actor_kind, a.actor, a.action, a.entity_id, a.detail_json); + } + Ok(()) + } + } +} + +struct Ctx { + db: db::Db, +} + +impl Ctx { + fn open(cfg: &Config) -> anyhow::Result { + cfg.ensure_dirs()?; + db::migrate(&cfg.db_path())?; + let db = db::Db::open_migrated(&cfg.db_path())?; + db::ensure_repo( + &db.writer, + &cfg.repo_name, + &cfg.repo_arch_dir().display().to_string(), + &cfg.arch, + &cfg.signing_key_id, + )?; + Ok(Self { db }) + } +} + +fn whoami() -> String { + std::env::var("USER").or_else(|_| std::env::var("USERNAME")).unwrap_or_else(|_| "cli".into()) +} + +fn need_candidate(db: &db::Db, id: i64) -> anyhow::Result { + candidates::candidate_by_id(db, id)? + .ok_or_else(|| anyhow::anyhow!("no candidate #{id}")) } diff --git a/src/pipeline/publish.rs b/src/pipeline/publish.rs index 639d717..5d03a06 100644 --- a/src/pipeline/publish.rs +++ b/src/pipeline/publish.rs @@ -152,19 +152,21 @@ fn commit_release(ctx: &Ctx, collect: &Collect) -> Result { }; // I1: nothing publishes without an approval. A manual rebuild inherits the // approval of the release it rebuilds. - let approval_id = match (approval_id, ctx.build.kind.as_str()) { - (Some(a), _) => Some(a), - (None, "manual_rebuild") => ctx + let inherited = match ctx.build.kind.as_str() { + "manual_rebuild" => ctx .build .release_id .and_then(|rid| db::release_by_id(&ctx.db, rid).ok().flatten()) .and_then(|r| r.approval_id), - (None, other) => { - return Err(Error::fail_closed(format!( - "refusing to publish a {other} build with no approval behind it" - ))) - } + _ => None, }; + let approval_id = approval_id.or(inherited).ok_or_else(|| { + Error::fail_closed(format!( + "refusing to publish a {} build with no approval behind it", + ctx.build.kind + )) + })?; + let build_id = ctx.build.id.clone(); let packages = collect.packages.clone(); let names: Vec = packages.iter().map(|p| p.name.clone()).collect(); diff --git a/src/review/candidates.rs b/src/review/candidates.rs index 4dc6c4f..566434b 100644 --- a/src/review/candidates.rs +++ b/src/review/candidates.rs @@ -142,6 +142,26 @@ impl NewCandidate { } } +/// Every candidate regardless of state, newest first (`aur-build reviews --all`). +pub fn all_candidates(db: &Db) -> Result> { + db.read(|c| { + let mut stmt = c.prepare( + "SELECT c.id, c.pkgbase_id, c.base_release_id, c.kind, c.snapshot_id, c.epoch, c.pkgver, + c.pkgrel, c.upstream_pins_json, c.source_digests_json, c.identity_hash, + c.diff_digest, c.revision, c.viewed_at, c.risk_level, c.risk_signals_json, + c.missing_deps_json, c.state, c.detected_at, c.resolved_at, b.name + FROM candidate c JOIN pkgbase b ON b.id = c.pkgbase_id + ORDER BY c.detected_at DESC LIMIT 500", + )?; + let rows = stmt.query_map([], row_to_candidate)?; + let mut out = Vec::new(); + for r in rows { + out.push(r?); + } + Ok(out) + }) +} + /// Mark a candidate `viewed` the first time a human opens it. That timestamp is /// what decides whether a later detection collapses or supersedes (§7.1). pub fn mark_viewed(db: &Db, id: i64) -> Result<()> { diff --git a/tests/approve.rs b/tests/approve.rs new file mode 100644 index 0000000..fb894f1 --- /dev/null +++ b/tests/approve.rs @@ -0,0 +1,285 @@ +//! Approval semantics (§7.1, §7.1a, §7.2) and the CLI approval path (P0). +//! +//! The rule these tests exist to protect: **we build exactly what was displayed, +//! or nothing.** An approval that does not match the hashes of what the reviewer +//! was shown is refused, never retargeted. + +mod common; + +use aur_build::db::model::*; +use aur_build::review::{approve::Stale, approve::*, candidates, diff}; +use common::*; + +/// Detect, open the review, and render it the way a reviewer opening the page +/// would — returning the candidate plus the two hashes an approval must echo. +fn open_review(env: &Env, name: &str) -> (CandidateRow, String) { + aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, name).unwrap(); + let c = candidates::pending_candidates(&env.db).unwrap().remove(0); + let dd = diff::render_and_store(&env.db, &env.cfg, &c).unwrap(); + (c, dd) +} + +#[test] +fn approve_writes_an_immutable_row_carrying_both_hashes() { + let (env, _fx) = env_with_fixture("plain-make"); + let (c, dd) = open_review(&env, "plain-make"); + let a = approve(&env.db, "tester", c.id, &c.identity_hash, &dd, None).unwrap(); + assert_eq!(a.decision, "approved"); + assert_eq!(a.identity_hash, c.identity_hash); + assert_eq!(a.diff_digest, dd); + // The row itself records them, so "the human approved *this* diff" is + // provable later (§7.2). + let stored: (String, String, Option) = env + .db + .read(|c| { + Ok(c.query_row( + "SELECT identity_hash, diff_digest, note FROM approval WHERE id=?1", + rusqlite::params![a.id], + |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)), + )?) + }) + .unwrap(); + assert_eq!(stored.0, c.identity_hash); + assert_eq!(stored.1, dd); + // Approvals are append-only: the audit trigger rejects any edit (§10 I10). + let err = env + .db + .writer + .tx(move |tx| { + tx.execute("UPDATE approval SET note='rewritten' WHERE id=1", [])?; + Ok(()) + }) + .err(); + assert!(err.is_some(), "approval rows must be immutable"); + // And the human action is in the audit log. + let actions: Vec = env + .db + .read(|c| { + let mut st = c.prepare("SELECT action FROM audit ORDER BY id")?; + let rows = st.query_map([], |r| r.get::<_, String>(0))?; + Ok(rows.filter_map(|r| r.ok()).collect()) + }) + .unwrap(); + assert!(actions.iter().any(|a| a == "approve"), "{actions:?}"); +} + +#[test] +fn a_stale_identity_hash_is_refused() { + let (env, fx) = env_with_fixture("plain-make"); + let (c, dd) = open_review(&env, "plain-make"); + // AUR moves while the reviewer is reading: the candidate collapses in place + // and its identity changes under them. + fx.bump(&[("pkgver", "2.0")]); + aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap(); + let now = candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap(); + assert_ne!(now.identity_hash, c.identity_hash, "identity should have moved"); + + let err = approve(&env.db, "tester", c.id, &c.identity_hash, &dd, None).unwrap_err(); + assert!(matches!(err, Stale::Identity { .. }), "{err:?}"); + assert_eq!( + env.query_i64("SELECT count(*) FROM approval", &[]), + Some(0), + "a refused approval must leave nothing behind" + ); + // Approving with the *current* identity succeeds: the reviewer just has to + // look at what is on screen now. + let dd2 = diff::render_and_store(&env.db, &env.cfg, &now).unwrap(); + approve(&env.db, "tester", c.id, &now.identity_hash, &dd2, None).unwrap(); +} + +#[test] +fn a_stale_diff_digest_is_refused() { + let (env, _fx) = env_with_fixture("plain-make"); + let (c, dd) = open_review(&env, "plain-make"); + let err = approve(&env.db, "tester", c.id, &c.identity_hash, "sha256:whatever", None).unwrap_err(); + assert!(matches!(err, Stale::Diff { .. }), "{err:?}"); + assert_eq!(env.query_i64("SELECT count(*) FROM approval", &[]), Some(0)); + let _ = dd; +} + +#[test] +fn approving_twice_is_refused_not_duplicated() { + let (env, _fx) = env_with_fixture("plain-make"); + let (c, dd) = open_review(&env, "plain-make"); + approve(&env.db, "tester", c.id, &c.identity_hash, &dd, None).unwrap(); + let err = approve(&env.db, "tester", c.id, &c.identity_hash, &dd, None).unwrap_err(); + assert!(matches!(err, Stale::NotPending { .. }), "{err:?}"); + assert_eq!(env.query_i64("SELECT count(*) FROM approval", &[]), Some(1)); +} + +#[test] +fn collapse_in_place_bumps_revision_without_a_new_row() { + let (env, fx) = env_with_fixture("plain-make"); + let (c, _dd) = open_review(&env, "plain-make"); + let first = c.revision; + assert!(c.viewed_at.is_none(), "render_and_store must not mark it viewed"); + + // Nobody has looked at it: the new upstream state collapses *into* the open + // review instead of queueing beside it (§7.1). + fx.bump(&[("pkgver", "2.0")]); + aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap(); + let after = candidates::pending_candidates(&env.db).unwrap(); + assert_eq!(after.len(), 1, "still exactly one open review (I7)"); + assert_eq!(after[0].id, c.id, "same row, not a new one"); + assert!(after[0].revision > first, "revision bumped: {}", after[0].revision); + assert_eq!(after[0].pkgver, "2.0"); + assert_eq!( + env.query_i64("SELECT count(*) FROM candidate WHERE pkgbase_id=?1", ¶ms(vec![after[0].pkgbase_id])), + Some(1) + ); +} + +#[test] +fn once_viewed_a_new_state_freezes_the_old_one_as_superseded() { + let (env, fx) = env_with_fixture("plain-make"); + let (c, _dd) = open_review(&env, "plain-make"); + candidates::mark_viewed(&env.db, c.id).unwrap(); + + fx.bump(&[("pkgver", "3.0")]); + aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap(); + let open = candidates::pending_candidates(&env.db).unwrap(); + assert_eq!(open.len(), 1); + assert_ne!(open[0].id, c.id, "a fresh review was opened"); + let frozen = candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap(); + assert_eq!(frozen.state, candidate_state::SUPERSEDED); + // The frozen one can no longer be approved: approving it would build a + // version nobody is looking at. + let err = approve(&env.db, "tester", c.id, &frozen.identity_hash, &frozen.diff_digest, None).unwrap_err(); + assert!(matches!(err, Stale::NotPending { .. }), "{err:?}"); +} + +#[test] +fn a_rejected_identity_is_not_re_raised() { + let (env, _fx) = env_with_fixture("plain-make"); + let (c, _dd) = open_review(&env, "plain-make"); + reject(&env.db, "tester", c.id, "not this").unwrap(); + // Same upstream state, polled again: nothing new to review. + aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, "plain-make").unwrap(); + assert!(candidates::pending_candidates(&env.db).unwrap().is_empty()); + // A different identity is a different question, and gets its own review. + let err = approve(&env.db, "tester", c.id, &c.identity_hash, &c.diff_digest, None).unwrap_err(); + assert!(matches!(err, Stale::NotPending { .. })); +} + +#[test] +fn reject_requires_a_reason_and_records_it() { + let (env, _fx) = env_with_fixture("plain-make"); + let (c, _dd) = open_review(&env, "plain-make"); + reject(&env.db, "tester", c.id, "upstream dropped the license we rely on").unwrap(); + let cid = c.id; + let note: String = env + .db + .read(|c| { + Ok(c.query_row( + "SELECT note FROM approval WHERE candidate_id=?1", + rusqlite::params![cid], + |r| r.get(0), + )?) + }) + .unwrap(); + assert!(note.contains("license"), "{note}"); +} + +// ------------------------------------------------------------- the CLI path -- + +/// Drive the real binary the way an operator would. This is the P0 approval +/// path: `init`, `subscribe`, `detect`, `show`, `approve --yes`. +#[test] +fn cli_end_to_end_approves_and_queues_a_build() { + let tmp = tempfile::tempdir().unwrap(); + let root = tmp.path().join("root"); + let (aur, _fx) = cli_fixture(tmp.path(), "plain-make"); + let bin = env!("CARGO_BIN_EXE_aur-build"); + + let out = cli(bin, &root, &["init", "--repo", "aurbuild"]); + assert!(out.status.success(), "init: {}", out.stderr); + assert!(root.join("config.json").exists()); + + let url = format!("file://{}", aur.display()); + let out = cli(bin, &root, &["subscribe", "plain-make", "--url", &url]); + assert!(out.status.success(), "subscribe: {}", out.stderr); + + let out = cli(bin, &root, &["detect", "plain-make"]); + assert!(out.status.success(), "detect: {}", out.stderr); + + let out = cli(bin, &root, &["reviews"]); + assert!(out.stdout.contains("#1"), "reviews: {}", out.stdout); + + // `show` renders the panels and the hashes; `approve` without --yes refuses + // to act, which is the CLI's version of "look before you approve". + let out = cli(bin, &root, &["show", "1"]); + assert!(out.stdout.contains("identity_hash"), "show: {}", out.stdout); + let shown = out.stdout.clone(); + + let out = cli(bin, &root, &["approve", "1"]); + assert!(out.stdout.contains("not approved"), "approve w/o --yes: {}", out.stdout); + assert_eq!(cli_count(&root, "approval"), 0); + + let out = cli(bin, &root, &["approve", "1", "--yes", "--note", "looked at it"]); + assert!(out.status.success(), "approve: {}", out.stderr); + assert!(out.stdout.contains("approved #1"), "approve: {}", out.stdout); + assert!(out.stdout.contains("queued build"), "approve should queue: {}", out.stdout); + assert_eq!(cli_count(&root, "approval"), 1); + assert_eq!(cli_count(&root, "build"), 1); + assert!(shown.contains("PKGBUILD") || shown.contains("pkgver"), "diff pane: {shown}"); + + // Approving the same review again is refused with a non-zero status. + let out = cli(bin, &root, &["approve", "1", "--yes"]); + assert_eq!(out.code, Some(2), "stale approval should exit 2: {:?}", out); +} + +#[test] +fn cli_approve_refuses_a_hash_that_was_never_shown() { + let tmp = tempfile::tempdir().unwrap(); + let root = tmp.path().join("root"); + let (aur, _fx) = cli_fixture(tmp.path(), "plain-make"); + let bin = env!("CARGO_BIN_EXE_aur-build"); + cli(bin, &root, &["init"]); + let url = format!("file://{}", aur.display()); + cli(bin, &root, &["subscribe", "plain-make", "--url", &url]); + cli(bin, &root, &["detect", "plain-make"]); + let out = cli(bin, &root, &["approve", "1", "--yes", "--identity", "sha256:invented", "--diff", "sha256:invented"]); + assert_eq!(out.code, Some(2), "must refuse: {:?}", out); + assert!(out.stderr.contains("refused"), "stderr: {}", out.stderr); + assert_eq!(cli_count(&root, "approval"), 0); +} + +#[derive(Debug)] +struct Out { + status: std::process::ExitStatus, + stdout: String, + stderr: String, + code: Option, +} + +fn cli(bin: &str, root: &std::path::Path, args: &[&str]) -> Out { + let out = std::process::Command::new(bin) + .arg("--root") + .arg(root) + .args(args) + .output() + .expect("run aur-build"); + Out { + code: out.status.code(), + status: out.status, + stdout: String::from_utf8_lossy(&out.stdout).into_owned(), + stderr: String::from_utf8_lossy(&out.stderr).into_owned(), + } +} + +/// A local git repo standing in for AUR, so the CLI test needs no network. +fn cli_fixture(root: &std::path::Path, name: &str) -> (std::path::PathBuf, Fixture) { + let fx = materialize_fixture(root, name); + (fx.aur.clone(), fx) +} + +/// Query the CLI's own database through a throwaway read connection. +fn cli_count(root: &std::path::Path, table: &str) -> i64 { + let conn = rusqlite::Connection::open_with_flags( + root.join("aur-build.db"), + rusqlite::OpenFlags::SQLITE_OPEN_READ_ONLY, + ) + .expect("open cli db"); + conn.query_row(&format!("SELECT count(*) FROM {table}"), [], |r| r.get::<_, i64>(0)) + .unwrap() +} diff --git a/tests/db.rs b/tests/db.rs index b455603..f64262a 100644 --- a/tests/db.rs +++ b/tests/db.rs @@ -39,7 +39,7 @@ fn migrations_apply_from_empty_and_are_idempotent() { Ok(c.pragma_query_value(None, "user_version", |r| r.get::<_, u32>(0))?) }) .unwrap(); - assert_eq!(v, 5, "all migrations applied"); + assert_eq!(v, 6, "all migrations applied"); // Re-running migration over an existing DB is a no-op, not an error. assert_eq!(db::migrate(&env.cfg.db_path()).unwrap(), 0); let journal: String = env diff --git a/tests/pipeline.rs b/tests/pipeline.rs index 835dcf0..1ad1dfd 100644 --- a/tests/pipeline.rs +++ b/tests/pipeline.rs @@ -404,9 +404,13 @@ fn i12_world_snapshot_is_recorded_at_ingest() { fn publish_refuses_without_an_approval_behind_it() { let (env, _fx) = env_with_fixture("plain-make"); let c = approve_fixture(&env, "plain-make"); - let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap(); - // Strip the approval: the publish step must refuse, not publish anyway. - env.exec("DELETE FROM approval", &[]); + run_for(&env, &c); + // Approval rows are immutable (I10 / §7.2), so we build the bad state from + // the other side: a release with nothing behind it. A rebuild of it must + // still refuse to publish — the guard is on publishing, not on noticing. + let rid = db::accepted_release(&env.db, "plain-make").unwrap().unwrap().id; + env.exec("UPDATE release SET approval_id=NULL WHERE id=?1", ¶ms(vec![rid])); + let id = pipeline::enqueue_manual_rebuild(&env.cfg, &env.db, "plain-make").unwrap(); match pipeline::run(&env.cfg, &env.db, &id).unwrap() { pipeline::Outcome::Failed { step, error, .. } => { assert_eq!(step, "publish"); @@ -414,7 +418,8 @@ fn publish_refuses_without_an_approval_behind_it() { } other => panic!("I1 requires a refusal, got {other:?}"), } - assert!(in_index(&env).is_empty()); + // The index still holds exactly the one entry that does have an approval. + assert_eq!(in_index(&env).len(), 1); } #[test] -- cgit v1.2.3