summaryrefslogtreecommitdiffstats
path: root/tests/config.rs
Commit message (Collapse)AuthorAgeFilesLines
* tests: the ratchet says what the code says nowaur-build8 days1-8/+0
| | | | | | | | | | | | 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.
* rustfmt,lints: pin the formatting, adopt the idiom lints, pay them offaur-build9 days1-23/+5
| | | | | | | | | | | | | | | 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(&format!()), let-else instead of match-on-Option, borrows where a thread entry point only reads what it owns, no `&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.
* db: move the state-enum tests into the model that declares themaur-build11 days1-16/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* config: move the parsing and validation tests into the moduleaur-build11 days1-207/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Eleven tests in tests/config.rs exercised how a config parses, what it refuses, and what it refuses to print. They reached those behaviours through the crate's public API only because that was the only way in, and that had been keeping two items public that nothing outside config names: DEFAULT_SANDBOX_IMAGE resolved at config.rs:187 and :374, nowhere else Sandbox::KINDS never read by production at all — serde builds the unknown-kind message itself KINDS is now `#[cfg(test)]` rather than merely private, and `cargo check --release` without the test-support feature compiles with zero warnings, which is the proof that nothing production needed was gated away by mistake. One honest caveat, recorded in the file: these tests still create a tempdir, because `Config::load` takes a directory and so even a pure parse needs a file on disk. That is plumbing for the signature, not the subject of the test — none of them touches the database, the fixture corpus, or a subprocess. What remains in tests/config.rs genuinely does: root resolution against real paths under target/, and two tests that run the built binary. config: 31 pub / 5 test-only -> 29 pub / 3 test-only. Suite: 281 passed, 0 failed.
* comments: keep only what the code cannot showaur-build12 days1-48/+0
| | | | | | | | | | | 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.
* comments: say why, not whataur-build12 days1-45/+19
| | | | | | | | | | | | | | 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.
* config: refuse a sandbox configuration that cannot work, at startupaur-build12 days1-0/+115
| | | | | | | | | | | | | | | | | | | | | The enum makes the impossible unrepresentable, but two things survive any type: a field that is present and empty, and an assertion the type leaves defaulted on purpose. `Config::validate` catches both, and it runs at startup — before the watcher, the dispatcher or the UI are up and looking healthy — and again where a backend is constructed, so nothing that builds one can skip it. The one that matters is the workspace. `Run` frames carry a hub-side working directory and the srcdir is never shipped to the sandbox, so a `remote` backend on a machine that does not share the hub's filesystem would fail in `makepkg` with a missing directory — and, worse, would *succeed* in the case nobody wants: quietly building untrusted code on the hub. So a remote or agent-sandbox config must say `"shared_workspace": true`, and the refusal says why rather than just naming the field. Loopback needs no assertion because it shares the filesystem by construction, which is also why it stays the zero-config default. Empty `listen`, `token`, `api`, `namespace`, `bearer` and `image` are each refused by name. Two tests drive the compiled binary rather than the library, because a guard that only exists as a callable function is a guard the CLI can walk past.
* config: the sandbox backend is an enum, not a string with a fallthroughaur-build12 days1-0/+190
| | | | | | | | | | | | | | | | | | | | | | | | | `sandbox_backend` was a free-form string and `backend_for` matched it with `_ => loopback`. So `sandbox_backend = "kata"` — a real, intended backend, documented in the design — meant "run the untrusted PKGBUILD as the hub's own user", and nothing anywhere said so. There was also no validation of any kind in the crate: an empty `agent_token` with a remote backend, or a missing listen address, parsed fine and failed later as something else. The four flat fields become one tagged `sandbox` object with three kinds: `loopback` (needs nothing, still the default, so every config on disk keeps working), `remote` (listen + token), and `agent-sandbox` (api, namespace, bearer, image, listen, token). Required fields are required by the type, an unknown kind is a parse error naming the valid set, and `deny_unknown_fields` means a misspelled field is named rather than read as absent. `agent-sandbox` parses and is refused at backend construction until it is wired up — a valid kind that is not implemented is an error, never a substitution. Retired keys are refused when they carry intent: a config saying `sandbox_backend: "remote"` errors and names the replacement shape, because quietly reinterpreting it as loopback is the bug being removed. A config saying `"loopback"` with the empty strings `init` wrote is noise, not intent, and loads unchanged. The token and the cluster bearer are redacted in `Debug`, so a config that reaches a log line cannot leak them.
* config: the root is the directory config.json lives inaur-build12 days1-0/+134
`--root` names a directory and `init` writes config.json inside it, so the root was already named by where the config lived. The `root` field in the file was treated as a second source of truth instead: a relative one was re-joined onto the config's own directory, and `init` saved whatever it had been handed. So `--root runtime` wrote `"root": "runtime"`, and every command after `init` resolved it to `runtime/runtime/` — a second tree with its own empty database, while `init` had created and migrated the first one. The user-visible half was a path like `runtime/runtime/repo/aur-build/os/x86_64/…` in an error message. Compounding it, the CLI fell back to a default config whenever loading failed, so a typo'd `--root` produced a fresh empty server that answered every command as though it were the one you meant. `load` now sets the root to the directory it found the config in, absolutized, and a missing config is an error for every command except `init` — the only one that runs before one exists.