Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ jobs:
tests/integration/test_knowledge_suite_drafts.py
tests/integration/test_suite_results.py
tests/integration/test_proposal_checks_state.py
tests/integration/test_proposal_checks_requirement.py
# The statement corpus: every builder's shapes through
# EXPLAIN QUERY TREE on the migrated service, and shapes.txt in step
# with the builders. ~10 s; a rejection here is a statement that would
Expand Down Expand Up @@ -1183,6 +1184,7 @@ jobs:
tests/integration/test_served_reads.py
tests/integration/test_read_receipts.py
tests/integration/test_stewardship.py
tests/integration/test_proposal_checks_requirement.py
tests/integration/test_memory_by_id.py
tests/integration/test_memory_bulk.py
tests/integration/test_memory_pin.py
Expand Down
74 changes: 72 additions & 2 deletions docs/architecture/regression-suites.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ the token (`writer_actor`).
| `case_ids`, `case_kinds` | The cases' ids and kinds, in id order. |
| `cases` | The cases, text included, as canonical JSON: sorted by id, sorted keys, compact. |
| `written_by`, `written_at` | The publishing actor and the time. |
| `required` | 1 or 0 when the revision states the requirement, -1 when it states none. |

A revision is one row and is never rewritten, so a merge has nothing to collapse and a
read needs no `FINAL`. The current revisions of a namespace are one aggregate: per suite,
Expand All @@ -46,6 +47,12 @@ tuple means two rows can never contribute different columns to one answer. That
selects no case text and no case id; only `knowledge.suites.get` and the publish's read
of its own suite add `cases` to the tuple.

The requirement is read beside the tuple, as
`argMaxIf(required, revision, required >= 0)`: the newest value a revision stated. A
build without the column inserts a revision that states none (the column's default, -1),
so the revision it publishes keeps the requirement of the one before it. A suite no
revision stated a requirement for is not required.

The table sets `index_granularity = 64`: it is small and every read names one namespace,
so a small granule keeps a read from loading other namespaces' rows. The value is set
when the table is created, because a self-hosted server refuses to change it on a table
Expand All @@ -60,7 +67,8 @@ In order:
2. The body is checked without a read (`server/knowledge/domain/suites.py`): one case per
id, the field each kind needs, a first revision that covers something, a case for a
suite that covers something. A refusal names the case id and the field, never text.
3. The fleet gate: 503 unless every live replica can erase a suite
3. The fleet gate: 503 unless every live replica can erase a suite, and for a body with
`required: true` unless every live replica checks a required suite before an accept
([rolling upgrades](#rolling-upgrades)).
4. A claim on the namespace's suites, held for the rest of the call. A publish that
cannot take it within 5 seconds answers 503.
Expand All @@ -72,7 +80,13 @@ In order:
writes.
8. A selection that overlaps another suite's current revision, or a new suite in a
namespace that holds 200, is refused with 409.
9. One insert at `revision + 1`.
9. When the publish turns the requirement on or lowers it, the audit row
`knowledge.suites.requirement` ([a required suite](#a-required-suite)). A row that
cannot be written fails the publish with 503.
10. One insert at `revision + 1`.

The requirement is part of the document that step 7 compares: `required` omitted takes
the current revision's value, so a body that only changes it writes a revision.

The claim is what makes the revision a compare-and-set. The table keeps every row it is
given, so two publishes that both read revision 3 would both insert revision 4. The
Expand Down Expand Up @@ -258,6 +272,15 @@ row does not serve. The listing and `knowledge.suites.results` call the one stat
function over the same deciding set (`server/knowledge/app/suite_checks.py`), so they
agree for one key and hash.

The listing reads no whole value, so it has only the stored hash. A full read hashes the
value it serves, and the two hashes differ for some values, such as an object with a
null field, which the served value drops. A runner records under the hash of the full
read, and [an acceptance](#a-required-suite) reads the state of that hash. For such a
row the listing's state, and the advice made from it, are therefore for the stored hash:
with results recorded the row lists `outdated`, and under a required suite the blocker
`checks_required`, whatever the acceptance answers. Serving one state for both needs the
listing to read each row's whole value.

The checks are read after `only` and `limit`, for the page alone, in two statements:
what each suite's current revision covers (no case kind, id or text), then, only when a
listed key is covered, one aggregate over the sets of the covered keys, grouped by key,
Expand All @@ -272,6 +295,45 @@ The listing never fails on the checks. When either read fails it answers with `c
null on every row and `checks_unread` in `degraded`: an unread state is never served as
`satisfied`, and the listing decides nothing.

## A required suite

A suite published with `required: true` makes its checks a condition of an acceptance.
`memory.proposal_decide` with `accept` reads, for the rows it picked, the same two
statements as the listing: what each suite's current revision covers, then the deciding
sets of the covered keys, each for the hash of the value the row serves, which is the
hash a full read answers and an acceptance sends. A key a
required suite covers is accepted only when that state is `satisfied` at the current
revision. Otherwise it answers the code `checks_required` with a sentence that names the
suite, the revision and what the results say, and stays pending; the other keys of the
call are decided.

- The check is the last refusal of an acceptance, after the proposer, the independence
and the hash checks, so it never hides one of them and a key it refuses is otherwise
acceptable.
- The two reads run one after the other inside the call's sequential reads, so both see
the writes the call's replica has taken. No broad `except` surrounds them: a read that
fails ends the call with a 5xx before any write. An unread state must not pass as
satisfied, and the listing's degraded answer has no place on a decision.
- A rejection, and the rejection an owner's policy writes, read no checks.
- The acceptance's audit row records what it read for a covered key: `checks`, with the
suite, the revision and the state.

This narrows Expand: where an owner required a suite, a proposal becomes a served fact
only with a record that its exact text did not break the suite's cases. It adds no
revision operator and changes no stored fact. A reviewer's read of the text and the
runner's results are different evidence: without the check an acceptance can be sent
with the results failed, outdated or absent. The check is on the acceptance alone,
because that is the one path where a person's decision is asked for: a direct write by a
writer of the namespace, a definition draft approved in the review queue and a promotion
are not checked, and the maintainer's guide says so.

A requirement is lowered by turning it off, or by removing a key, a prefix or a case
from a required suite. Each of those, and turning it on, writes
`knowledge.suites.requirement` with `audit.emit_strict` under the publish's claim and
before the insert: the suite, the revision before and after, the requirement before and
after, the keys and prefixes removed and the number of cases removed. The row is not
fail-open, since a requirement that can be lowered without a record holds nothing.

## Who reads a suite

A case states the answer an agent is expected to give, so the agents under test must not
Expand Down Expand Up @@ -342,6 +404,14 @@ That build refuses to publish a draft's id that the current revision does not ho
publishes a suite that already holds one, so a draft is taken through a replica of the
newer build ([rule 86](rolling-upgrades.md#the-rules)).

A build without the `required` column accepts a proposal without reading a suite, so a
requirement stated while such a build serves would hold on some replicas only.
`knowledge.suites.publish` with `required: true` therefore answers 503 `OVERLOADED`
until every live replica runs the migration that adds the column; a publish without the
field, or with `false`, is held only by the suites gate. After a rollback the older
build accepts unchecked, and the stored requirement applies again once the newer build
serves ([rule 102](rolling-upgrades.md#the-rules)).

## Limits

| Limit | Value |
Expand Down
22 changes: 22 additions & 0 deletions docs/architecture/rolling-upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,28 @@ See the [participant lifecycle baseline](cells.md#participant-lifecycle-baseline
`tests/unit/test_knowledge_reports.py` checks the refusal; the mixed-version gate
does not.

102. **A required regression suite** (`knowledge.suites.publish`, `memory.proposal_decide`,
migration 138): N stores whether a revision requires the suite's checks in
`loom.knowledge_suites.required` and refuses an acceptance of a covered key whose
checks are not satisfied. N-1 has no such check and accepts the key. So
`knowledge.suites.publish` with `required: true` answers 503 `OVERLOADED` until every
live replica of every deployment on the store runs migration 138, and while the
fleet cannot be read: a requirement is never stated while a replica would skip it. A
publish without the field or with `false` is not held by this gate. The column is
`Int8 DEFAULT -1`, and N-1 names its columns when it inserts a revision, so a
revision N-1 publishes states no requirement and the reads take the newest stated
value (`argMaxIf(required, revision, required >= 0)`): the suite keeps the
requirement it had. N-1 ignores `required` in a request and names it in
`ignored_args`, and its answers carry no `required`, which a client reads as its
signal that the requirement was not taken. After a rollback N-1 accepts unchecked
and the stored requirement applies again once N serves; nothing is turned off first.
A publish N-1 serves writes no `knowledge.suites.requirement` row: a key, a prefix
or a case it removes from a required suite is recorded only in the counts of its
`knowledge.suites.publish` row, and the requirement holds less once N serves.
`tests/unit/test_proposal_requirement.py` checks the gate, the constant against the
migration's file name and the read of a row N-1 wrote, and the mixed-version gate
does not check this rule.

## What checks them

`scripts/gates/mixed_version.py` (`make test-mixed-version`, the `mixed-version` CI job,
Expand Down
21 changes: 16 additions & 5 deletions docs/features/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,9 @@ row shows none.
When a listed proposal's key is covered by a regression suite, the tab has a **Suite
checks** column beside **Graded runs**: the state of the suite's checks for each proposal's
content, such as **4 of 4 passed**, **1 failed**, **No results yet** or **Results
outdated**, and an empty cell for a key no suite covers. It says **Checks unavailable** on
outdated**, and an empty cell for a key no suite covers. The cell of a suite that
[requires](regression-suites.md#require-passing-results) its checks ends with **·
required**. It says **Checks unavailable** on
every row when the server could not read the checks. See
[The state on each pending proposal](regression-suites.md#the-state-on-each-pending-proposal).

Expand All @@ -944,8 +946,11 @@ covers the key went for the text shown: the state, who recorded the results, wit
model and when, and one row a case with its baseline outcome, its outcome with the proposed
text and the change between the two; a case's id opens its prompt and its expected
behaviour. A role below `admin` reads the state the list shows, with the suite's name and
revision, and no case. The panel decides nothing, and a failed read of it leaves both
decisions as they are.
revision, and no case. For a suite that is not required the panel decides nothing. For a
required suite whose results the review read as not satisfied, **Accept** is unavailable
with the reason **A required suite's checks are not satisfied:** and the panel's own
first line; the comparison and the rejection stay. A failed read of the panel leaves both
decisions as they are, and the server answers an acceptance it refuses with its reason.
See [Suite checks in a proposal's review](regression-suites.md#suite-checks-in-a-proposals-review).

The Proposals tab's toolbar lists the queue **Newest first** or **Oldest first**, the
Expand Down Expand Up @@ -1010,7 +1015,8 @@ badge whose read fails is hidden.
suite: its name, the memory keys and key prefixes it covers, its cases counted by kind,
its revision, and who published that revision and when. A row names the first three keys
and the first three prefixes and counts the rest. A suite that covers no key is retired
and says **Covers nothing**. The drawer lists the page on a memory namespace only.
and says **Covers nothing**, and a suite that requires its checks says **Required**
beside its name. The drawer lists the page on a memory namespace only.

**New suite** opens a dialog for the suite's name, which cannot be changed afterwards, at
least one memory key or key prefix, and the first case. It publishes the suite's first
Expand All @@ -1036,7 +1042,12 @@ marked **Added**, **Edited** or **Removed** on its row, and nothing is sent unti
**Publish**. **Publish** counts the changes, lists them for confirmation, says that
[results](regression-suites.md#read-the-results-of-a-proposal) recorded for the revision
it replaces stop counting, and sends the whole suite as one revision, made from the
revision the page read:
revision the page read. The switch **Require passing results to accept a proposal** is
one of those changes: under it the page says **Holds proposals on these keys. A direct
write, a definition draft approved in the review queue and a promotion are not
checked.**, the confirmation of a publish that changes it adds that proposals on these
keys wait for new results, and after the publish the page says when a server a release
behind did not turn the requirement on, or off. After **Publish**:

- When the suite was published after the page read it, nothing is written. The page reads
the newer revision, applies the unpublished changes to it, names the cases changed on
Expand Down
Loading
Loading