<feed xmlns='http://www.w3.org/2005/Atom'>
<title>aur-build/src/db/queries.rs, branch ai/main</title>
<subtitle>Unnamed repository
</subtitle>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/'/>
<entry>
<title>db: one module per aggregate, and an interface you can read</title>
<updated>2026-11-20T17:13:44+00:00</updated>
<author>
<name>dev</name>
<email>dev@localhost</email>
</author>
<published>2026-11-20T17:13:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=8cd32e5309b14f5264813e5f2ce6ecdb5aa41fb4'/>
<id>8cd32e5309b14f5264813e5f2ce6ecdb5aa41fb4</id>
<content type='text'>
queries.rs was 1,501 lines holding 83 queries across seventeen aggregates,
separated by comment banners that said "settings", "release", "notices" and
then kept them in one file. The banners were the design; they just never got
files. Each one has one now, verbatim — the split is provably content-only,
the moved text being identical to the original as a sorted set of lines.

model.rs and builds.rs were each two concerns deep, so they became
directories. model.rs held what a row looks like and, separately, the state
machines that say which moves are legal; builds.rs held the build machine and,
below its own `step rows` banner, the step machine. The impl_state_enum!
macro implements StateEnum for all five enums from one place, so it moved
with its invocations rather than being exported across a boundary to chase
them.

They are directories rather than new sibling modules on purpose:
`db::model::CandidateState` and `db::builds::steps` are used across the crate
and by the integration tests, and renaming them would be a bigger change than
the one being made. No call site and no test changed.

db/mod.rs now lists its interface instead of spraying one. `pub use model::*`
and `pub use queries::*` are gone, replaced by seventeen explicit exports, and
the query modules are private — so a query that was not chosen for export is
not reachable, and the width of the module is visible from its own text
rather than only from a grep.

The ratchet caught the win immediately: db.glob went 2 -&gt; 0, which failed
a_shrunk_interface_is_written_back until the budget was written back at the
new value. db is off the glob allowlist now rather than holding a stale zero.

277 passed / 0 failed, clippy -D warnings clean, largest file in src/db 363
lines (candidates.rs, unchanged from before this work).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
queries.rs was 1,501 lines holding 83 queries across seventeen aggregates,
separated by comment banners that said "settings", "release", "notices" and
then kept them in one file. The banners were the design; they just never got
files. Each one has one now, verbatim — the split is provably content-only,
the moved text being identical to the original as a sorted set of lines.

model.rs and builds.rs were each two concerns deep, so they became
directories. model.rs held what a row looks like and, separately, the state
machines that say which moves are legal; builds.rs held the build machine and,
below its own `step rows` banner, the step machine. The impl_state_enum!
macro implements StateEnum for all five enums from one place, so it moved
with its invocations rather than being exported across a boundary to chase
them.

They are directories rather than new sibling modules on purpose:
`db::model::CandidateState` and `db::builds::steps` are used across the crate
and by the integration tests, and renaming them would be a bigger change than
the one being made. No call site and no test changed.

db/mod.rs now lists its interface instead of spraying one. `pub use model::*`
and `pub use queries::*` are gone, replaced by seventeen explicit exports, and
the query modules are private — so a query that was not chosen for export is
not reachable, and the width of the module is visible from its own text
rather than only from a grep.

The ratchet caught the win immediately: db.glob went 2 -&gt; 0, which failed
a_shrunk_interface_is_written_back until the budget was written back at the
new value. db is off the glob allowlist now rather than holding a stale zero.

277 passed / 0 failed, clippy -D warnings clean, largest file in src/db 363
lines (candidates.rs, unchanged from before this work).
</pre>
</div>
</content>
</entry>
<entry>
<title>comments: keep only what the code cannot show</title>
<updated>2026-11-19T17:33:17+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-19T17:33:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=4304b0f336ddba7b4ec6780795059ff2066d105b'/>
<id>4304b0f336ddba7b4ec6780795059ff2066d105b</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>comments: say why, not what</title>
<updated>2026-11-19T17:09:59+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-19T17:09:59+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=e757979f1a2afdbe7146066345bb9acd19d3b151'/>
<id>e757979f1a2afdbe7146066345bb9acd19d3b151</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>pipeline: replace the devtools chroot with pinned pacman -U provisioning</title>
<updated>2026-11-19T11:17:27+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-19T11:17:27+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=bc8f069d18c5de3dee04ae303227a255248efc1e'/>
<id>bc8f069d18c5de3dee04ae303227a255248efc1e</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>db, watch: two N+1s and a version rule with one owner</title>
<updated>2026-11-18T18:28:16+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-18T18:28:16+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=fdd004c50de6131be193044ae40424d691425a81'/>
<id>fdd004c50de6131be193044ae40424d691425a81</id>
<content type='text'>
m-17. `watch::staleness::dependents_of` walked the index and asked for each
package's recipe by name — one query per package, on the path that runs after
every publish, with N equal to the size of the index. `db::index_recipes` returns
the whole table in one query now. While there: a recipe that fails to parse is no
longer treated as "does not depend on this package". An unreadable srcinfo used
to hide a dependent from staleness by returning `None` into an `unwrap_or(false)`;
now it is a reason to look.

`db::builds::requeue_blocked` asked "is this name in the index?" once per
dependency of every blocked build, inside the dispatcher's hot loop. The set of
in-index names is read once per pass and tested in memory. Same answer, one
query.

m-18. `approved_but_unbuilt` assembled the version a human reads with two
`CASE WHEN epoch='0'` expressions in SQL — a second, independent copy of the
`epoch:pkgver-pkgrel` rule that `pkgver::full_version` owns. Two copies of a
formatting rule is how the Attention page ends up describing versions
differently from every other page. The query returns the parts; Rust formats
them. A guard test fails if version-string concatenation reappears in SQL.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
m-17. `watch::staleness::dependents_of` walked the index and asked for each
package's recipe by name — one query per package, on the path that runs after
every publish, with N equal to the size of the index. `db::index_recipes` returns
the whole table in one query now. While there: a recipe that fails to parse is no
longer treated as "does not depend on this package". An unreadable srcinfo used
to hide a dependent from staleness by returning `None` into an `unwrap_or(false)`;
now it is a reason to look.

`db::builds::requeue_blocked` asked "is this name in the index?" once per
dependency of every blocked build, inside the dispatcher's hot loop. The set of
in-index names is read once per pass and tested in memory. Same answer, one
query.

m-18. `approved_but_unbuilt` assembled the version a human reads with two
`CASE WHEN epoch='0'` expressions in SQL — a second, independent copy of the
`epoch:pkgver-pkgrel` rule that `pkgver::full_version` owns. Two copies of a
formatting rule is how the Attention page ends up describing versions
differently from every other page. The query returns the parts; Rust formats
them. A guard test fails if version-string concatenation reappears in SQL.
</pre>
</div>
</content>
</entry>
<entry>
<title>pipeline, db: the correctness minors — fsync, withdrawal, orphans, retry class</title>
<updated>2026-11-18T17:43:25+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-18T17:43:25+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=7587284ae48fb59c59da33af928322e8a621f4b0'/>
<id>7587284ae48fb59c59da33af928322e8a621f4b0</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>review: one host rule, one body rule, one audit constructor</title>
<updated>2026-11-18T17:25:41+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-18T17:25:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=f3e4c1496d2ddcdae535132427fdb499181f1695'/>
<id>f3e4c1496d2ddcdae535132427fdb499181f1695</id>
<content type='text'>
m-2. `hosts` existed twice, verbatim, in `review::diff` and `review::risk`. The
duplication that matters is the other one: "did the executable part of the
recipe change" also existed twice, with *different* semantics. The risk scorer
compared everything from the first function definition onward; the diff panel
compared only the lines that name a function, so a `build()` rewritten to
`curl … | sh` under the same function names told the risk scorer "code changed,
high" and told the reviewer nothing at all — the one reader who could have
caught it. Both questions now have one answer: `urlutil::hosts` (which also
strips the `git@` from ssh URLs, so a scheme change stops crying "new source
host" wolf) and `recipe::bodies_changed`, in the module that owns the recipe.

m-4. The three review decisions each hand-built an `AuditEntry` literal, and
their `detail` shapes drifted: approve recorded the identity hash, reject
recorded only the note, withdraw only the reason — so for two of the three the
log cannot answer which candidate bytes the decision was about. `AuditEntry` is
built by `::human` / `::system` now, and reject records the identity hash it
rejected.

m-3, the four-times-copied 21-column candidate `SELECT`, was already gone: the
`CANDIDATE_COLS` constant came with moving the candidate SQL into `db/` in an
earlier commit.

Tests: the body rule is pinned at the unit level with the exact drift case
(same function names, different body), `tests/production_surface.rs` fails if
either module grows a private copy again or if an audit row is hand-built, and
the reject test reads its own audit row back and requires the identity in it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
m-2. `hosts` existed twice, verbatim, in `review::diff` and `review::risk`. The
duplication that matters is the other one: "did the executable part of the
recipe change" also existed twice, with *different* semantics. The risk scorer
compared everything from the first function definition onward; the diff panel
compared only the lines that name a function, so a `build()` rewritten to
`curl … | sh` under the same function names told the risk scorer "code changed,
high" and told the reviewer nothing at all — the one reader who could have
caught it. Both questions now have one answer: `urlutil::hosts` (which also
strips the `git@` from ssh URLs, so a scheme change stops crying "new source
host" wolf) and `recipe::bodies_changed`, in the module that owns the recipe.

m-4. The three review decisions each hand-built an `AuditEntry` literal, and
their `detail` shapes drifted: approve recorded the identity hash, reject
recorded only the note, withdraw only the reason — so for two of the three the
log cannot answer which candidate bytes the decision was about. `AuditEntry` is
built by `::human` / `::system` now, and reject records the identity hash it
rejected.

m-3, the four-times-copied 21-column candidate `SELECT`, was already gone: the
`CANDIDATE_COLS` constant came with moving the candidate SQL into `db/` in an
earlier commit.

Tests: the body rule is pinned at the unit level with the exact drift case
(same function names, different body), `tests/production_surface.rs` fails if
either module grows a private copy again or if an audit row is hand-built, and
the reject test reads its own audit row back and requires the identity in it.
</pre>
</div>
</content>
</entry>
<entry>
<title>db: the review, step, release and subscription states are enums too</title>
<updated>2026-11-18T16:49:40+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-18T16:49:40+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=41fa1684de8eb13c5b76c3a3e174fece04ac5afa'/>
<id>41fa1684de8eb13c5b76c3a3e174fece04ac5afa</id>
<content type='text'>
M-8 named four more machines after `build_state`, and each had the same defect
in miniature: `&amp;str` constants, a writer that took any `&amp;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, &amp;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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
M-8 named four more machines after `build_state`, and each had the same defect
in miniature: `&amp;str` constants, a writer that took any `&amp;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, &amp;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.
</pre>
</div>
</content>
</entry>
<entry>
<title>db: the build state machine is an enum, and a state write is a compare-and-swap</title>
<updated>2026-11-18T16:31:58+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-18T16:31:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=101f077200e80c7869e4549db645ed94b01acb1b'/>
<id>101f077200e80c7869e4549db645ed94b01acb1b</id>
<content type='text'>
`build_state` was seven `&amp;str` constants and `set_state(&amp;str)` would write any
string a caller invented, so the machine existed only as `WHERE state IN (...)`
clauses scattered across six modules and nothing could say that
`succeeded → running` is nonsense. It is `db::model::BuildState` now: parsed
where a row is read (a state the code cannot name is an error, not an empty
string — which also retires m-12's `current_state` returning `""`), and
`set_state` takes the variant and writes only if the row's current state is one
of `to`'s legal predecessors. A refused transition writes nothing and says why.

Writing the machine down surfaced three things that were true of the flows but
of nobody's documentation. The step loop re-asserts `Running` at every step
boundary, so a self-write is a no-op and not a move — every state accepts its
own name. A failed build is resumed *on its own row* (I5: the step checkpoints
say where to continue), so `failed → running` is a real transition. And
`builds::retry` — the UI's requeue button — moved any row to `queued`
unconditionally, including one that had already published, re-queueing a build
whose every step was checkpointed as done; it goes through the machine now and
is refused with a reason. `requeue_transient` likewise.

What the CAS buys is the zombie case, which no test covered: a worker's lease
expires mid-step, the reaper returns the build to the queue, and the original
worker — still running — comes back and writes `succeeded` over whatever the new
owner has since done. That write now fails loudly and the queue keeps ownership.

`builds_for_pkgbase` had a second, hand-copied row mapper that dropped unreadable
rows with `filter_map(|r| r.ok())`; it shares `row_to_build` now and a bad row
fails the query instead of vanishing from the package page (m-9's policy,
applied where it bit).

`tests/state_machine.rs` pins the whole table, the zombie refusal, the unknown
state, the terminal build that does not move, and the requeue-of-a-published-
build refusal. `tests/live.rs` walks a build through `running` before succeeding
instead of teleporting it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`build_state` was seven `&amp;str` constants and `set_state(&amp;str)` would write any
string a caller invented, so the machine existed only as `WHERE state IN (...)`
clauses scattered across six modules and nothing could say that
`succeeded → running` is nonsense. It is `db::model::BuildState` now: parsed
where a row is read (a state the code cannot name is an error, not an empty
string — which also retires m-12's `current_state` returning `""`), and
`set_state` takes the variant and writes only if the row's current state is one
of `to`'s legal predecessors. A refused transition writes nothing and says why.

Writing the machine down surfaced three things that were true of the flows but
of nobody's documentation. The step loop re-asserts `Running` at every step
boundary, so a self-write is a no-op and not a move — every state accepts its
own name. A failed build is resumed *on its own row* (I5: the step checkpoints
say where to continue), so `failed → running` is a real transition. And
`builds::retry` — the UI's requeue button — moved any row to `queued`
unconditionally, including one that had already published, re-queueing a build
whose every step was checkpointed as done; it goes through the machine now and
is refused with a reason. `requeue_transient` likewise.

What the CAS buys is the zombie case, which no test covered: a worker's lease
expires mid-step, the reaper returns the build to the queue, and the original
worker — still running — comes back and writes `succeeded` over whatever the new
owner has since done. That write now fails loudly and the queue keeps ownership.

`builds_for_pkgbase` had a second, hand-copied row mapper that dropped unreadable
rows with `filter_map(|r| r.ok())`; it shares `row_to_build` now and a bad row
fails the query instead of vanishing from the package page (m-9's policy,
applied where it bit).

`tests/state_machine.rs` pins the whole table, the zombie refusal, the unknown
state, the terminal build that does not move, and the requeue-of-a-published-
build refusal. `tests/live.rs` walks a build through `running` before succeeding
instead of teleporting it.
</pre>
</div>
</content>
</entry>
<entry>
<title>db, watch: two upward edges removed, and the layering is now a test</title>
<updated>2026-11-18T16:13:30+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-18T16:13:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=f8370b48f3e4464a1454d0ff7af1819b5448c619'/>
<id>f8370b48f3e4464a1454d0ff7af1819b5448c619</id>
<content type='text'>
M-6. `db::stage_b_cache_get` and `db::stage_b_recent` returned
`watch::upstream::StageB`, so the persistence layer could not be read without
the VCS watcher, and the table's row shape was defined by whatever the watcher
happened to find convenient. The row is `db::model::StageBCacheRow` now —
epoch, pkgver, pkgrel, pins — and `watch::upstream` converts at its own
boundary. The two types are deliberately not the same one: `StageB` carries
`cached`, and "was this answer a cache hit?" is a fact about the resolution
that just happened, not a column.

M-7. `review::risk` called `watch::digests::skip_on_non_vcs` while
`watch::detect` called into `review::candidates`, a cycle between two sibling
domains. Whether a recipe declines to verify its own sources is a question about
the recipe, so `skip_on_non_vcs` — with `SKIP`, `declared_sums` and
`is_hex_digest`, which it needed and which the watcher had no business owning —
moved to `recipe.rs`, a leaf both sides may look down at. `watch::digests` keeps
its use of them for digest resolution; the re-export is gone.

`tests/layers.rs` enforces the direction from now on: `src/db` names no module
above itself, `src/review` does not name `watch`, `src/watch` does not name
`pipeline` or `http`, and `recipe.rs` names nothing at all. Each rule failed
before this commit and each failure message prints the exact file and line of
the offending edge, so the next reasonable-looking commit cannot reintroduce
one quietly.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
M-6. `db::stage_b_cache_get` and `db::stage_b_recent` returned
`watch::upstream::StageB`, so the persistence layer could not be read without
the VCS watcher, and the table's row shape was defined by whatever the watcher
happened to find convenient. The row is `db::model::StageBCacheRow` now —
epoch, pkgver, pkgrel, pins — and `watch::upstream` converts at its own
boundary. The two types are deliberately not the same one: `StageB` carries
`cached`, and "was this answer a cache hit?" is a fact about the resolution
that just happened, not a column.

M-7. `review::risk` called `watch::digests::skip_on_non_vcs` while
`watch::detect` called into `review::candidates`, a cycle between two sibling
domains. Whether a recipe declines to verify its own sources is a question about
the recipe, so `skip_on_non_vcs` — with `SKIP`, `declared_sums` and
`is_hex_digest`, which it needed and which the watcher had no business owning —
moved to `recipe.rs`, a leaf both sides may look down at. `watch::digests` keeps
its use of them for digest resolution; the re-export is gone.

`tests/layers.rs` enforces the direction from now on: `src/db` names no module
above itself, `src/review` does not name `watch`, `src/watch` does not name
`pipeline` or `http`, and `recipe.rs` names nothing at all. Each rule failed
before this commit and each failure message prints the exact file and line of
the offending edge, so the next reasonable-looking commit cannot reintroduce
one quietly.
</pre>
</div>
</content>
</entry>
</feed>
