| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
| |
Stripped every comment that described what an item does, documented its
arguments or fields, or cited the design docs (§n, I-n, m-n, decision n).
2247 comments down to 83.
What survives: the section dividers that segment the large modules, the
secret-handling warnings, the agent wire-frame directions, and the few notes
without which the code they attach to reads as redundant, reorderable, or
unsound.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Every module-level `//!` header is gone, and the comments that remained
either re-explained the line below them or had grown into paragraphs.
Density went from one comment line per 6.7 lines of code to one per 10.
827 insertions against 2194 deletions across 86 files.
What survived: the invariants (I1-I12), the design cross-references into
DESIGN.md, and the notes recording a bug that was found and fixed — those
are the comments that carry weight, because they answer a question the
code cannot answer about itself. What did not: restating a function
signature in prose, and narration of the statement underneath.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The enum makes the impossible unrepresentable, but two things survive any type:
a field that is present and empty, and an assertion the type leaves defaulted on
purpose. `Config::validate` catches both, and it runs at startup — before the
watcher, the dispatcher or the UI are up and looking healthy — and again where a
backend is constructed, so nothing that builds one can skip it.
The one that matters is the workspace. `Run` frames carry a hub-side working
directory and the srcdir is never shipped to the sandbox, so a `remote` backend
on a machine that does not share the hub's filesystem would fail in `makepkg`
with a missing directory — and, worse, would *succeed* in the case nobody wants:
quietly building untrusted code on the hub. So a remote or agent-sandbox config
must say `"shared_workspace": true`, and the refusal says why rather than just
naming the field. Loopback needs no assertion because it shares the filesystem by
construction, which is also why it stays the zero-config default.
Empty `listen`, `token`, `api`, `namespace`, `bearer` and `image` are each refused
by name. Two tests drive the compiled binary rather than the library, because a
guard that only exists as a callable function is a guard the CLI can walk past.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`sandbox_backend` was a free-form string and `backend_for` matched it with
`_ => loopback`. So `sandbox_backend = "kata"` — a real, intended backend,
documented in the design — meant "run the untrusted PKGBUILD as the hub's own
user", and nothing anywhere said so. There was also no validation of any kind in
the crate: an empty `agent_token` with a remote backend, or a missing listen
address, parsed fine and failed later as something else.
The four flat fields become one tagged `sandbox` object with three kinds:
`loopback` (needs nothing, still the default, so every config on disk keeps
working), `remote` (listen + token), and `agent-sandbox` (api, namespace,
bearer, image, listen, token). Required fields are required by the type, an
unknown kind is a parse error naming the valid set, and `deny_unknown_fields`
means a misspelled field is named rather than read as absent. `agent-sandbox`
parses and is refused at backend construction until it is wired up — a valid
kind that is not implemented is an error, never a substitution.
Retired keys are refused when they carry intent: a config saying
`sandbox_backend: "remote"` errors and names the replacement shape, because
quietly reinterpreting it as loopback is the bug being removed. A config saying
`"loopback"` with the empty strings `init` wrote is noise, not intent, and loads
unchanged. The token and the cluster bearer are redacted in `Debug`, so a config
that reaches a log line cannot leak them.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`--root` names a directory and `init` writes config.json inside it, so the root
was already named by where the config lived. The `root` field in the file was
treated as a second source of truth instead: a relative one was re-joined onto
the config's own directory, and `init` saved whatever it had been handed. So
`--root runtime` wrote `"root": "runtime"`, and every command after `init`
resolved it to `runtime/runtime/` — a second tree with its own empty database,
while `init` had created and migrated the first one. The user-visible half was a
path like `runtime/runtime/repo/aur-build/os/x86_64/…` in an error message.
Compounding it, the CLI fell back to a default config whenever loading failed, so
a typo'd `--root` produced a fresh empty server that answered every command as
though it were the one you meant. `load` now sets the root to the directory it
found the config in, absolutized, and a missing config is an error for every
command except `init` — the only one that runs before one exists.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The kata lease path is composition, not a new protocol: acquire mints a
rendezvous nonce, asks a Provisioner for a sandbox pointed at this hub,
and leases only the dial-in whose hello carries that nonce back. A box
that never dials in is a TTL expiry — the same vocabulary every other
failure here speaks (I5) — and a stray box that greets with a nonce
nobody ordered is dropped unread, never leased.
Two payload shapes are constructed as pure, unit-tested functions
because both are real targets: an agent-sandbox-style Kubernetes CR
(runtimeClass kata, activeDeadlineSeconds so the orchestrator enforces
the TTL even if the hub dies) and a nerdctl/containerd argv for hosts
without a cluster. The K8s provisioner is real ureq code exercised only
by the gated live tier, which skips with a printed note wherever
/dev/kvm or AUR_KATA_API is absent — the recorded-skip convention, not
a silent pass.
The rendezvous and TTL logic runs for real on any machine via
LocalAgentProvisioner: a real sandbox-agent process, real frames, real
nonce matching, no VM. That is the same honesty as the loopback
backend — the interface is under test, not a mock of it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The seam from the previous commits only had one body. This adds the
other one: a sandbox-agent binary that dials the hub (outbound
rendezvous — the hub never needs a route into an untrusted box), serves
Run/Put/Get frames over length-prefixed JSON, streams the child's
stdout/stderr as they fill, and dies — taking its child with it — when
the connection drops or its TTL expires. The TTL watchdog is the
backstop under every leak: hub crash, partition, a forgotten destroy.
Hub side, RemoteBackend implements the same SandboxBackend: acquire
waits for a dial-in and verifies the shared token and profile before a
lease exists; a vanished sandbox fails the step, which is already the
shape of an expired lease (I5), so the remote path adds no new failure
vocabulary. Run frames carry the hub's child environment, so the §16a
shim protocol reaches remote children exactly as local ones — which is
what makes the end-to-end test honest: a real build, real frames, real
log streaming into the SSE-tailed file, no root and no container.
Workspace sync over the wire is deliberately not here: Run carries a
hub-side cwd, honest for loopback-shaped deployments and this test
tier, and the module says so rather than pretending.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The chroot step existed to run mkarchroot/makechrootpkg, whose sudo
requirement was the whole reason a build had to run on the hub under
root-adjacent rules. The sandbox model makes the chroot redundant: the
sandbox boots from a base that already carries the official packages,
and step 2 now provisions it with a lease manifest instead — every
dependency we publish, pinned to the exact version and digest of the
artifact the index serves. The hub re-hashes every blob before staging
it, installs with pacman -U (no -Sy, no live resolution, no mirror at
build time), and the sandbox's own pacman -Q must confirm the pinned
world landed before a build may start. A byte that hashes differently,
or a world that drifted, fails closed.
The build step is now plain makepkg -c -f: no -s (dependencies arrive
installed; resolving at build time is what the pinning model forbids)
and no -si (ingest signs). mkarchroot/makechrootpkg are gone from the
pipeline and the config; their shims stay as stand-ins for the real
devtools so the shim protocol itself remains exercised. The shim pacman
grew a real fake installed-database: -U refuses bytes that do not hash
to the digest their name claims, -Q reports what landed, so the world
check is a test and not a no-op.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
type
m-5. `mark_approved_but_unbuilt` was a function that did nothing, called from
the failure path with a comment explaining that it did nothing. The mechanism is
real — a failed build leaves the accepted pointer alone, and "approved, build
failed, index still serving the old version" is what the derived query reads
back — but a no-op in the failure path is a trap for whoever traces a build
failure at 3am. Deleted; the explanation moved to the call site that needs it.
m-6. The step loop extended the lease by a hardcoded 90 seconds while `Config`
carried `lease_secs`, so an operator who raised the lease got leases that were
silently reset to 90s after the first step.
m-8. Dead parameters and `let _ =` debris: `upstream::run` took a `Db` it never
used (and a `let _ = local;` after the value's only use), `risk::assess` took a
`Pkgbase` it never used, `accepted_pins` took a `Db`, `detect::schedule_next`
took a `Pkgbase` it discarded, `diff::version_delta` computed a `vercmp` and
threw the answer away, and two HTTP handlers took arguments they ignored. All
gone, with the callers following.
m-11. `schedule_next` re-queried the subscription for `poll_interval_secs` that
its caller had read moments earlier to decide whether the pkgbase was paused —
two queries, and two chances to get different answers. The interval is now an
argument, and the scheduler's own tick (which already holds the row) was already
doing it the right way.
m-15. `Config::load`/`save`/`ensure_dirs` returned `anyhow::Result` while the
rest of the crate returns `error::Error`, which put two vocabularies on either
side of one boundary and turned "there is no config yet, run init" — the one
thing a caller can branch on — into an opaque string. They return the crate's
error now; `main` keeps `anyhow` at the CLI edge, where it belongs.
m-19. `skip_declared` was hardcoded `true` for VCS entries, so the field that
means "the recipe gave us no checksum to trust" also meant "this is a git
source", and a new `-git` source was rendered to a reviewer as
`sha256sums=SKIP` — a warning about a recipe that had done nothing wrong. The
field now means one thing everywhere, `SourceDigest::is_vcs()` says which
integrity mechanism protects an entry, and the diff panel prints "pinned commit"
for those.
n-6. `recipe_at` was `pub` for no reason; it is `pub(crate)`.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Ran the gated tier as far as this host allows, with real devtools, real root and
real network, and it paid for itself immediately.
`mkarchroot` has no `-N` option. The pipeline was calling `mkarchroot -N <seed>`;
the shim ignored the unknown flag, so every test passed, and the real tool
answered with a usage error. The first real chroot build would have died on its
first step in a code path the shim harness structurally cannot exercise. The
seed's package list is now configuration (`mkarchroot_args`, default `base`) and
the call follows the real usage: `mkarchroot <working-dir> <packages...>`.
What else the attempt verified, with the real binaries rather than the shims: a
generated GPG key detached-signed the artifact the pipeline produced and
`gpg --verify` reported a good signature; real `repo-add -s -k` built and signed
a pacman database over it, and that signature verified too. So "both the packages
and the .db are signed" now rests on real crypto.
Where it stops: `mkarchroot <dir> base` downloaded and installed the base set into
the chroot (437 MB, 14 packages, install scripts ran) and then failed in
devtools' init stage with `Failed to parse --bind(-ro)= argument` from
systemd-nspawn 262 inside an unprivileged container. DECISIONS.md records exactly
what was run, what passed, what failed and why, and what therefore remains
modelled rather than crossed — a silent skip would have hidden all of the above,
including the flag bug.
Also fixes the I9 test's expectation: a refused build is an `Outcome::Failed` at
the `collect` step, not an `Err` from the runner, which is the correct shape (the
build failed closed and said why) and the test now asserts the step name.
171 tests pass, clippy clean.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
README and the invariant index
Three things.
**A real hole, closed.** `collect` scans the build's srcdir for
`*.pkg.tar.zst`, and `ingest` copies whatever those paths resolve to into the
content-addressed store — from where the bytes are served from our repo and
signed with our key. The paths are generated by our own scan, but their *targets*
are not: a PKGBUILD that drops a symlink called `evil.pkg.tar.zst` pointing at
the signing keyring, the database, or anyone's home directory would have its
target copied in, published and signed by us. The chroot is supposed to be the
layer that prevents that, and the chroot tier is gated — but two protection
layers must not be load-bearing on each other, and the control plane should not
depend on isolation for the safety of its own secrets.
`collect` now rejects symlinks and rejects anything whose canonicalized target
escapes the build's own staging directory, failing the build closed with the path
in the message. `i9_a_build_cannot_smuggle_bytes_in_from_outside_its_own_staging_dir`
acts the attack out — the shim plants a symlink to the database file — and
asserts the build fails, the store is byte-for-byte untouched, and nothing
publishes. This is the last §2 invariant that had no named test; docs/INVARIANTS.md
says plainly which part of I9 this covers and which part belongs to the gated
chroot tier.
**README.md**, written for the person who has to operate this at 3am: the rule
everything else follows, the quick start, the layout, how the shim harness makes
the whole pipeline testable without root or network, the ops commands, the route
table, and the §14 constraints stated as the hard edges they are.
**docs/INVARIANTS.md**, mapping I1-I12 to the named tests that hold them, with
corroborating tests listed, and an explicit note on the two invariants enforced
by the schema (the partial unique index for I7, the append-only triggers for
I10/I7) so a future code path cannot forget them.
Also recorded in DECISIONS.md: metrics served without a session and why,
retention recording a purge instead of deleting the row, and the real-chroot tier
being explicitly skipped with what stands in for it and how to actually run it.
.gitignore already covered .pi/ but the goal-tracker files were tracked from
before the rule existed; untracked now so they stop appearing in every diff.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(§8.4, I5)
The crash-resume invariant was only ever simulated before: an in-process fault
hook returns an error, and an error can be caught, unwound and cleaned up by
accident. So the shims gained AUR_SHIM_KILL_PARENT — the named tool SIGKILLs
the process running the pipeline, mid-step, with no Drop and no atexit.
The test spawns the real aur-build binary, watches it die of SIGKILL inside
the build step, and then asserts the things that matter:
- the database is intact, because no transaction ever spans a build step
- the completed steps are checkpointed succeeded and the running one is
recorded running
- after the lease expires the reaper requeues it and marks the step
interrupted
- resuming publishes exactly one release, and the shim invocation log proves
mkarchroot ran once, makechrootpkg twice (crash + resume, not twice per
attempt) and repo-add once
**This found a real bug.** reap_expired only matched state='leased', but a
worker sets state='running' the moment it starts a step, so a process that
dies mid-step leaves a running row — and every real crash would have been
stranded forever. The reaper now reaps leased and running.
Also §8.4's other half, which was a comment rather than a feature: a failed
build must not leave the old version looking healthy. db::approved_but_unbuilt
finds approvals whose build failed and never published, and Attention and the
package page now say 'v2 approved, build failed, index still serving v1' with
a link to the log. Retrying is an explicit, audited POST, not something the
system does to itself.
Cancellation is asserted to be cooperative at a step boundary: a cancelled
build runs no steps, publishes nothing, and is not counted as a failure.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The harness that makes the rest of this developable. Six real binaries
named exactly like the tools the pipeline shells out to, sharing one
shim module, driven entirely by environment so no production code path
is test-only:
AUR_SHIM_DIR where invocations are recorded (jsonl)
AUR_SHIM_MANIFEST the fixture manifest to obey
AUR_SHIM_FAIL optional tool forced to fail
makechrootpkg emits real .pkg.tar.zst files with .PKGINFO and
.BUILDINFO (the full chroot world, which is why §10.1 filters it),
makepkg answers --printsrcinfo and --vercheck for Stage B, repo-add
rebuilds a gzip'd .db with %FILENAME%/%VERSION%/%SHA256SUM% DESC
entries, gpg writes a detached signature, mkarchroot creates a warm
root. Each one records its invocation so tests assert on what actually
ran.
testcorpus/ holds 17 fixtures, each a PKGBUILD plus a manifest with the
scripted outcome: plain-make, with-patch, install-hooks, skip-checksum,
split-pkgbase, build-fails, check-fails, missing-dep, dep-cycle,
epoch-bump, pkgrel-reset, downgrade, digest-drift, pin-drift,
git-sourced, git-submodules, unresolvable. The harness commits a fixture
into a real git repo standing in for AUR, materialises a local upstream
git repo for VCS fixtures, and swaps payload bytes for the drift cases.
Config.child_env is what puts the shims on PATH for child processes, so
the pipeline runs completely unmodified under test.
Part of P0 (DESIGN.md §17).
|
|
|
The §11 data model as four migrations, plus the §11a concurrency model:
one writer thread owning the write connection (mutations arrive as
closures over a crossbeam channel, so SQLITE_BUSY is not part of the
design) and thread-local read-only connections under WAL.
Invariants that are database guarantees rather than conventions:
I7 partial unique index -> at most one pending_review per pkgbase
I3 UNIQUE(pkgbase_id, identity_hash) -> no duplicate candidates
I10 audit table rejects UPDATE and DELETE by trigger
§16 current_accepted_release_id moves only by compare-and-swap
Also: vercmp + dependency-string parsing (ALPM algorithm, no libalpm),
hash helpers including recipe_hash over the whole AUR tree, the clock
helper that stamps every write, and the config/root layout.
Part of P0 (DESIGN.md §17).
|