summaryrefslogtreecommitdiffstats
path: root/tests/config.rs
Commit message (Collapse)AuthorAgeFilesLines
* 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.