diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 09:12:28 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 09:12:28 +0000 |
| commit | d9c8402180749df4452dc37febace4d933b8407d (patch) | |
| tree | 377a7b89203c266d00a714845b50d27febbda4c7 | |
| parent | 4cb2f4c7b68dceaed8f7ffbd8f0db3cfbf3f1ddc (diff) | |
| download | aur-build-d9c8402180749df4452dc37febace4d933b8407d.tar.gz aur-build-d9c8402180749df4452dc37febace4d933b8407d.zip | |
pkginfo: .PKGINFO/.BUILDINFO parsing gets a real home, and a parser bug fix (§10.1)
Ingest decides what the index claims about a package and what the world
snapshot records by reading two text files out of a tar inside a zstd stream.
That code was living in src/shims — the test harness — which meant production
depended on the harness for its view of a package's own metadata. Moved to
src/pkginfo.rs, with the shim now delegating to it so the harness and the
production path cannot disagree about what a package says about itself.
Still no libalpm: tar + zstd + eighty lines of key = value parsing. Unknown keys
are ignored rather than rejected, because makepkg adds fields over time and a new
one must not stop us publishing.
**The parser had a real bug.** A .BUILDINFO installed block puts its first entry
on the same line as the key:
installed = glibc 2.39-1 x86_64 -
gmp 6.3.0-1 x86_64 -
The old code skipped the header line, so the first dependency was silently
dropped from every snapshot — exactly the kind of gap that makes staleness
quietly wrong. The header line is parsed now.
tests/world.rs builds real .pkg.tar.zst files and asserts the fields come out of
the archive: repeated keys stay lists, an archive with no .PKGINFO is refused
rather than defaulted from the filename, and the world snapshot contains our own
packages and none of glibc/pacman/binutils. The empty-snapshot case for a first
build is asserted too — nothing of ours existed yet, and recording that honestly
beats inventing a world.
Split pkgbases produce one approval, one release and N index rows each with its
own artifact, asserted directly here. 143 tests pass, clippy clean.
| -rw-r--r-- | .pi/.goals-pool-snapshot.json | 2 | ||||
| -rw-r--r-- | .pi/goals/.goal-ledger-checkpoint.json | 2 | ||||
| -rw-r--r-- | .pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md | 28 | ||||
| -rw-r--r-- | .pi/goals/goal_events.jsonl | 3 | ||||
| -rw-r--r-- | src/lib.rs | 1 | ||||
| -rw-r--r-- | src/pipeline/steps.rs | 70 | ||||
| -rw-r--r-- | src/pkginfo.rs | 150 | ||||
| -rw-r--r-- | src/shims/mod.rs | 34 | ||||
| -rw-r--r-- | tests/world.rs | 226 |
9 files changed, 423 insertions, 93 deletions
diff --git a/.pi/.goals-pool-snapshot.json b/.pi/.goals-pool-snapshot.json index f0d6b76..d8b4e77 100644 --- a/.pi/.goals-pool-snapshot.json +++ b/.pi/.goals-pool-snapshot.json @@ -1 +1 @@ -{"version":1,"dirMtimeMs":1794992468011.855,"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":6265695,"activeSeconds":12132},"sisyphus":false,"createdAt":"2026-11-17T20:43:24.440Z","updatedAt":"2026-11-18T09:01:08.009Z","activePath":".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md","revision":647,"scheduler":{"version":1,"owner":"01a1eb32-2e3f-757c-a79a-21ac993facc5","generation":"dfbaf4f2-dad9-4dc6-9717-5038550aa75e","used":1,"phase":"running","repairUsed":false,"decision":{"kind":"ready","purpose":"kickoff"},"dispatch":{"id":"27430841-6f83-4343-a9fa-dd1c866de9d3","kind":"kickoff","claimedAt":1794985072841}},"taskList":{"tasks":[{"id":"task-setup","title":"Provision toolchain (pacman rustup + devtools) and initialize git","status":"complete","verificationContract":"`rustup show` and `cargo --version` work; `git -C /workspace/aur-build log` contains an initial commit with DESIGN.md, .gitignore, and a scaffolded Cargo.toml that `cargo build` compiles.","completedAt":"2026-11-17T20:48:20.900Z","evidence":"rustup 1.29.3 (pacman) + stable 1.100.0, devtools installed (mkarchroot/makechrootpkg present); git repo initialized on main with commit 3762c7c containing DESIGN.md, .gitignore, Cargo.toml; `cargo bu"},{"id":"task-p0","title":"P0 — walking skeleton + test harness (§17 P0, §16a)","status":"complete","subtasks":[{"id":"task-p0-schema","title":"SQLite schema, migrations, and single writer actor (§11, §11a)","status":"complete","verificationContract":"Migrations apply from empty DB; partial unique index rejects a second pending_review per pkgbase; audit table rejects UPDATE/DELETE by trigger; concurrent readers do not block the writer in a test.","completedAt":"2026-11-17T21:00:03.122Z","evidence":"tests/db.rs: 10 tests pass — migrations from empty + idempotent + WAL, default settings, I7 partial unique index rejects 2nd pending_review, candidate identity uniqueness, audit append-only triggers, "},{"id":"task-p0-shims","title":"Toolchain PATH shims + fake-package corpus (§16a)","status":"complete","verificationContract":"Fakes for mkarchroot/makechrootpkg/makepkg/repo-add/gpg/pacman record invocations and emit plausible .PKGINFO/.BUILDINFO/.sig per fixture manifest; at least plain-make, with-patch, skip-checksum, split-pkgbase, build-fails, missing-dep, epoch-bump, pkgrel-reset and downgrade fixtures exist and are driven by a test.","completedAt":"2026-11-17T21:31:09.120Z","evidence":"src/shims + src/bin/{mkarchroot,makechrootpkg,makepkg,repo-add,gpg,pacman}: shims record invocations to AUR_SHIM_DIR/invocations.jsonl, obey AUR_SHIM_MANIFEST, and emit real .pkg.tar.zst with .PKGINFO"},{"id":"task-p0-detect","title":"AUR mirror watcher: aur_commit pin, recipe_hash, source digests, candidate creation (§5.1, §5.1a, §5.3)","status":"complete","verificationContract":"Against a local file:// 'AUR' repo fixture: clone + ls-remote poll + fetch only on SHA move; snapshot records aur_commit and recipe_hash covering PKGBUILD/.SRCINFO/*.install/patches; SKIP sources are stream-hashed into source_cache; candidate.base is current_accepted_release; a brand-new pkgbase yields kind=first_introduction.","completedAt":"2026-11-17T21:20:02.693Z","evidence":"tests/detect.rs: 16 tests pass against real file:// git fixtures — clone+ls-remote poll with fetch only on SHA move (Sync::Unchanged vs Fetched), snapshot records aur_commit + recipe_hash covering shi"},{"id":"task-p0-approve","title":"Approval semantics + CLI approval path (§7.1, §7.1a, §7.2)","status":"complete","verificationContract":"CLI approve writes an immutable approval row with diff_digest and identity_hash; approving with a stale identity_hash or diff_digest is refused; collapse-in-place bumps revision without a new row while unviewed and freezes as superseded once viewed; a rejected identity is not re-detected.","completedAt":"2026-11-17T22:10:06.063Z","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi"},{"id":"task-p0-build","title":"Build pipeline steps 0–9 and atomic signed publish (§8.1, §9)","status":"complete","verificationContract":"Shim-driven run of materialize→plan→chroot→sources→pkgver→build→collect→verify→ingest→publish; step 0 materializes from the local mirror and fails closed on recipe_hash mismatch; step 4 fails closed on pkgver mismatch; publish writes .tmp, fsyncs, renames, signs package and db, and updates current_accepted_release_id by compare-and-swap.","completedAt":"2026-11-17T21:58:00.936Z","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean"},{"id":"task-p0-invariants","title":"Executable invariant tests I1/I2/I4/I5/I8","status":"complete","verificationContract":"cargo test includes: post-run query proving no index entry lacks an approval (I1); multi-detection fixture proving the diff base is the last accepted version (I2); kill-mid-publish leaving the old index intact (I4); restart-resumes-at-next-incomplete-step with no duplicate side effects (I5); index set equals accepted-release pointers (I8).","completedAt":"2026-11-18T07:01:31.398Z","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re"}],"completedAt":"2026-11-18T07:02:29.831Z","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit"},{"id":"task-p1","title":"P1 — VCS / computed pkgver detection (§5.2, §3)","status":"complete","subtasks":[{"id":"task-p1-stageA","title":"Stage A upstream probes over all VCS sources + persistent vcs_cache","status":"complete","verificationContract":"Parses source=() for git+/svn+/hg+ with #tag/#commit refs; probes via git ls-remote against local file:// repos; an unchanged HEAD set short-circuits before Stage B; multiple VCS sources each get their own pin entry.","completedAt":"2026-11-18T07:16:40.077Z","evidence":"tests/vcs.rs: stage_a_probes_every_vcs_source_not_just_the_first (git-multi → 2 pins matching both repo HEADs), stage_a_respects_a_tag_pin, stage_a_short_circuits_before_stage_b_when_nothing_moved (ma"},{"id":"task-p1-stageB","title":"Stage B pkgver() resolution with pin capture + identity tuple","status":"complete","verificationContract":"Resolved epoch:pkgver-pkgrel plus upstream_pins become part of identity_hash; cooldown and global concurrency cap enforced; cache keyed on (pkgbase, recipe_hash, upstream_tip); a git-sourced fixture produces a candidate whose pins match the fixture repo HEAD.","completedAt":"2026-11-18T07:17:57.387Z","evidence":"tests/vcs.rs: stage_b_resolves_pkgver_and_captures_the_pins (pins in identity_hash via Identity hash comparison), stage_b_is_cached_on_pkgbase_recipe_and_tip (cache row reuse + cooldown + re-resolve o"},{"id":"task-p1-notices","title":"Non-publishable change handling: pin_drift, recipe drift, digest drift → notice / integrity_alert (§5.2, §5.3, I11)","status":"complete","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.","completedAt":"2026-11-18T07:29:10.456Z","evidence":"tests/notices.rs: 8 tests — digest-drift fixture → high-severity integrity_alert + no candidate, pin-drift → info notice + no candidate, recipe drift → warning, skip-checksum → HIGH risk signal 'skip-"}],"completedAt":"2026-11-18T07:30:36.958Z","evidence":"All three P1 children complete: Stage A probe (every VCS source, #tag/#commit, short-circuit), Stage B resolution (pin capture, cache on pkgbase+recipe_hash+tip, cooldown, concurrency cap), notices+ri"},{"id":"task-p2","title":"P2 — review surface (§12, §13, §6)","status":"complete","subtasks":[{"id":"task-p2-http","title":"tiny_http server, templating, thread-local readers, CSRF + session gate","status":"complete","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.","completedAt":"2026-11-18T08:06:45.433Z","evidence":"tests/http.rs (14 tests, all pass): every_surface_renders covers all §12 routes on a live tiny_http server; every_post_requires_a_csrf_token asserts 403 for missing and forged tokens with zero rows wr"},{"id":"task-p2-inbox","title":"Inbox + diff panels + advisory risk scoring (§6, §7.1b)","status":"complete","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.","completedAt":"2026-11-18T08:07:10.624Z","evidence":"src/review/diff.rs now emits all eight §6 panels (recipe, version, source-digest, upstream, source, dependency, build-env, install-hook), each computed accepted→candidate; commit ab8d33d. tests/http.r"},{"id":"task-p2-approve409","title":"Optimistic-concurrency approve/reject + bulk operations (§7.1a, §7.4)","status":"complete","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.","completedAt":"2026-11-18T08:07:36.401Z","evidence":"tests/http.rs: a_stale_approval_is_a_409_that_renders_the_current_diff (upstream moves mid-review → 409, body explains the ground moved, re-render shows the new 9.9 version, zero approval rows written"},{"id":"task-p2-surfaces","title":"Subscriptions, Index, Builds, Attention, Ops/audit pages","status":"complete","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).","completedAt":"2026-11-18T08:23:18.650Z","evidence":"tests/surfaces.rs (7 tests): attention_lists_outdated_dependencies_from_the_recorded_world (dep-client stale after plain-make moves, dependency + built-against + now all named); attention_lists_a_down"}],"completedAt":"2026-11-18T08:24:11.640Z","evidence":"All four P2 children complete: tiny_http server + CSRF/session gate, inbox with the full eight-panel diff set, optimistic-concurrency approve/reject with 409-on-stale and per-item bulk confirmation, a"},{"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":"complete","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.","completedAt":"2026-11-18T08:36:46.877Z","evidence":"src/pipeline/dispatch.rs + tests/dispatch.rs (9 tests): claim_batch runs SELECT+UPDATE in one BEGIN IMMEDIATE tx (db.writer.tx uses TransactionBehavior::Immediate); an_expired_lease_is_requeued_and_it"},{"id":"task-p3-crash","title":"Cancellation, retry policy, and crash-resume tests against shims (I5)","status":"complete","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'.","completedAt":"2026-11-18T08:47:32.080Z","evidence":"tests/crash.rs (4 tests): a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work spawns the real aur-build binary, has a shim SIGKILL it inside the build step (asserts status.si"},{"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-p3-sse"}]}
\ No newline at end of file +{"version":1,"dirMtimeMs":1794993139578.6387,"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":6879748,"activeSeconds":12788},"sisyphus":false,"createdAt":"2026-11-17T20:43:24.440Z","updatedAt":"2026-11-18T09:12:19.576Z","activePath":".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md","revision":675,"scheduler":{"version":1,"owner":"01a1eb32-2e3f-757c-a79a-21ac993facc5","generation":"dfbaf4f2-dad9-4dc6-9717-5038550aa75e","used":1,"phase":"running","repairUsed":false,"decision":{"kind":"ready","purpose":"kickoff"},"dispatch":{"id":"27430841-6f83-4343-a9fa-dd1c866de9d3","kind":"kickoff","claimedAt":1794985072841}},"taskList":{"tasks":[{"id":"task-setup","title":"Provision toolchain (pacman rustup + devtools) and initialize git","status":"complete","verificationContract":"`rustup show` and `cargo --version` work; `git -C /workspace/aur-build log` contains an initial commit with DESIGN.md, .gitignore, and a scaffolded Cargo.toml that `cargo build` compiles.","completedAt":"2026-11-17T20:48:20.900Z","evidence":"rustup 1.29.3 (pacman) + stable 1.100.0, devtools installed (mkarchroot/makechrootpkg present); git repo initialized on main with commit 3762c7c containing DESIGN.md, .gitignore, Cargo.toml; `cargo bu"},{"id":"task-p0","title":"P0 — walking skeleton + test harness (§17 P0, §16a)","status":"complete","subtasks":[{"id":"task-p0-schema","title":"SQLite schema, migrations, and single writer actor (§11, §11a)","status":"complete","verificationContract":"Migrations apply from empty DB; partial unique index rejects a second pending_review per pkgbase; audit table rejects UPDATE/DELETE by trigger; concurrent readers do not block the writer in a test.","completedAt":"2026-11-17T21:00:03.122Z","evidence":"tests/db.rs: 10 tests pass — migrations from empty + idempotent + WAL, default settings, I7 partial unique index rejects 2nd pending_review, candidate identity uniqueness, audit append-only triggers, "},{"id":"task-p0-shims","title":"Toolchain PATH shims + fake-package corpus (§16a)","status":"complete","verificationContract":"Fakes for mkarchroot/makechrootpkg/makepkg/repo-add/gpg/pacman record invocations and emit plausible .PKGINFO/.BUILDINFO/.sig per fixture manifest; at least plain-make, with-patch, skip-checksum, split-pkgbase, build-fails, missing-dep, epoch-bump, pkgrel-reset and downgrade fixtures exist and are driven by a test.","completedAt":"2026-11-17T21:31:09.120Z","evidence":"src/shims + src/bin/{mkarchroot,makechrootpkg,makepkg,repo-add,gpg,pacman}: shims record invocations to AUR_SHIM_DIR/invocations.jsonl, obey AUR_SHIM_MANIFEST, and emit real .pkg.tar.zst with .PKGINFO"},{"id":"task-p0-detect","title":"AUR mirror watcher: aur_commit pin, recipe_hash, source digests, candidate creation (§5.1, §5.1a, §5.3)","status":"complete","verificationContract":"Against a local file:// 'AUR' repo fixture: clone + ls-remote poll + fetch only on SHA move; snapshot records aur_commit and recipe_hash covering PKGBUILD/.SRCINFO/*.install/patches; SKIP sources are stream-hashed into source_cache; candidate.base is current_accepted_release; a brand-new pkgbase yields kind=first_introduction.","completedAt":"2026-11-17T21:20:02.693Z","evidence":"tests/detect.rs: 16 tests pass against real file:// git fixtures — clone+ls-remote poll with fetch only on SHA move (Sync::Unchanged vs Fetched), snapshot records aur_commit + recipe_hash covering shi"},{"id":"task-p0-approve","title":"Approval semantics + CLI approval path (§7.1, §7.1a, §7.2)","status":"complete","verificationContract":"CLI approve writes an immutable approval row with diff_digest and identity_hash; approving with a stale identity_hash or diff_digest is refused; collapse-in-place bumps revision without a new row while unviewed and freezes as superseded once viewed; a rejected identity is not re-detected.","completedAt":"2026-11-17T22:10:06.063Z","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi"},{"id":"task-p0-build","title":"Build pipeline steps 0–9 and atomic signed publish (§8.1, §9)","status":"complete","verificationContract":"Shim-driven run of materialize→plan→chroot→sources→pkgver→build→collect→verify→ingest→publish; step 0 materializes from the local mirror and fails closed on recipe_hash mismatch; step 4 fails closed on pkgver mismatch; publish writes .tmp, fsyncs, renames, signs package and db, and updates current_accepted_release_id by compare-and-swap.","completedAt":"2026-11-17T21:58:00.936Z","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean"},{"id":"task-p0-invariants","title":"Executable invariant tests I1/I2/I4/I5/I8","status":"complete","verificationContract":"cargo test includes: post-run query proving no index entry lacks an approval (I1); multi-detection fixture proving the diff base is the last accepted version (I2); kill-mid-publish leaving the old index intact (I4); restart-resumes-at-next-incomplete-step with no duplicate side effects (I5); index set equals accepted-release pointers (I8).","completedAt":"2026-11-18T07:01:31.398Z","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re"}],"completedAt":"2026-11-18T07:02:29.831Z","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit"},{"id":"task-p1","title":"P1 — VCS / computed pkgver detection (§5.2, §3)","status":"complete","subtasks":[{"id":"task-p1-stageA","title":"Stage A upstream probes over all VCS sources + persistent vcs_cache","status":"complete","verificationContract":"Parses source=() for git+/svn+/hg+ with #tag/#commit refs; probes via git ls-remote against local file:// repos; an unchanged HEAD set short-circuits before Stage B; multiple VCS sources each get their own pin entry.","completedAt":"2026-11-18T07:16:40.077Z","evidence":"tests/vcs.rs: stage_a_probes_every_vcs_source_not_just_the_first (git-multi → 2 pins matching both repo HEADs), stage_a_respects_a_tag_pin, stage_a_short_circuits_before_stage_b_when_nothing_moved (ma"},{"id":"task-p1-stageB","title":"Stage B pkgver() resolution with pin capture + identity tuple","status":"complete","verificationContract":"Resolved epoch:pkgver-pkgrel plus upstream_pins become part of identity_hash; cooldown and global concurrency cap enforced; cache keyed on (pkgbase, recipe_hash, upstream_tip); a git-sourced fixture produces a candidate whose pins match the fixture repo HEAD.","completedAt":"2026-11-18T07:17:57.387Z","evidence":"tests/vcs.rs: stage_b_resolves_pkgver_and_captures_the_pins (pins in identity_hash via Identity hash comparison), stage_b_is_cached_on_pkgbase_recipe_and_tip (cache row reuse + cooldown + re-resolve o"},{"id":"task-p1-notices","title":"Non-publishable change handling: pin_drift, recipe drift, digest drift → notice / integrity_alert (§5.2, §5.3, I11)","status":"complete","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.","completedAt":"2026-11-18T07:29:10.456Z","evidence":"tests/notices.rs: 8 tests — digest-drift fixture → high-severity integrity_alert + no candidate, pin-drift → info notice + no candidate, recipe drift → warning, skip-checksum → HIGH risk signal 'skip-"}],"completedAt":"2026-11-18T07:30:36.958Z","evidence":"All three P1 children complete: Stage A probe (every VCS source, #tag/#commit, short-circuit), Stage B resolution (pin capture, cache on pkgbase+recipe_hash+tip, cooldown, concurrency cap), notices+ri"},{"id":"task-p2","title":"P2 — review surface (§12, §13, §6)","status":"complete","subtasks":[{"id":"task-p2-http","title":"tiny_http server, templating, thread-local readers, CSRF + session gate","status":"complete","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.","completedAt":"2026-11-18T08:06:45.433Z","evidence":"tests/http.rs (14 tests, all pass): every_surface_renders covers all §12 routes on a live tiny_http server; every_post_requires_a_csrf_token asserts 403 for missing and forged tokens with zero rows wr"},{"id":"task-p2-inbox","title":"Inbox + diff panels + advisory risk scoring (§6, §7.1b)","status":"complete","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.","completedAt":"2026-11-18T08:07:10.624Z","evidence":"src/review/diff.rs now emits all eight §6 panels (recipe, version, source-digest, upstream, source, dependency, build-env, install-hook), each computed accepted→candidate; commit ab8d33d. tests/http.r"},{"id":"task-p2-approve409","title":"Optimistic-concurrency approve/reject + bulk operations (§7.1a, §7.4)","status":"complete","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.","completedAt":"2026-11-18T08:07:36.401Z","evidence":"tests/http.rs: a_stale_approval_is_a_409_that_renders_the_current_diff (upstream moves mid-review → 409, body explains the ground moved, re-render shows the new 9.9 version, zero approval rows written"},{"id":"task-p2-surfaces","title":"Subscriptions, Index, Builds, Attention, Ops/audit pages","status":"complete","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).","completedAt":"2026-11-18T08:23:18.650Z","evidence":"tests/surfaces.rs (7 tests): attention_lists_outdated_dependencies_from_the_recorded_world (dep-client stale after plain-make moves, dependency + built-against + now all named); attention_lists_a_down"}],"completedAt":"2026-11-18T08:24:11.640Z","evidence":"All four P2 children complete: tiny_http server + CSRF/session gate, inbox with the full eight-panel diff set, optimistic-concurrency approve/reject with 409-on-stale and per-item bulk confirmation, a"},{"id":"task-p3","title":"P3 — durability (§8.2, §8.3, §8.4)","status":"complete","subtasks":[{"id":"task-p3-dispatch","title":"Dispatcher actor, worker pool, leases, and reaper","status":"complete","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.","completedAt":"2026-11-18T08:36:46.877Z","evidence":"src/pipeline/dispatch.rs + tests/dispatch.rs (9 tests): claim_batch runs SELECT+UPDATE in one BEGIN IMMEDIATE tx (db.writer.tx uses TransactionBehavior::Immediate); an_expired_lease_is_requeued_and_it"},{"id":"task-p3-crash","title":"Cancellation, retry policy, and crash-resume tests against shims (I5)","status":"complete","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'.","completedAt":"2026-11-18T08:47:32.080Z","evidence":"tests/crash.rs (4 tests): a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work spawns the real aur-build binary, has a shim SIGKILL it inside the build step (asserts status.si"},{"id":"task-p3-sse","title":"SSE log tail + htmx live builds table","status":"complete","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.","completedAt":"2026-11-18T09:01:22.683Z","evidence":"tests/live.rs (5 tests): the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends — a producer thread appends to the log while the SSE stream is open and the reader must see those bytes BEFORE"}],"completedAt":"2026-11-18T09:03:07.796Z","evidence":"All three P3 children complete: dispatcher/worker pool/reaper with BEGIN IMMEDIATE claims and disk-headroom backpressure (e27e90a), a real SIGKILL mid-step crash test plus the approved_but_unbuilt fai"},{"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-p4-world"}]}
\ No newline at end of file diff --git a/.pi/goals/.goal-ledger-checkpoint.json b/.pi/goals/.goal-ledger-checkpoint.json index 50fd68c..d5ebdbf 100644 --- a/.pi/goals/.goal-ledger-checkpoint.json +++ b/.pi/goals/.goal-ledger-checkpoint.json @@ -1 +1 @@ -{"version":4,"format":"goal-ledger-checkpoint","createdAt":"2026-11-18T08:48:58.622Z","coveredBytes":11537,"coveredEvents":36,"acc":{"goals":[{"goalId":"mwl5tehk-xhe7fk","latestStatus":"active","latestFocus":false,"createdAt":"2026-11-17T20:43:24.440Z","resumedAt":"2026-11-18T06:57:52.837Z"}],"terminalGoals":[],"focusedGoalId":null,"focusGeneration":0,"focusGenByGoal":[]},"recentEventsByGoal":[["mwl5tehk-xhe7fk",[{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-http","at":"2026-11-18T07:32:27.434Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-http","evidence":"tests/http.rs (14 tests, all pass): every_surface_renders covers all §12 routes on a live tiny_http server; every_post_requires_a_csrf_token asserts 403 for missing and forged tokens with zero rows wr","at":"2026-11-18T08:06:45.433Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-inbox","evidence":"src/review/diff.rs now emits all eight §6 panels (recipe, version, source-digest, upstream, source, dependency, build-env, install-hook), each computed accepted→candidate; commit ab8d33d. tests/http.r","at":"2026-11-18T08:07:10.624Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-approve409","evidence":"tests/http.rs: a_stale_approval_is_a_409_that_renders_the_current_diff (upstream moves mid-review → 409, body explains the ground moved, re-render shows the new 9.9 version, zero approval rows written","at":"2026-11-18T08:07:36.401Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","at":"2026-11-18T08:08:13.901Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","evidence":"tests/surfaces.rs (7 tests): attention_lists_outdated_dependencies_from_the_recorded_world (dep-client stale after plain-make moves, dependency + built-against + now all named); attention_lists_a_down","at":"2026-11-18T08:23:18.652Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2","evidence":"All four P2 children complete: tiny_http server + CSRF/session gate, inbox with the full eight-panel diff set, optimistic-concurrency approve/reject with 409-on-stale and per-item bulk confirmation, a","at":"2026-11-18T08:24:11.640Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","at":"2026-11-18T08:25:05.524Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","evidence":"src/pipeline/dispatch.rs + tests/dispatch.rs (9 tests): claim_batch runs SELECT+UPDATE in one BEGIN IMMEDIATE tx (db.writer.tx uses TransactionBehavior::Immediate); an_expired_lease_is_requeued_and_it","at":"2026-11-18T08:36:46.878Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","at":"2026-11-18T08:38:10.587Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","evidence":"tests/crash.rs (4 tests): a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work spawns the real aur-build binary, has a shim SIGKILL it inside the build step (asserts status.si","at":"2026-11-18T08:47:32.080Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","at":"2026-11-18T08:48:58.608Z"}]]],"runtimeIndex":[["mwl5tehk-xhe7fk",{"recent":[{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-http","at":"2026-11-18T07:32:27.434Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-http","evidence":"tests/http.rs (14 tests, all pass): every_surface_renders covers all §12 routes on a live tiny_http server; every_post_requires_a_csrf_token asserts 403 for missing and forged tokens with zero rows wr","at":"2026-11-18T08:06:45.433Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-inbox","evidence":"src/review/diff.rs now emits all eight §6 panels (recipe, version, source-digest, upstream, source, dependency, build-env, install-hook), each computed accepted→candidate; commit ab8d33d. tests/http.r","at":"2026-11-18T08:07:10.624Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-approve409","evidence":"tests/http.rs: a_stale_approval_is_a_409_that_renders_the_current_diff (upstream moves mid-review → 409, body explains the ground moved, re-render shows the new 9.9 version, zero approval rows written","at":"2026-11-18T08:07:36.401Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","at":"2026-11-18T08:08:13.901Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","evidence":"tests/surfaces.rs (7 tests): attention_lists_outdated_dependencies_from_the_recorded_world (dep-client stale after plain-make moves, dependency + built-against + now all named); attention_lists_a_down","at":"2026-11-18T08:23:18.652Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2","evidence":"All four P2 children complete: tiny_http server + CSRF/session gate, inbox with the full eight-panel diff set, optimistic-concurrency approve/reject with 409-on-stale and per-item bulk confirmation, a","at":"2026-11-18T08:24:11.640Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","at":"2026-11-18T08:25:05.524Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","evidence":"src/pipeline/dispatch.rs + tests/dispatch.rs (9 tests): claim_batch runs SELECT+UPDATE in one BEGIN IMMEDIATE tx (db.writer.tx uses TransactionBehavior::Immediate); an_expired_lease_is_requeued_and_it","at":"2026-11-18T08:36:46.878Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","at":"2026-11-18T08:38:10.587Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","evidence":"tests/crash.rs (4 tests): a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work spawns the real aur-build binary, has a shim SIGKILL it inside the build step (asserts status.si","at":"2026-11-18T08:47:32.080Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","at":"2026-11-18T08:48:58.608Z"}],"activity":[{"type":"goal_created","goalId":"mwl5tehk-xhe7fk","objective":"Implement the AUR Build Server described in DESIGN.md as a single-process Rust binary in /workspace/aur-build, delivering phases P0–P4 (walking skeleton + test harness, VCS/pkgver detection, review web UI, durable build pipeline, staleness tracking), with every §2 invariant expressed as an executable test and the work committed incrementally to git.\n\nSUCCESS CRITERIA (observable):\n1. `cargo test` passes on the host with no `#[ignore]`-tier tests required; the §16a fake-package corpus and toolchain PATH shims drive the full step machine, publishing and crash-resume tests without root, network, or a real chroot.\n2. Invariants I1–I12 of §2 each have a named test that passes (I1 no-artifact-without-approval is a post-test query; I2 diff-base-is-last-accepted; I4 atomic publish survives kill-mid-publish; I5 step checkpoint/resume; I7 one open review enforced by the partial unique index; I12 world snapshots recorded).\n3. End-to-end against shims: subscribe pkgbase → detect → review → approve → build → publish a signed repo where both packages and the .db are signed, and the served index equals the set of current_accepted_release pointers (I8).\n4. Web UI serves the five §13 surfaces (Inbox, Builds, Attention, Index, Subscriptions) plus Ops/audit as server-rendered HTML; approve carries identity_hash + diff_digest and returns HTTP 409 on a stale approval (§7.1a).\n5. `cargo clippy` reports no errors; `git log` shows a sequence of small, meaningful commits from the initial scaffold to the final state; README documents build, run, and test commands.\n\nBOUNDARIES — IN SCOPE: P0, P1, P2, P3, P4 of §17, the §11 schema, §16 edge cases, §16a test harness, and one gated real-chroot integration attempt (devtools installed) if time permits.\nOUT OF SCOPE: everything in §20 (auto-approval policies, automatic dependency rebuilds, recipe-mutating hardening transforms, build-time upstream-pin honouring, network controls, cost-weighted admission, notifications), P5 polish, multi-tenancy/RBAC, non-x86_64 arches, and any change to DESIGN.md's decided decisions in §18.\n\nCONSTRAINTS (hard):\n- Rust edition 2021, no `async`/`await`, no tokio/axum/actix/reqwest/sqlx/libgit2; threads + crossbeam channels only; blocking HTTP via tiny_http; outbound HTTP via ureq; git by shelling out.\n- SQLite via rusqlite in WAL mode with exactly one writer actor thread (channel-based `Tx` enum) and thread-local read-only readers; no transaction may span a build step.\n- UI is server-rendered (askama or minijinja) with at most vendored htmx (~14 KB) plus ~30 lines of glue; no JS written by us beyond that glue, no bundler.\n- Fail closed on every pin assertion (recipe_hash, pkgver match against approved identity); non-publishable changes become `notice` rows, never candidates, never dropped (I11).\n- Provisioning: `sudo pacman -S --needed rustup devtools` (fall back to `pacman -S rust` only if rustup is unusable); no other system mutations; never commit secrets, the signing key, or build artifacts.\n- Commit incrementally: one commit per coherent step with a descriptive message; never a single monolithic commit; DESIGN.md stays untouched.\n- If a §19 open question blocks a design choice, pick the least-entangling option, record it in a `docs/DECISIONS.md` entry, and keep moving; stop and ask only if the choice is genuinely irreversible.\n\nIF BLOCKED: stop and ask the user (e.g. no network for crates, toolchain uninstallable, an invariant that cannot be made testable).","sisyphus":false,"autoContinue":true,"at":"2026-11-17T20:43:24.440Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-setup","at":"2026-11-17T20:43:42.908Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-setup","evidence":"rustup 1.29.3 (pacman) + stable 1.100.0, devtools installed (mkarchroot/makechrootpkg present); git repo initialized on main with commit 3762c7c containing DESIGN.md, .gitignore, Cargo.toml; `cargo bu","at":"2026-11-17T20:48:20.900Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-schema","at":"2026-11-17T20:48:42.903Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-schema","evidence":"tests/db.rs: 10 tests pass — migrations from empty + idempotent + WAL, default settings, I7 partial unique index rejects 2nd pending_review, candidate identity uniqueness, audit append-only triggers, ","at":"2026-11-17T21:00:03.124Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-detect","at":"2026-11-17T21:00:47.994Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-detect","evidence":"tests/detect.rs: 16 tests pass against real file:// git fixtures — clone+ls-remote poll with fetch only on SHA move (Sync::Unchanged vs Fetched), snapshot records aur_commit + recipe_hash covering shi","at":"2026-11-17T21:20:02.693Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","at":"2026-11-17T21:21:27.981Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","evidence":"src/shims + src/bin/{mkarchroot,makechrootpkg,makepkg,repo-add,gpg,pacman}: shims record invocations to AUR_SHIM_DIR/invocations.jsonl, obey AUR_SHIM_MANIFEST, and emit real .pkg.tar.zst with .PKGINFO","at":"2026-11-17T21:31:09.121Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","at":"2026-11-17T21:32:52.768Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean","at":"2026-11-17T21:58:00.937Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","at":"2026-11-17T21:58:43.315Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi","at":"2026-11-17T22:10:06.063Z"},{"type":"goal_paused","goalId":"mwl5tehk-xhe7fk","reason":"user","status":"paused","at":"2026-11-17T22:12:03.674Z"},{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-invariants","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re","at":"2026-11-18T07:01:31.400Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit","at":"2026-11-18T07:02:29.831Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","at":"2026-11-18T07:04:12.225Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","evidence":"tests/vcs.rs: stage_a_probes_every_vcs_source_not_just_the_first (git-multi → 2 pins matching both repo HEADs), stage_a_respects_a_tag_pin, stage_a_short_circuits_before_stage_b_when_nothing_moved (ma","at":"2026-11-18T07:16:40.078Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageB","evidence":"tests/vcs.rs: stage_b_resolves_pkgver_and_captures_the_pins (pins in identity_hash via Identity hash comparison), stage_b_is_cached_on_pkgbase_recipe_and_tip (cache row reuse + cooldown + re-resolve o","at":"2026-11-18T07:17:57.387Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-notices","at":"2026-11-18T07:19:15.892Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-notices","evidence":"tests/notices.rs: 8 tests — digest-drift fixture → high-severity integrity_alert + no candidate, pin-drift → info notice + no candidate, recipe drift → warning, skip-checksum → HIGH risk signal 'skip-","at":"2026-11-18T07:29:10.457Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1","evidence":"All three P1 children complete: Stage A probe (every VCS source, #tag/#commit, short-circuit), Stage B resolution (pin capture, cache on pkgbase+recipe_hash+tip, cooldown, concurrency cap), notices+ri","at":"2026-11-18T07:30:36.958Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-http","at":"2026-11-18T07:32:27.434Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-http","evidence":"tests/http.rs (14 tests, all pass): every_surface_renders covers all §12 routes on a live tiny_http server; every_post_requires_a_csrf_token asserts 403 for missing and forged tokens with zero rows wr","at":"2026-11-18T08:06:45.433Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-inbox","evidence":"src/review/diff.rs now emits all eight §6 panels (recipe, version, source-digest, upstream, source, dependency, build-env, install-hook), each computed accepted→candidate; commit ab8d33d. tests/http.r","at":"2026-11-18T08:07:10.624Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-approve409","evidence":"tests/http.rs: a_stale_approval_is_a_409_that_renders_the_current_diff (upstream moves mid-review → 409, body explains the ground moved, re-render shows the new 9.9 version, zero approval rows written","at":"2026-11-18T08:07:36.401Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","at":"2026-11-18T08:08:13.901Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","evidence":"tests/surfaces.rs (7 tests): attention_lists_outdated_dependencies_from_the_recorded_world (dep-client stale after plain-make moves, dependency + built-against + now all named); attention_lists_a_down","at":"2026-11-18T08:23:18.652Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2","evidence":"All four P2 children complete: tiny_http server + CSRF/session gate, inbox with the full eight-panel diff set, optimistic-concurrency approve/reject with 409-on-stale and per-item bulk confirmation, a","at":"2026-11-18T08:24:11.640Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","at":"2026-11-18T08:25:05.524Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","evidence":"src/pipeline/dispatch.rs + tests/dispatch.rs (9 tests): claim_batch runs SELECT+UPDATE in one BEGIN IMMEDIATE tx (db.writer.tx uses TransactionBehavior::Immediate); an_expired_lease_is_requeued_and_it","at":"2026-11-18T08:36:46.878Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","at":"2026-11-18T08:38:10.587Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","evidence":"tests/crash.rs (4 tests): a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work spawns the real aur-build binary, has a shim SIGKILL it inside the build step (asserts status.si","at":"2026-11-18T08:47:32.080Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","at":"2026-11-18T08:48:58.608Z"}],"oracle":[],"lifecycle":{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},"lastActivityEvent":{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","at":"2026-11-18T08:48:58.608Z"}}]]}
\ No newline at end of file +{"version":4,"format":"goal-ledger-checkpoint","createdAt":"2026-11-18T09:04:51.619Z","coveredBytes":12285,"coveredEvents":39,"acc":{"goals":[{"goalId":"mwl5tehk-xhe7fk","latestStatus":"active","latestFocus":false,"createdAt":"2026-11-17T20:43:24.440Z","resumedAt":"2026-11-18T06:57:52.837Z"}],"terminalGoals":[],"focusedGoalId":null,"focusGeneration":0,"focusGenByGoal":[]},"recentEventsByGoal":[["mwl5tehk-xhe7fk",[{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-approve409","evidence":"tests/http.rs: a_stale_approval_is_a_409_that_renders_the_current_diff (upstream moves mid-review → 409, body explains the ground moved, re-render shows the new 9.9 version, zero approval rows written","at":"2026-11-18T08:07:36.401Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","at":"2026-11-18T08:08:13.901Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","evidence":"tests/surfaces.rs (7 tests): attention_lists_outdated_dependencies_from_the_recorded_world (dep-client stale after plain-make moves, dependency + built-against + now all named); attention_lists_a_down","at":"2026-11-18T08:23:18.652Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2","evidence":"All four P2 children complete: tiny_http server + CSRF/session gate, inbox with the full eight-panel diff set, optimistic-concurrency approve/reject with 409-on-stale and per-item bulk confirmation, a","at":"2026-11-18T08:24:11.640Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","at":"2026-11-18T08:25:05.524Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","evidence":"src/pipeline/dispatch.rs + tests/dispatch.rs (9 tests): claim_batch runs SELECT+UPDATE in one BEGIN IMMEDIATE tx (db.writer.tx uses TransactionBehavior::Immediate); an_expired_lease_is_requeued_and_it","at":"2026-11-18T08:36:46.878Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","at":"2026-11-18T08:38:10.587Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","evidence":"tests/crash.rs (4 tests): a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work spawns the real aur-build binary, has a shim SIGKILL it inside the build step (asserts status.si","at":"2026-11-18T08:47:32.080Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","at":"2026-11-18T08:48:58.608Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","evidence":"tests/live.rs (5 tests): the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends — a producer thread appends to the log while the SSE stream is open and the reader must see those bytes BEFORE","at":"2026-11-18T09:01:22.685Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3","evidence":"All three P3 children complete: dispatcher/worker pool/reaper with BEGIN IMMEDIATE claims and disk-headroom backpressure (e27e90a), a real SIGKILL mid-step crash test plus the approved_but_unbuilt fai","at":"2026-11-18T09:03:07.796Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p4-world","at":"2026-11-18T09:04:51.588Z"}]]],"runtimeIndex":[["mwl5tehk-xhe7fk",{"recent":[{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-approve409","evidence":"tests/http.rs: a_stale_approval_is_a_409_that_renders_the_current_diff (upstream moves mid-review → 409, body explains the ground moved, re-render shows the new 9.9 version, zero approval rows written","at":"2026-11-18T08:07:36.401Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","at":"2026-11-18T08:08:13.901Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","evidence":"tests/surfaces.rs (7 tests): attention_lists_outdated_dependencies_from_the_recorded_world (dep-client stale after plain-make moves, dependency + built-against + now all named); attention_lists_a_down","at":"2026-11-18T08:23:18.652Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2","evidence":"All four P2 children complete: tiny_http server + CSRF/session gate, inbox with the full eight-panel diff set, optimistic-concurrency approve/reject with 409-on-stale and per-item bulk confirmation, a","at":"2026-11-18T08:24:11.640Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","at":"2026-11-18T08:25:05.524Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","evidence":"src/pipeline/dispatch.rs + tests/dispatch.rs (9 tests): claim_batch runs SELECT+UPDATE in one BEGIN IMMEDIATE tx (db.writer.tx uses TransactionBehavior::Immediate); an_expired_lease_is_requeued_and_it","at":"2026-11-18T08:36:46.878Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","at":"2026-11-18T08:38:10.587Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","evidence":"tests/crash.rs (4 tests): a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work spawns the real aur-build binary, has a shim SIGKILL it inside the build step (asserts status.si","at":"2026-11-18T08:47:32.080Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","at":"2026-11-18T08:48:58.608Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","evidence":"tests/live.rs (5 tests): the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends — a producer thread appends to the log while the SSE stream is open and the reader must see those bytes BEFORE","at":"2026-11-18T09:01:22.685Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3","evidence":"All three P3 children complete: dispatcher/worker pool/reaper with BEGIN IMMEDIATE claims and disk-headroom backpressure (e27e90a), a real SIGKILL mid-step crash test plus the approved_but_unbuilt fai","at":"2026-11-18T09:03:07.796Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p4-world","at":"2026-11-18T09:04:51.588Z"}],"activity":[{"type":"goal_created","goalId":"mwl5tehk-xhe7fk","objective":"Implement the AUR Build Server described in DESIGN.md as a single-process Rust binary in /workspace/aur-build, delivering phases P0–P4 (walking skeleton + test harness, VCS/pkgver detection, review web UI, durable build pipeline, staleness tracking), with every §2 invariant expressed as an executable test and the work committed incrementally to git.\n\nSUCCESS CRITERIA (observable):\n1. `cargo test` passes on the host with no `#[ignore]`-tier tests required; the §16a fake-package corpus and toolchain PATH shims drive the full step machine, publishing and crash-resume tests without root, network, or a real chroot.\n2. Invariants I1–I12 of §2 each have a named test that passes (I1 no-artifact-without-approval is a post-test query; I2 diff-base-is-last-accepted; I4 atomic publish survives kill-mid-publish; I5 step checkpoint/resume; I7 one open review enforced by the partial unique index; I12 world snapshots recorded).\n3. End-to-end against shims: subscribe pkgbase → detect → review → approve → build → publish a signed repo where both packages and the .db are signed, and the served index equals the set of current_accepted_release pointers (I8).\n4. Web UI serves the five §13 surfaces (Inbox, Builds, Attention, Index, Subscriptions) plus Ops/audit as server-rendered HTML; approve carries identity_hash + diff_digest and returns HTTP 409 on a stale approval (§7.1a).\n5. `cargo clippy` reports no errors; `git log` shows a sequence of small, meaningful commits from the initial scaffold to the final state; README documents build, run, and test commands.\n\nBOUNDARIES — IN SCOPE: P0, P1, P2, P3, P4 of §17, the §11 schema, §16 edge cases, §16a test harness, and one gated real-chroot integration attempt (devtools installed) if time permits.\nOUT OF SCOPE: everything in §20 (auto-approval policies, automatic dependency rebuilds, recipe-mutating hardening transforms, build-time upstream-pin honouring, network controls, cost-weighted admission, notifications), P5 polish, multi-tenancy/RBAC, non-x86_64 arches, and any change to DESIGN.md's decided decisions in §18.\n\nCONSTRAINTS (hard):\n- Rust edition 2021, no `async`/`await`, no tokio/axum/actix/reqwest/sqlx/libgit2; threads + crossbeam channels only; blocking HTTP via tiny_http; outbound HTTP via ureq; git by shelling out.\n- SQLite via rusqlite in WAL mode with exactly one writer actor thread (channel-based `Tx` enum) and thread-local read-only readers; no transaction may span a build step.\n- UI is server-rendered (askama or minijinja) with at most vendored htmx (~14 KB) plus ~30 lines of glue; no JS written by us beyond that glue, no bundler.\n- Fail closed on every pin assertion (recipe_hash, pkgver match against approved identity); non-publishable changes become `notice` rows, never candidates, never dropped (I11).\n- Provisioning: `sudo pacman -S --needed rustup devtools` (fall back to `pacman -S rust` only if rustup is unusable); no other system mutations; never commit secrets, the signing key, or build artifacts.\n- Commit incrementally: one commit per coherent step with a descriptive message; never a single monolithic commit; DESIGN.md stays untouched.\n- If a §19 open question blocks a design choice, pick the least-entangling option, record it in a `docs/DECISIONS.md` entry, and keep moving; stop and ask only if the choice is genuinely irreversible.\n\nIF BLOCKED: stop and ask the user (e.g. no network for crates, toolchain uninstallable, an invariant that cannot be made testable).","sisyphus":false,"autoContinue":true,"at":"2026-11-17T20:43:24.440Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-setup","at":"2026-11-17T20:43:42.908Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-setup","evidence":"rustup 1.29.3 (pacman) + stable 1.100.0, devtools installed (mkarchroot/makechrootpkg present); git repo initialized on main with commit 3762c7c containing DESIGN.md, .gitignore, Cargo.toml; `cargo bu","at":"2026-11-17T20:48:20.900Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-schema","at":"2026-11-17T20:48:42.903Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-schema","evidence":"tests/db.rs: 10 tests pass — migrations from empty + idempotent + WAL, default settings, I7 partial unique index rejects 2nd pending_review, candidate identity uniqueness, audit append-only triggers, ","at":"2026-11-17T21:00:03.124Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-detect","at":"2026-11-17T21:00:47.994Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-detect","evidence":"tests/detect.rs: 16 tests pass against real file:// git fixtures — clone+ls-remote poll with fetch only on SHA move (Sync::Unchanged vs Fetched), snapshot records aur_commit + recipe_hash covering shi","at":"2026-11-17T21:20:02.693Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","at":"2026-11-17T21:21:27.981Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-shims","evidence":"src/shims + src/bin/{mkarchroot,makechrootpkg,makepkg,repo-add,gpg,pacman}: shims record invocations to AUR_SHIM_DIR/invocations.jsonl, obey AUR_SHIM_MANIFEST, and emit real .pkg.tar.zst with .PKGINFO","at":"2026-11-17T21:31:09.121Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","at":"2026-11-17T21:32:52.768Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-build","evidence":"tests/pipeline.rs: 17 shim-driven e2e tests pass (fail-closed recipe_hash + pkgver, kill-mid-publish I4, crash-resume I5, CAS pointer, signed db+pkgs); cargo clippy clean","at":"2026-11-17T21:58:00.937Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","at":"2026-11-17T21:58:43.315Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-approve","evidence":"tests/approve.rs: 10 tests pass incl. both-hash immutable approval row (migration 0006 trigger), stale identity/diff refused, collapse-in-place revision bump, viewed→superseded freeze, rejected identi","at":"2026-11-17T22:10:06.063Z"},{"type":"goal_paused","goalId":"mwl5tehk-xhe7fk","reason":"user","status":"paused","at":"2026-11-17T22:12:03.674Z"},{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0-invariants","evidence":"tests/invariants.rs: 10 named invariant tests pass as post-conditions on real runs (I1 approval trace, I2 base after 5 detections, I3 recipe pin, I4 byte-identical index after mid-publish crash, I5 re","at":"2026-11-18T07:01:31.400Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p0","evidence":"All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit","at":"2026-11-18T07:02:29.831Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","at":"2026-11-18T07:04:12.225Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageA","evidence":"tests/vcs.rs: stage_a_probes_every_vcs_source_not_just_the_first (git-multi → 2 pins matching both repo HEADs), stage_a_respects_a_tag_pin, stage_a_short_circuits_before_stage_b_when_nothing_moved (ma","at":"2026-11-18T07:16:40.078Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-stageB","evidence":"tests/vcs.rs: stage_b_resolves_pkgver_and_captures_the_pins (pins in identity_hash via Identity hash comparison), stage_b_is_cached_on_pkgbase_recipe_and_tip (cache row reuse + cooldown + re-resolve o","at":"2026-11-18T07:17:57.387Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-notices","at":"2026-11-18T07:19:15.892Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1-notices","evidence":"tests/notices.rs: 8 tests — digest-drift fixture → high-severity integrity_alert + no candidate, pin-drift → info notice + no candidate, recipe drift → warning, skip-checksum → HIGH risk signal 'skip-","at":"2026-11-18T07:29:10.457Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p1","evidence":"All three P1 children complete: Stage A probe (every VCS source, #tag/#commit, short-circuit), Stage B resolution (pin capture, cache on pkgbase+recipe_hash+tip, cooldown, concurrency cap), notices+ri","at":"2026-11-18T07:30:36.958Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-http","at":"2026-11-18T07:32:27.434Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-http","evidence":"tests/http.rs (14 tests, all pass): every_surface_renders covers all §12 routes on a live tiny_http server; every_post_requires_a_csrf_token asserts 403 for missing and forged tokens with zero rows wr","at":"2026-11-18T08:06:45.433Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-inbox","evidence":"src/review/diff.rs now emits all eight §6 panels (recipe, version, source-digest, upstream, source, dependency, build-env, install-hook), each computed accepted→candidate; commit ab8d33d. tests/http.r","at":"2026-11-18T08:07:10.624Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-approve409","evidence":"tests/http.rs: a_stale_approval_is_a_409_that_renders_the_current_diff (upstream moves mid-review → 409, body explains the ground moved, re-render shows the new 9.9 version, zero approval rows written","at":"2026-11-18T08:07:36.401Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","at":"2026-11-18T08:08:13.901Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2-surfaces","evidence":"tests/surfaces.rs (7 tests): attention_lists_outdated_dependencies_from_the_recorded_world (dep-client stale after plain-make moves, dependency + built-against + now all named); attention_lists_a_down","at":"2026-11-18T08:23:18.652Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p2","evidence":"All four P2 children complete: tiny_http server + CSRF/session gate, inbox with the full eight-panel diff set, optimistic-concurrency approve/reject with 409-on-stale and per-item bulk confirmation, a","at":"2026-11-18T08:24:11.640Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","at":"2026-11-18T08:25:05.524Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-dispatch","evidence":"src/pipeline/dispatch.rs + tests/dispatch.rs (9 tests): claim_batch runs SELECT+UPDATE in one BEGIN IMMEDIATE tx (db.writer.tx uses TransactionBehavior::Immediate); an_expired_lease_is_requeued_and_it","at":"2026-11-18T08:36:46.878Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","at":"2026-11-18T08:38:10.587Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","evidence":"tests/crash.rs (4 tests): a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work spawns the real aur-build binary, has a shim SIGKILL it inside the build step (asserts status.si","at":"2026-11-18T08:47:32.080Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","at":"2026-11-18T08:48:58.608Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","evidence":"tests/live.rs (5 tests): the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends — a producer thread appends to the log while the SSE stream is open and the reader must see those bytes BEFORE","at":"2026-11-18T09:01:22.685Z"},{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3","evidence":"All three P3 children complete: dispatcher/worker pool/reaper with BEGIN IMMEDIATE claims and disk-headroom backpressure (e27e90a), a real SIGKILL mid-step crash test plus the approved_but_unbuilt fai","at":"2026-11-18T09:03:07.796Z"},{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p4-world","at":"2026-11-18T09:04:51.588Z"}],"oracle":[],"lifecycle":{"type":"goal_resumed","goalId":"mwl5tehk-xhe7fk","reason":"user","at":"2026-11-18T06:57:52.837Z"},"lastActivityEvent":{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p4-world","at":"2026-11-18T09:04:51.588Z"}}]]}
\ No newline at end of file diff --git a/.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md b/.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md index a8cfcd8..8d9e24f 100644 --- a/.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md +++ b/.pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md @@ -5,14 +5,14 @@ "status": "active", "autoContinue": true, "usage": { - "tokensUsed": 6265695, - "activeSeconds": 12132 + "tokensUsed": 6879748, + "activeSeconds": 12788 }, "sisyphus": false, "createdAt": "2026-11-17T20:43:24.440Z", - "updatedAt": "2026-11-18T09:01:08.009Z", + "updatedAt": "2026-11-18T09:12:19.576Z", "activePath": ".pi/goals/active_goal_2026111720432444_mwl5tehk-xhe7fk.md", - "revision": 647, + "revision": 675, "scheduler": { "version": 1, "owner": "01a1eb32-2e3f-757c-a79a-21ac993facc5", @@ -174,7 +174,7 @@ { "id": "task-p3", "title": "P3 — durability (§8.2, §8.3, §8.4)", - "status": "pending", + "status": "complete", "subtasks": [ { "id": "task-p3-dispatch", @@ -195,10 +195,14 @@ { "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." + "status": "complete", + "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.", + "completedAt": "2026-11-18T09:01:22.683Z", + "evidence": "tests/live.rs (5 tests): the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends — a producer thread appends to the log while the SSE stream is open and the reader must see those bytes BEFORE" } - ] + ], + "completedAt": "2026-11-18T09:03:07.796Z", + "evidence": "All three P3 children complete: dispatcher/worker pool/reaper with BEGIN IMMEDIATE claims and disk-headroom backpressure (e27e90a), a real SIGKILL mid-step crash test plus the approved_but_unbuilt fai" }, { "id": "task-p4", @@ -241,7 +245,7 @@ "blockCompletion": true, "proposedAt": "2026-11-17T20:39:23.165Z" }, - "currentTaskId": "task-p3-sse" + "currentTaskId": "task-p4-world" } # Goal Prompt @@ -274,8 +278,8 @@ IF BLOCKED: stop and ask the user (e.g. no network for crates, toolchain uninsta - Status: running - Auto-continue: on - Sisyphus mode: no -- Time spent: 3h22m12s -- Tokens used: 6.3M (6,265,695) tokens +- Time spent: 3h33m08s +- Tokens used: 6.9M (6,879,748) tokens ## Tasks <!-- blockCompletion: true --> @@ -283,7 +287,7 @@ IF BLOCKED: stop and ask the user (e.g. no network for crates, toolchain uninsta - [x] task-p0: P0 — walking skeleton + test harness (§17 P0, §16a) — evidence: All P0 children complete: schema+writer actor, shims+corpus, mirror watcher, approval semantics+CLI, 10-step pipeline with signed atomic publish, invariant index. 81 tests pass, clippy clean, 7 commit - [x] task-p1: P1 — VCS / computed pkgver detection (§5.2, §3) — evidence: All three P1 children complete: Stage A probe (every VCS source, #tag/#commit, short-circuit), Stage B resolution (pin capture, cache on pkgbase+recipe_hash+tip, cooldown, concurrency cap), notices+ri - [x] task-p2: P2 — review surface (§12, §13, §6) — evidence: All four P2 children complete: tiny_http server + CSRF/session gate, inbox with the full eight-panel diff set, optimistic-concurrency approve/reject with 409-on-stale and per-item bulk confirmation, a -- [ ] task-p3: P3 — durability (§8.2, §8.3, §8.4) +- [x] task-p3: P3 — durability (§8.2, §8.3, §8.4) — evidence: All three P3 children complete: dispatcher/worker pool/reaper with BEGIN IMMEDIATE claims and disk-headroom backpressure (e27e90a), a real SIGKILL mid-step crash test plus the approved_but_unbuilt fai - [ ] 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 index eb02721..f4c6307 100644 --- a/.pi/goals/goal_events.jsonl +++ b/.pi/goals/goal_events.jsonl @@ -34,3 +34,6 @@ {"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","at":"2026-11-18T08:38:10.587Z"} {"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-crash","evidence":"tests/crash.rs (4 tests): a_process_killed_mid_step_resumes_from_its_checkpoints_with_no_duplicate_work spawns the real aur-build binary, has a shim SIGKILL it inside the build step (asserts status.si","at":"2026-11-18T08:47:32.080Z"} {"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","at":"2026-11-18T08:48:58.608Z"} +{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3-sse","evidence":"tests/live.rs (5 tests): the_log_stream_delivers_bytes_as_they_are_appended_and_then_ends — a producer thread appends to the log while the SSE stream is open and the reader must see those bytes BEFORE","at":"2026-11-18T09:01:22.685Z"} +{"type":"task_complete","goalId":"mwl5tehk-xhe7fk","taskId":"task-p3","evidence":"All three P3 children complete: dispatcher/worker pool/reaper with BEGIN IMMEDIATE claims and disk-headroom backpressure (e27e90a), a real SIGKILL mid-step crash test plus the approved_but_unbuilt fai","at":"2026-11-18T09:03:07.796Z"} +{"type":"task_started","goalId":"mwl5tehk-xhe7fk","taskId":"task-p4-world","at":"2026-11-18T09:04:51.588Z"} @@ -13,6 +13,7 @@ pub mod git; pub mod hash; pub mod http; pub mod pipeline; +pub mod pkginfo; pub mod pkgver; pub mod recipe; pub mod review; diff --git a/src/pipeline/steps.rs b/src/pipeline/steps.rs index b925afb..3f575bd 100644 --- a/src/pipeline/steps.rs +++ b/src/pipeline/steps.rs @@ -264,24 +264,32 @@ fn collect(ctx: &Ctx) -> Result<StepResult> { for path in entries { let bytes = std::fs::read(&path)?; let (digest, size) = crate::hash::digest_file(&path)?; - let pkginfo = crate::shims::read_pkginfo(&bytes) + // Read what the package says about itself out of the archive, rather + // than trusting what the build claimed on stdout (§10.1). + let pkginfo = crate::pkginfo::pkginfo_text(&bytes) .map_err(|e| Error::invalid(format!("{}: {e}", path.display())))?; - let buildinfo = crate::shims::read_buildinfo(&bytes).unwrap_or_default(); - let meta = parse_pkginfo(&pkginfo); + let meta = crate::pkginfo::parse_pkginfo(&pkginfo); + // `.BUILDINFO` is what the world snapshot is built from. Absent is not + // fatal — the snapshot is then simply empty for this package — but a + // present-but-unparseable one would be a lie we should not swallow. + let buildinfo = crate::pkginfo::buildinfo_text(&bytes).unwrap_or_default(); let sig = path.with_extension("pkg.tar.zst.sig"); pkgs.push(CollectedPkg { - name: meta.get("pkgname").cloned().unwrap_or_default(), - version: meta.get("pkgver").cloned().unwrap_or_default(), - arch: meta.get("pkgarch").cloned().unwrap_or_else(|| ctx.cfg.arch.clone()), + name: meta.name.clone(), + version: meta.version.clone(), + arch: if meta.arch.is_empty() { ctx.cfg.arch.clone() } else { meta.arch.clone() }, path: path.display().to_string(), digest, size, signature_path: sig.exists().then(|| sig.display().to_string()), - depends: meta_multi(&pkginfo, "depend"), - makedepends: meta_multi(&pkginfo, "makedepend"), - provides: meta_multi(&pkginfo, "provides"), - conflicts: meta_multi(&pkginfo, "conflict"), - installed: parse_installed(&buildinfo), + depends: meta.depends.clone(), + makedepends: meta.makedepends.clone(), + provides: meta.provides.clone(), + conflicts: meta.conflicts.clone(), + installed: crate::pkginfo::parse_installed(&buildinfo) + .into_iter() + .map(|i| (i.name, i.version)) + .collect(), }); } if pkgs.is_empty() { @@ -414,43 +422,3 @@ pub fn recipe_at(dir: &Path) -> Result<Recipe> { crate::recipe::recipe_from_tree(&files) } -fn parse_pkginfo(text: &str) -> std::collections::HashMap<String, String> { - let mut m = std::collections::HashMap::new(); - for line in text.lines() { - if let Some((k, v)) = line.split_once('=') { - m.insert(k.trim().to_string(), v.trim().to_string()); - } - } - m -} - -fn meta_multi(text: &str, key: &str) -> Vec<String> { - text.lines() - .filter_map(|l| l.split_once('=')) - .filter(|(k, _)| k.trim() == key) - .map(|(_, v)| v.trim().to_string()) - .collect() -} - -/// `.BUILDINFO` `installed =` block: ` name version arch sig` per line. -fn parse_installed(text: &str) -> Vec<(String, String)> { - let mut out = Vec::new(); - let mut in_block = false; - for line in text.lines() { - if line.trim_start().starts_with("installed") { - in_block = true; - continue; - } - if in_block { - if !line.starts_with(' ') && !line.starts_with('\t') { - in_block = false; - continue; - } - let mut it = line.split_whitespace(); - if let (Some(name), Some(version)) = (it.next(), it.next()) { - out.push((name.to_string(), version.to_string())); - } - } - } - out -} diff --git a/src/pkginfo.rs b/src/pkginfo.rs new file mode 100644 index 0000000..7ec8b83 --- /dev/null +++ b/src/pkginfo.rs @@ -0,0 +1,150 @@ +//! Reading `.PKGINFO` and `.BUILDINFO` out of a package archive (§10.1). +//! +//! A `.pkg.tar.zst` is a zstd-compressed tar with two plain-text metadata files +//! inside it. pacman reads these through libalpm; we do not link libalpm (no +//! FFI, no C toolchain dependency, §14), so this module parses the tar and the +//! text directly. That is not a shortcut — the format is a `key = value` file +//! with repeated keys, and a `.BUILDINFO` `installed =` block of +//! `name version arch signature` lines. Both are stable and documented, and +//! parsing them here is roughly eighty lines. +//! +//! This is production code, not harness code: the ingest step decides what the +//! index claims about a package, and what the world snapshot records, by reading +//! these two files. + +use std::io::Read; + +/// A package's own metadata, as `.PKGINFO` states it. +#[derive(Debug, Clone, Default, PartialEq, Eq)] +pub struct PkgInfo { + pub name: String, + pub version: String, + pub arch: String, + pub desc: String, + pub url: String, + pub license: Vec<String>, + pub groups: Vec<String>, + pub depends: Vec<String>, + pub makedepends: Vec<String>, + pub checkdepends: Vec<String>, + pub optdepends: Vec<String>, + pub provides: Vec<String>, + pub conflicts: Vec<String>, + pub replaces: Vec<String>, +} + +/// One entry of a `.BUILDINFO` `installed` block: a package that was present in +/// the build root. The signature field is optional in real files. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Installed { + pub name: String, + pub version: String, + pub arch: String, +} + +/// Extract one named member from a zstd-compressed tar. +fn member(bytes: &[u8], suffix: &[u8]) -> Result<String, String> { + let dec = zstd::Decoder::new(std::io::Cursor::new(bytes)).map_err(|e| e.to_string())?; + let mut ar = tar::Archive::new(dec); + for e in ar.entries().map_err(|e| e.to_string())? { + let mut e = e.map_err(|e| e.to_string())?; + if e.path_bytes().as_ref().ends_with(suffix) { + let mut s = String::new(); + e.read_to_string(&mut s).map_err(|e| e.to_string())?; + return Ok(s); + } + } + Err(format!("no {} in package", String::from_utf8_lossy(suffix))) +} + +/// `.PKGINFO` as raw text. +pub fn pkginfo_text(pkg_bytes: &[u8]) -> Result<String, String> { + member(pkg_bytes, b".PKGINFO") +} + +/// `.BUILDINFO` as raw text. Absent on some hand-built packages; callers decide +/// whether that is fatal. +pub fn buildinfo_text(pkg_bytes: &[u8]) -> Result<String, String> { + member(pkg_bytes, b".BUILDINFO") +} + +/// Parse `.PKGINFO`. Unknown keys are ignored rather than rejected: makepkg adds +/// fields over time and a new one must not stop us publishing. +pub fn parse_pkginfo(text: &str) -> PkgInfo { + let mut p = PkgInfo::default(); + for (k, v) in fields(text) { + match k { + "pkgname" => p.name = v.to_string(), + "pkgver" => p.version = v.to_string(), + "pkgarch" => p.arch = v.to_string(), + "pkgdesc" => p.desc = v.to_string(), + "url" => p.url = v.to_string(), + "license" => p.license.push(v.to_string()), + "group" => p.groups.push(v.to_string()), + "depend" => p.depends.push(v.to_string()), + "makedepend" => p.makedepends.push(v.to_string()), + "checkdepend" => p.checkdepends.push(v.to_string()), + "optdepend" => p.optdepends.push(v.to_string()), + "provides" => p.provides.push(v.to_string()), + "conflict" => p.conflicts.push(v.to_string()), + "replaces" => p.replaces.push(v.to_string()), + _ => {} + } + } + p +} + +/// Parse the `.BUILDINFO` `installed` block. +/// +/// The first entry shares the line with the key — `installed = glibc 2.39-1 +/// x86_64 -` — and the rest are indented under it, so the header line has to be +/// parsed as well as skipped. Dropping it would silently lose one dependency from +/// every snapshot, which is exactly the kind of gap that makes staleness lie. +pub fn parse_installed(text: &str) -> Vec<Installed> { + let mut out = Vec::new(); + let mut in_block = false; + for line in text.lines() { + if line.trim_start().starts_with("installed") { + in_block = true; + // Everything after `installed =` on this line is the first entry. + if let Some(rest) = line.split_once('=') { + push_entry(&mut out, rest.1); + } + continue; + } + if !in_block { + continue; + } + // The block is indented; the first unindented line ends it. + if !line.starts_with(' ') && !line.starts_with('\t') { + in_block = false; + continue; + } + push_entry(&mut out, line); + } + out +} + +fn push_entry(out: &mut Vec<Installed>, line: &str) { + let mut it = line.split_whitespace(); + if let (Some(name), Some(version)) = (it.next(), it.next()) { + out.push(Installed { + name: name.to_string(), + version: version.to_string(), + arch: it.next().unwrap_or_default().to_string(), + }); + } +} + +/// `key = value` pairs, with repeated keys preserved in order. +fn fields(text: &str) -> impl Iterator<Item = (&str, &str)> { + text.lines().filter_map(|l| l.split_once('=')).map(|(k, v)| (k.trim(), v.trim())) +} + +/// All values of one key. +pub fn values_of(text: &str, key: &str) -> Vec<String> { + fields(text) + .filter(|(k, _)| *k == key) + .map(|(_, v)| v.to_string()) + .collect() +} diff --git a/src/shims/mod.rs b/src/shims/mod.rs index 5560aa3..754bbb4 100644 --- a/src/shims/mod.rs +++ b/src/shims/mod.rs @@ -542,38 +542,16 @@ pub fn repo_add(args: &[String], _m: &Manifest) -> Result<i32, String> { Ok(0) } -/// Pull `.PKGINFO` out of a `.pkg.tar.zst` (§10.1: plain text in a tar, no -/// libalpm needed). +/// Pull `.PKGINFO` out of a `.pkg.tar.zst`. The real parsing lives in +/// `crate::pkginfo`, which the pipeline also uses — the shim and the production +/// path must agree about what a package says about itself, or a test that passes +/// here would not mean anything. pub fn read_pkginfo(pkg_bytes: &[u8]) -> Result<String, String> { - let dec = zstd::Decoder::new(std::io::Cursor::new(pkg_bytes)).map_err(|e| e.to_string())?; - let mut ar = tar::Archive::new(dec); - for e in ar.entries().map_err(|e| e.to_string())? { - let mut e = e.map_err(|e| e.to_string())?; - let name = e.path_bytes().to_vec(); - if name.ends_with(b".PKGINFO") { - use std::io::Read; - let mut s = String::new(); - e.read_to_string(&mut s).map_err(|e| e.to_string())?; - return Ok(s); - } - } - Err("no .PKGINFO in package".into()) + crate::pkginfo::pkginfo_text(pkg_bytes) } pub fn read_buildinfo(pkg_bytes: &[u8]) -> Result<String, String> { - let dec = zstd::Decoder::new(std::io::Cursor::new(pkg_bytes)).map_err(|e| e.to_string())?; - let mut ar = tar::Archive::new(dec); - for e in ar.entries().map_err(|e| e.to_string())? { - let mut e = e.map_err(|e| e.to_string())?; - let name = e.path_bytes().to_vec(); - if name.ends_with(b".BUILDINFO") { - use std::io::Read; - let mut s = String::new(); - e.read_to_string(&mut s).map_err(|e| e.to_string())?; - return Ok(s); - } - } - Err("no .BUILDINFO in package".into()) + crate::pkginfo::buildinfo_text(pkg_bytes) } fn parse_pkginfo(s: &str) -> (String, String, String, String) { diff --git a/tests/world.rs b/tests/world.rs new file mode 100644 index 0000000..8229d62 --- /dev/null +++ b/tests/world.rs @@ -0,0 +1,226 @@ +//! `.PKGINFO` / `.BUILDINFO` parsing and the world snapshot (§10.1, I12). +//! +//! The world snapshot is the whole basis of staleness: "would rebuilding this +//! change what a consumer gets?" only means something if we recorded, at build +//! time, the exact set of our packages the build saw. Two properties matter and +//! are tested here — that the record comes from the archive rather than from +//! anything the build asserted about itself, and that it is intersected with our +//! own index **at ingest time**, because an unfiltered `.BUILDINFO` would make +//! every package permanently stale (Arch never stops moving) and the Attention +//! page would be noise forever. + +mod common; + +use aur_build::db; +use aur_build::pipeline; +use aur_build::pkginfo; +use common::*; + +/// Build a real `.pkg.tar.zst`: zstd-compressed tar with the two metadata files +/// inside, exactly as makepkg lays them out. `None` for either means the file is +/// absent from the archive. +fn make_archive(dir: &std::path::Path, name: &str, pkginfo: Option<&str>, buildinfo: Option<&str>) -> std::path::PathBuf { + let path = dir.join(format!("{name}.pkg.tar.zst")); + let enc = std::io::BufWriter::new(std::fs::File::create(&path).unwrap()); + let mut enc = zstd::Encoder::new(enc, 3).unwrap(); + { + let mut ar = tar::Builder::new(&mut enc); + let mut add = |rel: String, body: &str| { + let mut h = tar::Header::new_gnu(); + h.set_size(body.len() as u64); + h.set_mode(0o644); + h.set_mtime(0); + ar.append_data(&mut h, rel, std::io::Cursor::new(body.as_bytes())).unwrap(); + }; + if let Some(p) = pkginfo { + add(format!("{name}/.PKGINFO"), p); + } + if let Some(b) = buildinfo { + add(format!("{name}/.BUILDINFO"), b); + } + add(format!("{name}/usr/bin/{name}"), "#!/bin/sh\necho hi\n"); + ar.finish().unwrap(); + } + enc.finish().unwrap(); + path +} + +const PKGINFO: &str = "\ +pkgname = plain-make +pkgbase = plain-make +pkgver = 1.0-1 +pkgarch = x86_64 +pkgdesc = a synthetic package +url = https://example.invalid/plain-make +license = MIT +license = Apache +depend = glibc +depend = openssl>=1.1 +makedepend = cmake +provides = make-thing +conflict = other-make +"; + +const BUILDINFO: &str = "\ +format = 2 +pkgname = plain-make +pkgbase = plain-make +pkgver = 1.0-1 +packager = builduser +builddate = 1700000000 +installed = glibc 2.39-1 x86_64 - + gmp 6.3.0-1 x86_64 - + plain-make 0.9-1 x86_64 - +sigfile = /dev/null +"; + +#[test] +fn pkginfo_fields_are_parsed_from_the_archive_itself() { + let dir = tempfile::tempdir().unwrap(); + let path = make_archive(dir.path(), "plain-make", Some(PKGINFO), Some(BUILDINFO)); + let bytes = std::fs::read(&path).unwrap(); + + let text = pkginfo::pkginfo_text(&bytes).expect(".PKGINFO is in the archive"); + assert!(text.contains("pkgname = plain-make")); + let meta = pkginfo::parse_pkginfo(&text); + assert_eq!(meta.name, "plain-make"); + assert_eq!(meta.version, "1.0-1"); + assert_eq!(meta.arch, "x86_64"); + assert_eq!(meta.desc, "a synthetic package"); + // Repeated keys are lists, not last-one-wins. + assert_eq!(meta.license, vec!["MIT", "Apache"]); + assert_eq!(meta.depends, vec!["glibc", "openssl>=1.1"]); + assert_eq!(meta.makedepends, vec!["cmake"]); + assert_eq!(meta.provides, vec!["make-thing"]); + assert_eq!(meta.conflicts, vec!["other-make"]); +} + +#[test] +fn the_buildinfo_installed_block_is_parsed_line_by_line() { + let dir = tempfile::tempdir().unwrap(); + let path = make_archive(dir.path(), "plain-make", Some(PKGINFO), Some(BUILDINFO)); + let bytes = std::fs::read(&path).unwrap(); + let text = pkginfo::buildinfo_text(&bytes).unwrap(); + let installed = pkginfo::parse_installed(&text); + assert_eq!( + installed.iter().map(|i| (i.name.clone(), i.version.clone())).collect::<Vec<_>>(), + vec![ + ("glibc".to_string(), "2.39-1".to_string()), + ("gmp".to_string(), "6.3.0-1".to_string()), + ("plain-make".to_string(), "0.9-1".to_string()), + ], + "the installed block must come through exactly" + ); + // The block ends at the first unindented line; `sigfile` is not an install. + assert!(!installed.iter().any(|i| i.name == "sigfile")); +} + +#[test] +fn a_package_without_a_pkginfo_is_refused_not_defaulted() { + // Ingest decides what the index claims about a package. Guessing a name from + // the filename would let a mislabeled artifact into a signed repo. + let dir = tempfile::tempdir().unwrap(); + let path = make_archive(dir.path(), "mystery", None, Some(BUILDINFO)); + let bytes = std::fs::read(&path).unwrap(); + assert!(pkginfo::pkginfo_text(&bytes).is_err(), "an archive with no .PKGINFO must not parse"); + // And a truncated archive is an error too, not an empty success. + assert!(pkginfo::pkginfo_text(b"not even a zstd stream").is_err()); +} + +#[test] +fn the_world_snapshot_is_intersected_with_our_index_at_ingest_time() { + // §10.1 / I12. The fixture's build root contains glibc, pacman, binutils and + // plain-make; only plain-make is ours, and only plain-make may be recorded. + let (env, fx) = env_with_fixture("plain-make"); + // The first build has no world of ours to record — nothing we publish exists + // yet. That is the honest answer, not an empty lie about glibc. + publish(&env, "plain-make"); + let first = world_of_last_build(&env); + assert!(first.is_empty(), "nothing of ours existed for the first build: {first:?}"); + + // Now plain-make is in the index, so a later build records it and nothing + // else. A real chroot with our repo enabled has the previous version of the + // package installed; the manifest says the same. + let mut manifest = fx.manifest_json(); + manifest["installed"] = serde_json::json!([ + { "name": "glibc", "version": "2.39-1", "arch": "x86_64" }, + { "name": "pacman", "version": "6.1.0-1", "arch": "x86_64" }, + { "name": "binutils", "version": "2.42-1", "arch": "x86_64" }, + { "name": "plain-make", "version": "1.0-1", "arch": "x86_64" } + ]); + std::fs::write(&fx.manifest, serde_json::to_string(&manifest).unwrap()).unwrap(); + fx.bump(&[("pkgver", "3.0")]); + publish(&env, "plain-make"); + let members = world_of_last_build(&env); + assert!(members.iter().any(|m| m.pkgbase == "plain-make"), "our own package belongs in the world: {members:?}"); + for foreign in ["glibc", "pacman", "binutils"] { + assert!( + !members.iter().any(|m| m.pkgbase == foreign), + "{foreign} is not ours and must not be in the snapshot — an unfiltered world makes every package permanently stale" + ); + } + // And the snapshot is attached to the build, not computed later. + assert_eq!( + env.query_i64("SELECT count(*) FROM build WHERE state='succeeded' AND world_snapshot_id IS NULL", &[]), + Some(0), + "I12: a succeeded build must have a recorded world" + ); +} + +#[test] +fn a_split_pkgbase_is_one_approval_and_many_index_rows() { + // §3: one recipe, several packages, one human decision. Every package the + // build produced gets its own index entry and its own artifact. + let (env, _fx) = env_with_fixture("split-pkgbase"); + publish(&env, "split-pkgbase"); + let rows: Vec<String> = env + .db + .read(|c| { + let mut st = c.prepare( + "SELECT p.name, p.version, p.artifact_id FROM package p + JOIN release r ON r.id = p.release_id + WHERE p.state='in_index' ORDER BY p.name", + )?; + let out = st + .query_map([], |r| Ok(format!("{} {} art={:?}", r.get::<_, String>(0)?, r.get::<_, String>(1)?, r.get::<_, Option<i64>>(2)?)))? + .filter_map(|x| x.ok()) + .collect(); + Ok(out) + }) + .unwrap(); + assert!(rows.len() >= 2, "a split pkgbase should produce several index rows: {rows:?}"); + assert!( + rows.iter().all(|r| r.contains("art=Some")), + "every index row needs its own artifact: {rows:?}" + ); + // One approval, however many packages came out of it. + assert_eq!(env.query_i64("SELECT count(*) FROM approval", &[]), Some(1)); + assert_eq!(env.query_i64("SELECT count(*) FROM release", &[]), Some(1)); +} + +fn publish(env: &Env, name: &str) { + aur_build::watch::detect::check_pkgbase(&env.cfg, &env.db, name).unwrap(); + let c = aur_build::review::candidates::pending_candidates(&env.db).unwrap().remove(0); + let dd = aur_build::review::diff::render_and_store(&env.db, &env.cfg, &c).unwrap(); + let c = aur_build::review::candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap(); + aur_build::review::approve::approve(&env.db, "t", c.id, &c.identity_hash, &dd, None).unwrap(); + let c = aur_build::review::candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap(); + let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap(); + pipeline::run(&env.cfg, &env.db, &id).unwrap(); +} + +fn world_of_last_build(env: &Env) -> Vec<db::WorldMember> { + let json: String = env + .db + .read(|c| { + Ok(c.query_row( + "SELECT w.members_json FROM world_snapshot w + JOIN build b ON b.world_snapshot_id = w.id + ORDER BY b.rowid DESC LIMIT 1", + [], + |r| r.get(0), + )?) + }) + .unwrap(); + serde_json::from_str(&json).unwrap() +} |
