summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-17 20:47:03 +0000
committeraur-build <aur-build@localhost>2026-11-17 20:47:03 +0000
commit3762c7ce9f765283f47e5716b708e04590339375 (patch)
tree59a2ceab670824c11cc2822363aff2ea887c5f9f
downloadaur-build-3762c7ce9f765283f47e5716b708e04590339375.tar.gz
aur-build-3762c7ce9f765283f47e5716b708e04590339375.zip
chore: scaffold cargo project, toolchain shim binaries, git baseline
Provisions rustup + devtools from the distro package set and lays down the crate skeleton: library, CLI binary, and one binary per external tool the pipeline shells out to (mkarchroot, makechrootpkg, makepkg, repo-add, gpg, pacman) so the §16a PATH shims are real executables that cargo builds and tests can locate via CARGO_BIN_EXE_*. Part of P0 (DESIGN.md §17).
-rw-r--r--.gitignore8
-rw-r--r--.pi/.goals-pool-snapshot.json1
-rw-r--r--.pi/goals/.goal-ledger-checkpoint.json1
-rw-r--r--.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md251
-rw-r--r--.pi/goals/goal_events.jsonl3
-rw-r--r--Cargo.lock1545
-rw-r--r--Cargo.toml61
-rw-r--r--DESIGN.md1235
-rw-r--r--src/bin/gpg.rs1
-rw-r--r--src/bin/makechrootpkg.rs1
-rw-r--r--src/bin/makepkg.rs1
-rw-r--r--src/bin/mkarchroot.rs1
-rw-r--r--src/bin/pacman.rs1
-rw-r--r--src/bin/repo-add.rs1
-rw-r--r--src/lib.rs1
-rw-r--r--src/main.rs3
16 files changed, 3115 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e86670d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+/target
+**/*.rs.bk
+Cargo.lock.orig
+/var
+*.db
+*.db-wal
+*.db-shm
+.DS_Store
diff --git a/.pi/.goals-pool-snapshot.json b/.pi/.goals-pool-snapshot.json
new file mode 100644
index 0000000..bfcdd3b
--- /dev/null
+++ b/.pi/.goals-pool-snapshot.json
@@ -0,0 +1 @@
+{"version":1,"dirMtimeMs":1794948419101.1257,"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":85148,"activeSeconds":210},"sisyphus":false,"createdAt":"2026-11-17T20:43:24.440Z","updatedAt":"2026-11-17T20:46:59.095Z","activePath":".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md","revision":16,"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":"pending","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."},{"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":"pending","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."},{"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-setup"}]} \ No newline at end of file
diff --git a/.pi/goals/.goal-ledger-checkpoint.json b/.pi/goals/.goal-ledger-checkpoint.json
new file mode 100644
index 0000000..5e37be3
--- /dev/null
+++ b/.pi/goals/.goal-ledger-checkpoint.json
@@ -0,0 +1 @@
+{"version":4,"format":"goal-ledger-checkpoint","createdAt":"2026-11-17T20:43:42.925Z","coveredBytes":3883,"coveredEvents":3,"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"}]]],"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"}],"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"}],"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-setup","at":"2026-11-17T20:43:42.908Z"}}]]} \ 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
new file mode 100644
index 0000000..6041cfd
--- /dev/null
+++ b/.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md
@@ -0,0 +1,251 @@
+{
+ "version": 3,
+ "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": 85148,
+ "activeSeconds": 210
+ },
+ "sisyphus": false,
+ "createdAt": "2026-11-17T20:43:24.440Z",
+ "updatedAt": "2026-11-17T20:46:59.095Z",
+ "activePath": ".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md",
+ "revision": 16,
+ "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": "pending",
+ "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."
+ },
+ {
+ "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": "pending",
+ "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."
+ },
+ {
+ "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-setup"
+}
+
+# Goal Prompt
+
+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.
+
+SUCCESS CRITERIA (observable):
+1. `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.
+2. 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).
+3. 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).
+4. 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).
+5. `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.
+
+BOUNDARIES — 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.
+OUT 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.
+
+CONSTRAINTS (hard):
+- 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.
+- 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.
+- 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.
+- Fail closed on every pin assertion (recipe_hash, pkgver match against approved identity); non-publishable changes become `notice` rows, never candidates, never dropped (I11).
+- 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.
+- Commit incrementally: one commit per coherent step with a descriptive message; never a single monolithic commit; DESIGN.md stays untouched.
+- 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.
+
+IF BLOCKED: stop and ask the user (e.g. no network for crates, toolchain uninstallable, an invariant that cannot be made testable).
+
+## Progress
+
+- Status: running
+- Auto-continue: on
+- Sisyphus mode: no
+- Time spent: 3m30s
+- Tokens used: 85K (85,148) tokens
+## Tasks
+
+<!-- blockCompletion: true -->
+- [ ] task-setup: Provision toolchain (pacman rustup + devtools) and initialize git — contract: `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.
+- [ ] task-p0: P0 — walking skeleton + test harness (§17 P0, §16a)
+- [ ] task-p1: P1 — VCS / computed pkgver detection (§5.2, §3)
+- [ ] task-p2: P2 — review surface (§12, §13, §6)
+- [ ] task-p3: P3 — durability (§8.2, §8.3, §8.4)
+- [ ] task-p4: P4 — staleness, retention, metrics (§10, §15)
+- [ ] task-verify: Final verification pass, real-chroot attempt, and documentation — contract: 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.
+
diff --git a/.pi/goals/goal_events.jsonl b/.pi/goals/goal_events.jsonl
new file mode 100644
index 0000000..5a879c6
--- /dev/null
+++ b/.pi/goals/goal_events.jsonl
@@ -0,0 +1,3 @@
+{"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"}
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..9bc62ae
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,1545 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "adler2"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
+
+[[package]]
+name = "android_system_properties"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "anstream"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
+
+[[package]]
+name = "anstyle-parse"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
+dependencies = [
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
+dependencies = [
+ "anstyle",
+ "once_cell_polyfill",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "anyhow"
+version = "1.0.104"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
+
+[[package]]
+name = "ascii"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16"
+
+[[package]]
+name = "askama"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4"
+dependencies = [
+ "askama_derive",
+ "itoa",
+ "percent-encoding",
+ "serde",
+ "serde_json",
+]
+
+[[package]]
+name = "askama_derive"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f"
+dependencies = [
+ "askama_parser",
+ "basic-toml",
+ "memchr",
+ "proc-macro2",
+ "quote",
+ "rustc-hash",
+ "serde",
+ "serde_derive",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "askama_parser"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358"
+dependencies = [
+ "memchr",
+ "serde",
+ "serde_derive",
+ "winnow",
+]
+
+[[package]]
+name = "aur-build"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "askama",
+ "chrono",
+ "clap",
+ "crossbeam-channel",
+ "flate2",
+ "hex",
+ "rusqlite",
+ "serde",
+ "serde_json",
+ "sha2",
+ "similar",
+ "tar",
+ "tempfile",
+ "thiserror",
+ "tiny_http",
+ "ureq",
+ "walkdir",
+ "zstd",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
+
+[[package]]
+name = "base64"
+version = "0.22.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+
+[[package]]
+name = "basic-toml"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "bitflags"
+version = "2.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
+
+[[package]]
+name = "block-buffer"
+version = "0.10.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
+dependencies = [
+ "generic-array",
+]
+
+[[package]]
+name = "bumpalo"
+version = "3.20.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
+
+[[package]]
+name = "cc"
+version = "1.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45"
+dependencies = [
+ "find-msvc-tools",
+ "jobserver",
+ "libc",
+ "shlex",
+]
+
+[[package]]
+name = "cfg-if"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
+
+[[package]]
+name = "chrono"
+version = "0.4.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327"
+dependencies = [
+ "iana-time-zone",
+ "js-sys",
+ "num-traits",
+ "serde",
+ "wasm-bindgen",
+ "windows-link",
+]
+
+[[package]]
+name = "chunked_transfer"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e4de3bc4ea267985becf712dc6d9eed8b04c953b3fcfb339ebc87acd9804901"
+
+[[package]]
+name = "clap"
+version = "4.6.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac230478587d0269d8d6998b82ae69ea51509d55df66d9e92edd1f986904cd4a"
+dependencies = [
+ "clap_builder",
+ "clap_derive",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.6.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "clap_lex",
+ "strsim",
+]
+
+[[package]]
+name = "clap_derive"
+version = "4.6.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "895c9d8d2ac2dd8b8a29f3724a14e72aaaa6debcf8c38c82f97305c6a172767a"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "clap_lex"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0921b3876b3a1df8a1c9f912e7f94342458022c2e84288015893d83c4d62a79"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+
+[[package]]
+name = "cpufeatures"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "crc32fast"
+version = "1.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "crossbeam-channel"
+version = "0.5.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1"
+dependencies = [
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-utils"
+version = "0.8.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
+
+[[package]]
+name = "crypto-common"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
+dependencies = [
+ "generic-array",
+ "typenum",
+]
+
+[[package]]
+name = "digest"
+version = "0.10.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
+dependencies = [
+ "block-buffer",
+ "crypto-common",
+]
+
+[[package]]
+name = "displaydoc"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "errno"
+version = "0.3.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "fallible-iterator"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
+
+[[package]]
+name = "fallible-streaming-iterator"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
+
+[[package]]
+name = "fastrand"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
+
+[[package]]
+name = "filetime"
+version = "0.2.30"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1255e7a9f1902190d4c10a75f2f7f495d3d3ce13e9ba26e6c48683a0f4dbed7"
+dependencies = [
+ "cfg-if",
+ "libc",
+]
+
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
+
+[[package]]
+name = "flate2"
+version = "1.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4"
+dependencies = [
+ "crc32fast",
+ "miniz_oxide",
+ "zlib-rs",
+]
+
+[[package]]
+name = "foldhash"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
+
+[[package]]
+name = "form_urlencoded"
+version = "1.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
+dependencies = [
+ "percent-encoding",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
+
+[[package]]
+name = "futures-task"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
+
+[[package]]
+name = "futures-util"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "pin-project-lite",
+ "slab",
+]
+
+[[package]]
+name = "generic-array"
+version = "0.14.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
+dependencies = [
+ "typenum",
+ "version_check",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "wasi",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.15.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
+dependencies = [
+ "foldhash",
+]
+
+[[package]]
+name = "hashlink"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
+dependencies = [
+ "hashbrown",
+]
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "hex"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
+
+[[package]]
+name = "httpdate"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
+
+[[package]]
+name = "iana-time-zone"
+version = "0.1.65"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
+dependencies = [
+ "android_system_properties",
+ "core-foundation-sys",
+ "iana-time-zone-haiku",
+ "js-sys",
+ "log",
+ "wasm-bindgen",
+ "windows-core",
+]
+
+[[package]]
+name = "iana-time-zone-haiku"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "icu_collections"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd"
+dependencies = [
+ "displaydoc",
+ "potential_utf",
+ "utf8_iter",
+ "yoke",
+ "zerofrom",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_locale_core"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0"
+dependencies = [
+ "displaydoc",
+ "litemap",
+ "tinystr",
+ "writeable",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599"
+dependencies = [
+ "icu_collections",
+ "icu_normalizer_data",
+ "icu_properties",
+ "icu_provider",
+ "smallvec",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer_data"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc"
+
+[[package]]
+name = "icu_properties"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_locale_core",
+ "icu_properties_data",
+ "icu_provider",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_properties_data"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf"
+
+[[package]]
+name = "icu_provider"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514"
+dependencies = [
+ "displaydoc",
+ "icu_locale_core",
+ "writeable",
+ "yoke",
+ "zerofrom",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "idna"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
+dependencies = [
+ "idna_adapter",
+ "smallvec",
+ "utf8_iter",
+]
+
+[[package]]
+name = "idna_adapter"
+version = "1.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"
+dependencies = [
+ "icu_normalizer",
+ "icu_properties",
+]
+
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
+
+[[package]]
+name = "itoa"
+version = "1.0.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
+
+[[package]]
+name = "jobserver"
+version = "0.1.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3"
+dependencies = [
+ "getrandom 0.4.3",
+ "libc",
+]
+
+[[package]]
+name = "js-sys"
+version = "0.3.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a"
+dependencies = [
+ "cfg-if",
+ "futures-util",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.191"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
+
+[[package]]
+name = "libsqlite3-sys"
+version = "0.35.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "133c182a6a2c87864fe97778797e46c7e999672690dc9fa3ee8e241aa4a9c13f"
+dependencies = [
+ "cc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
+
+[[package]]
+name = "litemap"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"
+
+[[package]]
+name = "log"
+version = "0.4.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
+
+[[package]]
+name = "memchr"
+version = "2.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+
+[[package]]
+name = "miniz_oxide"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
+dependencies = [
+ "adler2",
+ "simd-adler32",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
+name = "once_cell_polyfill"
+version = "1.70.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
+
+[[package]]
+name = "percent-encoding"
+version = "2.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
+
+[[package]]
+name = "pkg-config"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
+
+[[package]]
+name = "potential_utf"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661"
+dependencies = [
+ "zerovec",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "r-efi"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+
+[[package]]
+name = "ring"
+version = "0.17.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
+dependencies = [
+ "cc",
+ "cfg-if",
+ "getrandom 0.2.17",
+ "libc",
+ "untrusted",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "rusqlite"
+version = "0.37.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "165ca6e57b20e1351573e3729b958bc62f0e48025386970b6e4d29e7a7e71f3f"
+dependencies = [
+ "bitflags",
+ "chrono",
+ "fallible-iterator",
+ "fallible-streaming-iterator",
+ "hashlink",
+ "libsqlite3-sys",
+ "smallvec",
+]
+
+[[package]]
+name = "rustc-hash"
+version = "2.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
+
+[[package]]
+name = "rustix"
+version = "1.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "rustls"
+version = "0.23.46"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
+dependencies = [
+ "log",
+ "once_cell",
+ "ring",
+ "rustls-pki-types",
+ "rustls-webpki",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-pki-types"
+version = "1.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb"
+dependencies = [
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-webpki"
+version = "0.103.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5"
+dependencies = [
+ "ring",
+ "rustls-pki-types",
+ "untrusted",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
+
+[[package]]
+name = "same-file"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.154"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
+dependencies = [
+ "itoa",
+ "memchr",
+ "serde",
+ "serde_core",
+ "zmij",
+]
+
+[[package]]
+name = "sha2"
+version = "0.10.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "digest",
+]
+
+[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
+name = "simd-adler32"
+version = "0.3.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
+
+[[package]]
+name = "similar"
+version = "2.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
+
+[[package]]
+name = "slab"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
+
+[[package]]
+name = "smallvec"
+version = "1.16.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46"
+
+[[package]]
+name = "stable_deref_trait"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "subtle"
+version = "2.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
+
+[[package]]
+name = "syn"
+version = "2.0.119"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "3.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "synstructure"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "tar"
+version = "0.4.46"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840"
+dependencies = [
+ "filetime",
+ "libc",
+ "xattr",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
+dependencies = [
+ "fastrand",
+ "getrandom 0.4.3",
+ "once_cell",
+ "rustix",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "thiserror"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "tiny_http"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "389915df6413a2e74fb181895f933386023c71110878cd0825588928e64cdc82"
+dependencies = [
+ "ascii",
+ "chunked_transfer",
+ "httpdate",
+ "log",
+]
+
+[[package]]
+name = "tinystr"
+version = "0.8.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a"
+dependencies = [
+ "displaydoc",
+ "zerovec",
+]
+
+[[package]]
+name = "typenum"
+version = "1.20.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
+
+[[package]]
+name = "untrusted"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
+
+[[package]]
+name = "ureq"
+version = "2.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "02d1a66277ed75f640d608235660df48c8e3c19f3b4edb6a263315626cc3c01d"
+dependencies = [
+ "base64",
+ "flate2",
+ "log",
+ "once_cell",
+ "rustls",
+ "rustls-pki-types",
+ "serde",
+ "serde_json",
+ "url",
+ "webpki-roots 0.26.11",
+]
+
+[[package]]
+name = "url"
+version = "2.5.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
+dependencies = [
+ "form_urlencoded",
+ "idna",
+ "percent-encoding",
+ "serde",
+]
+
+[[package]]
+name = "utf8_iter"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0"
+dependencies = [
+ "utf_types",
+]
+
+[[package]]
+name = "utf8parse"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+
+[[package]]
+name = "utf_types"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6"
+
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
+[[package]]
+name = "version_check"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+
+[[package]]
+name = "walkdir"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
+dependencies = [
+ "same-file",
+ "winapi-util",
+]
+
+[[package]]
+name = "wasi"
+version = "0.11.1+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c"
+dependencies = [
+ "cfg-if",
+ "rustversion",
+ "wasm-bindgen-macro",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a"
+dependencies = [
+ "bumpalo",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.130"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "webpki-roots"
+version = "0.26.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9"
+dependencies = [
+ "webpki-roots 1.0.12",
+]
+
+[[package]]
+name = "webpki-roots"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7265c9301c16a8711c992c2d8da90ee77ef54b1ed51482d6dfeb00dc756b1297"
+dependencies = [
+ "rustls-pki-types",
+]
+
+[[package]]
+name = "winapi-util"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
+dependencies = [
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "windows-core"
+version = "0.62.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
+dependencies = [
+ "windows-implement",
+ "windows-interface",
+ "windows-link",
+ "windows-result",
+ "windows-strings",
+]
+
+[[package]]
+name = "windows-implement"
+version = "0.60.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "windows-interface"
+version = "0.59.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-result"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-strings"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-sys"
+version = "0.61.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "winnow"
+version = "0.7.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "writeable"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc"
+
+[[package]]
+name = "xattr"
+version = "1.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "963d6fab92d5504b971dc8bd90ca743c2575e590bc8071ea5bc571598667ae08"
+dependencies = [
+ "libc",
+ "rustix",
+]
+
+[[package]]
+name = "yoke"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3"
+dependencies = [
+ "stable_deref_trait",
+ "yoke-derive",
+ "zerofrom",
+]
+
+[[package]]
+name = "yoke-derive"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+ "synstructure",
+]
+
+[[package]]
+name = "zerofrom"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272"
+dependencies = [
+ "zerofrom-derive",
+]
+
+[[package]]
+name = "zerofrom-derive"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+ "synstructure",
+]
+
+[[package]]
+name = "zeroize"
+version = "1.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85ccff8a4805aba1eaa4cd4afcd49f7557dd2cf5fd79ffc37f8959466effc5aa"
+
+[[package]]
+name = "zerotrie"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f"
+dependencies = [
+ "displaydoc",
+ "yoke",
+ "zerofrom",
+]
+
+[[package]]
+name = "zerovec"
+version = "0.11.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40"
+dependencies = [
+ "yoke",
+ "zerofrom",
+ "zerovec-derive",
+]
+
+[[package]]
+name = "zerovec-derive"
+version = "0.11.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.10",
+]
+
+[[package]]
+name = "zlib-rs"
+version = "0.6.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
+
+[[package]]
+name = "zmij"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
+
+[[package]]
+name = "zstd"
+version = "0.13.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50adf04cf3ec914b0b9905c9dde90c80fe74bfd701e331fc80a39c512c525278"
+dependencies = [
+ "zstd-safe",
+]
+
+[[package]]
+name = "zstd-safe"
+version = "7.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "498d94ad68720c89b4fbe41b9090850651e68cb2dd9210ce7ffbff3a94653819"
+dependencies = [
+ "zstd-sys",
+]
+
+[[package]]
+name = "zstd-sys"
+version = "2.1.3+zstd.1.5.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f729a06d0257428fd9d997ac8db7e1407bd0262ab016b085b36bc52957c0052d"
+dependencies = [
+ "cc",
+ "pkg-config",
+]
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..10146c2
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,61 @@
+[package]
+name = "aur-build"
+version = "0.1.0"
+edition = "2021"
+description = "AUR build server: watch AUR packages, require human approval for every change, build in a clean chroot, publish a signed repo"
+license = "MIT"
+
+[lib]
+name = "aur_build"
+path = "src/lib.rs"
+
+[[bin]]
+name = "aur-build"
+path = "src/main.rs"
+
+# ---------------------------------------------------------------------------
+# Toolchain shims (DESIGN.md §16a). These are real binaries with the exact names
+# the pipeline shells out to; the test harness prepends their directory to PATH
+# so the whole step machine runs without root, network or an Arch chroot.
+# ---------------------------------------------------------------------------
+[[bin]]
+name = "mkarchroot"
+path = "src/bin/mkarchroot.rs"
+[[bin]]
+name = "makechrootpkg"
+path = "src/bin/makechrootpkg.rs"
+[[bin]]
+name = "makepkg"
+path = "src/bin/makepkg.rs"
+[[bin]]
+name = "repo-add"
+path = "src/bin/repo-add.rs"
+[[bin]]
+name = "gpg"
+path = "src/bin/gpg.rs"
+[[bin]]
+name = "pacman"
+path = "src/bin/pacman.rs"
+
+[dependencies]
+anyhow = "1"
+thiserror = "2"
+rusqlite = { version = "0.37", features = ["bundled", "chrono"] }
+crossbeam-channel = "0.5"
+tiny_http = "0.12"
+askama = "0.14"
+ureq = { version = "2", features = ["json"] }
+similar = "2"
+serde = { version = "1", features = ["derive"] }
+serde_json = "1"
+sha2 = "0.10"
+hex = "0.4"
+clap = { version = "4", features = ["derive"] }
+chrono = { version = "0.4", features = ["serde"] }
+walkdir = "2"
+tar = "0.4"
+zstd = "0.13"
+flate2 = "1"
+
+[dev-dependencies]
+tempfile = "3"
diff --git a/DESIGN.md b/DESIGN.md
new file mode 100644
index 0000000..a819e63
--- /dev/null
+++ b/DESIGN.md
@@ -0,0 +1,1235 @@
+# AUR Build Server — Design Sketch (v0)
+
+Status: **for discussion**. Nothing implemented. Open questions are collected in §18.
+
+---
+
+## 1. Problem statement
+
+A service that lets users subscribe to AUR packages, watches them for changes, requires a
+**human approval** for every change, and only then builds the package in a clean chroot and
+publishes it into a signed pacman repo that end consumers use.
+
+Two independent change sources must be caught:
+
+1. **Recipe change** — the AUR maintainer edited `PKGBUILD` / `.SRCINFO` / shipped patches.
+2. **Upstream change** — the recipe is untouched, but the *computed* `pkgver` moved
+ (the `-git`/`-svn`/VCS case: `pkgver()` clones upstream and derives a version).
+
+Plus a third, related concern:
+
+3. **Dependency drift** — when a dependency we publish moves, the packages built against the
+ older version must be *visible* as stale. v1 records and surfaces this; it does not
+ rebuild automatically (§10).
+
+### The two hard rules the user called out
+
+* **Nothing is accepted before it is approved.** The index is only ever a function of
+ approved releases. Unapproved versions are invisible to consumers.
+* **Diffs are always against the last *accepted* version, never the last *seen* version.**
+ If v1 is accepted and v2, v3, v4 arrive while nobody is looking, the human must be shown
+ `v1 → v4`, not `v3 → v4`.
+
+---
+
+## 2. Invariants (the contract we test against)
+
+These are the properties the design must guarantee. Everything else is an implementation
+detail that can change.
+
+| # | Invariant |
+|---|---|
+| I1 | Every artifact in a served repo index traces to an `approval` row. No approval ⇒ no index entry. |
+| I2 | A review's `base` is the pkgbase's `current_accepted_release`, not the previously detected candidate. |
+| I3 | A candidate identity is content-addressed over *everything that becomes a byte in the artifact*: AUR commit, resolved version, upstream VCS pins, and resolved source digests. Two byte-identical inputs never produce two candidates. |
+| I4 | Publishing is the only externally visible step, and it is atomic + serialized per repo. A crash mid-publish leaves the old index intact. |
+| I5 | Every build step is idempotent and checkpointed; a worker can die at any instant and the pipeline resumes at the next incomplete step with no duplicate side effects. |
+| I6 | A manual rebuild reuses the *approved source identity*; it never needs a new approval and never changes the source version. |
+| I12 | Every release records the exact set of our own packages it was built against, so "is this stale?" is always answerable from stored facts rather than re-derived guesswork. |
+| I7 | A pkgbase has at most one open review at a time. A newer detection **collapses into** the open review (same base) rather than queueing beside it. |
+| I8 | The set of packages in the index is exactly the set of `current_accepted_release` pointers for all active subscriptions (modulo explicit removals). No drift, no orphans. |
+| I9 | Build hosts are treated as untrusted: a malicious `PKGBUILD` must not reach the control-plane DB, the signing key, or another build. |
+| I10 | Every state transition is recorded in an append-only audit log with actor (human / policy / system) and timestamp. |
+| I11 | A change that is **not publishable** (version string unchanged) never silently disappears: it lands in `notice` and is surfaced in the UI. |
+
+---
+
+## 3. Core concepts
+
+```
+Subscription a user wants pkgbase X tracked in repo R
+Pkgbase the unit of AUR recipes (one PKGBUILD, may emit N packages)
+Snapshot an immutable pin of the AUR git repo for a pkgbase (commit SHA + tree hash)
+Candidate a detected, reviewable change: (pkgbase, snapshot, resolved version)
+Review the human-facing diff + decision for a Candidate
+Approval the immutable decision record: "candidate C, transition base→candidate, by U, at T"
+Release an approved candidate that has been built & published (the accepted state)
+Build an attempt to turn a Release-intent into artifacts; has BuildAttempts
+WorldSnapshot the fingerprint of the accepted dep set a build ran against
+Repo a signed pacman repo; holds Release pointers (one per pkgbase)
+```
+
+Key modelling decision: **`pkgbase` is the unit of subscription, detection, diffing and
+approval; `package` is the unit of the index and dependency resolution.** A split
+`PKGBUILD` producing `foo` and `foo-lua` is one approval and two index entries.
+
+### Version identity
+
+A candidate's identity is a tuple, not a string:
+
+```
+aur_commit, epoch, pkgver, pkgrel, upstream_pins[], source_digests[]
+```
+
+Every element is part of the key. That is deliberate, and the last one has a consequence
+worth stating out loud: **if a source tarball's bytes change while `pkgver` stays the same,
+that is a new candidate requiring a new approval.** Silent artifact swap is the classic AUR
+compromise, and folding the digest into the identity is what turns it from an invisible
+event into a reviewable one.
+
+* `recipe_hash` = hash over the *entire* AUR snapshot tree: `PKGBUILD`, `.SRCINFO`,
+ `*.install`, and any shipped patches/assets. Patches shipped in the AUR repo are part of
+ the recipe and are a classic silent-change vector. Implied by `aur_commit`.
+
+### Three things to pin, not one
+
+For a `-git` package there are **two distinct repositories**, and conflating them is the
+single easiest way to build something nobody reviewed:
+
+```
+PKGBUILD lives in: https://aur.archlinux.org/yay-git.git <- the RECIPE
+source=(git+https://github.com/dweiss/yay.git) <- the CODE
+```
+
+| Pin | What it pins | How obtained | Answers |
+|---|---|---|---|
+| `aur_commit` | the recipe text | our local AUR git mirror | "which PKGBUILD did the human read?" |
+| `upstream_pins[]` | the code that gets compiled | `git ls-remote` / forge API per VCS `source=()` entry | "which source revision did the human read?" |
+| `source_digests[]` | the actual bytes consumed | hash each resolved source (§5.3) | "is what we built what we reviewed?" |
+
+`upstream_pins[]` is a **set of HEADs, one per VCS source** — a pkgbase can have several
+(`git+…app.git` plus `git+…vendor.git`), and each moves independently. Each entry is:
+
+```json
+{"index": 0, "url": "git+https://github.com/dweiss/yay.git",
+ "ref": "HEAD", "branch": "main", "commit": "9f2c1ab…"}
+```
+
+The commit SHA alone is sufficient. A git commit transitively commits to its tree, and a
+gitlink entry in that tree transitively commits to any submodule's commit — so one SHA per
+VCS source already pins the whole source tree, submodules included. No separate tree hash
+needed.
+
+The one real caveat: **the pin is only honoured if the build actually checks out that
+commit.** A `pkgver()` or `prepare()` that clones with `--remote`, or a plain branch source
+with no `#commit=` fragment, will follow the tip instead of the recorded gitlink. So for now
+`upstream_pins` gives us identity, diffing, and traceability; making the build honour it is
+a deferred extension (§20). The interim guard is that `-git` `pkgver()` strings almost
+always encode the commit (`r1234.9f2c1ab`), so we **assert post-build that the produced
+`pkgver` equals the approved `pkgver`** and fail closed on mismatch.
+
+Displayed version is the usual `epoch:pkgver-pkgrel`; internal identity is the tuple. A
+`pkgrel` reset (`pkgrel=7 → 1`) is a *major* signal and must be surfaced loudly.
+
+---
+
+## 4. Architecture
+
+**One process, many threads, no async.** The whole application — HTTP server, watchers,
+scheduler, build workers, publisher — is a single native binary. Concurrency is
+`std::thread` + `crossbeam` channels. Blocking is not a compromise here, it is the right
+shape: build workers spend their lives blocked on a `makechrootpkg` child process.
+
+```
+ ┌────────────────────────────────────────────┐
+ │ aur-build (one binary) │
+ │ │
+ browser ──HTTP──► │ http threads (thread-per-connection) │
+ │ │ │
+ │ ▼ │
+ │ ┌──────────────┐ │
+ │ │ writer │ single SQLite writer │
+ │ │ actor │ (channel in, tx out) │
+ │ └──────┬───────┘ │
+ │ │ WAL │
+ │ ┌──────┴────────────────────────┐ │
+ │ │ SQLite (WAL) │ │
+ │ └──────┬───────────┬────────────┘ │
+ │ │ ▲ │
+ │ watcher threads │ build workers │
+ │ aur-mirror │ (N threads, each │
+ │ vcs-probe │ shells out to │
+ │ dep-watcher │ makechrootpkg) │
+ │ dispatcher │ │
+ │ publisher (1 thr) │ │
+ └──────────────────────┼────────────────────┘
+ ▼
+ artifact store + repo dir ──► nginx/caddy
+ local AUR git mirrors
+```
+
+Process separation still matters for the security boundary, but it is achieved with **OS
+users and sudo rules**, not separate services: the build steps that execute untrusted
+`PKGBUILD`s run as a distinct, unprivileged user with no access to the signing key or the
+DB file's directory. See §14.
+
+### Stack
+
+| Concern | Choice | Why |
+|---|---|---|
+| Language | Rust, edition 2021, **no `async`/`await`, no tokio** | user requirement; also removes the whole class of "blocking call starves the runtime" bugs |
+| HTTP | `tiny_http` (thread-per-connection, blocking) | no runtime dependency; SSE is just a thread that blocks and writes |
+| Templating | `askama` (compile-time checked) or `minijinja` | SSR, no build step |
+| Interactivity | htmx (one vendored `.js`, no build step) + a few SSE endpoints | "minimal functional javascript"; falls back to `<meta refresh>` if we prefer zero JS |
+| DB | `rusqlite` (bundled libsqlite), **WAL mode** | user requirement; see §11a for the concurrency model |
+| Migrations | `refinery` or a hand-rolled `user_version` stepper | |
+| Outbound HTTP | `ureq` (blocking) | `reqwest` pulls in tokio even in blocking mode — avoid |
+| Git | shell out to `git` | we need `git` on the host anyway; avoids libgit2 build pain |
+| Subprocesses | `std::process::Command` + `wait` with a watchdog thread | |
+| Scheduling | one tick thread + `sweep` over `next_check_at` columns | no cron dependency needed |
+| Diffing | `similar` | unified diffs in Rust |
+| Version/dep logic | hand-written `vercmp` + dep-string parser (~100 lines, well specified) | avoids binding libalpm |
+| External tools | `mkarchroot`, `makechrootpkg`, `repo-add`, `gpg`, `pacman`, `git` | |
+
+Deliberately **not** used: tokio, axum, actix, reqwest, sqlx (async), libgit2, any JS
+bundler/framework.
+
+---
+
+## 5. Detection (watchers)
+
+### 5.1 AUR recipe watcher
+
+**Clone, don't scrape.** For each subscribed pkgbase keep a git mirror:
+
+```
+mirrors/<pkgbase>/ ← git clone https://aur.archlinux.org/<pkgbase>.git
+```
+
+Plain clone, **no `--filter=blob:none`**. A partial clone can lazily drop blobs, and we need
+to be able to materialize any historical commit forever (see §5.1a). These repos contain a
+PKGBUILD and maybe a few patches — they are kilobytes.
+
+Poll cheaply with `git ls-remote` (one request per pkgbase), `git fetch` only when the SHA
+moved. This gives us:
+
+* exact change detection (SHA moved ⇒ recipe changed, no false positives from metadata),
+* free, authoritative diffs (`git log -p base..head`) including patch files,
+* the maintainer's own commit messages, which are excellent review context,
+* **the commit SHA itself, which becomes the build pin** (§5.1a),
+* detection of orphaning/deletion (repo 404s or goes read-only).
+
+Cross-check with the AUR RPC (`type=info&id[]=…`) for `LastModified`, `Maintainer`,
+`Version`, and to notice `pkgbase` renames. RPC `Version` catches the case where the
+maintainer bumped a *static* `pkgver` — cheap, no clone needed, so it can gate the clone.
+
+Also handle: package deleted from AUR, package transferred to a new maintainer,
+`pkgbase` renamed (old name becomes a redirect), and a pkgbase we track being folded into
+another pkgbase's split build.
+
+### 5.1a The AUR commit pin (`aur_commit`) — first-class metadata
+
+Every candidate records the exact AUR commit its recipe came from, and that SHA is used
+throughout the lifecycle:
+
+```
+detect: git fetch → HEAD = 4f9c02e… → candidate.aur_commit = 4f9c02e…
+diff: git diff <accepted.aur_commit>..<candidate.aur_commit>
+review: UI shows the SHA, links to AUR cgit, shows recipe_hash of that tree
+build: NEVER re-fetch from the network. Materialize from the local mirror at the pin:
+ git --git-dir=mirrors/<pkgbase> worktree add --detach <builddir> <aur_commit>
+ (or: git archive <aur_commit> | tar -x -C <builddir>)
+verify: recompute recipe_hash over <builddir>; assert == candidate.recipe_hash → fail closed
+audit: release stores aur_commit + recipe_hash, so any installed package can be traced
+ back to the exact bytes a human approved, forever
+```
+
+Consequences worth being deliberate about:
+
+* **The mirror is now load-bearing, not a cache.** Losing it means losing the ability to
+ rebuild or even reproduce any historical release. It goes in backups (§15), and mirror GC
+ must never prune a commit reachable from an accepted release. Since AUR branches are
+ append-only, "never prune" is the safe default; these repos stay small.
+* **The pin is shown in the UI** next to the diff, with a link to
+ `https://aur.archlinux.org/cgit/aur.git/commit/?h=<pkgbase>&id=<sha>`, so the reviewer can
+ independently verify what the server showed them against AUR itself.
+* **It pins the recipe, not the code.** For a `-git` package the compiled source is pinned
+ separately, by `upstream_pins` (§3). Both pins are required for "we built what you saw";
+ neither alone is enough.
+* **Non-reproducible by design.** `aur_commit` gives *traceability*, not bit-reproducible
+ builds. Reproducibility would additionally need upstream pins + a pinned build world.
+ Worth stating plainly so nobody mistakes one for the other.
+
+### 5.2 VCS / computed-pkgver watcher (the expensive one)
+
+RPC `Version` is the literal `pkgver=` field. For `-git` packages that field is frozen and
+the real version comes from `pkgver()` at build time. Two-stage funnel:
+
+**Stage A — cheap upstream probe (no build).** Parse `source=()` for VCS entries
+(`git+`, `svn+`, `hg+`, `bzr+`). For `git+https://…/repo.git` ask the host for the current
+ref tip: GitHub/GitLab/GitHub-Enterprise APIs, `git ls-remote` as the universal fallback,
+per-ref pinning respected (`…#tag=v2.1` / `#commit=abc`). Do this for **every** VCS source
+in the pkgbase, not just the first. If the resulting set of HEADs is identical to the set
+recorded on the accepted release, **stop** — nothing can have changed. This makes the common
+case (zero upstream movement) nearly free.
+
+**Stage B — authoritative pkgver resolution + pin capture.** Only when Stage A saw movement,
+run the real thing in a throwaway chroot:
+
+```
+makepkg --vercheck # or: makepkg -g / --printsrcinfo, then eval pkgver()
+```
+
+i.e. clone with the PKGBUILD's own depth/submodule/ref rules, run `pkgver()`, read back
+the computed `pkgver-pkgrel`. This is the only correct answer, because `pkgver()` can do
+arbitrary things (`git describe`, date-stamping, counting commits since a tag).
+
+Stage B also **captures the pins**, since the clone is already there: for each VCS source,
+the resolved commit and the branch/ref it came from. Cheap to do here; doing it later would
+mean another clone.
+
+**Crucial: a candidate exists only if something *publishable* changed.** If upstream moved
+but the resolved `epoch:pkgver-pkgrel` is unchanged, there is nothing to publish — consumers
+cannot observe a same-version package, `pacman` would not offer an upgrade, and inventing a
+`pkgrel` bump is not our call to make. So:
+
+| Situation | Action |
+|---|---|
+| pins moved, `pkgver` changed | normal candidate, requires approval |
+| pins moved, `pkgver` unchanged | **no candidate.** Record an informational `pin_drift` event, show it on the package page ("upstream moved 14 commits; pkgver unchanged, nothing publishable"), and surface it as a hint that `pkgver()` may be degenerate (date-based, or watching a non-default branch) |
+| `aur_commit` moved, version unchanged | **no candidate**, same reason — but flag it: the maintainer probably forgot to bump `pkgrel`, and the user should know the recipe drifted under a static version |
+
+This does not weaken the approval rule. Nothing was built and nothing was published, so no
+unapproved artifact can reach a consumer (I1). The index keeps serving the artifact built
+from the old pins, and the accepted release keeps recording the pins it was actually built
+from — which remain true.
+
+Cost control: Stage B is gated by Stage A, so it only runs for pkgbases whose upstream tip
+actually moved — with a once-a-day poll (§19) that is a small, self-limiting set per day. The
+one thing worth being deliberate about is **clone reuse**: keep a persistent cache of upstream
+VCS clones (same idea as the AUR mirrors) and `git fetch` into it rather than re-cloning per
+run, because some upstream repos are multi-gigabyte and re-cloning one daily would be silly.
+Also: per-pkgbase cooldown, a global concurrency cap on Stage B, and a cache keyed on
+`(pkgbase, recipe_hash, upstream_tip)`.
+
+### 5.3 Source digests, and the `SKIP` problem
+
+`sha256sums=('SKIP')` is the hole in the whole integrity story. It is idiomatic and
+unavoidable for VCS sources — the content changes constantly, that is the point — but it
+also shows up on static tarballs, downloaded `.desktop` files, prebuilt binaries, and
+"just grab whatever is on the CDN" packages. In every one of those cases the PKGBUILD
+promises nothing about what will actually be downloaded.
+
+**We resolve and record the digest of every source ourselves, at detection time**, and store
+it on the candidate regardless of what the PKGBUILD declares.
+
+| Source kind | What we record | Cost |
+|---|---|---|
+| Static file with a declared checksum | the declared checksum (makepkg will verify it at build anyway) | free — no download |
+| Static file with `SKIP` | **download and stream-hash `sha256`** | paid once, cached and reused by the build |
+| VCS (`git+`/`svn+`/`hg+`) | the resolved commit SHA (same value as `upstream_pins`), captured during Stage B where we clone anyway | near free |
+| Local file shipped in the AUR repo | hash of the file at `aur_commit` | free |
+
+Design points:
+
+* **Only `SKIP` sources cost bandwidth.** Declared-checksum sources are trusted-as-declared
+ for identity purposes, because makepkg enforces them at build. This keeps the expensive
+ path narrow and targeted at exactly the unverified cases.
+* **Stream-hash, don't buffer.** Hash while downloading into the source cache; the build
+ reuses the cached file, so the bytes are paid for once, not twice.
+* **Digest drift is a headline event, but not a candidate.** If a source digest changes while
+ `pkgver`, `pkgrel` and `aur_commit` are all unchanged, there is nothing publishable (same
+ version string ⇒ `pacman` sees no upgrade), so per §5.2 this does not create a review.
+ It creates something stronger: a **high-severity `integrity_alert`** on the package page
+ and the dashboard — *"the artifact in your index was built from bytes upstream no longer
+ serves; the version string is unchanged"* — which is the signature of a swapped artifact or
+ a compromised CDN. An approval prompt would be useless here (approving it would not let us
+ publish anything); an unmissable alert is the right response. If the version *also*
+ changed, the digests are part of the candidate identity (§3) and it becomes a normal,
+ high-risk review. This is arguably the single most valuable detection in the system.
+* **Digests are part of the candidate identity** (§3), so drift accompanying a version change
+ cannot be silently absorbed.
+* **`SKIP` on a non-VCS source is itself a risk signal**, independent of whether anything
+ drifted — it means the recipe permanently refuses to verify its input.
+
+### 5.3a Not in scope: turning `SKIP` into a real checksum
+
+Since we know the digest at review time, we *could* rewrite `sha256sums=('SKIP')` to the
+actual digest before building, so makepkg verifies the bytes we reviewed and the build fails
+if the CDN serves something else in the meantime. Same class of thing as pinning VCS sources
+to `#commit=<sha>`.
+
+**Both are deferred** — see §20 Future extensions. For now we record digests and pins for
+identity, diffing and forensics; we do not mutate the recipe. Recording is enough to make
+drift visible, which is the main win, and it costs us no correctness guarantees we would
+otherwise be silently skipping.
+
+### 5.4 Dependency bookkeeping
+
+No watcher. Dependency facts are captured at build time from `.PKGINFO`/`.BUILDINFO` and
+consumed by staleness tracking (§10), which is a read-time query rather than a trigger.
+
+---
+
+## 6. Diff & risk analysis
+
+A review is not one diff, it's a panel. Every panel compares **what the accepted release
+recorded** against **what the candidate records now** — i.e. `accepted.aur_commit →
+candidate.aur_commit`, `accepted.upstream_pins → candidate.upstream_pins`,
+`accepted.source_digests → candidate.source_digests`. Never "last seen".
+
+| Panel | Content |
+|---|---|
+| Recipe diff | unified diff of `PKGBUILD`, `.SRCINFO`, `*.install`, and every shipped patch file, from `git diff <accepted_aur_commit>..<candidate_aur_commit>` |
+| Version delta | `epoch:pkgver-pkgrel` old → new; flags `pkgrel` reset, `epoch` bump, downgrade |
+| **Source digest delta** | per-source old → new digest, plus any newly-declared `SKIP` or `sha256sums` entry changed *to* `SKIP`. Note: drift with **no** version change is an `integrity_alert` on the package page, not a review (§5.3) |
+| Upstream delta | for each VCS source: `git log --oneline old_commit..new_commit`, commit count, changed-file stat, links to the upstream compare URL, submodule pointer moves |
+| Source delta | added/removed `source=()` entries, host changes (e.g. `github.com` → unknown mirror), new/removed `sha256sums`, `pgp`/`validpgpkeys` changes |
+| Dependency delta | `depends`, `makedepends`, `checkdepends`, `optdepends`, `provides`, `conflicts` — resolved against our index so we can say "will pull in new package X" |
+| Build-env delta | `options=()`, `arch=()`, `makepkg`/devtools flags, `pkgbase` renames, split-package set membership changes |
+| Install-script delta | `.install` `pre_install`/`post_install`/`pre_upgrade` hooks — arbitrary code that runs on consumer machines |
+
+### Risk scoring
+
+The reviewer's attention is the scarcest resource, so every candidate gets a computed risk
+level that drives ordering and colour in the inbox.
+
+Elevating signals (non-exhaustive):
+**source digest changed with no version change** (highest - but see §5.3: this is an
+`integrity_alert`, not a review) · `SKIP` declared on a non-VCS
+source · `sha256sums` entry changed *to* `SKIP` · new `source` host ·
+`--skippgpcheck` / removed `validpgpkeys` · new
+`makedepends` (especially compilers, `cargo`, `npm`) · new `.install` script or changed
+hooks · `pkgrel` reset · `epoch` bump · `options=(!debug)`/`(!buildflags)`/`(!strip)` ·
+`!security` flags · `checkdepends` removal (tests silently skipped) · recipe diff touching
+`build()`/`package()` bodies vs. only comments/metadata · upstream commit range containing
+build-system changes (`Cargo.toml`, `package.json`, `setup.py`, `Makefile`) · first
+candidate from a newly-orphaned pkgbase (new maintainer = new trust).
+
+Digest drift is an **alert, not an approval** (see above).
+
+Risk level is **advisory only** in v1 — it orders and colours the inbox. There is no
+auto-approval, so nothing is gated on it (§7.3).
+
+---
+
+## 7. Approval semantics
+
+### 7.1 Candidate / review state machine
+
+One review object per pkgbase at a time. New detections **collapse into** the open review
+rather than creating new rows:
+
+```
+ detected ──► diffing ──► pending_review ──┬──► approved ──► (build) ──► release
+ ▲ │ ├──► rejected (terminal for this identity)
+ │ └────────┴──► withdrawn (terminal, pkgbase unsubscribed)
+ │
+ newer detection while pending_review and unviewed
+ └─► UPDATE IN PLACE: new aur_commit/pkgver/diff, revision += 1
+ base is unchanged, no new row, no superseded state
+
+ newer detection while pending_review and already viewed/acted-on
+ └─► freeze old row as `superseded` (audit trail), open a new review
+```
+
+* `base` is fixed at creation to the pkgbase's `current_accepted_release` and **never
+ changes**, no matter how many times the candidate collapses in place. That is what
+ guarantees the diff is always against the last accepted version. (I2)
+* `superseded` therefore only exists for the case where a human actually saw the old diff —
+ otherwise it is pure noise and we don't create it. The `revision` counter plus the audit
+ log still records that detections happened in between.
+* `rejected` is remembered per identity hash so the watcher doesn't nag about the same
+ version forever. A rejection can be manually re-opened. Rejection does not block newer
+ candidates.
+
+### 7.1a Stale approvals are rejected outright
+
+If a human approves a candidate whose identity no longer matches what was rendered, the
+approval is **refused**. No silent retargeting, no "approve latest" magic.
+
+The approve POST carries an optimistic-concurrency token:
+
+```
+POST /reviews/:id/approve { candidate_id, identity_hash, diff_digest }
+
+server, in one write transaction:
+ 1. candidate must still be state = pending_review
+ 2. candidate.identity_hash must equal the submitted identity_hash
+ 3. candidate.diff_digest must equal the submitted diff_digest
+ 4. candidate.base_release_id must equal pkgbase.current_accepted_release_id
+ any mismatch → HTTP 409 with a re-render of the *current* diff and the message
+ "v3 was detected while you were looking; this is v3, not v2"
+```
+
+Rule of the system: **we build exactly what was displayed, or nothing.** The `diff_digest`
+check is what makes that provable rather than aspirational — it closes the window where the
+watcher updated the row between page render and click.
+
+The UI still offers an explicit "show me the newest" path, but that is a fresh action on a
+fresh diff, never a side effect of approving an old one.
+
+### 7.1b First acceptance is a different kind of review
+
+A brand-new subscription has no `current_accepted_release`, so there is nothing to diff
+against and invariant I2 has no referent. These get a distinct review kind,
+`first_introduction`:
+
+* No diff pane. Instead: the full `PKGBUILD` and `.SRCINFO` rendered readably, the complete
+ source list with resolved digests, the resolved dependency set, and the `aur_commit`.
+* The identity of the maintainer and how long the package has existed in AUR are shown —
+ with no history of our own, those are the only trust signals available.
+* Visually distinguished, **quietly**. A thin red accent on the card and a one-line note
+ ("first build of this package here") is enough. This is a more careful review, not a
+ warning that the user is doing something wrong.
+* Approving it creates the first `release` and establishes the base every future diff will be
+ measured against, so it is the single most consequential approval for a pkgbase.
+
+### 7.2 Approval record
+
+Immutable, append-only:
+
+```
+approval(id, candidate_id, base_release_id, decided_at,
+ decision, risk_level, diff_digest, identity_hash, note)
+```
+
+`diff_digest` is a hash of the exact rendered diff the human was shown. Storing it means
+we can later prove "the human approved *this* diff", which matters because this system's
+whole purpose is being a human firewall against arbitrary code.
+
+### 7.3 No auto-approval in v1
+
+**Every review is approved by a human.** Auto-approve policies are deferred (§20). This
+simplifies things considerably: risk scoring is *advisory* — it orders the inbox, colours
+rows, and surfaces signals, but it never gates anything. There is no policy engine, no
+`policy_id`, and no class of bug where a heuristic let something through.
+
+### 7.4 Bulk operations
+
+Multi-select approve/reject in the inbox, with a guard: bulk approve always shows a
+per-item risk summary first and refuses to include anything flagged high-risk unless each is
+individually confirmed. Bulk approve is per-candidate, never "approve everything forever".
+
+---
+
+## 8. Build pipeline
+
+### 8.1 Steps
+
+```
+0 materialize git worktree add --detach <builddir> <aur_commit> (local mirror only, no net)
+ recompute recipe_hash; assert == candidate.recipe_hash → fail closed
+1 plan resolve deps against current accepted index; compute WorldSnapshot
+2 chroot acquire/refresh chroot overlay; install makedepends + depends from our repo
+3 sources seed from source_cache, fetch what is missing, then verify against
+ candidate.source_digests (not only the PKGBUILD's declared sums) + PGP
+4 pkgver (VCS only) resolve pkgver(); assert == approved pkgver/pkgrel
+5 build makechrootpkg -c -r <chroot> -- -si <key> -f
+6 collect parse .PKGINFO/.BUILDINFO, extract artifacts + build log
+7 verify signature valid, deps satisfiable in target repo, no downgrade
+8 ingest move artifacts to content-addressed store, record rows
+9 publish repo-add + repo-remove, sign, atomic swap
+8 ingest move artifacts to content-addressed store, record rows
+9 publish repo-add + repo-remove, sign, atomic swap
+```
+
+Each step writes `build_step(build_id, step, status, attempt, started_at, finished_at,
+output_digest, error)`. A worker claims a build, runs the next incomplete step, records it,
+and requeues. Steps 0–8 are idempotent and parallel-safe across builds. **Step 9 is
+serialized by a single-writer lock per repo** and is the only externally visible mutation.
+
+Step 0 is the `aur_commit` pin doing its job: the bytes we build are checked out of the
+local mirror at the reviewed SHA and re-hashed. There is no path from "AUR moved since the
+review" to "we built it anyway" — the build simply never asks the network for a recipe.
+
+Step 3 verifies against **our** recorded digest, not the PKGBUILD's. For a source declared
+`SKIP` this is the only verification that exists, and it closes the window between "we
+hashed it at review time" and "makepkg downloaded something else just now".
+
+Step 4 is the belt-and-braces assertion that the thing we build is the thing that was
+approved: if upstream moved between approval and build, the build fails with "approved
+`r1234.9f2c1ab`, upstream now `r1248.a11beef`" instead of silently shipping the new one.
+
+### 8.2 Restartability
+
+SQLite has no `SKIP LOCKED`, and we don't need it: there is exactly **one writer**, so claim
+contention doesn't exist. The queue is a dispatcher actor.
+
+```
+dispatcher thread:
+ loop:
+ tx: BEGIN IMMEDIATE
+ SELECT id FROM build WHERE state='queued' ORDER BY priority DESC, created_at
+ LIMIT <admissible>;
+ UPDATE build SET state='leased', lease_owner=?, lease_expires_at=now()+90s,
+ attempt=attempt+1 WHERE id IN (...);
+ COMMIT
+ for each id: build_tx.send(id) // crossbeam unbounded channel
+
+worker thread (N of them):
+ for build_id in build_rx:
+ loop over incomplete steps:
+ run step (blocking, child process) → record → extend lease
+ publish step goes through the publisher's single-thread channel instead
+
+reaper (in the dispatcher loop):
+ UPDATE build SET state='queued' WHERE state='leased' AND lease_expires_at < now()
+ mark its in-flight step 'interrupted'
+```
+
+* **Crash-safe by construction.** On restart, the dispatcher's first act is the reaper pass:
+ every `leased` row with an expired lease goes back to `queued`, and the step-level
+ checkpoint decides where it resumes. Nothing lives only in a worker's memory.
+* **Idempotent steps.** `build_id` is deterministic:
+ `hash(pkgbase, candidate_identity_hash, world_snapshot_hash, build_profile)`.
+ Re-submitting the same intent is an `INSERT OR IGNORE` no-op — which is what makes
+ manual rebuilds safe to enqueue carelessly.
+* **Staging is disposable.** Artifacts land in `staging/<build_id>/` and are only moved into
+ the content-addressed store at `ingest`. A GC pass sweeps abandoned staging dirs.
+* **Cancellation.** A newer approved release for the same pkgbase marks in-flight builds
+ `cancel_requested`; workers check at step boundaries and kill the chroot process group.
+* **Backpressure.** `admissible` is `min(max_concurrent_builds - in_flight, disk headroom,
+ chroot pool free)`. Default `max_concurrent_builds = 1`, which also means the chroot pool
+ only needs one warm root by default. A build that cannot fit on disk is not admitted.
+* **Single-process assumption.** If we ever split workers onto other hosts, the claim
+ `UPDATE … WHERE state='queued'` in a `BEGIN IMMEDIATE` transaction is still atomic across
+ processes, so the design survives that split unchanged.
+
+### 8.3 Clean chroot specifics
+
+* devtools: `mkarchroot` per profile (`extra-x86_64`), one warm root per profile,
+ per-build CoW snapshot (`makechrootpkg -c`), never mutate the seed.
+* The chroot's pacman is configured to trust **only** our repo key + the arch keyring;
+ `SigLevel = Required DatabaseOptional` inside the chroot so a poisoned mirror can't inject
+ a build dep.
+* Network: **available during `build()`**, no controls in v1 (decided). Many AUR packages
+ fetch at build time (cargo, npm, go, `pip install` during `build()`), so blocking egress
+ would break a large share of the set. Consequence stated plainly: a `PKGBUILD` can fetch
+ code the reviewer never saw, and neither `sha256sums` nor PGP covers it. We accept this for
+ v1; egress accounting and per-package denial are future work (§20). The one cheap thing we
+ do now is flag `cargo`/`npm`/`go`/`pip` in `makedepends` as a risk signal, so the reviewer
+ at least knows the build will pull unreviewed dependencies.
+* Resource limits: cgroup v2 per build (cpu, mem, io, pid, disk quota), wall-clock timeout,
+ disk-space guard before starting.
+* Build user is unprivileged and unique per build; it has **no read access to the SQLite
+ file, the mirrors directory, or the signing key** — enforced with OS file permissions and
+ `sudo` rules, since this is one process (§14).
+* `--holdsrc` + source cache to avoid re-downloading tarballs. VCS sources are re-fetched
+ from the branch tip for now — honouring `upstream_pins` at build time is deferred (§20).
+
+### 8.4 Failure handling
+
+* Retry policy per step: transient (network, mirror 5xx) retries with backoff; deterministic
+ build failures do **not** auto-retry — they surface as a build failure on the release with
+ the log, and the release stays `approved_but_unbuilt`.
+ **Important:** a failed build must not silently leave the old version looking healthy.
+ The UI shows "v2 approved, build failed, index still serving v1".
+* Upstream 404 / moved URL: candidate marked `blocked`, watcher backs off, user notified.
+* Flaky test suites: `checkdepends` failures produce a distinct "build ok, check() failed"
+ state with a "retry with --nocheck" action that is itself an explicit, audited decision.
+
+---
+
+## 9. Publishing & serving the index
+
+**One repo.** Single-user system, so there is exactly one repo entity. The `repo` table
+stays (it holds the signing key id, path, and the release pointers) but there is no
+multi-tenancy, no per-user approval state, and no fan-out publish.
+
+* Layout: `/srv/repo/aur-build/os/x86_64/` with `*.pkg.tar.zst`, `*.pkg.tar.zst.sig`,
+ `aur-build.db.{tar,zst,sig}`.
+* Signing: `repo-add -s -p <keyid> -R` (replace old entry). **Both the packages and the
+ database are signed**, so consumers can use `SigLevel = Required` and get real verification
+ end to end rather than trusting a plaintext package with a signed index.
+* Atomic publish: write new db to `.tmp`, `fsync`, `rename` over the real one, then the sig.
+ Serve read-only via nginx/caddy with `etag`/`last-modified` handled correctly (pacman
+ caches dbs aggressively; make sure `Cache-Control` doesn't strand clients on a stale db).
+* `repo-remove` path for unsubscribes and for "revoke this version" incidents — plus a
+ documented rollback: republishing an older accepted release is allowed and audited.
+* Publish is a single-writer transaction per repo; concurrent approvals queue. Keep the
+ critical section tiny (db file rewrite only), not the build.
+
+---
+
+## 10. Staleness: tracking what a package was built against
+
+**There is no automatic rebuild engine.** An earlier draft had one; it was removed, for a
+concrete reason: a dependency-triggered rebuild produces the *same*
+`epoch:pkgver-pkgrel` as the package already in the index, and `pacman -Syu` will not
+reinstall a same-version package. Making rebuilds observable would have required bumping
+`pkgrel` server-side, which makes our published versions diverge from AUR's and collides when
+upstream later publishes that same `pkgrel`. Rather than invent a versioning scheme, v1
+**records the facts and shows them**, and leaves automation for later (§20).
+
+### 10.1 What is recorded
+
+Every release stores the exact set of *our* packages it was built against, taken from
+`.BUILDINFO` — the full installed package set at build time, with versions.
+
+```
+world_snapshot = sorted (pkgbase, epoch:pkgver-pkgrel) of .BUILDINFO members
+ INTERSECT our index <-- important, see below
+```
+
+**Filter to our own repo.** `.BUILDINFO` also lists the entire build chroot — `glibc`,
+`pacman`, `binutils`, everything. Left unfiltered, every package would be permanently stale
+because Arch never stops updating. Restricting the snapshot to packages we ourselves publish
+makes staleness mean something specific and actionable: *our* dependency moved. Official-repo
+drift is explicitly out of scope (§20).
+
+Both `.PKGINFO` and `.BUILDINFO` are plain text inside the `.pkg.tar.zst`, so parsing is
+`tar` + a line-oriented reader. No libalpm needed.
+
+### 10.2 The staleness rule
+
+> A release is **stale** if any pkgbase in its `world_snapshot` now has a different accepted
+> version in our index, or is no longer present.
+
+That is the whole rule. Purely derived, recomputed on read (or cached in a materialised
+table if the query gets slow), no triggers, no queues, no cascade, no debounce, no cycle
+detection. All of that machinery disappeared with the rebuild engine.
+
+Two distinct states, shown separately because they mean different things:
+
+| State | Meaning |
+|---|---|
+| `stale_outdated` | a dependency we publish has a newer accepted version |
+| `stale_missing` | a dependency we used to publish is gone (withdrawn or unsubscribed) — harder to fix |
+
+### 10.3 The Attention dashboard
+
+This is where staleness lands (§13). One screen, three kinds of row, all of them "things a
+human may want to look at" rather than "things the system will do about":
+
+* **Outdated dependencies** — package, its accepted version, which dep moved from what to
+ what, how long ago.
+* **Downgrades** — a subscribed pkgbase where AUR's version is now *lower* than what we
+ serve (maintainer reverted). Flagged, not blocked; consumers need `--allow-downgrades`.
+* **Blocked builds** — an approved release that cannot build because a dependency is not in
+ the index yet (§10.4).
+
+Each row gets an action: open the package, rebuild manually, ignore. The "rebuild manually"
+path is how a user acts on staleness today — they bump nothing, they just ask for a rebuild
+of the same version and accept that consumers must reinstall it. That is a deliberate
+limitation, documented rather than papered over.
+
+### 10.4 Missing dependencies: block and wait
+
+A build's plan step resolves every `depends`/`makedepends` and classifies each as: in our
+index / in the official repos / **unresolvable**. Unresolvable means the dependency is a
+pkgbase we subscribe to but have not approved a version of yet — the classic bootstrap case
+where `A` depends on `B` and `B` is still sitting in the review inbox.
+
+* The build enters `blocked_missing_dep` and waits. It is **not** a failure and is not
+ retried on a timer; it is re-checked whenever a publish lands.
+* It appears on the Attention dashboard with the blocking pkgbase named and a link to the
+ review that would unblock it.
+* **The review page shows it too.** Approving `A` while `B` is missing would produce a build
+ that cannot run, so the review for `A` carries an inline warning listing the missing
+ dependencies. Approving is still allowed — the user may intend to handle `B` separately —
+ but they are told before they click, not after.
+
+### 10.5 Dependents (read-only)
+
+`dep_edge` survives as a *derived, read-only* view built from `.PKGINFO` `depend` +
+`makedepends` resolved against our index. It exists for one genuinely useful piece of review
+context: **"approving this will mark 12 packages stale."** That is a read-time query over the
+world snapshots, not a trigger source — nothing consumes it automatically.
+
+## 11. Data model (sketch)
+
+Single user, so no `user` table and no per-row ownership. Authentication is one shared
+credential at the HTTP edge (§14); the DB records *that* a human decision happened, not
+which of several humans.
+
+```sql
+repo(id, name, signing_key_id, path, arch, state) -- exactly one row; arch = 'x86_64'
+
+subscription(id, repo_id, pkgbase, aur_url, maintainer,
+ state, -- active | paused | orphaned | removed
+ next_check_at, last_checked_at, last_error)
+
+pkgbase(id, name UNIQUE, aur_url, mirror_path, aur_head, -- live mirror tip
+ current_accepted_release_id, state)
+
+snapshot(id, pkgbase_id,
+ aur_commit TEXT NOT NULL, -- THE PIN: exact AUR commit these bytes came from
+ recipe_hash TEXT NOT NULL, -- hash of PKGBUILD+.SRCINFO+*.install+patches
+ srcinfo_json, files_json, fetched_at,
+ UNIQUE (pkgbase_id, aur_commit))
+
+candidate(id, pkgbase_id,
+ base_release_id, -- last ACCEPTED; NULL for first_introduction
+ kind, -- new_version | first_introduction
+ snapshot_id NOT NULL, -- carries aur_commit + recipe_hash
+ epoch, pkgver, pkgrel,
+ upstream_pins_json, -- [{index,url,ref,branch,commit}]
+ source_digests_json, -- [{index,url,kind,digest,size,skip_declared}]
+ identity_hash TEXT NOT NULL, -- hash(aur_commit,epoch,pkgver,pkgrel,pins,digests)
+ revision INT DEFAULT 0, -- bumped when a newer detection collapses in place
+ viewed_at, -- null until a human opened it
+ risk_level, risk_signals_json,
+ missing_deps_json, -- unresolved deps at review time; shown on the review (§10.4)
+ state, -- pending_review|approved|rejected|superseded|blocked
+ detected_at, resolved_at,
+ UNIQUE (pkgbase_id, state) WHERE state='pending_review', -- I7: one open review
+ UNIQUE (pkgbase_id, identity_hash))
+
+approval(id, candidate_id NOT NULL UNIQUE, base_release_id, decided_at,
+ decision, risk_level, diff_digest, identity_hash, note)
+
+release(id, pkgbase_id, candidate_id, approval_id,
+ aur_commit, recipe_hash, -- copied from the snapshot: permanent provenance
+ upstream_pins_json, source_digests_json, -- copied too: what was actually built
+ epoch, pkgver, pkgrel,
+ world_snapshot_id, -- what it was built against -> staleness (§10)
+ state, -- published | withdrawn | failed_unbuilt
+ published_at)
+
+package(id, repo_id, release_id, name, arch, version, artifact_id) -- split pkgbases: N rows
+artifact(id, digest, size, path, signature_path, build_log_path, source_archive_path)
+
+build(id TEXT PRIMARY KEY, -- deterministic intent hash, see §8.2
+ pkgbase_id, candidate_id, release_id,
+ kind, -- new_version | manual_rebuild
+ world_snapshot_id, build_profile,
+ state, -- queued|leased|running|blocked_missing_dep|
+ -- succeeded|failed|cancelled
+ blocked_on_json, -- which pkgbases are holding it (§10.4)
+ current_step, lease_owner, lease_expires_at, attempt, priority, cancel_requested)
+build_step(build_id, step, status, attempt, output_digest, error,
+ started_at, finished_at, PRIMARY KEY (build_id, step))
+
+-- the dependency set a build ran against, filtered to our own repo (§10.1)
+world_snapshot(id, hash UNIQUE, members_json, created_at)
+
+-- derived, read-only: "approving this marks N packages stale". No trigger consumes it.
+dep_edge(from_pkgbase, to_pkgbase, kind, updated_at,
+ CHECK (kind IN ('depend','makedepends')),
+ PRIMARY KEY (from_pkgbase, to_pkgbase, kind))
+
+-- non-candidate events: things worth telling a human about that are not publishable
+-- (digest drift with no version change, pin drift with no version change,
+-- recipe drift with no version change, unpinable pkgver)
+notice(id, pkgbase_id, kind, severity, detail_json, created_at, acknowledged_at)
+
+-- the Attention dashboard (§10.3) is computed from release + world_snapshot + notice;
+-- it is a query, not a table.
+
+source_cache(url, digest, size, fetched_at, path) -- dedupe + reuse for the build
+vcs_cache(url, head, path, fetched_at) -- persistent upstream clones (§5.2)
+
+audit(id, at, actor_kind, action, entity, entity_id, detail_json) -- append-only
+
+settings(key PRIMARY KEY, value)
+-- max_concurrent_builds = 1 (default; see §8.2)
+-- build_timeout = 90m
+-- poll_interval = 24h (conservative default, per-source overridable)
+-- stage_b_cooldown = 24h
+-- retention_versions = 3 (N releases kept per pkgbase for rollback)
+-- dry_run = 0 (test harness, §16a)
+```
+
+Notes:
+
+* `release` is created only at successful publish. `current_accepted_release_id` is the
+ single pointer everything reads, and updating it is a compare-and-swap.
+* `aur_commit`, `recipe_hash`, `upstream_pins` and `source_digests` are **copied onto the
+ release**, not just referenced, so provenance survives even if the snapshot/candidate
+ tables are ever compacted. This is what makes "which bytes produced this installed
+ package" answerable years later.
+* The partial unique index enforcing one `pending_review` per pkgbase makes invariant I7 a
+ database guarantee rather than a convention. (SQLite supports partial unique indexes.)
+* `notice` is the escape valve for "something changed but nothing is publishable" (§5.2).
+ Without it those events are invisible, and a silently-drifting tarball is exactly the kind
+ of thing that must not be invisible.
+* `world_snapshot.members_json` is **filtered to our own packages** at ingest time (§10.1),
+ not at query time — storing the whole chroot would make everything permanently stale and
+ bloat the row for no reason.
+* The Attention dashboard is a query over `release` + `world_snapshot` + `notice` +
+ `build.state = 'blocked_missing_dep'`. Deliberately not a table: nothing to keep in sync.
+* `audit` is append-only; enforce with a trigger that rejects `UPDATE`/`DELETE`.
+
+---
+
+## 11a. SQLite concurrency model
+
+SQLite is the right choice here, but only with a discipline, because the app is
+multi-threaded and SQLite has one writer at a time.
+
+* **WAL mode**: `PRAGMA journal_mode=WAL`, `busy_timeout=5000`. `synchronous=FULL` for
+ approval/audit writes (durability of the approval trail is worth the fsync); `NORMAL`
+ is acceptable elsewhere.
+* **One writer actor.** A dedicated thread owns the write connection. Everything that
+ mutates goes to it over a crossbeam channel as a small `Tx` enum, and it replies with
+ `Result<T>`. This makes "who can write" a compile-time fact and removes `SQLITE_BUSY`
+ from the design entirely.
+* **Many reader connections**, one per thread (`thread_local!`), read-only, used by HTTP
+ handlers and watchers. WAL lets readers proceed concurrently with the writer.
+* **No transaction spans a build step.** Steps record their result in one short
+ transaction; the long-running child process happens outside any transaction. Long-lived
+ write transactions are the classic way to make SQLite hurt.
+* **DB size is a non-issue**: thousands of pkgbases, tens of thousands of audit rows. The
+ heavy bytes (packages, logs, mirrors) live on the filesystem, referenced by path.
+* **Backups**: `VACUUM INTO` or the online backup API for a consistent snapshot — never
+ `cp` a live WAL database — plus the mirrors dir and the artifact store.
+
+---
+
+## 12. Interface: server-rendered HTML first
+
+The UI is **server-rendered HTML from Askama templates**. No SPA, no JS bundler, no client
+router. Handlers read via thread-local read connections and render a full page.
+
+```
+GET / dashboard: pending count, attention count, running builds, recent publishes
+GET /reviews?state=pending&sort=risk
+GET /reviews/:id full diff panels + risk (marks viewed_at)
+POST /reviews/:id/approve {candidate_id, identity_hash, diff_digest} -> 409 if stale
+POST /reviews/:id/reject {note}
+POST /reviews/bulk {ids[], decision, tokens[]}
+GET /subscriptions list + add/remove/pause
+GET /attention staleness, downgrades, blocked builds (§10.3)
+GET /packages current index contents
+GET /packages/:name timeline, deps in/out, staleness, aur_commit history, builds
+POST /packages/:name/rebuild manual rebuild of the current accepted version
+POST /packages/:name/withdraw
+GET /builds running + queued
+GET /builds/:id step timeline + log
+GET /builds/:id/log.txt full log
+GET /builds/:id/log.stream SSE - a thread that blocks and tails the file
+GET /audit
+GET /settings
+GET /metrics prometheus text format
+```
+
+**Dynamic behaviour, minimal JS.** Two mechanisms, both degradable:
+
+1. **htmx** (one vendored ~14 KB file, no build step) for the handful of fragments that
+ update: the builds table (`hx-get` + `hx-trigger="every 3s"`), the pending-review badge,
+ approve/reject posting and swapping in the next row, log tail append. Every fragment
+ endpoint has a plain-HTML equivalent, so the app still works with JS disabled - just
+ with manual reloads.
+2. **SSE** for live build logs, since polling a whole log is wasteful. With thread-per-
+ connection HTTP, an SSE handler is just a thread that seeks to EOF and blocks on the log
+ file. No async needed.
+
+Form posts are plain `<form method=post>` with a CSRF token, so approve/reject work with no
+JS at all. Target: **< 20 KB of JS, all of it vendored, none of it written by us** (htmx
+only), plus ~30 lines of glue for the log tail.
+
+---
+
+## 13. GUI
+
+Five primary surfaces:
+
+**Inbox / Reviews** (the heart of the product)
+Pending reviews, sorted by risk desc then age. Row shows
+`pkgbase · v1 → v2 · recipe/VCS · 3 signals · 4h`. Detail view: tabbed diff panels
+(recipe / sources / deps / install hooks / upstream-commits-when-implemented), side-by-side
+and unified, with risk signals called out inline ("⚠ new source host: `evil.example`",
+"⚠ pkgrel reset 7→1"). Approve / Reject / Approve-with-note. Keyboard-driven (j/k, a, r).
+Two things are always visible and unmissable:
+
+* the base: *"comparing against **v1.2.3** — accepted 2025-03-02"* (proves I2 to the user),
+* the pin: *"AUR commit `4f9c02e` — this exact tree is what will be built"*, linked to AUR
+ cgit so it can be independently verified.
+
+If a newer detection landed after the page rendered, approve comes back as a 409 and the
+page re-renders with the new diff and an explicit explanation (§7.1a).
+
+**Builds**
+Live table of running builds with step + elapsed + queue position; per-build page with step
+timeline and streaming log; failures pinned at top; cancel/retry. Queue header shows depth,
+configured parallelism, and a rough ETA for the backlog.
+
+**Attention** (see §10.3)
+Three kinds of row, all "a human may want to look at this", none "the system will act":
+outdated dependencies (package, its version, which dep moved from what to what, how long
+ago), downgrades (AUR now lower than what we serve), and blocked builds (approved but
+waiting on a dependency that is not in the index yet, with a link to the review that would
+unblock it). Each row links out; the only action is a manual rebuild.
+
+**Index**
+What consumers actually get: pkgbase, version, published at, `aur_commit`, built-against
+world, staleness flags, artifact size. Per-package drill-down: full timeline (detected →
+reviewed → approved → built → published), dependencies in and out, "rebuild now", "withdraw".
+
+**Subscriptions**
+Add/remove/pause, last-checked + last-error per pkgbase, "check now", per-source poll
+interval override.
+
+**Ops**
+Audit log, **notices** (unacknowledged integrity alerts, pin drift with no publishable
+change, unpinable `pkgver`, queue depth/ETA — badge on the dashboard),
+watcher health (last successful poll per source, Stage-B budget usage), worker thread
+status, disk/chroot pool status, publish history, SQLite checkpoint/WAL size.
+
+---
+
+## 14. Security posture
+
+The threat model is unusual: **the input is arbitrary code chosen by third parties, and a
+human is the intended firewall.**
+
+* **Single-user ≠ unauthenticated.** An approval is a decision to run third-party code on
+ every consumer machine, so the UI must not be open. Default: bind to localhost or a
+ tailnet interface only. If it must be internet-reachable, put it behind a reverse proxy
+ with client certs or basic auth over TLS, plus a session cookie and CSRF tokens on every
+ POST. No password database, no reset flow, no user table - one credential, deliberately.
+* **Untrusted build code, same host, enforced by OS users.** Since this is one process on
+ one machine, the boundary is file permissions + `sudo`: the build worker spawns
+ `makechrootpkg` as user `aurbuild`, which cannot read the SQLite file, the mirrors
+ directory, the signing keyring, or the config. Ideally the signing key lives on a separate
+ host and the publisher only ever asks it to sign a digest; if that's overkill, at minimum
+ keep the key in a separate user's keyring with a `sudo` rule permitting exactly the
+ `repo-add`/`gpg` invocation and nothing else.
+* **Chroot trust pinning**: only our key + the arch keyring; `SigLevel = Required` for
+ packages inside the build chroot, so a poisoned mirror cannot inject a build dep.
+* **Source integrity**: we resolve and record a digest for every source ourselves (§5.3), so
+ a `SKIP` declaration does not mean "unknown" — it means "unverified by the recipe, but
+ hashed and diffed by us". PGP verification is required where the PKGBUILD declares keys;
+ `--skippgpcheck` and removed `validpgpkeys` are high-risk signals. Every source URL +
+ digest is on the candidate, so the reviewer sees exactly what will run.
+* **Network during `build()` is granted, with no controls, in v1** (decided). This is the
+ weakest point in the design and we are accepting it knowingly: a `PKGBUILD` can fetch code
+ the reviewer never saw, and neither `sha256sums` nor PGP covers it. Per-package network
+ denial was considered and dropped — it would break a large share of AUR packages, and the
+ machinery to discover which ones tolerate it is not worth building up front. Recorded as
+ future work (§20) alongside egress accounting, which would at least make the exposure
+ visible after the fact.
+* **Tamper-evident review**: diffs are rendered from the pinned local mirror, never
+ live-fetched at review time, and `diff_digest` + `identity_hash` are stored with the
+ approval and re-checked at approve time (§7.1a). This is what makes "we built what you
+ saw" provable rather than aspirational.
+
+---
+
+## 15. Observability
+
+Metrics: poll lag per source, detections/h, candidates pending + age histogram (the
+"review debt" number), approvals/rejections/h, build queue depth + step latency histogram,
+build success rate by pkgbase, publish latency, index size, count of stale releases by
+reason, blocked_missing_dep count, Stage-B budget usage, SQLite WAL size + checkpoint lag.
+
+Alerts: watcher silent > N min, publish failure, chroot pool exhausted, disk low, review
+debt older than X days, a pkgbase stuck in `blocked`, a build blocked on a missing
+dependency for longer than a budget, queue age past a configured budget.
+
+Backups: the SQLite DB via `VACUUM INTO` (the approval history is the crown jewel), the
+**AUR git mirrors** (now load-bearing for rebuildability, §5.1a), and the artifact store.
+
+---
+
+## 16. Edge cases to design for explicitly
+
+* **Split pkgbases** — one approval, N packages; partial build failure means nothing publishes.
+* **`pkgbase` rename / package moves between pkgbases** — re-pin subscription, don't orphan index entries.
+* **AUR deletion or orphaning** — subscription state `orphaned`, keep serving last accepted, warn loudly.
+* **Downgrades** (maintainer reverts) — allowed but flagged; pacman needs `--allow-downgrades`, so decide policy.
+* **Epoch bumps** — flagged; often means a version-format change, not a real update.
+* **`provides`/`conflicts` collisions** with the official repos or with another subscribed pkgbase.
+* **Cyclic build deps** through `makedepends` (very common: python packages).
+* **A dep that isn't built yet** — plan step must detect "required package not in our index and not in official repos" and block with a clear message rather than fail obscurely.
+* **VCS `pkgver()` that ignores the pins** (e.g. uses `date`, or reads a non-default branch) — the version can move without the code moving, or vice versa. Detect: pins unchanged but `pkgver` changed, or pins moved but `pkgver` frozen. Mark the pkgbase as "unpinable", emit a `notice`, and fall back to recipe-hash + poll-time identity.
+* **Recurring build failures** — don't retry forever; exponential backoff + park.
+* **Two users, different approval states** — out of scope by decision; single user, one repo.
+* **Clock skew / ordering** — use DB time (`strftime` at write) for all ordering and audit stamps.
+* **Concurrent approvals on the same pkgbase** — `current_accepted_release_id` update is a guarded compare-and-swap inside the writer actor.
+* **Mirror divergence** — if the local mirror's history is ever force-pushed or rewritten (AUR shouldn't, but), `aur_commit` may vanish. Detect at fetch time and hard-fail the pkgbase rather than silently re-pinning.
+
+---
+
+## 16a. Testability (first-class, not an afterthought)
+
+A system whose side effects are chroot builds and repo mutations is impossible to develop
+against if every test needs a real Arch host. Development would slow to a crawl. So the test
+harness is part of the design, built alongside P0.
+
+**Two layers.**
+
+**1. Fake-package corpus.** A checked-in `testcorpus/` of synthetic PKGBUILDs, each
+exercising one behaviour the system must handle:
+
+| Fixture | Exercises |
+|---|---|
+| `plain-make` | trivial build, happy path |
+| `with-patch` | shipped patch file in the recipe → `recipe_hash` coverage |
+| `install-hooks` | `.install` script → hook diff panel |
+| `skip-checksum` | `sha256sums=('SKIP')` on a static file → digest resolution + risk signal |
+| `git-sourced` | `git+file://` upstream with a real local git repo → Stage A/B, `pkgver()` |
+| `git-submodules` | submodule gitlink handling |
+| `split-pkgbase` | one PKGBUILD, three packages → one approval, N index rows |
+| `epoch-bump` / `downgrade` / `pkgrel-reset` | version-delta flagging |
+| `build-fails` | deterministic failure, no auto-retry |
+| `check-fails` | `check()` failure → the `--nocheck` decision path |
+| `missing-dep` | depends on a pkgbase not in the index → `blocked_missing_dep` |
+| `dep-cycle` | `makedepends` cycle |
+| `digest-drift` | same version, swapped tarball → `integrity_alert`, not a candidate |
+| `pin-drift` | upstream moved, `pkgver` unchanged → `notice`, not a candidate |
+| `unresolvable` | source 404 → `blocked` + backoff |
+
+Each fixture is a directory with a PKGBUILD, an optional local git repo, and a `manifest`
+describing the expected outcome, so the corpus doubles as executable documentation of the
+edge cases in §16.
+
+**2. Toolchain shims.** The pipeline shells out to `mkarchroot`, `makechrootpkg`, `repo-add`,
+`gpg`, `pacman` and `git`. In test mode the harness prepends a directory of **fake executables
+to `PATH`**. Each fake records its invocation, respects a scripted outcome from the fixture
+manifest, and emits plausible `.PKGINFO`/`.BUILDINFO`/`.sig` output. That means:
+
+* the full step machine, checkpointing, lease/reaper recovery, publishing and index
+ regeneration all run for real, in milliseconds, on any machine — no Arch host, no root,
+ no network;
+* crash-recovery tests become trivial: kill the process mid-step, restart, assert it resumes
+ at the right step (I5);
+* staleness tracking is testable because the fakes can emit arbitrary dependency sets;
+* `dry_run` in `settings` gives the same shimming for manual exploration.
+
+**The §2 invariants become executable tests**, not prose. I1 (no artifact without an
+approval) is a query run after every test. I2 (diff base is last accepted) is asserted by
+the multi-detection fixtures. I4 (atomic publish) is a kill-mid-publish test. If an invariant
+cannot be written as a test, that is a signal the invariant is wrong or the design is.
+
+**3. Real integration, gated.** A `#[ignore]`-style tier that does actual `mkarchroot` +
+`makechrootpkg` builds against one or two real AUR packages, run manually or on a schedule
+on a real host. Fast tests give confidence about our logic; this tier gives confidence that
+the assumptions about devtools are still true.
+
+---
+
+## 17. Suggested phasing
+
+**P0 — walking skeleton + test harness**
+Rust binary, SQLite schema + writer actor, the toolchain shims and the first corpus fixtures
+(§16a), AUR git mirror watcher with `aur_commit` pinning, source digest resolution for `SKIP`
+sources, candidate creation with `base = last accepted`, `first_introduction` handling,
+manual approval via a CLI subcommand, single-machine build with `makechrootpkg`
+(`max_concurrent_builds = 1`), `repo-add` publish with package + db signing, static file
+serving. Prove I1/I2/I4/I5 end to end on one normal package.
+
+**P1 — VCS / pkgver detection** (core requirement, not a nice-to-have)
+Stage A upstream probes over all VCS sources, persistent VCS clone cache, Stage B `pkgver()`
+resolution with commit capture, `upstream_pins` in the identity, upstream commit-range diffs,
+`notice` for non-publishable drift. Prove it on one real `-git` package.
+
+**P2 — review surface**
+`tiny_http` + templates, the Inbox and diff panels, risk scoring (advisory), the
+optimistic-concurrency approve flow with 409-on-stale, the Attention dashboard. This is where
+the value lands.
+
+**P3 — durability**
+Dispatcher + worker pool + reaper, chroot pool, step checkpointing, cancellation,
+deterministic build ids, SSE log tail, crash-resume tests against the shims.
+
+**P4 — staleness**
+`.PKGINFO`/`.BUILDINFO` parsing, world snapshots, the staleness query, downgrades and
+blocked-build views, retention & GC (N versions with logs and sources), metrics/alerting.
+
+**P5 — polish**
+`network` controls if ever wanted, backup automation, hardening transforms (§20).
+
+---
+
+## 18. Decisions taken
+
+| # | Decision |
+|---|---|
+| 1 | **Stack**: Rust, no `async`/`await`, no tokio. Threads + channels. |
+| 2 | **DB**: SQLite (WAL, single writer actor). |
+| 3 | **UI**: server-rendered, minimal functional JS (htmx + SSE), no SPA, no bundler. |
+| 4 | **Tenancy**: single user. One repo, one credential, no user table, no RBAC. |
+| 5 | **Stale approvals**: refused with HTTP 409 and a re-render. Never retarget silently. |
+| 6 | **AUR pin**: record `aur_commit` as first-class metadata; show it in the diff; build by checking that SHA out of the local mirror and re-hashing. |
+| 7 | **Network in `build()`**: granted, no controls in v1 (§14). Accepted risk. |
+| 8 | **Superseded reviews**: collapse in place; `superseded` only when a human already saw the old diff. |
+| 9 | **No automatic rebuild engine.** Record the world each package was built against and surface staleness in a dashboard; leave automation to later (§10, §20). |
+| 10 | **`upstream_pins[]` is part of the candidate key** — one HEAD (commit SHA) per VCS source. No separate tree hash; the commit already pins the tree and any submodule gitlinks. |
+| 11 | **Source digests are recorded for every source**, regardless of what the PKGBUILD declares, and are part of the candidate key. |
+| 12 | **Non-publishable changes** (version string unchanged) produce a `notice`, never a review, and are never silently dropped. |
+| 13 | **VCS detection is P1**, not a later enhancement — `-git` pkgver changes are a core requirement. |
+| 14 | **Recipe-mutating hardening transforms are deferred** (§20). We record pins and digests; we do not rewrite the PKGBUILD. |
+| 15 | **First acceptance is a distinct review kind** (`first_introduction`): full recipe shown, no diff, subtly accented — not obnoxious. |
+| 16 | **Missing dependencies: block and wait.** Builds enter `blocked_missing_dep`, the Attention dashboard monitors them, and the review page warns about missing deps before approval. |
+| 17 | **Architecture: x86_64 only.** |
+| 18 | **Default parallelism: 1.** Configurable. |
+| 19 | **No auto-approval in v1.** Risk scoring is advisory only. |
+| 20 | **Downgrades are a dashboard warning**, alongside outdated dependencies. Not blocked. |
+| 21 | **Retention: N versions per pkgbase for rollback**, with the build log and source cache retained alongside the package as a unit. |
+| 22 | **Sign packages as well as the database; key on the same host.** Consumers can use `SigLevel = Required`. |
+| 23 | **Withdrawal warns, it does not block.** Breakage of dependents is the user's call. |
+| 24 | **Full integration testability via a fake-package corpus and toolchain PATH shims** (§16a). Built in P0, not retrofitted. |
+| 25 | **Conservative default poll interval: once a day**, configurable per source. |
+
+---
+
+## 19. Still open
+
+Most of the earlier open questions were resolved above. What is genuinely left:
+
+1. **`N` for retention** — how many versions per pkgbase? Depends on the disk budget for the
+ target host, which is still unchosen.
+2. **Target host specs** — cores, RAM, disk. Only affects defaults now that parallelism is 1,
+ but the retention number and the Stage-B budget both want real numbers.
+3. **How `first_introduction` interacts with a pkgbase that has history elsewhere** — e.g. the
+ user unsubscribed and resubscribed. Do we treat the old releases as the base again, or
+ start fresh? Cheap to decide now, annoying to retrofit.
+4. **Split pkgbases and partial subscription** — the unit is the pkgbase, so subscribing to
+ `foo` also publishes `foo-lua`. Probably fine, but worth confirming rather than discovering.
+5. **`unpinable pkgver` fallback identity** — §16 says "fall back to recipe-hash + poll-time",
+ which is vague and non-deterministic. Needs a concrete rule.
+6. **Askama vs minijinja** — compile-time checked templates are nicer, but slow rebuild times.
+ Decide in P2.
+7. **Backup frequency and retention** — the mirrors and the DB are load-bearing; the schedule
+ and retention are unspecified.
+8. **Repo hostname / path and the consumer `pacman.conf` snippet** — trivial, but it is the
+ entire user-facing contract and worth pinning down before P0.
+
+---
+
+## 20. Future extensions (explicitly not in v1)
+
+Kept here so they are not lost, and so nobody has to re-derive the reasoning later.
+
+**Automatic rebuilds on dependency change.** The obvious follow-up to the staleness
+dashboard. Blocked on the versioning problem described in §10: a rebuild produces a
+same-version package that `pacman` will not offer, so any automation has to decide how
+consumers observe it — most likely a server-side `pkgrel` bump with collision handling.
+Build the dashboard first, watch which packages actually go stale, and let real usage pick
+the policy.
+
+**Auto-approval policies.** Narrow rules evaluated against risk scoring — `metadata-only`
+(recipe diff touches only `pkgrel`/`pkgdesc`/comments), `vcs-bump` (recipe unchanged, only
+the upstream commit moved, low risk), `pin-range` (accept only commits matching a refspec or
+semver range). Would need risk scoring to become load-bearing, plus a revocable
+auto-approved review state.
+
+**Recipe-mutating hardening transforms (§5.3a).** Rewrite `sha256sums=('SKIP')` to the digest
+we recorded, and/or pin VCS sources to `#commit=<sha>`. Both make the built artifact match
+the reviewed one. Both must be displayed as an explicit "server applied:" transform, and the
+`#commit=` one interacts badly with `pkgver()` functions that expect a branch.
+
+**Honouring `upstream_pins` at build time.** We record the commit; making the build actually
+check it out (rather than following the branch tip) needs either the transform above or
+seeding a prepared clone into `$startdir` with the fetch suppressed.
+
+**Network controls.** Per-package `network = deny` for the packages that tolerate it, and
+egress accounting so "this build touched N new hosts" can be surfaced. Both are pure
+hardening on top of the v1 posture of granting network unconditionally.
+
+**Cost-weighted build admission.** Admit work against a capacity budget rather than a slot
+count, using a per-pkgbase `build_cost` (EMA of measured durations, initialised pessimistically
+for never-seen pkgbases). Makes a queue of 40 two-minute packages behave differently from 40
+half-hour ones, and enables honest ETA display.
+
+**Official-repo-triggered staleness.** Currently the world snapshot is filtered to our own
+packages (§10.1), so an Arch `python` update does not mark our `python-*` packages stale. If
+that bites, the cheap fix is an allowlist of ABI-critical official packages rather than
+general `world` tracking.
+
+**Soname/ABI-aware staleness**, if plain version-inequality turns out to be too noisy.
+
+**Notifications** (email / matrix / webhook) for pending reviews, build failures, notices,
+and newly stale packages.
diff --git a/src/bin/gpg.rs b/src/bin/gpg.rs
new file mode 100644
index 0000000..1c84fe2
--- /dev/null
+++ b/src/bin/gpg.rs
@@ -0,0 +1 @@
+fn main() { eprintln!("shim: gpg (not implemented)"); std::process::exit(70); }
diff --git a/src/bin/makechrootpkg.rs b/src/bin/makechrootpkg.rs
new file mode 100644
index 0000000..4043161
--- /dev/null
+++ b/src/bin/makechrootpkg.rs
@@ -0,0 +1 @@
+fn main() { eprintln!("shim: makechrootpkg (not implemented)"); std::process::exit(70); }
diff --git a/src/bin/makepkg.rs b/src/bin/makepkg.rs
new file mode 100644
index 0000000..9b3411b
--- /dev/null
+++ b/src/bin/makepkg.rs
@@ -0,0 +1 @@
+fn main() { eprintln!("shim: makepkg (not implemented)"); std::process::exit(70); }
diff --git a/src/bin/mkarchroot.rs b/src/bin/mkarchroot.rs
new file mode 100644
index 0000000..f7c12e8
--- /dev/null
+++ b/src/bin/mkarchroot.rs
@@ -0,0 +1 @@
+fn main() { eprintln!("shim: mkarchroot (not implemented)"); std::process::exit(70); }
diff --git a/src/bin/pacman.rs b/src/bin/pacman.rs
new file mode 100644
index 0000000..bdcb13b
--- /dev/null
+++ b/src/bin/pacman.rs
@@ -0,0 +1 @@
+fn main() { eprintln!("shim: pacman (not implemented)"); std::process::exit(70); }
diff --git a/src/bin/repo-add.rs b/src/bin/repo-add.rs
new file mode 100644
index 0000000..87abfd2
--- /dev/null
+++ b/src/bin/repo-add.rs
@@ -0,0 +1 @@
+fn main() { eprintln!("shim: repo-add (not implemented)"); std::process::exit(70); }
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..77aa7d7
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1 @@
+//! AUR Build Server — see DESIGN.md.
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..0ea8a90
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("aur-build");
+}