summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.pi/.goals-pool-snapshot.json2
-rw-r--r--.pi/goals/.goal-ledger-checkpoint.json2
-rw-r--r--.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md20
-rw-r--r--.pi/goals/goal_events.jsonl2
-rw-r--r--Cargo.toml2
-rw-r--r--src/bin/gpg.rs6
-rw-r--r--src/bin/makechrootpkg.rs6
-rw-r--r--src/bin/makepkg.rs6
-rw-r--r--src/bin/mkarchroot.rs6
-rw-r--r--src/bin/pacman.rs6
-rw-r--r--src/bin/repo-add.rs6
-rw-r--r--src/config.rs21
-rw-r--r--src/lib.rs1
-rw-r--r--src/shims/mod.rs641
-rw-r--r--testcorpus/build-fails/PKGBUILD13
-rw-r--r--testcorpus/build-fails/manifest.json31
-rw-r--r--testcorpus/check-fails/PKGBUILD14
-rw-r--r--testcorpus/check-fails/manifest.json30
-rw-r--r--testcorpus/dep-cycle/PKGBUILD14
-rw-r--r--testcorpus/dep-cycle/manifest.json36
-rw-r--r--testcorpus/digest-drift/PKGBUILD15
-rw-r--r--testcorpus/digest-drift/manifest.json30
-rw-r--r--testcorpus/digest-drift/payload.bin1
-rw-r--r--testcorpus/downgrade/PKGBUILD13
-rw-r--r--testcorpus/downgrade/manifest.json33
-rw-r--r--testcorpus/epoch-bump/PKGBUILD13
-rw-r--r--testcorpus/epoch-bump/manifest.json33
-rw-r--r--testcorpus/git-sourced/PKGBUILD19
-rw-r--r--testcorpus/git-sourced/manifest.json31
-rw-r--r--testcorpus/git-submodules/PKGBUILD15
-rw-r--r--testcorpus/git-submodules/manifest.json28
-rw-r--r--testcorpus/install-hooks/PKGBUILD14
-rw-r--r--testcorpus/install-hooks/install-hooks.install6
-rw-r--r--testcorpus/install-hooks/manifest.json30
-rw-r--r--testcorpus/missing-dep/PKGBUILD14
-rw-r--r--testcorpus/missing-dep/manifest.json41
-rw-r--r--testcorpus/pin-drift/PKGBUILD15
-rw-r--r--testcorpus/pin-drift/manifest.json31
-rw-r--r--testcorpus/pkgrel-reset/PKGBUILD13
-rw-r--r--testcorpus/pkgrel-reset/manifest.json33
-rw-r--r--testcorpus/plain-make/PKGBUILD13
-rw-r--r--testcorpus/plain-make/manifest.json33
-rw-r--r--testcorpus/skip-checksum/PKGBUILD15
-rw-r--r--testcorpus/skip-checksum/manifest.json32
-rw-r--r--testcorpus/skip-checksum/payload.bin1
-rw-r--r--testcorpus/split-pkgbase/PKGBUILD20
-rw-r--r--testcorpus/split-pkgbase/manifest.json35
-rw-r--r--testcorpus/unresolvable/PKGBUILD15
-rw-r--r--testcorpus/unresolvable/manifest.json30
-rw-r--r--testcorpus/with-patch/PKGBUILD15
-rw-r--r--testcorpus/with-patch/fix.patch5
-rw-r--r--testcorpus/with-patch/manifest.json30
-rw-r--r--tests/common/mod.rs151
-rw-r--r--tests/shims.rs309
54 files changed, 1980 insertions, 17 deletions
diff --git a/.pi/.goals-pool-snapshot.json b/.pi/.goals-pool-snapshot.json
index bf2cb53..2267dfc 100644
--- a/.pi/.goals-pool-snapshot.json
+++ b/.pi/.goals-pool-snapshot.json
@@ -1 +1 @@
-{"version":1,"dirMtimeMs":1794950339520.5022,"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":790359,"activeSeconds":2083},"sisyphus":false,"createdAt":"2026-11-17T20:43:24.440Z","updatedAt":"2026-11-17T21:18:59.512Z","activePath":".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md","revision":113,"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":"pending","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."},{"id":"task-p0-detect","title":"AUR mirror watcher: aur_commit pin, recipe_hash, source digests, candidate creation (§5.1, §5.1a, §5.3)","status":"pending","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."},{"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-detect"}]} \ No newline at end of file
+{"version":1,"dirMtimeMs":1794951010773.5957,"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":1174285,"activeSeconds":2746},"sisyphus":false,"createdAt":"2026-11-17T20:43:24.440Z","updatedAt":"2026-11-17T21:30:10.771Z","activePath":".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md","revision":134,"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":"pending","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."},{"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-shims"}]} \ No newline at end of file
diff --git a/.pi/goals/.goal-ledger-checkpoint.json b/.pi/goals/.goal-ledger-checkpoint.json
index c6dc2ea..91c7f6e 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:00:48.001Z","coveredBytes":4747,"coveredEvents":7,"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"}]]],"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"}],"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"}],"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-detect","at":"2026-11-17T21:00:47.994Z"}}]]} \ No newline at end of file
+{"version":4,"format":"goal-ledger-checkpoint","createdAt":"2026-11-17T21:21:28.005Z","coveredBytes":5181,"coveredEvents":9,"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"}]]],"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"}],"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"}],"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-shims","at":"2026-11-17T21:21:27.981Z"}}]]} \ 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 957cea5..ffbe5ca 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": 790359,
- "activeSeconds": 2083
+ "tokensUsed": 1174285,
+ "activeSeconds": 2746
},
"sisyphus": false,
"createdAt": "2026-11-17T20:43:24.440Z",
- "updatedAt": "2026-11-17T21:18:59.512Z",
+ "updatedAt": "2026-11-17T21:30:10.771Z",
"activePath": ".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md",
- "revision": 113,
+ "revision": 134,
"scheduler": {
"version": 1,
"owner": "01a1eb32-2e3f-757c-a79a-21ac993facc5",
@@ -62,8 +62,10 @@
{
"id": "task-p0-detect",
"title": "AUR mirror watcher: aur_commit pin, recipe_hash, source digests, candidate creation (§5.1, §5.1a, §5.3)",
- "status": "pending",
- "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."
+ "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",
@@ -207,7 +209,7 @@
"blockCompletion": true,
"proposedAt": "2026-11-17T20:39:23.165Z"
},
- "currentTaskId": "task-p0-detect"
+ "currentTaskId": "task-p0-shims"
}
# Goal Prompt
@@ -240,8 +242,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: 34m43s
-- Tokens used: 790K (790,359) tokens
+- Time spent: 45m46s
+- Tokens used: 1.2M (1,174,285) tokens
## Tasks
<!-- blockCompletion: true -->
diff --git a/.pi/goals/goal_events.jsonl b/.pi/goals/goal_events.jsonl
index 3551e1a..3748eec 100644
--- a/.pi/goals/goal_events.jsonl
+++ b/.pi/goals/goal_events.jsonl
@@ -5,3 +5,5 @@
{"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"}
diff --git a/Cargo.toml b/Cargo.toml
index 1749fac..ed3b0f7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -64,3 +64,5 @@ unused_dependencies = "allow"
[dev-dependencies]
tempfile = "3"
+flate2 = "1"
+tar = "0.4"
diff --git a/src/bin/gpg.rs b/src/bin/gpg.rs
index 1c84fe2..e9df5e3 100644
--- a/src/bin/gpg.rs
+++ b/src/bin/gpg.rs
@@ -1 +1,5 @@
-fn main() { eprintln!("shim: gpg (not implemented)"); std::process::exit(70); }
+//! Toolchain shim: `gpg` (§16a). See `aur_build::shims`.
+
+fn main() {
+ std::process::exit(aur_build::shims::run("gpg"));
+}
diff --git a/src/bin/makechrootpkg.rs b/src/bin/makechrootpkg.rs
index 4043161..00569fb 100644
--- a/src/bin/makechrootpkg.rs
+++ b/src/bin/makechrootpkg.rs
@@ -1 +1,5 @@
-fn main() { eprintln!("shim: makechrootpkg (not implemented)"); std::process::exit(70); }
+//! Toolchain shim: `makechrootpkg` (§16a). See `aur_build::shims`.
+
+fn main() {
+ std::process::exit(aur_build::shims::run("makechrootpkg"));
+}
diff --git a/src/bin/makepkg.rs b/src/bin/makepkg.rs
index 9b3411b..1c5cd7f 100644
--- a/src/bin/makepkg.rs
+++ b/src/bin/makepkg.rs
@@ -1 +1,5 @@
-fn main() { eprintln!("shim: makepkg (not implemented)"); std::process::exit(70); }
+//! Toolchain shim: `makepkg` (§16a). See `aur_build::shims`.
+
+fn main() {
+ std::process::exit(aur_build::shims::run("makepkg"));
+}
diff --git a/src/bin/mkarchroot.rs b/src/bin/mkarchroot.rs
index f7c12e8..a4be6eb 100644
--- a/src/bin/mkarchroot.rs
+++ b/src/bin/mkarchroot.rs
@@ -1 +1,5 @@
-fn main() { eprintln!("shim: mkarchroot (not implemented)"); std::process::exit(70); }
+//! Toolchain shim: `mkarchroot` (§16a). See `aur_build::shims`.
+
+fn main() {
+ std::process::exit(aur_build::shims::run("mkarchroot"));
+}
diff --git a/src/bin/pacman.rs b/src/bin/pacman.rs
index bdcb13b..5f7a357 100644
--- a/src/bin/pacman.rs
+++ b/src/bin/pacman.rs
@@ -1 +1,5 @@
-fn main() { eprintln!("shim: pacman (not implemented)"); std::process::exit(70); }
+//! Toolchain shim: `pacman` (§16a). See `aur_build::shims`.
+
+fn main() {
+ std::process::exit(aur_build::shims::run("pacman"));
+}
diff --git a/src/bin/repo-add.rs b/src/bin/repo-add.rs
index 87abfd2..6714de6 100644
--- a/src/bin/repo-add.rs
+++ b/src/bin/repo-add.rs
@@ -1 +1,5 @@
-fn main() { eprintln!("shim: repo-add (not implemented)"); std::process::exit(70); }
+//! Toolchain shim: `repo-add` (§16a). See `aur_build::shims`.
+
+fn main() {
+ std::process::exit(aur_build::shims::run("repo-add"));
+}
diff --git a/src/config.rs b/src/config.rs
index 44b110c..05f9a74 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -46,6 +46,10 @@ pub struct Config {
/// Directory prepended to PATH for child processes. The test harness puts
/// the toolchain shims here (§16a).
pub path_prepend: Option<PathBuf>,
+ /// Fixture manifest the shims should obey, exported as `AUR_SHIM_MANIFEST`.
+ pub shim_manifest: Option<PathBuf>,
+ /// Where shims record their invocations, exported as `AUR_SHIM_DIR`.
+ pub shim_dir: Option<PathBuf>,
}
impl Default for Config {
@@ -67,6 +71,8 @@ impl Default for Config {
gpg_bin: "gpg".into(),
build_user: String::new(),
path_prepend: None,
+ shim_manifest: None,
+ shim_dir: None,
}
}
}
@@ -96,6 +102,21 @@ impl Config {
Ok(())
}
+ /// Environment for a child process: PATH with the shims in front, plus the
+ /// shim protocol variables (§16a).
+ pub fn child_env(&self, cmd: &mut std::process::Command) {
+ if let Some(dir) = &self.path_prepend {
+ let path = std::env::var("PATH").unwrap_or_default();
+ cmd.env("PATH", format!("{}:{path}", dir.display()));
+ }
+ if let Some(m) = &self.shim_manifest {
+ cmd.env("AUR_SHIM_MANIFEST", m);
+ }
+ if let Some(d) = &self.shim_dir {
+ cmd.env("AUR_SHIM_DIR", d);
+ }
+ }
+
/// Create the directory tree the server needs. Idempotent.
pub fn ensure_dirs(&self) -> anyhow::Result<()> {
for d in [
diff --git a/src/lib.rs b/src/lib.rs
index f60f941..7e35c39 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -14,6 +14,7 @@ pub mod hash;
pub mod pkgver;
pub mod recipe;
pub mod review;
+pub mod shims;
pub mod time;
pub mod watch;
diff --git a/src/shims/mod.rs b/src/shims/mod.rs
new file mode 100644
index 0000000..32ae7c9
--- /dev/null
+++ b/src/shims/mod.rs
@@ -0,0 +1,641 @@
+//! Toolchain shims (§16a).
+//!
+//! The pipeline shells out to `mkarchroot`, `makechrootpkg`, `makepkg`,
+//! `repo-add`, `gpg` and `pacman`. In test mode the harness prepends a directory
+//! of fakes to `PATH`; each fake records its invocation, obeys a scripted
+//! outcome from the fixture manifest, and emits plausible
+//! `.PKGINFO`/`.BUILDINFO`/`.sig` output.
+//!
+//! That is what makes the full step machine, checkpointing, lease/reaper
+//! recovery, publishing and index regeneration runnable in milliseconds on any
+//! machine — no Arch host, no root, no network.
+//!
+//! Protocol, all via environment so the pipeline needs no test-only code paths:
+//!
+//! | var | meaning |
+//! |---|---|
+//! | `AUR_SHIM_DIR` | where invocations are recorded (`invocations.jsonl`) |
+//! | `AUR_SHIM_MANIFEST` | fixture manifest describing the scripted outcome |
+//! | `AUR_SHIM_FAIL` | optional step name that must fail, e.g. `build` |
+
+use std::path::{Path, PathBuf};
+
+use serde::{Deserialize, Serialize};
+
+use crate::hash;
+
+/// One package the fake toolchain emits.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(default)]
+pub struct FakePackage {
+ pub name: String,
+ pub version: String,
+ pub arch: String,
+ pub desc: String,
+ pub url: String,
+ pub license: Vec<String>,
+ pub depends: Vec<String>,
+ pub makedepends: Vec<String>,
+ pub checkdepends: Vec<String>,
+ pub provides: Vec<String>,
+ pub conflicts: Vec<String>,
+ pub backup: Vec<String>,
+}
+
+impl Default for FakePackage {
+ fn default() -> Self {
+ Self {
+ name: String::new(),
+ version: "1.0-1".into(),
+ arch: "x86_64".into(),
+ desc: "fake package".into(),
+ url: String::new(),
+ license: vec!["MIT".into()],
+ depends: vec![],
+ makedepends: vec![],
+ checkdepends: vec![],
+ provides: vec![],
+ conflicts: vec![],
+ backup: vec![],
+ }
+ }
+}
+
+impl FakePackage {
+ /// `1.0-1` split into the `(pkgver, pkgrel)` pacman expects in `.PKGINFO`.
+ pub fn split_version(&self) -> (String, String) {
+ match self.version.rsplit_once('-') {
+ Some((v, r)) => (v.to_string(), r.to_string()),
+ None => (self.version.clone(), "1".into()),
+ }
+ }
+}
+
+/// A member of the fake chroot world, for `.BUILDINFO` (§10.1).
+#[derive(Debug, Clone, Default, Serialize, Deserialize)]
+#[serde(default)]
+pub struct FakeInstalled {
+ pub name: String,
+ pub version: String,
+ pub arch: String,
+}
+
+/// The scripted outcome of a fixture.
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(default)]
+pub struct Manifest {
+ pub name: String,
+ /// `succeed` | `fail` | `check-fail` | `no-pkgver`
+ pub build: String,
+ /// Text the fake build writes to its log, for log-tail tests.
+ pub log_lines: Vec<String>,
+ pub packages: Vec<FakePackage>,
+ pub installed: Vec<FakeInstalled>,
+ /// Emit `.sig` files (default true).
+ pub sig: bool,
+ /// `pkgver` the fake `makepkg --vercheck` computes (VCS fixtures, §5.2).
+ pub vercheck: Option<String>,
+ /// Extra files to drop into the package tarball.
+ pub files: Vec<String>,
+}
+
+impl Default for Manifest {
+ fn default() -> Self {
+ Self {
+ name: "fixture".into(),
+ build: "succeed".into(),
+ log_lines: vec!["==> Making package.".into()],
+ packages: vec![],
+ installed: vec![],
+ sig: true,
+ vercheck: None,
+ files: vec![],
+ }
+ }
+}
+
+pub fn manifest() -> Manifest {
+ match std::env::var("AUR_SHIM_MANIFEST") {
+ Ok(p) => match std::fs::read_to_string(&p) {
+ Ok(s) => serde_json::from_str(&s).unwrap_or_default(),
+ Err(_) => Manifest::default(),
+ },
+ Err(_) => Manifest::default(),
+ }
+}
+
+/// Record that a shim ran, so tests can assert on what the pipeline actually
+/// invoked rather than what it intended to invoke.
+pub fn record(tool: &str, args: &[String]) {
+ let dir = match std::env::var("AUR_SHIM_DIR") {
+ Ok(d) => d,
+ Err(_) => return,
+ };
+ let _ = std::fs::create_dir_all(&dir);
+ let entry = serde_json::json!({
+ "tool": tool,
+ "args": args,
+ "cwd": std::env::current_dir().map(|p| p.display().to_string()).unwrap_or_default(),
+ });
+ if let Ok(mut f) = std::fs::OpenOptions::new()
+ .create(true)
+ .append(true)
+ .open(Path::new(&dir).join("invocations.jsonl"))
+ {
+ use std::io::Write;
+ let _ = f.write_all(format!("{entry}\n").as_bytes());
+ }
+}
+
+/// True when the harness asked this tool to fail.
+fn forced_fail(tool: &str) -> bool {
+ std::env::var("AUR_SHIM_FAIL").map(|v| v == tool).unwrap_or(false)
+}
+
+/// Read the invocation log back (test side).
+pub fn invocations(dir: &Path) -> Vec<serde_json::Value> {
+ let path = dir.join("invocations.jsonl");
+ match std::fs::read_to_string(path) {
+ Ok(s) => s
+ .lines()
+ .filter_map(|l| serde_json::from_str(l).ok())
+ .collect(),
+ Err(_) => Vec::new(),
+ }
+}
+
+/// Entries whose `args` mention `needle`.
+pub fn called_with(dir: &Path, tool: &str, needle: &str) -> usize {
+ invocations(dir)
+ .iter()
+ .filter(|e| e["tool"] == tool)
+ .filter(|e| {
+ e["args"]
+ .as_array()
+ .map(|a| a.iter().any(|v| v.as_str().is_some_and(|s| s.contains(needle))))
+ .unwrap_or(false)
+ })
+ .count()
+}
+
+/// Dispatch table used by every `src/bin/*.rs`.
+pub fn run(tool: &str) -> i32 {
+ let args: Vec<String> = std::env::args().skip(1).collect();
+ record(tool, &args);
+ let m = manifest();
+ let r = match tool {
+ "mkarchroot" => mkarchroot(&args),
+ "makechrootpkg" => makechrootpkg(&args, &m),
+ "makepkg" => makepkg(&args, &m),
+ "repo-add" => repo_add(&args, &m),
+ "gpg" => gpg(&args),
+ "pacman" => Ok(0),
+ other => Err(format!("no shim named {other}")),
+ };
+ match r {
+ Ok(code) => code,
+ Err(e) => {
+ eprintln!("shim {tool}: {e}");
+ 1
+ }
+ }
+}
+
+/// `mkarchroot <path>`: create a directory that stands in for a warm root.
+pub fn mkarchroot(args: &[String]) -> Result<i32, String> {
+ // `mkarchroot [-C pacman.conf] [-M makepkg.conf] <root>`: the config options
+ // take a value, so they cannot be skipped blindly.
+ let mut target = None;
+ let mut skip = false;
+ for a in args {
+ if skip {
+ skip = false;
+ continue;
+ }
+ if matches!(a.as_str(), "-C" | "-M" | "-k") {
+ skip = true;
+ continue;
+ }
+ if !a.starts_with('-') {
+ target = Some(a.clone());
+ break;
+ }
+ }
+ let target = target.ok_or("mkarchroot: no target")?;
+ std::fs::create_dir_all(&target).map_err(|e| e.to_string())?;
+ // A marker so the pipeline can tell a real root from a fake one.
+ let _ = std::fs::write(Path::new(&target).join("SHIM-ROOT"), "fake chroot\n");
+ Ok(0)
+}
+
+/// `makechrootpkg -c -r <chroot> -- -si<key> -f`, run with cwd = the build dir.
+///
+/// Emits one `.pkg.tar.zst` per package in the manifest into the current
+/// directory, exactly where the real tool leaves them.
+pub fn makechrootpkg(args: &[String], m: &Manifest) -> Result<i32, String> {
+ for l in &m.log_lines {
+ println!("{l}");
+ }
+ if forced_fail("makechrootpkg") || m.build == "fail" {
+ eprintln!("==> ERROR: A build function returned error.");
+ return Ok(1);
+ }
+ if m.build == "check-fail" {
+ eprintln!("==> ERROR: A failure occurred in check().");
+ return Ok(1);
+ }
+ // The pipeline always passes a chroot root; asserting it keeps the fake
+ // honest about the real tool's contract.
+ if !args.iter().any(|a| a == "-r") {
+ return Err("makechrootpkg: expected -r <chroot>".into());
+ }
+ let startdir = std::env::current_dir().map_err(|e| e.to_string())?;
+ // The real tool reads the PKGBUILD it was handed; we assert it is there so a
+ // broken materialize step cannot pass silently.
+ if !startdir.join("PKGBUILD").exists() {
+ let found = std::fs::read_dir(&startdir)
+ .map(|rd| rd.filter_map(|e| e.ok()).map(|e| e.file_name().to_string_lossy().into_owned()).collect::<Vec<_>>())
+ .unwrap_or_default();
+ return Err(format!(
+ "makechrootpkg: no PKGBUILD in {} (contains {found:?})",
+ startdir.display()
+ ));
+ }
+ let pkgs = packages_to_emit(m, &startdir);
+ for p in &pkgs {
+ let path = write_package(&startdir, p, m)?;
+ println!("==> Creating package '{}'", path.file_name().unwrap().to_string_lossy());
+ if m.sig {
+ if let Ok(bytes) = std::fs::read(&path) {
+ let sig = path.with_extension("pkg.tar.zst.sig");
+ let _ = std::fs::write(&sig, fake_sig(&bytes));
+ }
+ }
+ }
+ Ok(0)
+}
+
+fn packages_to_emit(m: &Manifest, startdir: &Path) -> Vec<FakePackage> {
+ if !m.packages.is_empty() {
+ return m.packages.clone();
+ }
+ // No explicit manifest: derive one package from the PKGBUILD we were given.
+ let text = std::fs::read_to_string(startdir.join("PKGBUILD")).unwrap_or_default();
+ let recipe = crate::recipe::parse_pkgbuild(&text).ok();
+ match recipe {
+ Some(r) => r
+ .pkgnames
+ .iter()
+ .map(|n| FakePackage {
+ name: n.clone(),
+ version: format!("{}-{}", r.pkgver, r.pkgrel),
+ arch: r.arch.first().cloned().unwrap_or_else(|| "x86_64".into()),
+ desc: r.pkgdesc.clone(),
+ url: r.url.clone(),
+ depends: crate::pkgver::dep_names(&r.depends),
+ makedepends: crate::pkgver::dep_names(&r.makedepends),
+ checkdepends: crate::pkgver::dep_names(&r.checkdepends),
+ provides: r.provides.clone(),
+ conflicts: r.conflicts.clone(),
+ ..Default::default()
+ })
+ .collect(),
+ None => vec![FakePackage { name: "unknown".into(), ..Default::default() }],
+ }
+}
+
+/// Write a `.pkg.tar.zst` containing `.PKGINFO`, `.BUILDINFO` and any scripted
+/// payload files.
+pub fn write_package(dir: &Path, p: &FakePackage, m: &Manifest) -> Result<PathBuf, String> {
+ let (pkgver, pkgrel) = p.split_version();
+ let filename = format!("{}-{}-{}.pkg.tar.zst", p.name, p.version, p.arch);
+ let path = dir.join(&filename);
+ let enc = zstd::Encoder::new(std::io::BufWriter::new(
+ std::fs::File::create(&path).map_err(|e| e.to_string())?,
+ ), 3)
+ .map_err(|e| e.to_string())?;
+ let mut ar = tar::Builder::new(enc);
+ // NOTE: the zstd frame must be finished explicitly or the archive is a
+ // truncated stream that nothing can read back.
+
+ let pkginfo = pkginfo(p, &pkgver, &pkgrel);
+ write_entry(&mut ar, ".PKGINFO", pkginfo.as_bytes())?;
+ let buildinfo = buildinfo(p, &pkgver, &pkgrel, m);
+ write_entry(&mut ar, ".BUILDINFO", buildinfo.as_bytes())?;
+ for f in &m.files {
+ write_entry(&mut ar, &format!("usr/share/{}/{f}", p.name), f.as_bytes())?;
+ }
+ // A payload file so the artifact has non-metadata bytes and a real size.
+ write_entry(&mut ar, &format!("usr/bin/{}", p.name), b"#!/bin/sh\necho hi\n")?;
+ let enc = ar.into_inner().map_err(|e| e.to_string())?;
+ enc.finish().map_err(|e| e.to_string())?;
+ Ok(path)
+}
+
+fn write_entry<W: std::io::Write>(ar: &mut tar::Builder<W>, path: &str, body: &[u8]) -> Result<(), String> {
+ let mut h = tar::Header::new_gnu();
+ h.set_size(body.len() as u64);
+ h.set_mode(0o644);
+ h.set_mtime(0);
+ h.set_entry_type(tar::EntryType::Regular);
+ ar.append_data(&mut h, path, body).map_err(|e| e.to_string())
+}
+
+fn pkginfo(p: &FakePackage, pkgver: &str, pkgrel: &str) -> String {
+ let mut s = String::new();
+ s.push_str(&format!("pkgname = {}\n", p.name));
+ s.push_str(&format!("pkgbase = {}\n", p.name));
+ s.push_str(&format!("pkgver = {pkgver}-{pkgrel}\n"));
+ s.push_str(&format!("pkgarch = {}\n", p.arch));
+ s.push_str(&format!("pkgdesc = {}\n", p.desc));
+ s.push_str(&format!("url = {}\n", p.url));
+ s.push_str("builddate = 1700000000\n");
+ s.push_str("packager = shim <shim@example.invalid>\n");
+ s.push_str("size = 42\n");
+ for l in &p.license {
+ s.push_str(&format!("license = {l}\n"));
+ }
+ for d in &p.depends {
+ s.push_str(&format!("depend = {d}\n"));
+ }
+ for d in &p.makedepends {
+ s.push_str(&format!("makedepend = {d}\n"));
+ }
+ for d in &p.checkdepends {
+ s.push_str(&format!("checkdepend = {d}\n"));
+ }
+ for d in &p.provides {
+ s.push_str(&format!("provides = {d}\n"));
+ }
+ for d in &p.conflicts {
+ s.push_str(&format!("conflicts = {d}\n"));
+ }
+ for b in &p.backup {
+ s.push_str(&format!("backup = {b}\n"));
+ }
+ s
+}
+
+/// `.BUILDINFO`: the full installed set at build time. Left unfiltered this is
+/// the whole chroot, which is exactly why §10.1 intersects it with our own
+/// packages before storing a world snapshot.
+fn buildinfo(p: &FakePackage, pkgver: &str, pkgrel: &str, m: &Manifest) -> String {
+ let mut s = String::new();
+ s.push_str("format = 2\n");
+ s.push_str(&format!("pkgname = {}\n", p.name));
+ s.push_str(&format!("pkgbase = {}\n", p.name));
+ s.push_str(&format!("pkgver = {pkgver}-{pkgrel}\n"));
+ s.push_str(&format!("pkgarch = {}\n", p.arch));
+ s.push_str("packager = shim <shim@example.invalid>\n");
+ s.push_str("builddate = 1700000000\n");
+ s.push_str("buildenv = (!debug !strip)\n");
+ s.push_str("installed =\n");
+ for i in &m.installed {
+ s.push_str(&format!(" {} {} {} -\n", i.name, i.version, if i.arch.is_empty() { "any" } else { &i.arch }));
+ }
+ s
+}
+
+fn fake_sig(bytes: &[u8]) -> Vec<u8> {
+ format!("-----BEGIN FAKE PGP SIGNATURE-----\n{}\n-----END FAKE PGP SIGNATURE-----\n", hash::hex(bytes)).into_bytes()
+}
+
+/// `makepkg --printsrcinfo` / `--vercheck` (§5.2 Stage B).
+pub fn makepkg(args: &[String], m: &Manifest) -> Result<i32, String> {
+ if args.iter().any(|a| a == "--vercheck" || a == "-V-check") {
+ let v = m.vercheck.clone().unwrap_or_else(|| "1.0-1".into());
+ println!("{v}");
+ return Ok(0);
+ }
+ if args.iter().any(|a| a == "--printsrcinfo" || a == "-g") {
+ let text = std::fs::read_to_string("PKGBUILD").unwrap_or_default();
+ match crate::recipe::parse_pkgbuild(&text) {
+ Ok(r) => {
+ let mut s = String::new();
+ if let Some(si) = r.srcinfo {
+ s = si;
+ } else {
+ s.push_str(&format!("pkgbase = {}\n", r.pkgbase));
+ s.push_str(&format!("\tpkgver = {}\n", r.pkgver));
+ s.push_str(&format!("\tpkgrel = {}\n", r.pkgrel));
+ if r.epoch != "0" {
+ s.push_str(&format!("\tepoch = {}\n", r.epoch));
+ }
+ for a in &r.arch {
+ s.push_str(&format!("\tarch = {a}\n"));
+ }
+ for d in &r.depends {
+ s.push_str(&format!("\tdepends = {d}\n"));
+ }
+ for src in &r.source {
+ s.push_str(&format!("\tsource = {src}\n"));
+ }
+ for c in &r.sha256sums {
+ s.push_str(&format!("\tsha256sums = {c}\n"));
+ }
+ for n in &r.pkgnames {
+ s.push_str(&format!("pkgname = {n}\n"));
+ }
+ }
+ print!("{s}");
+ Ok(0)
+ }
+ Err(e) => {
+ eprintln!("makepkg: {e}");
+ Ok(1)
+ }
+ }
+ } else {
+ // `makepkg -si` style: behave like a local build.
+ makechrootpkg(args, m)
+ }
+}
+
+/// `repo-add [-s -p key -R] <db.tar.{gz,zst}> <pkg...>`: rebuild the database
+/// from the packages handed to it.
+///
+/// The real tool appends; `-R` replaces an existing entry. We rebuild the whole
+/// db from the packages given, which is what our publish step does anyway (it
+/// passes exactly the packages that belong in the index).
+pub fn repo_add(args: &[String], _m: &Manifest) -> Result<i32, String> {
+ // `-p <key>` and friends take a value; a naive filter would treat the key id
+ // as a package path.
+ let mut positional: Vec<&String> = Vec::new();
+ let mut skip = false;
+ for a in args {
+ if skip {
+ skip = false;
+ continue;
+ }
+ if matches!(a.as_str(), "-p" | "--key" | "-o" | "-e") {
+ skip = true;
+ continue;
+ }
+ if !a.starts_with('-') {
+ positional.push(a);
+ }
+ }
+ let (db_path, pkgs) = match positional.split_first() {
+ Some((db, rest)) => (PathBuf::from(db), rest.iter().map(|p| PathBuf::from(p.as_str())).collect::<Vec<_>>()),
+ None => return Err("repo-add: no database given".into()),
+ };
+ let mut ar = tar::Builder::new(Vec::new());
+ for pkg in &pkgs {
+ let bytes = std::fs::read(pkg).map_err(|e| format!("repo-add: {}: {e}", pkg.display()))?;
+ let pkginfo = read_pkginfo(&bytes)?;
+ let (name, version, arch, extra) = parse_pkginfo(&pkginfo);
+ let mut entry = String::new();
+ entry.push_str(&format!("%FILENAME%\n{}\n\n", pkg.file_name().unwrap().to_string_lossy()));
+ entry.push_str(&format!("%NAME%\n{name}\n\n"));
+ entry.push_str(&format!("%BASE%\n{name}\n\n"));
+ entry.push_str(&format!("%VERSION%\n{version}\n\n"));
+ entry.push_str(&format!("%ARCH%\n{arch}\n\n"));
+ entry.push_str(&format!("%CSIZE%\n{}\n\n", bytes.len()));
+ entry.push_str("%DSIZE%\n42\n\n");
+ entry.push_str(&format!("%MD5SUM%\n{}\n\n", hash::hex(&bytes)));
+ entry.push_str(&format!("%SHA256SUM%\n{}\n\n", hash::hex(&bytes)));
+ if !extra.is_empty() {
+ entry.push_str(&format!("{extra}\n"));
+ }
+ let mut h = tar::Header::new_gnu();
+ h.set_size(entry.len() as u64);
+ h.set_mode(0o644);
+ h.set_mtime(0);
+ ar.append_data(&mut h, format!("{name}/DESC"), entry.as_bytes())
+ .map_err(|e| e.to_string())?;
+ let mut h2 = tar::Header::new_gnu();
+ h2.set_size(pkginfo.len() as u64);
+ h2.set_mode(0o644);
+ h2.set_mtime(0);
+ ar.append_data(&mut h2, format!("{name}/.PKGINFO"), pkginfo.as_bytes())
+ .map_err(|e| e.to_string())?;
+ }
+ let tar = ar.into_inner().map_err(|e| e.to_string())?;
+ // pacman databases are gzip'd tarballs.
+ let mut enc = flate2::write::GzEncoder::new(
+ std::fs::File::create(&db_path).map_err(|e| e.to_string())?,
+ flate2::Compression::default(),
+ );
+ use std::io::Write;
+ enc.write_all(&tar).map_err(|e| e.to_string())?;
+ enc.finish().map_err(|e| e.to_string())?;
+ println!("==> Updating repository");
+ Ok(0)
+}
+
+/// Pull `.PKGINFO` out of a `.pkg.tar.zst` (§10.1: plain text in a tar, no
+/// libalpm needed).
+pub fn read_pkginfo(pkg_bytes: &[u8]) -> Result<String, String> {
+ let dec = zstd::Decoder::new(std::io::Cursor::new(pkg_bytes)).map_err(|e| e.to_string())?;
+ let mut ar = tar::Archive::new(dec);
+ for e in ar.entries().map_err(|e| e.to_string())? {
+ let mut e = e.map_err(|e| e.to_string())?;
+ let name = e.path_bytes().to_vec();
+ if name.ends_with(b".PKGINFO") {
+ use std::io::Read;
+ let mut s = String::new();
+ e.read_to_string(&mut s).map_err(|e| e.to_string())?;
+ return Ok(s);
+ }
+ }
+ Err("no .PKGINFO in package".into())
+}
+
+pub fn read_buildinfo(pkg_bytes: &[u8]) -> Result<String, String> {
+ let dec = zstd::Decoder::new(std::io::Cursor::new(pkg_bytes)).map_err(|e| e.to_string())?;
+ let mut ar = tar::Archive::new(dec);
+ for e in ar.entries().map_err(|e| e.to_string())? {
+ let mut e = e.map_err(|e| e.to_string())?;
+ let name = e.path_bytes().to_vec();
+ if name.ends_with(b".BUILDINFO") {
+ use std::io::Read;
+ let mut s = String::new();
+ e.read_to_string(&mut s).map_err(|e| e.to_string())?;
+ return Ok(s);
+ }
+ }
+ Err("no .BUILDINFO in package".into())
+}
+
+fn parse_pkginfo(s: &str) -> (String, String, String, String) {
+ let mut name = String::new();
+ let mut version = String::new();
+ let mut arch = String::new();
+ let mut groups = Vec::new();
+ let mut deps = Vec::new();
+ let mut optdeps = Vec::new();
+ let mut provides = Vec::new();
+ let mut conflicts = Vec::new();
+ let mut replaces = Vec::new();
+ let mut license = Vec::new();
+ let mut desc = String::new();
+ let mut url = String::new();
+ for line in s.lines() {
+ let (k, v) = match line.split_once('=') {
+ Some((k, v)) => (k.trim(), v.trim()),
+ None => continue,
+ };
+ match k {
+ "pkgname" => name = v.to_string(),
+ "pkgver" => version = v.to_string(),
+ "pkgarch" => arch = v.to_string(),
+ "pkgdesc" => desc = v.to_string(),
+ "url" => url = v.to_string(),
+ "license" => license.push(v.to_string()),
+ "depend" => deps.push(v.to_string()),
+ "optdepend" => optdeps.push(v.to_string()),
+ "checkdepend" => {}
+ "makedepend" => {}
+ "provides" => provides.push(v.to_string()),
+ "conflict" => conflicts.push(v.to_string()),
+ "replace" => replaces.push(v.to_string()),
+ "group" => groups.push(v.to_string()),
+ _ => {}
+ }
+ }
+ let mut extra = String::new();
+ let mut push = |tag: &str, vals: &Vec<String>| {
+ if !vals.is_empty() {
+ extra.push_str(&format!("{tag}\n{}\n\n", vals.join("\n")));
+ }
+ };
+ push("%DESC%", &desc_vec(&desc));
+ push("%URL%", &url_vec(&url));
+ push("%LICENSE%", &license);
+ push("%DEPENDS%", &deps);
+ push("%OPTDEPENDS%", &optdeps);
+ push("%PROVIDES%", &provides);
+ push("%CONFLICTS%", &conflicts);
+ push("%REPLACES%", &replaces);
+ push("%GROUPS%", &groups);
+ (name, version, arch, extra)
+}
+
+fn desc_vec(s: &str) -> Vec<String> {
+ if s.is_empty() { vec![] } else { vec![s.to_string()] }
+}
+fn url_vec(s: &str) -> Vec<String> {
+ if s.is_empty() { vec![] } else { vec![s.to_string()] }
+}
+
+/// `gpg --detach-sign --output <sig> <file>`: write a deterministic stand-in
+/// signature so the signing path is exercised end to end.
+pub fn gpg(args: &[String]) -> Result<i32, String> {
+ let out = args
+ .iter()
+ .position(|a| a == "--output" || a == "-o")
+ .and_then(|i| args.get(i + 1))
+ .cloned();
+ let target = args.iter().rev().find(|a| !a.starts_with('-') && Some(*a) != out.as_ref());
+ let target = match target {
+ Some(t) => t,
+ None => return Err("gpg: nothing to sign".into()),
+ };
+ let bytes = std::fs::read(target).map_err(|e| format!("gpg: {target}: {e}"))?;
+ let sig = match out {
+ Some(o) => o,
+ None => format!("{target}.sig"),
+ };
+ std::fs::write(&sig, fake_sig(&bytes)).map_err(|e| e.to_string())?;
+ Ok(0)
+}
diff --git a/testcorpus/build-fails/PKGBUILD b/testcorpus/build-fails/PKGBUILD
new file mode 100644
index 0000000..32fd553
--- /dev/null
+++ b/testcorpus/build-fails/PKGBUILD
@@ -0,0 +1,13 @@
+pkgbase=build-fails
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/build-fails"
+license=(MIT)
+arch=(x86_64)
+build() {
+ echo building build-fails
+}
+package_build-fails() {
+ echo packaging build-fails
+}
diff --git a/testcorpus/build-fails/manifest.json b/testcorpus/build-fails/manifest.json
new file mode 100644
index 0000000..844ce4c
--- /dev/null
+++ b/testcorpus/build-fails/manifest.json
@@ -0,0 +1,31 @@
+{
+ "name": "build-fails",
+ "build": "fail",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "build": "fail",
+ "retry": false
+ }
+}
diff --git a/testcorpus/check-fails/PKGBUILD b/testcorpus/check-fails/PKGBUILD
new file mode 100644
index 0000000..ccb3fe4
--- /dev/null
+++ b/testcorpus/check-fails/PKGBUILD
@@ -0,0 +1,14 @@
+pkgbase=check-fails
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/check-fails"
+license=(MIT)
+arch=(x86_64)
+checkdepends=(pytest)
+build() {
+ echo building check-fails
+}
+package_check-fails() {
+ echo packaging check-fails
+}
diff --git a/testcorpus/check-fails/manifest.json b/testcorpus/check-fails/manifest.json
new file mode 100644
index 0000000..5dd76e7
--- /dev/null
+++ b/testcorpus/check-fails/manifest.json
@@ -0,0 +1,30 @@
+{
+ "name": "check-fails",
+ "build": "check-fail",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "build": "check-fail"
+ }
+}
diff --git a/testcorpus/dep-cycle/PKGBUILD b/testcorpus/dep-cycle/PKGBUILD
new file mode 100644
index 0000000..452a467
--- /dev/null
+++ b/testcorpus/dep-cycle/PKGBUILD
@@ -0,0 +1,14 @@
+pkgbase=dep-cycle
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/dep-cycle"
+license=(MIT)
+arch=(x86_64)
+makedepends=(dep-cycle)
+build() {
+ echo building dep-cycle
+}
+package_dep-cycle() {
+ echo packaging dep-cycle
+}
diff --git a/testcorpus/dep-cycle/manifest.json b/testcorpus/dep-cycle/manifest.json
new file mode 100644
index 0000000..79dec4e
--- /dev/null
+++ b/testcorpus/dep-cycle/manifest.json
@@ -0,0 +1,36 @@
+{
+ "name": "dep-cycle",
+ "build": "succeed",
+ "sig": true,
+ "packages": [
+ {
+ "name": "dep-cycle",
+ "version": "1.0-1",
+ "arch": "x86_64",
+ "makedepends": [
+ "dep-cycle"
+ ]
+ }
+ ],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ]
+}
diff --git a/testcorpus/digest-drift/PKGBUILD b/testcorpus/digest-drift/PKGBUILD
new file mode 100644
index 0000000..444ff72
--- /dev/null
+++ b/testcorpus/digest-drift/PKGBUILD
@@ -0,0 +1,15 @@
+pkgbase=digest-drift
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/digest-drift"
+license=(MIT)
+arch=(x86_64)
+source=("@AUR_DIR@/payload.bin")
+sha256sums=("SKIP")
+build() {
+ echo building digest-drift
+}
+package_digest-drift() {
+ echo packaging digest-drift
+}
diff --git a/testcorpus/digest-drift/manifest.json b/testcorpus/digest-drift/manifest.json
new file mode 100644
index 0000000..46b4838
--- /dev/null
+++ b/testcorpus/digest-drift/manifest.json
@@ -0,0 +1,30 @@
+{
+ "name": "digest-drift",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "notes": "swap payload.bin bytes; expect integrity_alert"
+ }
+}
diff --git a/testcorpus/digest-drift/payload.bin b/testcorpus/digest-drift/payload.bin
new file mode 100644
index 0000000..cf16385
--- /dev/null
+++ b/testcorpus/digest-drift/payload.bin
@@ -0,0 +1 @@
+good release tarball
diff --git a/testcorpus/downgrade/PKGBUILD b/testcorpus/downgrade/PKGBUILD
new file mode 100644
index 0000000..7562a41
--- /dev/null
+++ b/testcorpus/downgrade/PKGBUILD
@@ -0,0 +1,13 @@
+pkgbase=downgrade
+pkgver=2.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/downgrade"
+license=(MIT)
+arch=(x86_64)
+build() {
+ echo building downgrade
+}
+package_downgrade() {
+ echo packaging downgrade
+}
diff --git a/testcorpus/downgrade/manifest.json b/testcorpus/downgrade/manifest.json
new file mode 100644
index 0000000..a85552e
--- /dev/null
+++ b/testcorpus/downgrade/manifest.json
@@ -0,0 +1,33 @@
+{
+ "name": "downgrade",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "bump": {
+ "pkgver": "1.0"
+ },
+ "notes": "maintainer reverted; flagged not blocked"
+ }
+}
diff --git a/testcorpus/epoch-bump/PKGBUILD b/testcorpus/epoch-bump/PKGBUILD
new file mode 100644
index 0000000..28875fe
--- /dev/null
+++ b/testcorpus/epoch-bump/PKGBUILD
@@ -0,0 +1,13 @@
+pkgbase=epoch-bump
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/epoch-bump"
+license=(MIT)
+arch=(x86_64)
+build() {
+ echo building epoch-bump
+}
+package_epoch-bump() {
+ echo packaging epoch-bump
+}
diff --git a/testcorpus/epoch-bump/manifest.json b/testcorpus/epoch-bump/manifest.json
new file mode 100644
index 0000000..e7ffb43
--- /dev/null
+++ b/testcorpus/epoch-bump/manifest.json
@@ -0,0 +1,33 @@
+{
+ "name": "epoch-bump",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "bump": {
+ "epoch": "1"
+ },
+ "notes": "epoch bump flagged"
+ }
+}
diff --git a/testcorpus/git-sourced/PKGBUILD b/testcorpus/git-sourced/PKGBUILD
new file mode 100644
index 0000000..ba9ae33
--- /dev/null
+++ b/testcorpus/git-sourced/PKGBUILD
@@ -0,0 +1,19 @@
+pkgbase=git-sourced
+pkgver=r1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/git-sourced"
+license=(MIT)
+arch=(x86_64)
+source=("git+file://@UPSTREAM_DIR@")
+sha256sums=("SKIP")
+build() {
+ echo building git-sourced
+}
+package_git-sourced() {
+ echo packaging git-sourced
+}
+pkgver() {
+ cd "$srcdir/upstream" 2>/dev/null || cd @UPSTREAM_DIR@
+ printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
+}
diff --git a/testcorpus/git-sourced/manifest.json b/testcorpus/git-sourced/manifest.json
new file mode 100644
index 0000000..01a781f
--- /dev/null
+++ b/testcorpus/git-sourced/manifest.json
@@ -0,0 +1,31 @@
+{
+ "name": "git-sourced",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "vercheck": "r1.0-1",
+ "expect": {
+ "notes": "pkgver() derives from upstream HEAD"
+ }
+}
diff --git a/testcorpus/git-submodules/PKGBUILD b/testcorpus/git-submodules/PKGBUILD
new file mode 100644
index 0000000..6885cad
--- /dev/null
+++ b/testcorpus/git-submodules/PKGBUILD
@@ -0,0 +1,15 @@
+pkgbase=git-submodules
+pkgver=r1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/git-submodules"
+license=(MIT)
+arch=(x86_64)
+source=("git+file://@UPSTREAM_DIR@")
+sha256sums=("SKIP")
+build() {
+ echo building git-submodules
+}
+package_git-submodules() {
+ echo packaging git-submodules
+}
diff --git a/testcorpus/git-submodules/manifest.json b/testcorpus/git-submodules/manifest.json
new file mode 100644
index 0000000..6fd894a
--- /dev/null
+++ b/testcorpus/git-submodules/manifest.json
@@ -0,0 +1,28 @@
+{
+ "name": "git-submodules",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "vercheck": "r1.0-1"
+}
diff --git a/testcorpus/install-hooks/PKGBUILD b/testcorpus/install-hooks/PKGBUILD
new file mode 100644
index 0000000..149da79
--- /dev/null
+++ b/testcorpus/install-hooks/PKGBUILD
@@ -0,0 +1,14 @@
+pkgbase=install-hooks
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/install-hooks"
+license=(MIT)
+arch=(x86_64)
+install=install-hooks.install
+build() {
+ echo building install-hooks
+}
+package_install-hooks() {
+ echo packaging install-hooks
+}
diff --git a/testcorpus/install-hooks/install-hooks.install b/testcorpus/install-hooks/install-hooks.install
new file mode 100644
index 0000000..17a34be
--- /dev/null
+++ b/testcorpus/install-hooks/install-hooks.install
@@ -0,0 +1,6 @@
+post_install() {
+ echo "welcome"
+}
+pre_upgrade() {
+ echo "upgrading"
+}
diff --git a/testcorpus/install-hooks/manifest.json b/testcorpus/install-hooks/manifest.json
new file mode 100644
index 0000000..5ce0555
--- /dev/null
+++ b/testcorpus/install-hooks/manifest.json
@@ -0,0 +1,30 @@
+{
+ "name": "install-hooks",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "notes": "install hook delta panel"
+ }
+}
diff --git a/testcorpus/missing-dep/PKGBUILD b/testcorpus/missing-dep/PKGBUILD
new file mode 100644
index 0000000..5e75ee7
--- /dev/null
+++ b/testcorpus/missing-dep/PKGBUILD
@@ -0,0 +1,14 @@
+pkgbase=missing-dep
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/missing-dep"
+license=(MIT)
+arch=(x86_64)
+depends=(dep-partner)
+build() {
+ echo building missing-dep
+}
+package_missing-dep() {
+ echo packaging missing-dep
+}
diff --git a/testcorpus/missing-dep/manifest.json b/testcorpus/missing-dep/manifest.json
new file mode 100644
index 0000000..7d8d36a
--- /dev/null
+++ b/testcorpus/missing-dep/manifest.json
@@ -0,0 +1,41 @@
+{
+ "name": "missing-dep",
+ "build": "succeed",
+ "sig": true,
+ "packages": [
+ {
+ "name": "missing-dep",
+ "version": "1.0-1",
+ "arch": "x86_64",
+ "depends": [
+ "dep-partner"
+ ]
+ }
+ ],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "blocked_on": [
+ "dep-partner"
+ ]
+ }
+}
diff --git a/testcorpus/pin-drift/PKGBUILD b/testcorpus/pin-drift/PKGBUILD
new file mode 100644
index 0000000..5296ba4
--- /dev/null
+++ b/testcorpus/pin-drift/PKGBUILD
@@ -0,0 +1,15 @@
+pkgbase=pin-drift
+pkgver=r1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/pin-drift"
+license=(MIT)
+arch=(x86_64)
+source=("git+file://@UPSTREAM_DIR@")
+sha256sums=("SKIP")
+build() {
+ echo building pin-drift
+}
+package_pin-drift() {
+ echo packaging pin-drift
+}
diff --git a/testcorpus/pin-drift/manifest.json b/testcorpus/pin-drift/manifest.json
new file mode 100644
index 0000000..5db2b9c
--- /dev/null
+++ b/testcorpus/pin-drift/manifest.json
@@ -0,0 +1,31 @@
+{
+ "name": "pin-drift",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "vercheck": "r1.0-1",
+ "expect": {
+ "notes": "add a commit upstream; pkgver frozen"
+ }
+}
diff --git a/testcorpus/pkgrel-reset/PKGBUILD b/testcorpus/pkgrel-reset/PKGBUILD
new file mode 100644
index 0000000..75d9836
--- /dev/null
+++ b/testcorpus/pkgrel-reset/PKGBUILD
@@ -0,0 +1,13 @@
+pkgbase=pkgrel-reset
+pkgver=1.0
+pkgrel=7
+pkgdesc="synthetic fixture"
+url="https://example.invalid/pkgrel-reset"
+license=(MIT)
+arch=(x86_64)
+build() {
+ echo building pkgrel-reset
+}
+package_pkgrel-reset() {
+ echo packaging pkgrel-reset
+}
diff --git a/testcorpus/pkgrel-reset/manifest.json b/testcorpus/pkgrel-reset/manifest.json
new file mode 100644
index 0000000..3ce8ffc
--- /dev/null
+++ b/testcorpus/pkgrel-reset/manifest.json
@@ -0,0 +1,33 @@
+{
+ "name": "pkgrel-reset",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "bump": {
+ "pkgrel": "1"
+ },
+ "notes": "pkgrel reset is a major signal"
+ }
+}
diff --git a/testcorpus/plain-make/PKGBUILD b/testcorpus/plain-make/PKGBUILD
new file mode 100644
index 0000000..2da4fe2
--- /dev/null
+++ b/testcorpus/plain-make/PKGBUILD
@@ -0,0 +1,13 @@
+pkgbase=plain-make
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/plain-make"
+license=(MIT)
+arch=(x86_64)
+build() {
+ echo building plain-make
+}
+package_plain-make() {
+ echo packaging plain-make
+}
diff --git a/testcorpus/plain-make/manifest.json b/testcorpus/plain-make/manifest.json
new file mode 100644
index 0000000..5451fa8
--- /dev/null
+++ b/testcorpus/plain-make/manifest.json
@@ -0,0 +1,33 @@
+{
+ "name": "plain-make",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "build": "succeed",
+ "packages": [
+ "plain-make"
+ ]
+ }
+}
diff --git a/testcorpus/skip-checksum/PKGBUILD b/testcorpus/skip-checksum/PKGBUILD
new file mode 100644
index 0000000..93661a1
--- /dev/null
+++ b/testcorpus/skip-checksum/PKGBUILD
@@ -0,0 +1,15 @@
+pkgbase=skip-checksum
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/skip-checksum"
+license=(MIT)
+arch=(x86_64)
+source=("@AUR_DIR@/payload.bin")
+sha256sums=("SKIP")
+build() {
+ echo building skip-checksum
+}
+package_skip-checksum() {
+ echo packaging skip-checksum
+}
diff --git a/testcorpus/skip-checksum/manifest.json b/testcorpus/skip-checksum/manifest.json
new file mode 100644
index 0000000..0c56179
--- /dev/null
+++ b/testcorpus/skip-checksum/manifest.json
@@ -0,0 +1,32 @@
+{
+ "name": "skip-checksum",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "risk_signals": [
+ "skip-non-vcs"
+ ]
+ }
+}
diff --git a/testcorpus/skip-checksum/payload.bin b/testcorpus/skip-checksum/payload.bin
new file mode 100644
index 0000000..cd574fd
--- /dev/null
+++ b/testcorpus/skip-checksum/payload.bin
@@ -0,0 +1 @@
+the bytes that become the package
diff --git a/testcorpus/split-pkgbase/PKGBUILD b/testcorpus/split-pkgbase/PKGBUILD
new file mode 100644
index 0000000..416d817
--- /dev/null
+++ b/testcorpus/split-pkgbase/PKGBUILD
@@ -0,0 +1,20 @@
+pkgbase=split-pkgbase
+pkgname=(split-pkgbase split-pkgbase-docs split-pkgbase-lua)
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/split-pkgbase"
+license=(MIT)
+arch=(x86_64)
+build() {
+ echo building split-pkgbase
+}
+package_split-pkgbase() {
+ echo packaging split-pkgbase
+}
+package_split-pkgbase-docs() {
+ echo packaging split-pkgbase-docs
+}
+package_split-pkgbase-lua() {
+ echo packaging split-pkgbase-lua
+}
diff --git a/testcorpus/split-pkgbase/manifest.json b/testcorpus/split-pkgbase/manifest.json
new file mode 100644
index 0000000..864b74d
--- /dev/null
+++ b/testcorpus/split-pkgbase/manifest.json
@@ -0,0 +1,35 @@
+{
+ "name": "split-pkgbase",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "packages": [
+ "split-pkgbase",
+ "split-pkgbase-docs",
+ "split-pkgbase-lua"
+ ],
+ "notes": "one approval, three index rows"
+ }
+}
diff --git a/testcorpus/unresolvable/PKGBUILD b/testcorpus/unresolvable/PKGBUILD
new file mode 100644
index 0000000..3185435
--- /dev/null
+++ b/testcorpus/unresolvable/PKGBUILD
@@ -0,0 +1,15 @@
+pkgbase=unresolvable
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/unresolvable"
+license=(MIT)
+arch=(x86_64)
+source=("@AUR_DIR@/does-not-exist.tar.gz")
+sha256sums=("SKIP")
+build() {
+ echo building unresolvable
+}
+package_unresolvable() {
+ echo packaging unresolvable
+}
diff --git a/testcorpus/unresolvable/manifest.json b/testcorpus/unresolvable/manifest.json
new file mode 100644
index 0000000..1d7a229
--- /dev/null
+++ b/testcorpus/unresolvable/manifest.json
@@ -0,0 +1,30 @@
+{
+ "name": "unresolvable",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "notes": "source missing -> blocked"
+ }
+}
diff --git a/testcorpus/with-patch/PKGBUILD b/testcorpus/with-patch/PKGBUILD
new file mode 100644
index 0000000..c4246a9
--- /dev/null
+++ b/testcorpus/with-patch/PKGBUILD
@@ -0,0 +1,15 @@
+pkgbase=with-patch
+pkgver=1.0
+pkgrel=1
+pkgdesc="synthetic fixture"
+url="https://example.invalid/with-patch"
+license=(MIT)
+arch=(x86_64)
+source=("fix.patch")
+sha256sums=("SKIP")
+build() {
+ echo building with-patch
+}
+package_with-patch() {
+ echo packaging with-patch
+}
diff --git a/testcorpus/with-patch/fix.patch b/testcorpus/with-patch/fix.patch
new file mode 100644
index 0000000..128d5b6
--- /dev/null
+++ b/testcorpus/with-patch/fix.patch
@@ -0,0 +1,5 @@
+--- a/src/main.c
++++ b/src/main.c
+@@ -1,2 +1,2 @@
+-int x = 1;
++int x = 2;
diff --git a/testcorpus/with-patch/manifest.json b/testcorpus/with-patch/manifest.json
new file mode 100644
index 0000000..cf4776e
--- /dev/null
+++ b/testcorpus/with-patch/manifest.json
@@ -0,0 +1,30 @@
+{
+ "name": "with-patch",
+ "build": "succeed",
+ "sig": true,
+ "packages": [],
+ "installed": [
+ {
+ "name": "glibc",
+ "version": "2.39-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "pacman",
+ "version": "6.1.0-1",
+ "arch": "x86_64"
+ },
+ {
+ "name": "binutils",
+ "version": "2.42-1",
+ "arch": "x86_64"
+ }
+ ],
+ "log_lines": [
+ "==> Making package.",
+ "==> Entering fakeroot environment."
+ ],
+ "expect": {
+ "notes": "recipe_hash must cover fix.patch"
+ }
+}
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index b598b80..d5a4f81 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -22,6 +22,10 @@ impl Env {
signing_key_id: "TESTKEY".into(),
..Config::default()
};
+ Self::with_cfg(tmp, cfg)
+ }
+
+ pub fn with_cfg(tmp: tempfile::TempDir, cfg: Config) -> Self {
cfg.ensure_dirs().expect("ensure_dirs");
db::migrate(&cfg.db_path()).expect("migrate");
let db = Db::open_migrated(&cfg.db_path()).expect("open db");
@@ -175,6 +179,153 @@ impl Drop for Env {
}
}
+// ------------------------------------------------------------- fixtures ----
+
+/// Root of the checked-in fake-package corpus (§16a).
+pub fn corpus_root() -> PathBuf {
+ PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("testcorpus")
+}
+
+/// Directory holding the shim executables cargo just built. Prepending this to
+/// PATH is the whole test harness: the pipeline runs unmodified.
+pub fn shim_dir() -> PathBuf {
+ Path::new(&env!("CARGO_BIN_EXE_makechrootpkg"))
+ .parent()
+ .unwrap()
+ .to_path_buf()
+}
+
+/// An environment wired to one corpus fixture: the fixture is committed into a
+/// real git repo standing in for AUR, an optional local upstream git repo exists
+/// for VCS sources, and the shims are told to obey the fixture manifest.
+pub fn env_with_fixture(name: &str) -> (Env, Fixture) {
+ let tmp = tempfile::tempdir().expect("tempdir");
+ let fx = materialize_fixture(tmp.path(), name);
+ let cfg = Config {
+ root: tmp.path().to_path_buf(),
+ signing_key_id: "TESTKEY".into(),
+ path_prepend: Some(shim_dir()),
+ shim_manifest: Some(fx.manifest.clone()),
+ shim_dir: Some(tmp.path().join("shimlog")),
+ ..Config::default()
+ };
+ std::fs::create_dir_all(cfg.shim_dir.as_ref().unwrap()).unwrap();
+ cfg.ensure_dirs().unwrap();
+ let env = Env::with_cfg(tmp, cfg);
+ env.subscribe(name);
+ (env, fx)
+}
+
+/// Copy a corpus fixture into a server root: recipe files into a git repo that
+/// stands in for AUR, payload files beside it so their bytes can be swapped,
+/// and a local upstream repo when the recipe references one.
+pub fn materialize_fixture(root: &Path, name: &str) -> Fixture {
+ let src = corpus_root().join(name);
+ assert!(src.exists(), "no fixture {name} in {}", corpus_root().display());
+ let manifest = root.join("manifest.json");
+ std::fs::copy(src.join("manifest.json"), &manifest).expect("copy manifest");
+
+ // Data files that a source URL points at live outside the recipe so a test
+ // can swap their bytes (the digest-drift case) without touching git.
+ let data = root.join(format!("fixture/{name}"));
+ std::fs::create_dir_all(&data).unwrap();
+ let aur = root.join(format!("aur/{name}.git"));
+ std::fs::create_dir_all(&aur).unwrap();
+
+ let upstream = root.join(format!("upstream/{name}"));
+ let subs = [
+ ("@AUR_DIR@".to_string(), data.display().to_string()),
+ ("@UPSTREAM_DIR@".to_string(), upstream.display().to_string()),
+ ];
+
+ let mut recipe_files: Vec<(String, String)> = Vec::new();
+ let mut has_upstream_ref = false;
+ for entry in std::fs::read_dir(&src).unwrap() {
+ let path = entry.unwrap().path();
+ let fname = path.file_name().unwrap().to_string_lossy().to_string();
+ if fname == "manifest.json" {
+ continue;
+ }
+ let body = std::fs::read_to_string(&path).unwrap_or_default();
+ let body = subs.iter().fold(body, |b, (from, to)| b.replace(from, to));
+ has_upstream_ref |= body.contains(&upstream.display().to_string());
+ if matches!(fname.as_str(), "payload.bin" | "data.bin") {
+ std::fs::write(data.join(&fname), &body).unwrap();
+ } else {
+ recipe_files.push((fname, body));
+ }
+ }
+ if has_upstream_ref {
+ make_git_repo(&upstream, &[("README", "upstream\n")], "upstream: initial");
+ }
+ make_git_repo(
+ &aur,
+ &recipe_files.iter().map(|(n, b)| (n.as_str(), b.as_str())).collect::<Vec<_>>(),
+ "initial",
+ );
+ Fixture {
+ name: name.to_string(),
+ src,
+ aur,
+ data,
+ manifest,
+ upstream: has_upstream_ref.then_some(upstream),
+ }
+}
+
+pub struct Fixture {
+ pub name: String,
+ pub src: PathBuf,
+ pub aur: PathBuf,
+ pub data: PathBuf,
+ pub manifest: PathBuf,
+ pub upstream: Option<PathBuf>,
+}
+
+impl Fixture {
+ /// Commit a new recipe revision, rewriting `pkgver`/`pkgrel`/`epoch`.
+ pub fn bump(&self, changes: &[(&str, &str)]) -> String {
+ let path = self.aur.join("PKGBUILD");
+ let text = std::fs::read_to_string(&path).unwrap();
+ let mut out = String::new();
+ for line in text.lines() {
+ let key = line.split('=').next().unwrap_or("").to_string();
+ match changes.iter().find(|(k, _)| *k == key) {
+ Some((_, v)) => out.push_str(&format!("{key}={v}\n")),
+ None => out.push_str(line),
+ }
+ out.push('\n');
+ }
+ std::fs::write(&path, out).unwrap();
+ git(&self.aur, &["add", "-A"]);
+ git(&self.aur, &["commit", "-q", "-m", "bump"]);
+ git(&self.aur, &["rev-parse", "HEAD"])
+ }
+
+ /// Swap the bytes behind a `SKIP` source without touching the recipe.
+ pub fn swap_payload(&self, body: &str) {
+ for f in ["payload.bin", "data.bin"] {
+ let p = self.data.join(f);
+ if p.exists() {
+ std::fs::write(p, body).unwrap();
+ return;
+ }
+ }
+ panic!("fixture {} has no payload file", self.name);
+ }
+
+ /// Add a commit to the local upstream repo (pin drift, §5.2).
+ pub fn upstream_commit(&self, body: &str) -> String {
+ let up = self.upstream.clone().expect("fixture has no upstream repo");
+ git_add_commit(&up, &[("README", body)], body);
+ git(&up, &["rev-parse", "HEAD"])
+ }
+
+ pub fn manifest_json(&self) -> serde_json::Value {
+ serde_json::from_str(&std::fs::read_to_string(&self.manifest).unwrap()).unwrap()
+ }
+}
+
/// A minimal PKGBUILD for tests that need recipe bytes without a fixture dir.
pub fn pkgbuild(pkgbase: &str, pkgver: &str, pkgrel: &str, extra: &str) -> String {
format!(
diff --git a/tests/shims.rs b/tests/shims.rs
new file mode 100644
index 0000000..f5cab7d
--- /dev/null
+++ b/tests/shims.rs
@@ -0,0 +1,309 @@
+//! The §16a test harness itself: toolchain shims and the fake-package corpus.
+//!
+//! If these tests fail, nothing above the harness can be trusted.
+
+mod common;
+
+use std::path::{Path, PathBuf};
+use std::process::Command;
+
+use common::{corpus_root, env_with_fixture, shim_dir, Env};
+
+use aur_build::shims;
+
+/// Run a shim binary with the harness protocol in the environment.
+fn shim(tool: &str, cwd: &Path, envs: &[(&str, &Path)], args: &[&str]) -> (i32, String, String) {
+ let exe = shim_dir().join(tool);
+ assert!(exe.exists(), "shim {tool} not built at {}", exe.display());
+ let out = Command::new(&exe)
+ .current_dir(cwd)
+ .envs(
+ envs
+ .iter()
+ .map(|(k, v)| (*k, v.as_os_str().to_os_string())),
+ )
+ .args(args)
+ .output()
+ .expect("run shim");
+ (
+ out.status.code().unwrap_or(-1),
+ String::from_utf8_lossy(&out.stdout).into_owned(),
+ String::from_utf8_lossy(&out.stderr).into_owned(),
+ )
+}
+
+fn fixture_manifest(name: &str) -> PathBuf {
+ corpus_root().join(name).join("manifest.json")
+}
+
+#[test]
+fn makechrootpkg_emits_pkginfo_buildinfo_and_sig() {
+ let tmp = tempfile::tempdir().unwrap();
+ let build = tmp.path().join("build");
+ std::fs::create_dir_all(&build).unwrap();
+ std::fs::write(
+ build.join("PKGBUILD"),
+ common::pkgbuild("plain-make", "1.0", "1", ""),
+ )
+ .unwrap();
+ let log = tmp.path().join("shimlog");
+ std::fs::create_dir_all(&log).unwrap();
+
+ // Exactly the invocation §8.1 step 5 makes.
+ let chroot_args = ["-c", "-r", "chroot", "--", "-siTESTKEY", "-f"];
+ let (code, out, err) = shim(
+ "makechrootpkg",
+ &build,
+ &[("AUR_SHIM_MANIFEST", &fixture_manifest("plain-make")), ("AUR_SHIM_DIR", &log)],
+ &chroot_args,
+ );
+ assert_eq!(code, 0, "stdout={out} stderr={err}");
+
+ let pkg = build.join("plain-make-1.0-1-x86_64.pkg.tar.zst");
+ assert!(pkg.exists(), "artifact left in the build dir like the real tool does");
+ let bytes = std::fs::read(&pkg).unwrap();
+ let pkginfo = shims::read_pkginfo(&bytes).unwrap();
+ assert!(pkginfo.contains("pkgname = plain-make"));
+ assert!(pkginfo.contains("pkgver = 1.0-1"));
+ assert!(pkginfo.contains("pkgarch = x86_64"));
+ let buildinfo = shims::read_buildinfo(&bytes).unwrap();
+ assert!(buildinfo.contains("format = 2"));
+ assert!(buildinfo.contains("installed ="), "BUILDINFO carries the chroot world (§10.1)");
+ assert!(buildinfo.contains(" glibc 2.39-1 x86_64 -"));
+ assert!(build.with_extension("pkg.tar.zst.sig").exists() || pkg.with_extension("pkg.tar.zst.sig").exists());
+ assert_eq!(
+ shims::invocations(&log)
+ .iter()
+ .filter(|e| e["tool"] == "makechrootpkg")
+ .count(),
+ 1,
+ "invocation recorded for the pipeline to assert on"
+ );
+}
+
+#[test]
+fn makechrootpkg_refuses_a_missing_pkgbuild() {
+ // Step 0 materializes from the mirror; if that silently produced nothing,
+ // the fake tool must notice rather than build an empty package.
+ let tmp = tempfile::tempdir().unwrap();
+ let build = tmp.path().join("build");
+ std::fs::create_dir_all(&build).unwrap();
+ let (code, _, err) = shim(
+ "makechrootpkg",
+ &build,
+ &[("AUR_SHIM_MANIFEST", &fixture_manifest("plain-make"))],
+ &["-c", "-r", "chroot"],
+ );
+ assert_eq!(code, 1);
+ assert!(err.contains("no PKGBUILD"), "{err}");
+}
+
+#[test]
+fn scripted_failures_are_honoured() {
+ for (fixture, expect) in [("build-fails", 1), ("check-fails", 1), ("plain-make", 0)] {
+ let tmp = tempfile::tempdir().unwrap();
+ let build = tmp.path().join("build");
+ std::fs::create_dir_all(&build).unwrap();
+ std::fs::write(
+ build.join("PKGBUILD"),
+ std::fs::read_to_string(corpus_root().join(fixture).join("PKGBUILD")).unwrap(),
+ )
+ .unwrap();
+ let (code, _, err) = shim(
+ "makechrootpkg",
+ &build,
+ &[("AUR_SHIM_MANIFEST", &fixture_manifest(fixture))],
+ &["-c", "-r", "chroot"],
+ );
+ assert_eq!(code, expect, "{fixture}: {err}");
+ }
+}
+
+#[test]
+fn repo_add_writes_a_pacman_database() {
+ let tmp = tempfile::tempdir().unwrap();
+ let build = tmp.path().join("build");
+ std::fs::create_dir_all(&build).unwrap();
+ std::fs::write(build.join("PKGBUILD"), common::pkgbuild("plain-make", "1.0", "1", "")).unwrap();
+ shim(
+ "makechrootpkg",
+ &build,
+ &[("AUR_SHIM_MANIFEST", &fixture_manifest("plain-make"))],
+ &["-c", "-r", "chroot"],
+ );
+ let pkg = build.join("plain-make-1.0-1-x86_64.pkg.tar.zst");
+
+ let db = tmp.path().join("aur-build.db.tar.gz");
+ let out = Command::new(shim_dir().join("repo-add"))
+ .current_dir(tmp.path())
+ .env("AUR_SHIM_MANIFEST", fixture_manifest("plain-make"))
+ .args(["-R", "-s", "-p", "TESTKEY", &db.display().to_string(), &pkg.display().to_string()])
+ .output()
+ .unwrap();
+ assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
+ assert!(db.exists(), "database written");
+
+ // The db is a gzip'd tar with one DESC per package — what pacman downloads.
+ let dec = flate2::read::GzDecoder::new(std::fs::File::open(&db).unwrap());
+ let mut ar = tar::Archive::new(dec);
+ let names: Vec<String> = ar
+ .entries()
+ .unwrap()
+ .map(|e| e.unwrap().path().unwrap().display().to_string())
+ .collect();
+ assert!(names.iter().any(|n| n == "plain-make/DESC"), "{names:?}");
+ let desc = {
+ let dec = flate2::read::GzDecoder::new(std::fs::File::open(&db).unwrap());
+ let mut ar = tar::Archive::new(dec);
+ let mut found = String::new();
+ for e in ar.entries().unwrap() {
+ let mut e = e.unwrap();
+ if e.path().unwrap().ends_with("plain-make/DESC") {
+ use std::io::Read;
+ e.read_to_string(&mut found).unwrap();
+ }
+ }
+ found
+ };
+ assert!(desc.contains("%FILENAME%"));
+ assert!(desc.contains("plain-make-1.0-1-x86_64.pkg.tar.zst"));
+ assert!(desc.contains("%VERSION%\n1.0-1"));
+ assert!(desc.contains("%SHA256SUM%"));
+}
+
+#[test]
+fn gpg_writes_a_detached_signature() {
+ let tmp = tempfile::tempdir().unwrap();
+ let f = tmp.path().join("thing.pkg.tar.zst");
+ std::fs::write(&f, b"bytes").unwrap();
+ let sig = tmp.path().join("thing.pkg.tar.zst.sig");
+ let out = Command::new(shim_dir().join("gpg"))
+ .current_dir(tmp.path())
+ .args(["--batch", "--detach-sign", "--output", &sig.display().to_string(), &f.display().to_string()])
+ .output()
+ .unwrap();
+ assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
+ let body = std::fs::read_to_string(&sig).unwrap();
+ assert!(body.contains("PGP SIGNATURE"));
+ assert!(body.contains(&aur_build::hash::hex(b"bytes")));
+}
+
+#[test]
+fn mkarchroot_creates_a_warm_root() {
+ let tmp = tempfile::tempdir().unwrap();
+ let root = tmp.path().join("chroot/extra-x86_64");
+ let out = Command::new(shim_dir().join("mkarchroot"))
+ .args(["-C", "/dev/null", &root.display().to_string()])
+ .output()
+ .unwrap();
+ assert!(out.status.success());
+ assert!(root.join("SHIM-ROOT").exists());
+}
+
+/// Every fixture in the corpus must be drivable through the shims. This is the
+/// executable documentation of the §16 edge cases.
+#[test]
+fn every_fixture_is_drivable_through_the_shims() {
+ let mut names = Vec::new();
+ for entry in std::fs::read_dir(corpus_root()).unwrap() {
+ let dir = entry.unwrap().path();
+ if !dir.is_dir() || !dir.join("manifest.json").exists() {
+ continue;
+ }
+ let name = dir.file_name().unwrap().to_string_lossy().to_string();
+ names.push(name.clone());
+
+ let tmp = tempfile::tempdir().unwrap();
+ let build = tmp.path().join("build");
+ std::fs::create_dir_all(&build).unwrap();
+ for f in std::fs::read_dir(&dir).unwrap() {
+ let p = f.unwrap().path();
+ if p.file_name().unwrap() == "manifest.json" {
+ continue;
+ }
+ std::fs::copy(&p, build.join(p.file_name().unwrap())).unwrap();
+ }
+ let manifest = dir.join("manifest.json");
+ let want_fail = serde_json::from_str::<serde_json::Value>(&std::fs::read_to_string(&manifest).unwrap())
+ .unwrap()["build"]
+ .as_str()
+ .unwrap_or("succeed")
+ != "succeed";
+ let out = Command::new(shim_dir().join("makechrootpkg"))
+ .current_dir(&build)
+ .env("AUR_SHIM_MANIFEST", &manifest)
+ .args(["-c", "-r", "chroot", "--", "-siTESTKEY", "-f"])
+ .output()
+ .unwrap();
+ if want_fail {
+ assert!(!out.status.success(), "{name} should fail");
+ } else {
+ assert!(out.status.success(), "{name}: {}", String::from_utf8_lossy(&out.stderr));
+ let pkgs: Vec<_> = std::fs::read_dir(&build)
+ .unwrap()
+ .filter_map(|e| e.ok())
+ .map(|e| e.file_name().to_string_lossy().into_owned())
+ .filter(|n| n.ends_with(".pkg.tar.zst"))
+ .collect();
+ assert!(!pkgs.is_empty(), "{name} produced no package");
+ }
+ }
+ for required in [
+ "plain-make",
+ "with-patch",
+ "install-hooks",
+ "skip-checksum",
+ "split-pkgbase",
+ "build-fails",
+ "check-fails",
+ "missing-dep",
+ "dep-cycle",
+ "epoch-bump",
+ "pkgrel-reset",
+ "downgrade",
+ "digest-drift",
+ "pin-drift",
+ "git-sourced",
+ "unresolvable",
+ ] {
+ assert!(names.iter().any(|n| n == required), "missing fixture {required}");
+ }
+}
+
+/// The corpus doubles as detection fixtures: each one must be detectable through
+/// the real watcher against its local git repo.
+#[test]
+fn fixtures_are_detected_through_the_watcher() {
+ for name in ["plain-make", "with-patch", "install-hooks", "skip-checksum", "split-pkgbase", "epoch-bump"] {
+ let (env, _fx) = env_with_fixture(name);
+ let rep = aur_build::watch::check_pkgbase(&env.cfg, &env.db, name).unwrap();
+ match &rep.outcome {
+ aur_build::watch::Outcome::Candidate { kind, .. } => {
+ assert_eq!(kind, "first_introduction", "{name}");
+ }
+ other => panic!("fixture {name}: expected a first_introduction candidate, got {other:?}"),
+ }
+ assert!(
+ aur_build::db::unapproved_index_entries(&env.db).unwrap().is_empty(),
+ "detection alone must never touch the index (I1)"
+ );
+ }
+}
+
+#[test]
+fn shim_environment_reaches_child_processes_through_the_config() {
+ let env = Env::new();
+ let mut cfg = env.cfg.clone();
+ cfg.path_prepend = Some(shim_dir());
+ cfg.shim_manifest = Some(fixture_manifest("plain-make"));
+ cfg.shim_dir = Some(env.path("shimlog"));
+ std::fs::create_dir_all(env.path("shimlog")).unwrap();
+
+ // Prove the config is what puts the shims on PATH, not the test process env.
+ let mut cmd = Command::new("sh");
+ cfg.child_env(&mut cmd);
+ let out = cmd.args(["-c", "command -v makechrootpkg; echo $AUR_SHIM_MANIFEST"]).output().unwrap();
+ let s = String::from_utf8_lossy(&out.stdout);
+ assert!(s.contains("makechrootpkg"), "{s}");
+ assert!(s.contains("manifest.json"), "{s}");
+}