diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:09:59 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:09:59 +0000 |
| commit | e757979f1a2afdbe7146066345bb9acd19d3b151 (patch) | |
| tree | 30d5f5fbccd25ea7bf01c5202684af463b74e7d3 /src/pipeline/steps.rs | |
| parent | 94c318f13264bb3c00a9f3057ba2e1aafb57c9e4 (diff) | |
| download | aur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.tar.gz aur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.zip | |
comments: say why, not what
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.
Diffstat (limited to 'src/pipeline/steps.rs')
| -rw-r--r-- | src/pipeline/steps.rs | 93 |
1 files changed, 34 insertions, 59 deletions
diff --git a/src/pipeline/steps.rs b/src/pipeline/steps.rs index 59c9a64..c19ac6b 100644 --- a/src/pipeline/steps.rs +++ b/src/pipeline/steps.rs @@ -1,8 +1,3 @@ -//! The ten pipeline steps (§8.1). -//! -//! Every step is idempotent and records its result in one short transaction; -//! the long-running child process happens outside any transaction (§11a). - use std::path::Path; use crate::db::{self, builds, model::*}; @@ -115,16 +110,14 @@ fn plan(ctx: &Ctx) -> Result<StepResult> { /// Step 2 — provision the sandbox with the pinned lease set. /// -/// The devtools chroot is gone: the sandbox boots from a base that already -/// carries the official packages, and everything *we* publish that this build -/// needs arrives as content-addressed blobs installed with `pacman -U`. The -/// step id stays `chroot` in the checkpoint table — the DB does not care what -/// the string means, and renaming would strand every existing checkpoint row. +/// The devtools chroot is gone: the sandbox boots from a base that already carries +/// the official packages, and everything *we* publish arrives as blobs installed +/// with `pacman -U`. The step id stays `chroot` so existing checkpoint rows are +/// not stranded. /// -/// Nothing is resolved at build time: the lease manifest is the plan, every -/// blob is re-hashed before it is staged, and the sandbox's own `pacman -Q` -/// must confirm the pinned world actually landed. A byte that hashes to -/// something else, or a world that drifted, fails the build closed. +/// Nothing is resolved at build time: the lease manifest is the plan, every blob +/// is re-hashed before it is staged, and the sandbox's own `pacman -Q` must confirm +/// the pinned world landed. fn provision(ctx: &Ctx) -> Result<StepResult> { let lease = lease_manifest(ctx)?; if lease.is_empty() { @@ -152,18 +145,15 @@ fn provision(ctx: &Ctx) -> Result<StepResult> { argv.extend(lease.iter().map(|e| format!("blob:{}", e.digest))); let out = sbx.run(&Cmd::new(argv), &mut |_| {})?; if !out.success() { - // A refused `-U` is almost always an incomplete closure: the lease set - // cannot satisfy itself. Its own error class, because "the sandbox - // lied about its world" must not look like "the sandbox broke". + // A refused `-U` is almost always an incomplete closure — "the sandbox lied + // about its world", not "the sandbox broke". return Err(Error::world_mismatch(format!( "{} -U refused the lease set: {}", ctx.cfg.pacman_bin, tail(&out.stderr) ))); } - // Fail-closed world check: every pinned entry must be present in the - // sandbox at exactly the pinned version. The world we approved is the - // world we build in, or nothing. + // Fail-closed world check: the world we approved is the world we build in. let q = sbx.run(&Cmd::new(vec![ctx.cfg.pacman_bin.clone(), "-Q".into()]), &mut |_| {})?; if !q.success() { return Err(Error::fail_closed(format!( @@ -197,9 +187,8 @@ fn provision(ctx: &Ctx) -> Result<StepResult> { Ok(StepResult::Done(Some(crate::hash::canonical_json(&world)?))) } -/// Lease a sandbox for a step, or report that the pool cannot fit one right -/// now. A full pool is not a broken build: the build blocks and waits, the -/// same way it waits for a dependency it publishes (§10.4). +/// Lease a sandbox for a step, or report that the pool cannot fit one. A full +/// pool blocks the build rather than failing it (§10.4). fn sandbox_or_wait( ctx: &Ctx, ) -> Result<Option<std::sync::Arc<dyn crate::sandbox::Sandbox>>> { @@ -223,9 +212,8 @@ struct LeasePkg { /// The lease manifest: every dependency this build needs that we publish, /// pinned to the exact version and digest of the artifact we serve. Official -/// packages are the base image's business — they arrive with the sandbox, and -/// pinning them is the hub's official-repo cache, not this step. Anything -/// unresolvable here would have been `plan()`'s problem (blocked, not built). +/// packages arrive with the sandbox; anything unresolvable here would have been +/// `plan()`'s problem. fn lease_manifest(ctx: &Ctx) -> Result<Vec<LeasePkg>> { let recipe = recipe_at(&ctx.srcdir)?; let mut wanted: Vec<String> = Vec::new(); @@ -248,8 +236,7 @@ fn lease_manifest(ctx: &Ctx) -> Result<Vec<LeasePkg>> { /// Step 3 — make sure every source we reviewed is on disk and hashes to what the /// candidate recorded. For a `SKIP` source this is the only verification that -/// exists, and it closes the window between "we hashed it at review time" and -/// "makepkg downloaded something else just now" (§8.1). +/// exists (§8.1). fn sources(ctx: &Ctx) -> Result<StepResult> { let digests: Vec<SourceDigest> = serde_json::from_str(&ctx.src.source_digests_json).unwrap_or_default(); let mut verified = 0; @@ -281,9 +268,8 @@ fn sources(ctx: &Ctx) -> Result<StepResult> { )))) } -/// Step 4 — the belt-and-braces assertion that what we build is what was -/// approved. If upstream moved between approval and build, fail with both -/// versions instead of silently shipping the new one (§8.1). +/// Step 4 — the belt-and-braces assertion that what we build is what was approved. +/// If upstream moved between approval and build, fail with both versions (§8.1). fn pkgver(ctx: &Ctx) -> Result<StepResult> { let recipe = recipe_at(&ctx.srcdir)?; let has_vcs = recipe.source_entries.iter().any(|s| s.is_vcs()); @@ -323,19 +309,17 @@ fn pkgver(ctx: &Ctx) -> Result<StepResult> { } /// Step 5 — `makepkg -c -f` in the provisioned sandbox, with the log going to -/// the file the SSE tail reads. No `-s`: the lease set is already installed, -/// and a build that resolves dependencies at build time is exactly what the -/// pinning model forbids. No `-si`: the sandbox never holds the signing key; -/// ingest signs hub-side. +/// the file the SSE tail reads. No `-s`: the lease set is already installed, and +/// resolving dependencies at build time is what the pinning model forbids. No +/// `-si`: the sandbox never holds the signing key. fn build(ctx: &Ctx) -> Result<StepResult> { let argv = vec![ctx.cfg.makepkg_bin.clone(), "-c".into(), "-f".into()]; let sbx = match sandbox_or_wait(ctx)? { Some(s) => s, None => return Ok(StepResult::Blocked(vec!["sandbox-pool".into()])), }; - // Capture the child's output into the build log regardless of outcome — - // the sandbox streams it here as it arrives, and the SSE tail reads the - // same file. + // The sandbox streams the child's output here as it arrives; the SSE tail + // reads the same file. if let Some(parent) = ctx.log.parent() { let _ = std::fs::create_dir_all(parent); } @@ -376,16 +360,12 @@ fn collect(ctx: &Ctx) -> Result<StepResult> { .filter(|p| p.to_string_lossy().ends_with(".pkg.tar.zst")) .collect(); entries.sort(); - // I9: the build is untrusted. In production it runs in a chroot, but the - // control plane must not *depend* on that for its own safety. Everything - // below takes a path that a PKGBUILD could have arranged to exist in the - // srcdir, and the next step copies whatever that path points at into the - // content-addressed store — from where it is served from our repo and signed - // with our key. A symlink to the signing keyring, the database, or anyone's - // home directory would otherwise become a signed artifact we publish. So: - // no symlinks, and the resolved target must live inside this build's own - // staging directory. Anything else fails the build closed. - let staging_root = ctx.staging.canonicalize()?; + // I9: the build is untrusted, and the control plane must not *depend* on the + // sandbox for its own safety. Everything below takes a path a PKGBUILD could + // have arranged to exist in the srcdir, and the next step copies whatever it + // points at into the store, from where we serve and sign it. So: no symlinks, + // and the resolved target must live inside this build's staging directory. + let staging_root = ctx.staging.canonicalize()?;; for path in entries { if std::fs::symlink_metadata(&path).map(|m| m.file_type().is_symlink()).unwrap_or(true) { return Err(Error::fail_closed(format!( @@ -409,8 +389,7 @@ fn collect(ctx: &Ctx) -> Result<StepResult> { .map_err(|e| Error::invalid(format!("{}: {e}", path.display())))?; 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. + // fatal; present-but-unparseable 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 { @@ -436,14 +415,12 @@ fn collect(ctx: &Ctx) -> Result<StepResult> { } let collect = Collect { packages: pkgs.clone() }; collect.save(&ctx.collect_path)?; - // A split pkgbase is one approval and N index entries (§3). ctx.log_line(&format!(" collected {}", pkgs.iter().map(|p| format!("{}-{}", p.name, p.version)).collect::<Vec<_>>().join(", "))); Ok(StepResult::Done(Some(crate::hash::hex_str(&serde_json::to_string(&pkgs)?)))) } /// Step 7 — dependencies satisfiable, no downgrade. Signature checking is not -/// here: the build no longer signs (the sandbox never sees the key), so the -/// signature is made at ingest, after these checks pass. +/// here: the sandbox never sees the key, so the signature is made at ingest. fn verify(ctx: &Ctx) -> Result<StepResult> { let collect = Collect::load(&ctx.collect_path)?; let ours = db::our_package_names(&ctx.db)?; @@ -486,10 +463,8 @@ fn ingest(ctx: &Ctx) -> Result<StepResult> { std::fs::copy(from, &dest)?; } p.path = dest.display().to_string(); - // Hub-side signing: the build environment never holds the key, so the - // signature is made here, over the exact bytes that just entered the - // store, by the same key that signs the database. A gpg failure fails - // the build closed — an unsigned artifact never reaches the repo. + // Hub-side signing: over the exact bytes that just entered the store. A + // gpg failure fails the build closed. if !ctx.cfg.signing_key_id.is_empty() { let sigdest = ctx.cfg.store_path(&format!("{}-sig", p.digest)); if !sigdest.exists() { @@ -524,8 +499,8 @@ fn ingest(ctx: &Ctx) -> Result<StepResult> { })?; // §10.1: the world snapshot is the build's installed set INTERSECTED with our - // own packages, filtered at ingest time, not at query time. Left unfiltered, - // every package would be permanently stale because Arch never stops moving. + // own packages, filtered at ingest time. Left unfiltered, every package would + // be permanently stale because Arch never stops moving. let ours = db::our_package_names(&ctx.db)?; let mut members: Vec<WorldMember> = Vec::new(); for p in &collect.packages { |
