Skip to content
Loom Docs
Esc
↑↓navigate↵open⌘Jpreview
Product
View as Markdown
On this page

Regression suites

A regression suite is a record of one namespace: a name, the memory keys and key prefixes it covers, and a set of cases that a change to those keys must not…

A regression suite is a record of one namespace: a name, the memory keys and key prefixes it covers, and a set of cases that a change to those keys must not break. Each publish writes one frozen revision. Loom stores suites and serves them to the namespace’s administrators; the job that runs the cases and grades the answers is outside Loom. The job records how each case went for one content of a covered key, and Loom derives the state of that content from what was recorded. Regression suites in the features section is the maintainer’s guide.

A suite is a record about memory, not a memory: it changes no served fact and takes no part in belief revision. It has no agent, user or session axis. Its identity is (org, namespace, suite), taken from the gated request, and written_by is the actor of the token (writer_actor).

Storage

loom.knowledge_suites is a plain MergeTree ordered by (org, namespace, suite, revision), insert only, with no partition and no TTL.

Column Holds
org, namespace, suite The suite.
revision Counts from 1.
memory_keys, memory_key_prefixes What the revision covers, sorted and without duplicates.
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, max(revision) and argMax of a tuple of the other columns. Taking the columns as one tuple means two rows can never contribute different columns to one answer. That read 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 that holds parts.

Publishing

knowledge.suites.publish takes the whole document and the revision it was made from. In order:

  1. A personal collection is refused: it has no suite.
  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, and for a body with required: true unless every live replica checks a required suite before an accept (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.
  5. Under the claim, two reads: the current revision of every suite of the namespace (coverage only) and this suite’s current row with its cases.
  6. The origin rule (below), which needs the stored cases.
  7. The document equal to the current revision answers written=false. A document made from an older revision answers conflict=true with the current revision. Neither 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. When the publish turns the requirement on or lowers it, the audit row knowledge.suites.requirement (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 claim is per namespace, not per suite, because the overlap check reads every suite of the namespace. It is taken with settled writes: an insert sent under the claim ends before the claim can pass to another publish, so the insert of a cancelled or timed-out call cannot land after the next publish has read the head.

Keys and prefixes are stored sorted and without duplicates and cases sorted by id, so a reordered file is the same document and writes nothing.

One suite per key

A key is covered by at most one suite of its namespace. The check and the lookup share one structure (Coverage): exact keys in a dictionary, prefixes in a dictionary, and the distinct prefix lengths. suite_for(key) looks the key up, then each key[:n] for the distinct lengths. A publish is refused when one of its keys is covered by another suite, or when one of its prefixes is covered by, or covers, another suite’s key or prefix.

A suite published with an empty selection covers nothing and frees its keys. It still counts toward the 200 suites, since its revisions stay stored.

The origin rule

A case may name the runs it was written from (origin: a namespace and a run id). The server sets a case’s origin, and the body only proposes it:

  • A case id the current revision does not hold takes the body’s entries. An id that starts with draft- is accepted there only when it is the id of a pending draft of the suite, and the case then takes the entries stored with the draft (draft cases).
  • A case id the current revision holds keeps its stored entries. The body may leave entries out, and may not add one.

So an origin is never dropped by an edit, and never added to a case after the fact.

Draft cases

A writer files a draft case with knowledge.suites.add_draft: a memory key and one case without an id. In order:

  1. The case is checked as a publish checks one, without a read.
  2. The fleet gate: 503 unless every live replica can erase a draft (rolling upgrades).
  3. The current revision of every suite of the namespace (coverage only). A key no suite covers answers 404.
  4. The number of pending drafts of the covering suite. At 200 the call answers 409.
  5. One insert under an id the server issues: draft- and twelve hexadecimal digits.

The answer is the id alone. The writer is an agent the suite grades, so neither the answer nor a refusal carries the suite’s name, a case or a count. The call takes no claim: the limit is read before the insert, so drafts in flight together may pass it by their number, which bounds the tray without making writers wait on each other.

loom.knowledge_suite_drafts is a plain MergeTree ordered by (org, namespace, suite, case_id, drafted_at), insert only, with no partition and no TTL, at index_granularity = 256.

Column Holds
org, namespace, suite The suite that covered the key when the draft was filed.
case_id The id the server issued.
content The case as canonical JSON, origin included. Empty for a dismissal.
drafted_by, drafted_at The actor of the token and the time, of the draft or the dismissal.

A draft’s state is not stored. A draft is pending when no row of its id is a dismissal and no revision of the suite holds the id, and each read derives that in one statement: the ids whose max(empty(content)) is 0, less the ids in arrayJoin(case_ids) of the suite’s revisions. A publish that takes a draft therefore writes nothing to this table, and a dismissal is one more row. The rule reads no drafted_at: a draft and its dismissal may be written through replicas whose clocks differ, and a dismissal stamped earlier than its draft still dismisses it. The statements that count pending drafts, or test ids, read empty(content), which reads the column’s sizes and not its text; only knowledge.suites.get and a publish that names a new draft- id select content.

knowledge.suites.dismiss_drafts writes a dismissal for each named id that is pending and skips the others, so a repeat dismisses nothing. knowledge.suites.get serves the pending drafts with a read of the current revision, their origins filtered with the cases’ in one pass, and knowledge.suites.list adds each suite’s count.

Reading

knowledge.suites.get reads one revision, the current one by default. It filters each case’s origin before it answers: an entry is served only when the caller holds viewer on the entry’s namespace and the run still exists (one statement over loom.agent_runs for all the entries). An entry that fails either test is left out with no marker, so the answer does not confirm a run the caller cannot read, or one that was erased. With the origin rule, a caller who is served fewer entries than are stored can publish what it read without losing them.

knowledge.suites.list reads the current revision of every suite: names, coverage, counts by kind, who published and when.

Both run inside own_write_reads(), so a read that follows a publish on another replica sees the publish.

Results

A result set records, for one memory key a suite covers and one exact content of it (content_sha256), how every case of one suite revision went with that content as the candidate and, when the runner sent it, on the published state in the same run (baseline). A result set is evidence about a proposal. It changes no fact and takes no part in belief revision, a pass grants nothing, and no decision reads it.

loom.knowledge_suite_results is a plain MergeTree ordered by (org, namespace, memory_key, suite, recorded_at), insert only, with no partition and no TTL, at index_granularity = 256.

Column Holds
org, namespace, suite The suite.
memory_key, content_sha256 What was run: the key, and the hash of the candidate content.
suite_revision The revision whose cases were run.
case_ids, candidate, baseline Parallel arrays in case id order: each case’s outcome with the candidate (pass, fail, unavailable) and on the published state (the same, or '' when not sent).
config What the runner said produced the outcomes; model is always present.
runner, recorded_at The actor of the token (writer_actor), and the serving replica’s clock.

The table holds no case text. A set has no agent, user or session axis: like the suite, it is a record of the namespace.

Recording a set

knowledge.suites.submit_results, in order:

  1. Checks without a read (server/knowledge/domain/suite_state.py): each case named once, and a config with a non-empty model and pairs in shape.
  2. The fleet gate: 503 unless every live replica can erase a result set (rolling upgrades).
  3. One read of the suite’s current revision: what it covers and its case ids, no case text. It runs inside own_write_reads().
  4. The refusals: 404 when the suite has no revision, 409 when revision is not the current one, 422 when the suite does not cover the key or the outcomes do not name every case of the revision exactly once.
  5. One insert. The answer is the state and counts of the set as sent.

The submit reads no memory row, so a set for a hash that no proposal holds is stored. A set is complete by construction: a case that could not run is sent as unavailable, and a revision is frozen, so a stored set names every case of its revision. That is why the state needs only counts. No claim is taken: a publish that lands between the read and the insert leaves a set for the revision before it, which reads outdated.

The state

The state is derived on every read by one pure function and is never stored. For a key covered by suite S at current revision N and a content hash H, with C the newest set for (key, S, H, N):

State When Counts served
satisfied C exists, no case failed and none was unavailable of C
failed C exists and a case failed of C
missing C exists with no failed case and an unavailable one, or no set names the key under S of C, or zeros
outdated No C, and a set names the key under S with another hash or another revision zeros

No evidence is no verdict: an unavailable case and an absent set read missing, never satisfied.

knowledge.suites.results reads the namespace’s suite heads (coverage and case ids), then one aggregate over the sets of the key under S, grouped by content hash and revision (server/knowledge/store/suite_results.py). The group of (H, N) is ordered first and the read takes two rows, so the answer holds two rows at most: the group of (H, N) when it has a set, and another group when one exists. The scan is not bounded: the statement reads every set stored for the key under S and builds every group before it orders them. Only a namespace erasure removes a set, so the scan grows with the key’s history. Inside a group the deciding set is argMax(columns, (recorded_at, has a failed case, has an unavailable case)): the newest set, and of sets with one recorded_at the worse one. recorded_at is the serving replica’s clock, and the skew between replicas is below the length of a run. earlier is the group’s size less one, and earlier_failed its sets with a failed case, less the deciding set when it has one.

Each case of C carries a change, derived inside the set: fixed (baseline fail, candidate pass), regressed (the reverse), same, unavailable (either side, so an outage is never a fix or a regression) and no_baseline. Loom computes no rate, threshold or statistic; the runner states its trial rule in config.

The state on a proposal listing

memory.proposals serves the same state on each row it returns, as checks: the covering suite, its current revision, the state and the counts of C for the row’s stored content hash. A high row lists it too: the server reads with the stored hash, which the row does not serve. The listing and knowledge.suites.results call the one state 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 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, suite, content hash and revision, that selects each group’s deciding outcomes and no case id, baseline or config. The keys are bound a slice at a time, so a page of long keys takes one statement a slice. A slice that holds more than 20,000 groups is not cut: the read fails, since a cut read could drop the group that decides. count_only reads neither table. The reads are plain: a set recorded on another replica shows on the next listing.

The listing never fails on the checks. When either read fails it answers with checks 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 read it, and must not record how they did on it:

  • Six of the seven ops need admin on the namespace. knowledge.suites.add_draft needs writer and answers the draft’s id alone.
  • memory.proposals, at its viewer floor, serves for a pending proposal the name of the suite that covers its key, the suite’s revision, the state and the number of cases by outcome. A proposer learns why its proposal waits, and no case id or text. A token narrowed below the namespace gets no checks: a set carries no user or session, so the state of the caller’s row would show that a set exists for another user’s content of the key.
  • A token narrowed below the namespace (to a user or a session) is refused at the gate: a suite row carries no user to filter by.
  • The six ops are hidden from MCP, under every toolset. knowledge.suites.add_draft is on no toolset’s listing and is called by name.
  • Case text is stored in loom.knowledge_suites and loom.knowledge_suite_drafts and reaches no memory row, record, embedding or text index. Search, recall, context packs and exports cannot return it.
  • An answer of knowledge.suites.get sent with an Idempotency-Key is kept for 24 hours in the replay cache (loom.idempotency). It is served to the same caller only and removed by the namespace’s erasure.
  • The audit row of a publish holds the suite’s name, the revisions, the outcome, the number of keys, prefixes and cases by kind, the length of the canonical cases and a keyed hash prefix of them. It holds no case id and no text. The hash is keyed with the deployment’s signing secret because the audit log is read by every reader of the namespace and outlives the suite: a plain hash would let a reader confirm a guessed case.
  • The audit row of a submit holds the suite’s name, the revision, the memory key, the content hash, the number of cases by outcome and the names of the config pairs. It holds no case id and no config value.
  • The audit row of a draft holds the memory key, the id the server issued, the case’s kind, the length and a keyed hash prefix of the stored case and the number of origin entries. The audit row of a dismissal holds the suite’s name, the ids named and how many were dismissed; a named id has the shape the server issues, so it is no text a person wrote. Neither holds case text.

Erasure

The three tables are in the erasure census at namespace scope. A namespace erasure deletes the namespace’s rows of each in the knowledge_suites.delete step, one mutation a table. A user’s erasure has no step for any of them: a case, a result set and a draft belong to the namespace and name no user, so a draft, or a case written from a user’s run, outlives that user’s erasure. Nothing short of erasing the namespace removes a revision, a result set or a draft, a dismissed draft’s text included.

Rolling upgrades

A build without the table serves none of the ops, and its namespace erasure has no step for the table. knowledge.suites.publish therefore answers 503 OVERLOADED until every live replica of every deployment on the store runs the migration that adds the table, and while the fleet cannot be read. The reads are not held. A rollback leaves the rows stored and unserved; a namespace erasure the older build runs leaves them, and is run again once the newer build serves (rule 86, the rollback note).

The results table follows the same rule at the migration that adds it. A build without it serves neither results op, and its knowledge_suites.delete step deletes the suites and leaves the result sets. knowledge.suites.submit_results therefore answers 503 OVERLOADED until every live replica runs the migration that adds the results table; knowledge.suites.results is not held (rule 91).

The drafts table follows it too. A build without it leaves the drafts in a namespace erasure, so knowledge.suites.add_draft and knowledge.suites.dismiss_drafts answer 503 OVERLOADED until every live replica runs the migration that adds the drafts table. That build refuses to publish a draft’s id that the current revision does not hold, and publishes a suite that already holds one, so a draft is taken through a replica of the newer build (rule 86).

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).

Limits

Limit Value
Suites in a namespace 200
Cases in a revision 200
Exact keys in a revision 200
Key prefixes in a revision 50
Origin entries in a case 8
Origin namespaces named in a revision 16
Outcomes in a result set 200
Pairs in a result set’s config 16
Pending drafts of a suite 200
Draft ids in one dismissal 200

The limits are fixed, not settings: they bound the size of one row and of the coverage read a publish makes under its claim.

Last updated on

Was this page helpful?