summaryrefslogtreecommitdiffstats
path: root/docs/INVARIANTS.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/INVARIANTS.md')
-rw-r--r--docs/INVARIANTS.md23
1 files changed, 23 insertions, 0 deletions
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` |