| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 -> 201 pub / 11 test-only.
Suite: 283 passed, 0 failed, 0 ignored. Clippy clean.
|
|
|
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 -> 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).
|