From 8835a0a86c82d922a2d674f3543c331dc9adb9e5 Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 19:00:25 +0000 Subject: docs: the review's decisions, and the invariants that hold them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The structural findings are only durable if they are written down as rules with the test that enforces each one, so: `docs/INVARIANTS.md` gains a second table. The first one is the twelve numbered invariants from DESIGN.md §2 — claims about what the system does. The new one is about how the code is allowed to be shaped: SQL has one owner, a version is formatted in one place, the dependency arrows point one way, the state machines are the ones the transition table defines, the production binary carries no test scaffolding, the served index has one lock, `canonical_json` is canonical in fact, the session id is the credential, and a pinned clock pins everything derived from it. Each row names the test that fails if the shape regresses. `docs/DECISIONS.md` gains the decisions the review turned into code — the session id as the credential, `db/` as a boundary that does not hand out connections, a stale review and a broken database being different answers, shims compiled out of production, states as enums with compare-and-swap writes, unreadable rows failing the query, and only momentary I/O counting as transient. Two existing entries were amended rather than added to: the publisher lock (there is now one, and the second one that used to sit inside it is gone) and the test hooks (they are a gated submodule now, not fields on the production config). `README.md` says where the shims live and that none of them exist in a plain `cargo build`. --- docs/INVARIANTS.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'docs/INVARIANTS.md') diff --git a/docs/INVARIANTS.md b/docs/INVARIANTS.md index 3e9c7ae..c148961 100644 --- a/docs/INVARIANTS.md +++ b/docs/INVARIANTS.md @@ -42,3 +42,26 @@ than through the application: * I7 — a partial unique index on `candidate (pkgbase_id) WHERE state='pending_review'`. * I10 — `UPDATE`/`DELETE` triggers on `audit`, and on `approval` (§7.2, the approval record is immutable because it is the only proof of what a human saw). + +## Structural invariants, and the test that holds each one + +The rest of this file is about the twelve numbered invariants, which are claims +about what the system does. The ones below are claims about how the code is +allowed to be shaped — the kind that a review finds once and that a test then +holds forever, because a convention nobody checks erodes back into inconsistency +within a few commits. Each is enforced by a test that reads the source tree and +fails on the shape, not on behaviour. + +| Invariant | Test | +|---|---| +| SQL has one owner: `db/`. No other module holds a statement or touches a rusqlite connection. | `schema_ownership::no_sql_statements_outside_the_db_module` | +| A version string is formatted in exactly one place, `pkgver::full_version` — never again as a `CASE` in SQL. | `schema_ownership::only_rust_formats_a_version` | +| Dependency direction: `db` does not know about `review`/`watch`/`pipeline`; `review` does not call back into the watcher; `watch` does not reach into the pipeline or the UI; `recipe` is a leaf. | `layers::persistence_names_nothing_above_itself` · `layers::review_does_not_call_back_into_the_watcher` · `layers::the_watcher_does_not_reach_into_the_pipeline_or_the_ui` · `layers::the_recipe_leaf_depends_on_nothing_above_it` | +| The five state machines are enums. A row whose state text the code does not define is an error, not an empty string, and a transition the table does not define is refused rather than applied. | `state_machine::the_machine_refuses_a_transition_it_does_not_define` · `state_machine::a_state_the_code_does_not_know_is_an_error_not_an_empty_string` · `state_machine::every_state_round_trips_through_its_column_text` · `state_machine::an_unnamed_state_in_any_row_is_an_error` | +| A worker that lost its lease cannot write over the worker that owns the build. | `state_machine::a_zombie_worker_cannot_finish_a_build_it_no_longer_owns` | +| The production binary contains no test scaffolding: no shim harness, no shim binaries, no ungated fault-injection branch, and a default config with no hooks attached. | `production_surface::no_production_module_references_the_shim_harness` · `production_surface::the_shim_binaries_are_test_only` · `production_surface::the_publish_hot_path_has_no_ungated_test_branch` · `production_surface::a_default_config_has_no_hooks_attached` | +| The served index has exactly one serialization lock, so no second lock can be added that does not know about the first. | `production_surface::the_served_index_has_exactly_one_serialization_lock` | +| The rules a reviewer reads are the same rules the machine scored: no private copies of the host rule, the body-changed rule, or a hand-built audit row. | `production_surface::the_review_modules_do_not_keep_private_copies_of_the_rules` · `production_surface::audit_rows_are_built_by_the_constructors_not_by_hand` | +| `canonical_json` is canonical in fact — key order is a property of the bytes, not of the struct declaration — and a value that cannot be serialized is an error, never an empty object that hashes like a real identity. | `hash::the_rendering_is_canonical_in_fact_not_in_name` · `hash::a_value_that_cannot_be_serialized_is_an_error_not_an_empty_object` | +| The session id is the credential: a cookie a client typed by hand proves nothing, and logging out invalidates the id rather than flipping a bit inside a cookie the client controls. | `http::a_forged_auth_cookie_is_not_a_session` · `http::login_rotates_the_session_and_logout_ends_it` | +| A pinned clock pins everything derived from it, including lease expiry — a test that freezes time must not compute a real-clock deadline. | `time::a_pinned_clock_moves_relative_arithmetic_with_it` · `time::a_lease_taken_under_a_pinned_clock_expires_against_that_clock` | -- cgit v1.2.3