| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The build step used to pass -si<key> through makechrootpkg, which meant
whatever machine ran the build had to hold the signing key - fine for a
chroot on the hub, disqualifying for a remote sandbox. The build now
produces unsigned bytes; ingest signs the exact bytes that entered the
store, with the same key and code path that signs the database, and a
gpg failure fails the build closed. verify() no longer checks for a
build-made signature: the meaningful guarantee moved to 'ingest produced
one or the build failed'. The shim makechrootpkg now only emits .sig
when -si is passed, like the real tool, so the suite cannot accidentally
test a signing path that no longer exists.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
m-7. `fsync_file` and `fsync_dir` opened, ignored every error, and returned Ok,
in the module whose entire guarantee is "fsync, then rename". A filesystem that
refused the sync — full, read-only, a network mount that had dropped — still
produced a successful publish whose database might not be on disk. They
propagate now, with the path and the cause.
m-10. `withdraw_release_in` set `state='withdrawn'` unconditionally, so
withdrawing twice reported success the second time while changing nothing, and
withdrawing a release that had never been live did the same. The write is a
compare-and-swap on `state='published'`, and a refusal names the state that was
actually there ("release 1 is withdrawn, not published: nothing to withdraw").
m-16. Artifacts are copied into the served tree before the DB commit, and when
the commit refused they stayed: files no index names, sitting in the directory
consumers download from. `publish` now tracks which files it created (a file
that already existed belongs to the release still being served and is never
touched) and removes them if the publish does not land.
m-14. `is_transient` treated every `Error::Io` as retryable, which made ENOSPC
and EACCES — plain `Io` — into three identical failures and a silent build.
Only the kinds that mean "ask again in a moment" retry now. This turned a test
that had been asserting the bug: it simulated a transient failure by pointing
`makechrootpkg` at a nonexistent path, which is a missing binary, not a flaky
network. That test now asserts the opposite (one attempt, no retries), and a new
one produces a genuinely transient failure the way production does — a `SKIP`
source whose bytes go unreachable after detection, cache dropped, so the
`sources` step fails over the fetch path and retries to the cap.
m-13. `random_hex` read `/dev/urandom` into a zeroed buffer, ignored every
error, and hashed it anyway. Since C-1 the session id is the whole credential,
so a failed read is now a refusal: `new_session()` returns `Option`, and the two
call sites answer 500 rather than mint a token derivable from the clock and a
counter.
m-9. The row-error policy is decided and applied: a row that cannot be read
fails the query instead of vanishing from the result (six `filter_map(|r|
r.ok())` sites, including the reaper's and the claimer's), and `setting_i64`
documents its own policy — absent means default, nonsense means default *and a
complaint*, because a typo that silently does nothing is worse than a knob that
refuses to apply.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Seven fields sat on `Config` next to `signing_key_id` and `bind`: a PATH
override, three shim protocol variables, a fault-injection point in the middle
of `publish()`, and two more shims could obey. m-9's complaint was not that they
exist — the shims are how I4, I5 and I9 are tested for real, and a mock would
have asserted the mock's own behaviour — but that nothing said which of these
was production and which was scaffolding, and the publish path carried a test
branch on every real publish.
They are one `TestHooks` submodule now, documented as what it is, and the whole
submodule is `#[cfg(feature = "test-support")]` — the same feature that already
gates the shims and the raw SQL escape hatch, and which only this crate's own
dev-dependency turns on. A production build has no `hooks` field, no shim
protocol in `child_env`, and no fault-injection branch in `publish()`; the
serialized config skips the section entirely when nothing is hooked, so a real
`config.json` never mentions any of it.
`TestHooks::is_empty()` names the state a real process runs in, and three tests
hold the line: the hook fields may be declared exactly once and only inside
`TestHooks`, every `publish_fault` read in `publish.rs` must sit behind the
feature gate, and a default config serializes without a trace of hooks.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
M-8 named four more machines after `build_state`, and each had the same defect
in miniature: `&str` constants, a writer that took any `&str`, and a rule that
lived only in the caller's discipline. They are `CandidateState`, `StepState`,
`ReleaseState` and `SubscriptionState` now, all parsed through one
`db::state_col` at the row boundary — a column value the code cannot name fails
the read rather than becoming a state it did not ask for.
The one that mattered is the review machine. `resolve_in(tx, id, &str)` would
move a candidate to any state from any state, so an approval racing a
rejection, or a stale worker resolving a review that had already been
superseded, silently overwrote what a human had decided — the direct route to
breaking I2 and I3 with no symptom anywhere. It is a compare-and-swap on
`CandidateState` now: a decided review is only ever frozen, never re-decided,
and a refusal names both states. `supersede_in` goes through it, so the freeze
cannot resurrect a superseded review either.
`StepState` gives I5 teeth. `begin_step` upserted over any existing checkpoint,
including one recorded `succeeded`, so a resume that asked to re-run a finished
step could rewrite the very row that told it to skip; the upsert now refuses to
touch a done checkpoint and `finish_step` is a CAS. The blocked path
(`running → pending`) and the reaper's `running → interrupted` are unchanged,
and both are in the table.
Two behaviour changes, both for the better and both tested: the UI's pause
button now says "orphaned: nothing to pause" instead of rewriting an orphaned
subscription back to a pausable state, and a step checkpoint that is already
done makes `begin_step` an error rather than a quiet overwrite.
Five tests in `tests/state_machine.rs` cover the review CAS in both directions,
the frozen checkpoint, the interrupted/blocked transitions, and the unknown
value in a candidate and a step row.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`publish.rs` had two static mutexes, each documented as *the* "one publish per
repo" guarantee — `PUBLISH_LOCK` taken at the top of `publish()`, `REPO_LOCK`
taken partway through and by `withdraw_package`. Either the second was
redundant or the guarantee was incomplete, and a reader could not tell which,
which is worse than either answer: the comment on `REPO_LOCK` claimed a
single-writer property that its own position in the function did not provide
(artifacts were already staged by then), and the comment on `PUBLISH_LOCK`
claimed it for a section that did not include the rename.
There is one lock now. `REPO_LOCK` is taken at the top of `publish()` and held
for the whole of it — staging, render, DB commit, rename, sign — which is the
sequence that must not interleave, and `withdraw_package` takes the same lock
for the same reason. The poison-recovery rule that belonged to both is stated
once, on the lock. `reconcile` is documented as the one rewriter that does not
take it, because it runs at startup before the dispatcher exists.
M-5 is a clarity defect rather than a live misbehaviour, so the guard is
structural: `tests/production_surface.rs` fails if `publish.rs` declares a
second serialization mutex, if `PUBLISH_LOCK` comes back, or if either index
writer stops taking the one that remains. A timing-based test would have been
the flaky kind and would not have proven anything the I4 and I8 crash tests do
not already prove.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
shims are test-only
`publish.rs::package_name` — the function that decides which package a built
artifact is, and therefore what the index says — called into the test harness
(`shims::read_pkginfo`) to read it. Worse, the shim module carried its own
`.PKGINFO` field parser alongside the real one in `pkginfo.rs`. Two parsers
that can drift is a supply-chain-shaped foot-gun in a system whose whole job
is provenance: the bytes we sign and the bytes the tests believed in would be
interpreted by different code, and a green shim test would not have meant the
pipeline read the package the same way.
There is now one parser. `package_name` uses `pkginfo::pkginfo_text` and
`pkginfo::parse_pkginfo`; the shim's `repo-add` renders its `DESC` entry from
the same `PkgInfo` the production code parses, so the fake tool and the real
pipeline cannot disagree about what a package calls itself. The duplicate
parser and the two wrapper functions are deleted, and the harness test reads
its artifact with `pkginfo` too.
The module itself is now test-only in the way the review asked for. `pub(crate)`
was not available — the shim binaries are separate crates that link the
library — so the equivalent enforcement is used instead: `shims` is compiled
out unless the `test-support` feature is on, and every shim binary declares
`required-features = ["test-support"]`. A production `cargo build --release`
neither builds the fakes nor links their code; `cargo build --bin makepkg`
says so out loud. `tests/production_surface.rs` covers the half the compiler
cannot see: no module in `src/` outside the harness may name `shims::`, and the
binaries must keep declaring the feature.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
writer stops handing out connections
Twelve modules outside `db/` contained hand-rolled SQL — 22 statements in
`ops.rs`, 17 in `approve.rs`, 15 in `candidates.rs`, 11 in `publish.rs`, and a
dozen more scattered through `watch`, `pipeline`, `http` — which meant the
blast radius of a schema change was "any module", and `db/` was a directory
rather than a boundary. The audit trail alone was defined in four places with
three different detail payloads.
Every statement now lives in `db/`. New modules `db::candidates` and
`db::approvals` own their tables (including the 21-column candidate select,
spelled once as `CANDIDATE_COLS` instead of four times); `db::queries` gains
the metrics reads, the retention reads and writes, the publish writes
(`insert_release_in`, `cas_accepted_release_in`, `remove_index_packages_in`),
the staleness reads and the source-cache lookups; `db::builds` gains
`set_release_in`. Where a mutation is a *decision* — the collapse rules, the
approval gate, the publish compare-and-swap — the decision stays where it was
and the statements are called through the transaction handle, so the atomicity
is unchanged and only the SQL moved.
`audit_in` is the in-transaction audit append, and `audit` is now a wrapper
over it: a decision and its audit row commit together or not at all, which is
what I10 actually claims.
Enforcement is two-layered, because one layer is a lie. `Writer::call`, `tx`
and `send` are `pub(crate)`, which keeps the crate's *users* out — the
integration tests and the shim binaries — but `pub(crate)` is crate-wide, so
on its own it would not stop `approve.rs` from writing SQL tomorrow. The layer
that does is `tests/schema_ownership.rs`: it walks `src/` and fails the build
if a statement literal or a rusqlite statement call appears outside `src/db/`.
It was checked against a deliberate violation. The test harness still needs to
construct states no typed API reaches, so the raw door exists but only under
the `test-support` feature, which nothing but this crate's own dev-dependency
enables; a production binary cannot see it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
One dispatcher thread, N workers, one crossbeam channel between them. The
dispatcher loop is reap -> cancel -> claim -> send, and the reaper runs first
on every pass including the first, so 'recover from a crash' and 'notice an
expired lease' are literally the same code path. There is no startup recovery
routine to get wrong.
- claim_batch does the SELECT and the UPDATE in one BEGIN IMMEDIATE
transaction. SQLite has no SKIP LOCKED, but with exactly one writer the
claim cannot race: nobody can see a row between the two statements.
- Backpressure is min(max_concurrent_builds - in_flight, disk headroom),
measured with statvfs. A build that cannot fit on disk stays queued instead
of filling the filesystem halfway through a compile.
- Retry policy (§8.4): transient failures (IO, HTTP) requeue up to
max_transient_attempts; a deterministic build failure is never retried, and
the release stays approved_but_unbuilt so the old version never looks
healthy. Tests assert attempt==1 for build-fails and attempt==3 for a
transient one.
- A superseded candidate sets cancel_requested on in-flight builds; the worker
stops at the step boundary rather than mid-step, which is what keeps the
checkpoints honest.
- Publish takes a process-wide lock so two workers cannot interleave the index
rewrite. The critical section is the db file rewrite, never a build.
- The deterministic build id makes re-enqueue an INSERT OR IGNORE no-op, so a
careless 'rebuild that again' is harmless.
tests/dispatch.rs drives the real threads: the pool takes a queued build all
the way to publication, a reaped build resumes from its checkpoints without
re-running makechrootpkg, and backpressure admits exactly one build per slot.
Serve now starts the pool alongside the watcher and the HTTP server.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
aur-build init/subscribe/detect/reviews/show/approve/reject/build/run/
builds/status/packages/audit. approve renders the review and then
approves with the hashes it just rendered, so the CLI cannot approve a
diff it did not show you; --identity/--diff reproduce the stale case
explicitly and a refusal exits 2 (the web equivalent is 409).
Approvals are now immutable at the schema level: migration 0006 rejects
UPDATE and DELETE on the approval table, because that row is the only
proof the system has of what a human actually looked at (§7.2, I10).
Publishing also refuses when no approval is reachable, including the
manual-rebuild path that inherits one.
10 tests, including two that drive the compiled binary end to end
against a file:// AUR fixture.
|
|
|
materialize -> plan -> chroot -> sources -> pkgver -> build -> collect ->
verify -> ingest -> publish, each checkpointed in build_step so a worker
that dies resumes at the next incomplete step without repeating the
expensive one (I5).
Step 0 materializes from the local mirror only and re-hashes the tree:
there is no path from 'AUR moved since the review' to 'we built it
anyway' (I3). Step 4 re-resolves a VCS pkgver and refuses when it no
longer matches the approved identity. Publish renders the index to .tmp,
fsyncs, commits release + package rows and the accepted pointer under a
compare-and-swap, then renames over the served database and signs it, so
a crash leaves the old index byte-for-byte intact (I4) and every index
entry traces back to an approval (I1). Ingest records the world
snapshot as the BUILDINFO installed set intersected with our own
packages, which is what keeps staleness meaningful (I12).
17 shim-driven end-to-end tests, including kill-mid-publish and
crash-resume, with no root, network, or real chroot.
|