Skip to content

Architecture Quality Requirements

Mohammad Rasoul Kazemi edited this page Nov 26, 2026 · 2 revisions

Architecture Quality Requirements

This page is arc42 chapter 10. It states the quality goals as a tree with scenarios and, for each, how it is tested. The goals themselves are on Architecture Introduction and Goals; the test layers are described on Testing Strategy and Development and Testing; the open findings against these requirements are on Architecture Risks and Technical Debt.

There is no automated build service: the project owner forbids using GitHub Actions, so every check is run locally and its result goes in the work log. Where testing.md says "CI" it describes an intended wiring that is not written yet.

Quality tree

flowchart TD
    Q["Quality"]
    Q --> C["Correctness and consistency"]
    Q --> I["Integrity and tamper evidence"]
    Q --> A["Availability"]
    Q --> S["Security"]
    Q --> M["Maintainability and compatibility"]
    Q --> O["Operability"]
    Q --> P["Performance"]
    C --> C1["Same answer as a single node"]
    C --> C2["Atomic distributed commit"]
    I --> I1["History changes are detected"]
    I --> I2["Verifier needs no trust in the database"]
    A --> A1["No two primaries for one group"]
    A --> A2["No acknowledged write lost on a planned switchover"]
    S --> S1["Least privilege and no secret leaks"]
    M --> M1["One source for PostgreSQL 18 and 19"]
    M --> M2["Thin fork with few core patches"]
    O --> O1["Every state is visible and resumable"]
    P --> P1["Pushdown beats the row-moving scan"]
Loading

Scenarios and how each is tested

Requirement Scenario How it is tested State
Same answer as a single node A generated read or write over distributed tables returns the rows a single node returns, also after bucket moves Generated statements compared with a single node on both majors; with every pushdown switch off the extension behaves as in phase 2a, and the complete scan answers every shape (ADR 0022) Built; the differences that pushdown makes visible are listed in Limitations and Known Issues
Atomic distributed commit A crash at any point of a two-phase commit leaves the transaction committed on all nodes or none TAP tests with several Cluster instances (contrib/kingres_shard/t/), recovery by recover_prepared_transactions() and the worker, a documented test of the no-global-snapshot anomaly so a later change is noticed Built; across a failover, with a synchronous standby, a distributed transaction commits or aborts on every node
Bucket move without lost rows A move under load ends with each bucket read or written once, by its owner TAP test 027_move_under_load and others; control plane unit tests of the planner and integration tests that restart the leader; the stale-map check KS001 Built; a leader change at every step of a move is not tested on a cluster
History changes are detected A direct change of a ledger row, block or table is found by ledger_verify or by a digest check pg_regress and TAP in contrib/kingres_ledger/; fixed test vectors for the canonical serialisation, including cases that vary DateStyle, extra_float_digits, bytea_output and locale Built; a check inside the database is relative to a digest kept elsewhere
Verifier trusts nothing No input makes the verifier accept a rewritten history Go tests without a database, fixtures from a real server, property tests against an independent implementation, fuzz targets (FuzzParse, FuzzVerify, FuzzParseTile and others, run by kingres/verifier/scripts/fuzz.sh) Built; it proves what is in the files it is given and nothing else
No two writable primaries for a group A failover while the old primary is alive or partitioned never leaves two writable primaries Unit tests of the lease and fence logic, cluster tests on real instances for a dead and a live old primary, tests that fail for a one-line mutant of the fix Built; two failures at once and a failure during a rebalance are not tested on a cluster
No acknowledged write lost on a planned switchover A clean stop and switchover_verify prove the standby has all WAL The extension README names the test behind every answer (t/080, t/085 and others) and a table of ways to stop the old primary Built, also for the map group
Least privilege, no secret leak No role gains rights through the API; logs, answers and rows hold no secret; a user database cannot make the service role run its code The guard tests; one reproducing test per security finding; browser tests of the content security policy (csp.test.ts); the schema-spoof tests (spooftest) and the checks of extguard; hostile-archive tests of the import Built
One source for both majors Each extension builds without warnings and passes its regression and TAP suites on 18 and 19 kingres/dev/ext-majors.sh <extension> builds with warnings as errors and runs regress and tap on each configured major; the control plane integration suite runs against either installation Built on PostgreSQL 18.7 and 19.0
Thin fork Upstream files change only through registered core patches kingres/docs/dev/core-patches.md register; the rule is part of the definition of done Built
Every state visible and resumable After a restart or a change of leader a task resumes or ends with a report; alerts name the cause Task engine crash-point tests, lease and epoch fencing tests, tests of listings and alerts against a real three-server cluster Built; a change of the manager leader at every step of a table transfer or a database import is not tested on a cluster
Pushdown beats the scan A path is taken only when its cost is lower; its answer equals the scan's The same compared-with-single-node runs; EXPLAIN (VERBOSE) shows the path and the reason a statement was not pushed Built; no benchmark figures are given in the sources used here
Console accessible and safe Pages pass accessibility and layout checks and run under a content security policy Vitest and Testing Library component tests, browser tests axe.test.ts, layout.test.ts, csp.test.ts Built
Packages install and start The package installs, the service starts uninitialised, the first-run token works, uninstall is clean Container and Debian package tests under kingres/packaging/test/ Built; the compose cluster test does not exercise removing a server, failover, switchover or rebalance

Test layers (summary)

The layers of kingres/docs/dev/testing.md:

  1. pg_regress for the SQL interface of each extension (contrib/kingres_*/sql, expected).
  2. PostgreSQL TAP tests for crash recovery, background workers, replication and, with several Cluster instances, routing, two-phase commit recovery, moves and failover (contrib/kingres_*/t).
  3. Go unit tests with -race, table-driven, next to the code; go vet, gofmt, golangci-lint.
  4. Go integration tests against real PostgreSQL instances, run when KINGRES_PG_BIN is set; scripts/run-integration.ps1 runs them in WSL on a slice of ports of their own, and takes a machine-wide mutex so that several people or agents queue up instead of colliding.
  5. Contract tests: every operation of openapi.yaml has a handler and every handler is in the spec; the generated role table is checked against the file (go generate ./internal/contract; a test fails while the table is stale).
  6. Web: Vitest component tests with the network mocked by responses valid against the contract, and browser tests.
  7. Verifier: Go tests without a database, fixtures, fuzzing.
  8. Packaging: container and package tests.
  9. Mutants and independent reviews: a bug fix starts with a test that fails without the fix; for high findings the authors also show a test that fails for the one-line mutant of the fix. Independent reviews (reports under kingres/docs/reviews/) check the code from outside. See Review Process.

Rules from testing.md: every phase deliverable includes tests; a flaky test is a bug; tests use no fixed ports, no fixed paths outside their temporary directory and no network except to servers they start. A change is done only with tests, documentation and a work-log entry; C code is tested on a build with assertions enabled. Each extension has a test that upgrades from the oldest supported version and compares with a fresh install.

Sources

Clone this wiki locally