diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 14:15:16 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 14:15:16 +0000 |
| commit | 153e72cc797c1e45a60f4896d00163fb4bdf3056 (patch) | |
| tree | 7e2308552e5f5a33f4ddad07eba7a816e28e8568 /docs | |
| parent | 43a2bfaaac60bc378135ad90c46c9d42777aeb1e (diff) | |
| download | aur-build-153e72cc797c1e45a60f4896d00163fb4bdf3056.tar.gz aur-build-153e72cc797c1e45a60f4896d00163fb4bdf3056.zip | |
publish: repo-add decides the database filename
Publishing renders the index before the DB commits and renames it into place
after, so a crash between the two leaves the old index serving (I4). The way
that was written did it at `<db>.tar.gz.tmp` beside the live file — a filename
real repo-add refuses, because its database argument has to be a name pacman
would accept. Every publish test passed; the first real package anyone tried to
publish died at the last step with the release already committed.
`render_db` now renders into a scratch directory under the served directory,
under the name a consumer will download. Same filesystem, so the rename is still
the atomic swap, and the live database is never the file repo-add is writing
into. `publish`, `reconcile` and `withdraw_package` all had the bug and all share
the helper now; `reconcile` sweeps scratch directories a crash left behind.
`run_repo_add` drops `-s` too: repo-add would sign into scratch space that is
about to be deleted, and `publish::sign` already signs the renamed file.
The reason 238 tests missed this is that the shim would write the database
anywhere it was told. It now enforces the accepted set — measured against
`repo-add (pacman) 7.1.0`, not read out of its docs — with the real tool's
wording and exit status, and a gated test re-derives the set against the
installed tool, in the shape of the vercmp oracle. A shim that is more
permissive than its tool is not a test of the tool.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/DECISIONS.md | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 2861fed..bded52a 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -379,3 +379,51 @@ world mismatch rather than being helpfully fetched, which is correct here but depends on `plan()` computing the closure honestly. The shim `pacman` models all of this for real: `-U` refuses bytes that do not hash to the digest their name claims, and `-Q` reports exactly what landed. + +## repo-add names the database; the render happens in scratch space + +Publishing needs the index rendered *before* the DB transaction commits and +renamed into place *after* it, so a crash between the two leaves the old index +serving (I4). The obvious way to get that was to render to `<db>.tar.gz.tmp` +beside the live file and rename over it. That is also a filename real `repo-add` +refuses: its database argument has to be a name pacman would itself accept, and +a trailing `.tmp` is a usage error to it. Every publish test passed and the first +real package anyone tried to publish died at the last step, with the database +already committed and the served index untouched. + +**Choice.** `render_db` renders into a scratch directory *under* the served +directory — `.render-<pid>-<n>-<tag>/` — under the exact name a consumer will +download. Same filesystem, so the caller's `rename` is still the atomic swap I4 +requires, and the live database is never the file repo-add is writing into. The +scratch directory is removed on every path this code controls, and +`reconcile` sweeps leftovers at startup for the paths it does not. `run_repo_add` +also dropped `-s`: repo-add would sign the database into scratch space that is +about to be deleted, and `publish::sign` signs the renamed file — one key, one +code path, signature always over the bytes that shipped. + +**Cost.** Three call sites (`publish`, `reconcile`, `withdraw_package`) now share +the render helper instead of each doing its own tmp-and-rename, and a publish that +dies between render and rename leaves a directory for the next startup to sweep +rather than a single stray `.tmp` for a human to notice. + +## A shim is as strict as the tool it replaces, or it is not a test of it + +The `repo-add` shim wrote the database wherever it was told to. The real tool +validates the filename first. That asymmetry is the whole reason the previous +entry was possible: 200+ tests drove a real subprocess through a real publish and +reported success, because the fake accepted what the real thing rejects. + +**Choice.** The shim enforces the accepted set — `.db.tar` with or without a +compression suffix, nothing else, `.files.*` included in the refusals because +those belong to `repo-files` — with the real tool's wording and exit status. The +set was measured against `repo-add (pacman) 7.1.0`, not read out of its docs, and +`shims::repo_add_db_names_match_the_real_repo_add` re-derives it against the +installed tool whenever there is one, in the shape of the `vercmp` oracle test. +The same rule already holds elsewhere — the `pacman` shim refuses bytes that do +not hash to the digest their name claims — this is that rule, applied where it was +missing. + +**Cost.** The shim now rejects things the pipeline might one day want to do, and +the rejection has to be updated if pacman's rule changes. That is the correct +failure: a shim drifting from its tool should break a test loudly, not let a +production path go untested. |
