<feed xmlns='http://www.w3.org/2005/Atom'>
<title>aur-build/tests/state_machine.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>tests: the ratchet says what the code says now</title>
<updated>2026-11-23T13:56:40+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-23T13:56:40+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=6872e81644546a9ccd0e1420c3ef64a26358f78a'/>
<id>6872e81644546a9ccd0e1420c3ef64a26358f78a</id>
<content type='text'>
The architecture test's own essays were the largest block of prose left
in the tree, and the test-file headers were notes about which tests moved
into `src/` — history the file no longer needs.

Removing those mentions moved two measured numbers, and the ratchet was
right to complain. `db.Writer` now sits in the allowlist with the
compiler fact that keeps it `pub` — narrowing it makes every call site
say `type db::Writer is private` — and the counts that got smaller are
written back at the smaller value, as the ratchet demands.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The architecture test's own essays were the largest block of prose left
in the tree, and the test-file headers were notes about which tests moved
into `src/` — history the file no longer needs.

Removing those mentions moved two measured numbers, and the ratchet was
right to complain. `db.Writer` now sits in the allowlist with the
compiler fact that keeps it `pub` — narrowing it makes every call site
say `type db::Writer is private` — and the counts that got smaller are
written back at the smaller value, as the ratchet demands.
</pre>
</div>
</content>
</entry>
<entry>
<title>src,tests: say each thing once, in the code or not at all</title>
<updated>2026-11-22T10:44:04+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-22T10:44:04+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=1e1e12e7220a3fd288782ae40f0823db32acf6cb'/>
<id>1e1e12e7220a3fd288782ae40f0823db32acf6cb</id>
<content type='text'>
The repeated explanations go: sixteen copies of why a `pub` under
`test-support` has two declarations, six notes about where a test moved
from, forty-three banner comments naming the section they sit above.

The prose that stays is the prose the code cannot say — a hand-written
Debug that keeps a token out of a log line, a git pipe that would
deadlock if the write came first, an end-of-string check that has to
precede the separator skip. Enum docs in error.rs collapse to the line
that names what the type is; the argument for why it is shaped that way
is in the variants.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The repeated explanations go: sixteen copies of why a `pub` under
`test-support` has two declarations, six notes about where a test moved
from, forty-three banner comments naming the section they sit above.

The prose that stays is the prose the code cannot say — a hand-written
Debug that keeps a token out of a log line, a git pipe that would
deadlock if the write came first, an end-of-string check that has to
precede the separator skip. Enum docs in error.rs collapse to the line
that names what the type is; the argument for why it is shaped that way
is in the variants.
</pre>
</div>
</content>
</entry>
<entry>
<title>rustfmt,lints: pin the formatting, adopt the idiom lints, pay them off</title>
<updated>2026-11-22T10:36:24+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-22T10:36:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=3dc71b2f5160ef9bd46143eed0edb5d2557b58e6'/>
<id>3dc71b2f5160ef9bd46143eed0edb5d2557b58e6</id>
<content type='text'>
rustfmt.toml fixes the shape the tree is written in (120 columns, small
items kept on one line) and one canonical pass makes it the truth.

[lints.clippy] names the idiom lints worth enforcing and leaves out the
two that would add doc-comment boilerplate rather than remove it. The
tree pays them off here: write!/writeln! instead of push_str(&amp;format!()),
let-else instead of match-on-Option, borrows where a thread entry point
only reads what it owns, no `&amp;self` on a Copy state and no `self` nobody
reads.

ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and
value are now emitted by the same call instead of three.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
rustfmt.toml fixes the shape the tree is written in (120 columns, small
items kept on one line) and one canonical pass makes it the truth.

[lints.clippy] names the idiom lints worth enforcing and leaves out the
two that would add doc-comment boilerplate rather than remove it. The
tree pays them off here: write!/writeln! instead of push_str(&amp;format!()),
let-else instead of match-on-Option, borrows where a thread entry point
only reads what it owns, no `&amp;self` on a Copy state and no `self` nobody
reads.

ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and
value are now emitted by the same call instead of three.
</pre>
</div>
</content>
</entry>
<entry>
<title>db: move the state-enum tests into the model that declares them</title>
<updated>2026-11-20T20:33:11+00:00</updated>
<author>
<name>aur-build</name>
<email>aur-build@localhost</email>
</author>
<published>2026-11-20T20:33:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/aur-build/commit/?id=39ae04fcc1e25d6b252a7432dfc8257e41237750'/>
<id>39ae04fcc1e25d6b252a7432dfc8257e41237750</id>
<content type='text'>
tests/state_machine.rs was built around a database, so two tests that
asserted nothing about a database still sat there: the column-text round
trip, and the enumeration of the transition table. Both moved into
src/db/model/build_state.rs, where `BuildState` and its table are
declared.

Making them in-module tests is what let the table stop being public.
`ALL` and `can_transition` had no reader outside db/model at all —
production enforces transitions by asking `predecessors(to)` and putting
the answer in a SQL `WHERE state IN (...)` guard — so both are now
private, and the five state enums' `ALL` consts with them.

One assertion moved rather than being dropped.
`a_terminal_build_is_history_and_does_not_move` made two claims per
state: a table claim (`!Succeeded.can_transition(to)`) and a database
claim (`set_state(...).is_err()`). The table claim now lives with the
table; the database claim stayed where the database is. Neither was
weakened.

Two findings, recorded rather than quietly acted on:
`ReleaseState::can_transition` and `SubscriptionState::can_transition`
are consulted by nothing — not by `predecessors`, not by a test. They are
dead tables for machines nothing enforces. Left `pub` with a NOTE and
handed to the disposition table, because deleting a stated invariant and
wiring up an unwired one are both decisions above this commit.

Added two round-trip tests (StepState, and the three enums declared in
state.rs) so the newly private `ALL` consts are still exercised.

db: 202 pub / 13 test-only -&gt; 201 pub / 11 test-only.
Suite: 283 passed, 0 failed, 0 ignored. Clippy clean.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
tests/state_machine.rs was built around a database, so two tests that
asserted nothing about a database still sat there: the column-text round
trip, and the enumeration of the transition table. Both moved into
src/db/model/build_state.rs, where `BuildState` and its table are
declared.

Making them in-module tests is what let the table stop being public.
`ALL` and `can_transition` had no reader outside db/model at all —
production enforces transitions by asking `predecessors(to)` and putting
the answer in a SQL `WHERE state IN (...)` guard — so both are now
private, and the five state enums' `ALL` consts with them.

One assertion moved rather than being dropped.
`a_terminal_build_is_history_and_does_not_move` made two claims per
state: a table claim (`!Succeeded.can_transition(to)`) and a database
claim (`set_state(...).is_err()`). The table claim now lives with the
table; the database claim stayed where the database is. Neither was
weakened.

Two findings, recorded rather than quietly acted on:
`ReleaseState::can_transition` and `SubscriptionState::can_transition`
are consulted by nothing — not by `predecessors`, not by a test. They are
dead tables for machines nothing enforces. Left `pub` with a NOTE and
handed to the disposition table, because deleting a stated invariant and
wiring up an unwired one are both decisions above this commit.

Added two round-trip tests (StepState, and the three enums declared in
state.rs) so the newly private `ALL` consts are still exercised.

db: 202 pub / 13 test-only -&gt; 201 pub / 11 test-only.
Suite: 283 passed, 0 failed, 0 ignored. Clippy clean.
</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>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>
</feed>
