---
title: Run a correction through review and publication
lastModified: '2026-12-06T10:23:58.000Z'
description: 'Needs a disposable org on a Loom server and three tokens minted for it. sdk/python/examples/knowledge_factory.py runs one correction over HTTP: a weekly report…'
---

Needs a disposable org on a Loom server and three tokens minted for it.
[`sdk/python/examples/knowledge_factory.py`](https://github.com/ClickHouse/loom/blob/main/sdk/python/examples/knowledge_factory.py)
runs one correction over HTTP: a weekly report fails on an outdated definition, the
reporter files a problem report against the revision it read, a writer prepares a
correction from the source document, an administrator approves the exact text and
resolves the report with the published revision, and a fresh run is served the
published definition and passes on other numbers. This guide gives the commands, what a
pass proves, the reads that show it without the script, and the limits.

The reporter, the curator, the reviewer and the grader are scripted, and no call is
answered by a model. A pass shows that Loom keeps its contract. It does not measure an
agent.

The run does not exercise the following, and its result lists each under `coverage`:

- a curation pass, its retry after an interruption, a source that changed before the
  approval, and a guard against publishing twice
- a run by a real agent, and the MCP transport

Until the first is exercised the result reads `qualified: false`, also when every
check passes.

The [knowledge factory walkthrough](/docs/use-cases/knowledge-factory#run-a-knowledge-factory-walkthrough)
is a shell session that publishes a document and saves a lesson citing it. This guide
starts later: a published definition turns out wrong.

## Run it

Install the Python SDK (`pip install clickhouse-loom`) and set the inputs. Each has a
flag of the same name, such as `--team-namespace`.

| Variable                                                                 | Meaning                                     |
| ------------------------------------------------------------------------ | ------------------------------------------- |
| `LOOM_BASE_URL`, `LOOM_ORG`                                              | The deployment and a disposable org         |
| `LOOM_TEAM_NAMESPACE`, `LOOM_REPORTER_NAMESPACE`                         | Two namespace names that do not exist yet   |
| `LOOM_REVIEWER_API_KEY`, `LOOM_CURATOR_API_KEY`, `LOOM_REPORTER_API_KEY` | The three tokens, each with its own subject |

From an operator shell that holds the signing key
([mint a token](/docs/guides/tokens-and-grants#mint-a-token)):

```sh
suffix=$(date +%s)
export LOOM_TEAM_NAMESPACE=kf-team-$suffix LOOM_REPORTER_NAMESPACE=kf-reporter-$suffix
export LOOM_REVIEWER_API_KEY=$(loom mint-token --user-token --subject kf-reviewer \
  --org "$LOOM_ORG" --namespaces "$LOOM_TEAM_NAMESPACE" --roles admin --ttl-days 1)
export LOOM_CURATOR_API_KEY=$(loom mint-token --subject sa:kf-curator \
  --org "$LOOM_ORG" --namespaces "$LOOM_TEAM_NAMESPACE" --roles writer --ttl-days 1)
export LOOM_REPORTER_API_KEY=$(loom mint-token --subject sa:kf-reporter \
  --org "$LOOM_ORG" --namespaces "$LOOM_TEAM_NAMESPACE" "$LOOM_REPORTER_NAMESPACE" \
  --roles writer --ttl-days 1)
python sdk/python/examples/knowledge_factory.py run --result kf-result.json
```

The reviewer is a person with `admin` on the team namespace. The curator and the
reporter are service accounts with `writer`; the reporter's token also names a
namespace of its own. Nothing is turned on at the server, and the example sends no
model credential: Loom embeds on the server.

The run prints one line per stage, then the result document, which it also writes to
`--result`. Each stage of the result lists the request ids of its calls, except the
identity and capability reads of preflight.

| Exit | `status`      | Meaning                                                                          |
| ---- | ------------- | -------------------------------------------------------------------------------- |
| 0    | `passed`      | Every check passed; read `qualified` for the gate                                |
| 1    | `failed`      | A check failed, or the server refused a call during the run                      |
| 2    |               | A usage error                                                                    |
| 3    | `not_ready`   | The setup is wrong: a token, a grant, a fixture file, a namespace that is in use |
| 4    | `unavailable` | The deployment does not serve an op or a request field the run needs             |

A usage error names the options the command does not take and counts every other word
without printing it: such a word may be a token.

Before the first write, preflight names everything the run lacks, each as one entry of
`stages[0].misses`. It checks the inputs, among them a base URL that is not an http or
https URL with a host and a `--result` path whose directory is missing or cannot be
written, reads each token's identity (`GET /v1/whoami`) and claims, asks the deployment
for every op and request field of the run, and checks that the team namespace is absent
and holds no grant. A run that cannot write its result file still prints the result.

Three things to know before running:

- **Names are spent after a run.** A namespace's registry row and its grants outlive
  the cleanup. For another run, choose a new suffix, mint the tokens again and name a
  new `--result` path: a run does not replace a result file that holds a run.
- **Send no request that names the reporter's namespace before the run.** Loom lets a
  `writer` register a name only while nothing is recorded under it, and a read that
  runs over its latency budget is recorded under the namespace it names. The reporter's
  registration is the first request of the run that names its namespace. When the
  server refuses it the run ends `not_ready` before any write.
- **The server provisions a personal namespace for the reviewer.** On the reviewer's
  first op call, when its subject holds no grant in the org, Loom registers
  `personal-kf-reviewer` with an admin grant. The example neither writes to it nor
  erases it. One reviewer subject for every run in an org provisions it once.

## The stages

| Stage           | Token              | What happens                                                                                                                                                                                                                                                                                                                                                |
| --------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `preflight`     | all three          | Identity, claims, ops and fields, the absent team namespace; then the two writers' `memory.definitions.list` must answer 403                                                                                                                                                                                                                                |
| `setup`         | all three          | `namespace.register` for both names with the run's marker, and the curator's refused read of the reporter's namespace; the definition (`memory.set`, `memory.promote`), the data dictionary (`knowledge.upsert`), the procedure (`procedure.add`), a personal request; then a `memory.search` of the shared scope for the copy the promotion wrote          |
| `run_1`         | reporter, reviewer | `run.begin`, a labelled `memory.search` and `memory.get`, the report on week 1's numbers, `run.complete` with a reflection, `run.grade`: fail, then `run.reliance`, which lists the copy the first promotion wrote                                                                                                                                          |
| `report`        | reporter, reviewer | `memory.get` of the definition's source row, then `knowledge.reports.submit` against that revision with the run and its reflection as evidence, and the same submit a second time; the reviewer's `knowledge.reports.update`: `take`, then a `resolve` that answers 422; `knowledge.reports.get`, whose target and report id the reviewer hands the curator |
| `investigation` | curator            | `memory.get` of the definition, which must hold the revision the report names; `knowledge.get` of the source document, then the candidate: `memory.set` with `if_match_sha256` and `source_resource_id`; the same write sent a second time answers 409                                                                                                      |
| `review`        | all three          | What a reader is served meanwhile, two refused promotions, an amended candidate, a stale approval refused with 409, a personal request proposed for the team and rejected, a team note proposed and accepted, a note the reviewer proposed and cannot accept                                                                                                |
| `publication`   | reviewer           | `memory.get` of the amended text, `memory.promote` of that read's hash, `memory.lineage`, `audit.list`, `knowledge.reports.update` with `resolve` and the published revision, then a `memory.search` of the shared scope for the copy the promotion wrote                                                                                                   |
| `run_2`         | reporter, reviewer | A new client, session and run on week 2's numbers: the first search result is the governed definition, the report passes, and `run.reliance` lists the copy the correction's promotion wrote                                                                                                                                                                |
| `evidence`      | reporter           | `run.get` for both runs, the reflection, `memory.provenance`, the resolved report (`knowledge.reports.get`)                                                                                                                                                                                                                                                 |

The numbers come from the fixture's numbers source on every run and are never saved as
knowledge: no request of the example holds one of them.

## What Loom enforces and what the example arranges

| Property                                                    | Loom                                                                                                                                                             | The example                                                                                                 |
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| Publication needs `admin` on the namespace                  | Enforced: `memory.promote` answers 403 to a `writer`                                                                                                             |                                                                                                             |
| An approval names the exact text                            | Enforced: `approved_sha256`, else 409 `PRECONDITION_FAILED` with `current_sha256`                                                                                | Reads the text again after a 409                                                                            |
| A write does not replace a revision its writer did not read | Enforced for a write that sends `if_match_sha256`: 409 when the row holds another hash                                                                           | Both of the curator's writes send it                                                                        |
| The approver of a definition is a person                    | Not enforced: a service account with `admin` can promote                                                                                                         | Preflight requires a person's token for the reviewer                                                        |
| The approver is not the author                              | Not enforced for a promotion                                                                                                                                     | By tokens: the curator holds `writer`; the result shows author and approver                                 |
| Deciding a proposal needs `admin` on the namespace          | Enforced: `memory.proposal_decide` answers 403 to a `writer`                                                                                                     |                                                                                                             |
| A person other than the proposer accepts a proposal         | Enforced by `memory.proposal_decide` ([proposals](/docs/features/memory/writing#proposals))                                                                      | The reviewer cannot accept a note it proposed: 200 with nothing decided                                     |
| A proposal is not served                                    | Enforced: a `proposed` row is in no search result                                                                                                                | The same search returns the row once it is accepted                                                         |
| A `writer` cannot change an active team row without review  | Not enforced                                                                                                                                                     | A limit, below                                                                                              |
| The approved definition stays served during review          | No: an edit of its source row ends governance until the next approval                                                                                            | The reporter uses a definition only from a governed hit                                                     |
| The link from the problem to the correction                 | Held: a report keeps the revision it was filed against and, once resolved, its `resolution_revision` ([knowledge reports](/docs/architecture/knowledge-reports)) | Files the report and resolves it with the revision the promotion published                                  |
| One problem is one report                                   | Enforced: the same reporter, kind, target and problem text give the same `report_id`                                                                             | Sends the same `knowledge.reports.submit` twice                                                             |
| Only an administrator takes, resolves or dismisses a report | Enforced: `knowledge.reports.update` needs `admin` on the namespace                                                                                              | The reviewer takes and resolves; the curator holds `writer` and calls no report op                          |
| A resolution names a newer revision                         | Enforced: 422 while the target holds no revision newer than the reported one, and for a number other than the version `memory.get` serves                        | The reviewer's `resolve` before the correction is refused                                                   |
| A resolution names a published revision                     | Not enforced: a newer revision of the source row resolves a report, promoted or not                                                                              | The reviewer resolves after the promotion; a limit, below                                                   |
| The revision a run was served                               | Kept as a read receipt where one is written; `run.reliance` lists it ([what a run read](/docs/features/runs#what-a-run-read))                                    | Reads it after each run and compares it with the copy the last promotion wrote; a run with no receipt fails |
| An independent grader                                       | Not enforced: `run.grade` takes any `writer`                                                                                                                     | The reviewer's token grades; the audit row shows who called                                                 |
| No duplicate publication                                    | Not enforced: `memory.promote` is not idempotent                                                                                                                 | One call; one that gets no usable answer is settled by reads                                                |

[Governed definitions in search](/docs/concepts/identities-and-namespaces#governed-definitions-in-search)
explains when a definition is governed and how a query matches its term.

## What the example checks

1. Only an administrator publishes, and a `writer` cannot decide a proposal. The
   curator's and the reporter's `memory.promote` and the curator's
   `memory.proposal_decide` answer 403, and the definitions list is unchanged after
   them. The curator's decision is a rejection, which the role alone refuses: an
   acceptance also needs a person. A refusal counts only as Loom's 403, which carries
   the code `AUTH_INSUFFICIENT`. After publication `memory.lineage` names the reviewer
   as `promoted_by` and `memory.get` names the curator as `actor`.
2. An approval names the text it approved. The reviewer's approval of the hash it read
   before the curator amended the candidate answers 409 with the current hash. The
   reviewer reads the row again, compares it with the text it accepts and approves the
   hash of that read.
3. A candidate write names the revision it read. Both of the curator's writes send
   `if_match_sha256`, and the candidate write sent a second time answers 409 with the
   current hash, because the revision it names is gone.
4. Nothing unreviewed is served as governed. While the candidate awaits review the
   definition is `lapsed` with reason `changed`, no search hit is governed, and the
   reporter, given that search, produces no report.
5. A proposal is served only once it is accepted. The curator cannot read the
   reporter's namespace. The personal request it writes as a team proposal is listed,
   stays `proposed`, is in no result of a search for its text and is rejected by the
   reviewer with the hash of the entry it read in the list. A second proposal, a team note, is the control: the same search for its
   text does not return it while it is proposed and returns it once the reviewer
   accepted the hash of the entry it read in the list. A proposal's own writer cannot
   accept it: the reviewer proposes a note and accepts it with the hash its write
   answered. The call answers 200 with `decided: 0`, and the key's result reads
   `decided: false` and `status: "proposed"`. The reviewer then rejects the note with
   the same hash, which takes no second person. The check reads these fields and not the reason text.
6. The fresh run is served the published text. Its first search result is governed,
   `term_leg` is `complete`, the served value equals the approved one, and the report
   equals the expected report for week 2.
7. Loom recorded the revision each run was served, and it is the published one. After
   each promotion the reviewer reads the version of the shared copy the promotion wrote.
   After each run the reporter reads `run.reliance`, whose newest version for the
   definition must be that copy's: run 1 was served the copy of the first promotion and
   the fresh run the copy of the correction.
8. The correction leaves a question it does not concern unaffected. The report's title
   and account count rest on the procedure row: both runs read the same revision of it
   and both get that part right.
9. Evidence is three objects per run and none fills in for another: what `run.get`
   reports Loom returned (`returned`), what the client reported it relied on
   (`client_reported`), and the grade with the caller Loom recorded (`graded`). Where
   `run.get` reports the keys the labelled search returned, the check fails unless
   `returned` holds the definition's key.
10. A problem is reported against the revision that was read. The reporter reads the
    definition's source row and files `knowledge.reports.submit` with that read's
    `version_text` and `content_sha256`, the run in `run_id`, and two references as
    evidence: `run:<run 1>` and `reflection:<run 1>`. The same request sent a second
    time answers the same `report_id`, state and version. The report the reviewer then
    reads names that revision, reads `target_changed: false` and serves both references.
11. Only an administrator takes, resolves or dismisses a report, and a report resolves
    only with a newer revision. The reviewer takes the report. Its `resolve` that names
    the reported revision answers 422 `VALIDATION_FAILED` with a message that names
    that revision, and the report stays `taken` at version 2. Only its reporter and an
    administrator read a report, so the reviewer hands the curator the target the
    report names and its id; the curator reads that revision and calls no report op.
    After the promotion the reviewer resolves the report with the `version_text` that
    `memory.get` served, and the reporter reads its report as `resolved` with that
    `resolution_revision`.
12. Every link between the stages is typed and says who holds it: `loom`, or `client`
    for a link that is only text the example wrote.

`tests/unit/test_sdk_example_knowledge_factory.py` runs the example against a scripted
server, and `tests/integration/test_sdk_example_knowledge_factory.py` against a live
one, where it also compares the result with the fixture's `expected.json`.

## Check it yourself

With the names and ids of the result file, each read as the token named:

1. `run.get` on run 1 (any of the three): `grade` is `fail`, and `memories_used` holds
   the definition's and the procedure's keys.
2. `memory.get` on `reflection:<run 1>` with agent `kf-reporter` (any): the problem as
   the reporter recorded it.
3. `memory.provenance` on `definition/active-account` with agent `-` (any):
   `source_resource_id`. Then `knowledge.get` on the source URI: the same `doc_id`, and
   its `revision`.
4. `memory.lineage` on the definition with agent `-` and `scope: "shared"` (any):
   `promoted_by`, `rationale`, `promotion_event`.
5. `audit.list` with `event_type` `memory.promote`, then `run.grade` (reviewer): who
   called each, by request id.
6. `memory.search` for "What is an active account?" (any): the first result has
   `governed: true`. `memory.definitions.list` (reviewer): `verdict` is `governed`.
7. `run.get` on run 2 (any): `grade` is `pass`.
8. `run.reliance` on each run (any): the item of `definition/active-account` reads
   `reported` and lists one revision. Its highest version is the one the run's stage
   names.
9. `memory.search` for the same question with `scope: "shared"` and `min_body_chars: 1`
   (any): `term_leg` is `off`, and the hit of `definition/active-account` carries the
   `version` the correction's promotion wrote, the one run 2's stage and the `copy` of
   the `publication` stage name. The version is a number above 2^53: read it with a
   client that keeps integers whole, such as Python.
10. `knowledge.reports.get` with the `report_id` of `ids` (reviewer or reporter): `state`
    is `resolved`, `target_version_text` is the version the `report` stage names and
    `resolution_revision` the one the `publication` stage names. `knowledge.reports.list`
    with `target_key` `definition/active-account` (reviewer): that one report.

## The result document

| Field          | Holds                                                                                                                                                                                                                                                                                         |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mode`         | `deterministic`: every role is scripted                                                                                                                                                                                                                                                       |
| `status`       | `passed`, `failed`, `not_ready` or `unavailable`; `running` in a file whose run did not reach its end                                                                                                                                                                                         |
| `qualified`    | True when the run passed and every gating coverage entry is exercised                                                                                                                                                                                                                         |
| `run`          | The run's id and marker, the base URL without any `user:password@`, the org, the two namespaces and the three subjects                                                                                                                                                                        |
| `stages`       | Each stage's status and request ids; a `revision` where the stage read one; for `report` the `handoff`, the target and the report id the reviewer hands the curator; for `setup` and `publication` the `copy` the promotion wrote; for the two runs `served` and the `revision` Loom recorded |
| `runs`         | Per run: the report, the control question, `returned`, `client_reported`, `graded`                                                                                                                                                                                                            |
| `links`        | Problem, correction, source, review, published revision, later run and outcome: a typed `ref`, `held_by` and the `read` that shows it                                                                                                                                                         |
| `observations` | What a reader is served while a candidate awaits review; values of this path, not required behaviour                                                                                                                                                                                          |
| `coverage`     | What this version exercises, and the capability each entry that is not exercised needs                                                                                                                                                                                                        |
| `checks`       | Every check, with its stage and a detail; a refusal, a grade, the search during review and the audited promotion name their request id                                                                                                                                                        |
| `ids`          | The source document's `doc_id`, the two promotion events and the report's id                                                                                                                                                                                                                  |
| `cleanup`      | `not_run`, `completed` or `failed`; after a cleanup also `erasures` and `remains`                                                                                                                                                                                                             |

A revision is the source row's `version_text` and `content_sha256` from one
`memory.get`, with `read` saying which. The version is a decimal string: as a number it
is above 2^53, which a reader holding doubles rounds.

The two run stages hold another kind of revision. A governed hit carries no version
and no hash. Loom keeps the revision each labelled read held as a read receipt under
the run's `run_id`, and `run.reliance` lists the versions a run was served
([what a run read](/docs/features/runs#what-a-run-read)). Once a run is closed and
graded, the reporter reads its report, the run prints one line for each item of it,
and the stage's `revision` holds the newest version listed for the definition, with
no hash: the op answers none.

That version names the namespace's shared copy, the row a governed hit is served from
([the version and the hash](/docs/architecture/read-receipts#the-version-and-the-hash)).
A promotion writes the copy at a version of its own, so it differs from the
`version_text` of the source row, and `memory.promote` does not answer it. The
reviewer reads it after each promotion with a `memory.search` of the shared scope
whose term leg is off: `scope: "shared"` and `min_body_chars: 1`, a floor that drops
no row with a text and
[turns the leg off](/docs/concepts/identities-and-namespaces#governed-definitions-in-search).
The hit is then the copy's search document. Its `version` is that document's, which a
promotion writes at the copy's version, and its text is the copy's under the
`bodies: "unit"` every search of the example sends. A promotion writes the copy and
then its search document, so the read is repeated until the hit holds the approved
text at a version other than the `copy` of the promotion before, and the `setup` and
`publication` stages keep the version as `copy`. A search hit holds the version as a
number, which the Python client reads whole; the result holds it as decimal text.
`memory_type` does not select the copy: `memory.search` takes no `definition` type.

Each run's `served_the_published_copy` check then compares the two: the newest version
`run.reliance` lists for the definition must be the `copy` of the last promotion
before the run.

The report can list a second, older version in the same revision. A search that
answers before the term leg serves the copy returns the source row as an ordinary hit,
and the reporter searches again. The row holds the same content at its own version,
so the report lists one revision under both versions, and the newest is the copy's.

A receipt is written after its read answered, and the receipts of two searches can be
written apart, so the reporter repeats the read of the report for up to 10 s, until
its newest version is the copy's. The source row's version alone does not end the
wait. A report that still lists no version for the definition is not filled in from
another read: the stage prints `revision: "not_recorded"`, its `revision_recorded`
check fails and the run ends `failed`. A report whose newest version is not the
copy's fails `served_the_published_copy`, and the stage holds the version it lists.
A deployment writes no receipt while `LOOM_READ_RECEIPTS_ENABLED` is off or a replica
of an older build serves, and in the other cases of
[what gets none](/docs/architecture/read-receipts#what-gets-none).

`returned` holds what `run.get` reports and nothing else. It reads `not_recorded` unless
the server keeps the search trace log (`LOOM_SEARCH_TRACE_LOG_ENABLED`); it then lists
the keys the run's labelled search returned, and the run's evidence check fails when the
definition's key is not among them once the wait is spent. `recalled: -1` on `run.get`
means that it holds no count, not zero
([runs](/docs/features/runs#recalled-is-not-relied-on)).

## Coverage

| Entry                                                                                                | Exercised | Needs                          |
| ---------------------------------------------------------------------------------------------------- | --------- | ------------------------------ |
| `run_1`, `report`, `investigation`, `review`, `publication`, `run_2`, `evidence`, `control_question` | yes       |                                |
| `revision_receipts`, `repeated_report`                                                               | yes       |                                |
| `curation_pass`, `interrupted_pass_retry`, `stale_source_refusal`, `duplicate_publication_guard`     | no        | A curation pass                |
| `real_agent_run`                                                                                     | no        | An agent runner; does not gate |
| `mcp_path`                                                                                           | no        | An MCP client; does not gate   |

The table is a constant of the example's version. An entry reads exercised only in the
version that makes its calls and checks them, never at run time.

## Clean up, and what remains

```sh
python sdk/python/examples/knowledge_factory.py cleanup --result kf-result.json \
  --accept-org-cache-loss
```

`cleanup` needs the result file, the run's base URL and the reviewer's and the
reporter's tokens; it has no flag for the curator's. It erases the two namespaces of
the run with `erasure.request`, each with the token that holds `admin` there, and
waits for `erasure.status` to read `completed` with no residue
([erasure](/docs/features/memory/retention-and-erasure#erasure)).

It refuses, with no erasure request sent:

- a `--result` path that holds no file, or a file that is not a result file
- a call without `--accept-org-cache-loss`: an erasure also deletes the org's replay
  cache and its cached query vectors, which is why the org must be disposable
- a base URL or one of the two tokens that is not set, a base URL other than the one
  the result file records, each compared without `user:password@`, and one that is
  not an http or https URL with a host
- a namespace whose tags lack the marker in the result file

`cleanup` asks for the erasure of each namespace once, however many times it runs.
The erasure runs inside its request, so `cleanup` writes an entry for the namespace to
the result file before it sends the request, with status `requested` and no id, and
the erasure's id as soon as the request answers. A request that gets no usable answer
may have erased: no response, a 5xx, or a 2xx whose body is not the server's JSON,
such as a proxy's page. `cleanup` then reads the erasure's id from `erasure.list` and
sends no second request. When the ledger shows no erasure of the namespace, the pass
ends `failed` and a later pass reads the ledger again. To have the erasure asked for
again, remove that namespace's entry from `erasures` in the result file. A request
the server refused with a 4xx erased nothing and leaves no entry.

A later `cleanup` reads the status of the erasures the file records and sends no
request for them, also after a pass that failed. An `erasure.status` answer that does
not find the erasure is read again, for as long as one that reads `in_progress`, and
replaces nothing the file records. `cleanup` exits 0 when every erasure completed
with no residue, 1 when one did not or a namespace the run registered is absent, and
3 when it refused.

What remains, as the result's `remains` lists it: the registry rows of both
namespaces, the admin grants their registration wrote, the reviewer's provisioned
namespace with its grant, the audit rows, and the erasure ledger rows.

## What the agent host runs

Loom holds the knowledge, its review state and each run's evidence. The loop around
them runs in the agent host. In the example a script plays every part.

| Part                               | The host                                                                                           | Loom                                                                                                                                         |
| ---------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| The reporting agent, on a schedule | Starts each run, labels its reads with it, reports what it relied on                               | `run.begin`, `run.complete` with `memories_used` ([runs](/docs/features/runs))                                                               |
| The report of a problem            | Files it against the revision the agent read, with the run as evidence; maintainers work the queue | `knowledge.reports.submit`, `knowledge.reports.list`, `knowledge.reports.update` ([knowledge reports](/docs/architecture/knowledge-reports)) |
| The sweep that finds work          | Lists failed and ungraded runs, and questions no source answered                                   | `run.list` with `grade`; [`knowledge.gaps.list`](/docs/features/knowledge#knowledge-gaps) where it is on                                     |
| The curator                        | Reads the reported revision and the source document, writes the candidate                          | `memory.set` with `if_match_sha256` and `source_resource_id`                                                                                 |
| The evaluator                      | Decides each grade and names itself in `source`                                                    | `run.grade` records the grade and its caller, and judges nothing                                                                             |
| The display of what an answer used | Shows the keys a run reported and, where listed, those its search returned                         | `run.get`: `memories_used`, `recalled_keys`; `run.reliance`: the versions served                                                             |

## Limits

- **A `writer` can end governance.** Any `writer` of the namespace can edit a
  definition's source row, which stops it being served as governed, and can write an
  active team row without a proposal.
- **A service account can publish.** Loom requires `admin` for `memory.promote`, not a
  person, and not someone other than the author. Proposal acceptance requires both.
- **Review has a gap.** While a candidate awaits review the approved definition is not
  served as governed, and the candidate is an ordinary row every reader of the
  namespace can read. The result records both under `observations`.
- **Another form of the term is a silent miss.** A term matches at word edges, and a
  word in capitals only as written. A query that names another form is answered with
  `term_leg` `complete` and no governed hit. `governed` is on a hit only when true.
- **After a 409 on a promotion, read the text again.** Never send `current_sha256` back
  unseen: it names text the approver has not read.
- **A `memory.promote` that gets no usable answer is settled by reads**, never by
  sending it again: no response, a 5xx, or a 2xx whose body is not the server's JSON.
  The example reads the definitions list, the source row and the lineage until they
  show the promotion. Only the lineage names it, by its rationale: the row held the
  approved hash before. Any other write that ends this way fails the run and is not
  sent again.
- **`grade_source` is text the caller sent.** The audit row says who graded.
- **A resolution needs a newer revision, not a promotion.** `knowledge.reports.update`
  compares `resolution_revision` with the version `memory.get` serves for the source
  row. A candidate that awaits review is such a revision, so an administrator can
  resolve a report before its correction is published. The example resolves after the
  promotion.
- **Name the run when filing through the Python SDK.** `Agent.call` sends `-` for a
  `run_id` the caller does not set, and `knowledge.reports.submit` reads it as a run:
  the call answers 422 with `evidence 'run:-' was not found`. The example sends the
  failed run's id.
- **The report stage needs every replica on the reports migration.** While a live
  replica runs a schema below the migration that adds the reports table,
  `knowledge.reports.submit` and `knowledge.reports.update` answer 503. A run that
  reaches the `report` stage then ends `failed` there, after `setup` registered both
  namespaces, whose names are spent. Run the example once the rolling upgrade is done
  ([rolling upgrades](/docs/architecture/knowledge-reports#rolling-upgrades)).
- **The copy's version is read by a search.** `memory.promote` and `memory.lineage`
  answer no version of the shared copy, and `memory.get` serves the source row. The
  example reads the copy with a `memory.search` of the shared scope, so the read
  depends on the ordinary legs returning the definition for the question that names
  its term. The hit's version is its search document's. A search document the
  embedding worker filled after a promotion's inline embedding failed sits one
  version above its copy, and the run then fails `served_the_published_copy`.
- **A run with no receipt fails.** The example needs a deployment that writes read
  receipts: a report that lists no version for the definition ends the run `failed`.
- **Run 1's fail grade stays with the key.** Grades are counted against each key a run
  relied on, so the corrected revision carries the earlier failure
  ([graded runs](/docs/features/runs#graded-runs)).
- **HTTP only.** A read over MCP is filed under the connection's implicit run, so its
  run evidence differs.
- **Minted, flat tokens only.** The tokens come from `loom mint-token` with
  `--namespaces` and `--roles`. Preflight refuses a token minted with
  `--namespace-role`. A token minted with a `--read-scope` below the namespace fails
  the run: Loom refuses it `memory.promote`, `run.reliance` and every
  `knowledge.reports.*` op, and bounds its reads to one user or session
  ([read scope](/docs/concepts/identities-and-namespaces#read-scope-inside-a-namespace)).
  A reviewer signed in through an identity provider, and a token pinned to one user,
  are not covered by the example's tests.
- **Preview ops.** The example calls these ops that the [status page](/docs/reference/status) lists as preview:
  - marked `experimental`: `memory.definitions.list`, `memory.promote`, `memory.lineage`, `memory.proposals`, `memory.proposal_decide`, `knowledge.upsert`, `knowledge.reports.submit`, `knowledge.reports.get`, `knowledge.reports.update`, `run.reliance`, `run.grade`, `audit.list`, `erasure.status`, `erasure.list`

## Related

- [Build a knowledge factory](/docs/use-cases/knowledge-factory): documents, lessons
  and the walkthrough.
- [Identities and namespaces](/docs/concepts/identities-and-namespaces#agent-written-rows-and-the-shared-layer):
  the shared layer and governed definitions.
- [Runs](/docs/features/runs): reliance, grades and what `run.get` returns.
- [Tokens and grants](/docs/guides/tokens-and-grants): minting tokens and roles.
