---
title: Regression suites
lastModified: '2026-12-05T15:55:08.000Z'
description: '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.
[Regression suites](/docs/features/regression-suites) in the features section is the
maintainer's guide.

```mermaid
flowchart LR
    F["suite file"] -->|"knowledge.suites.publish<br/>(admin)"| T["loom.knowledge_suites<br/>one row per revision"]
    T -->|"knowledge.suites.get<br/>(admin)"| J["evaluation job"]
    T -->|"knowledge.suites.list<br/>(admin)"| L["names, coverage, counts"]
```

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

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 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
   ([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.
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. One insert at `revision + 1`.

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 refused there: the prefix is kept for ids the server issues.
- 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.

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

## Who reads a suite

A case states the answer an agent is expected to give, so the agents under test must not
read it:

- The three ops need `admin` on the namespace.
- 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 ops are hidden from MCP, under every toolset.
- Case text is stored in `loom.knowledge_suites` 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.

## Erasure

The table is in the erasure census at namespace scope. A namespace erasure deletes the
namespace's rows in the `knowledge_suites.delete` step, a mutation. A user's erasure has
no step for the table: a case belongs to the namespace and names no user. Nothing short
of erasing the namespace removes a revision.

## 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](/docs/architecture/rolling-upgrades#the-rules), the
[rollback note](/docs/operations/upgrades#rollback)).

## 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    |

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