Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
00cf011
Knowledge reports have kinds, states and checked transitions
VanshajPoonia Dec 1, 2026
4797f8f
Knowledge reports have a table and are covered by erasure
VanshajPoonia Dec 1, 2026
3798b2a
The person a token stands for is resolved in one shared module
VanshajPoonia Dec 1, 2026
48fd563
A memory key's readable version is checked without serving the row
VanshajPoonia Dec 1, 2026
84080b1
Agents report wrong, outdated or missing knowledge with knowledge.rep…
VanshajPoonia Dec 1, 2026
3272eb2
Knowledge reports are documented with their rollout rule
VanshajPoonia Dec 1, 2026
2e8b503
Knowledge reports are tested against ClickHouse
VanshajPoonia Dec 1, 2026
81376b3
Report writes stop at the erasure fence
VanshajPoonia Dec 1, 2026
b87542d
A repeated report is returned before its checks run again
VanshajPoonia Dec 1, 2026
5898805
Report versions carry the actor and source class of their write
VanshajPoonia Dec 1, 2026
6d250a0
A document report's target_key is described as its source URI
VanshajPoonia Dec 1, 2026
22a705d
Reading a report draws on the knowledge read bucket
VanshajPoonia Dec 1, 2026
ae47a2e
The cell control census classifies the report fence's delete
VanshajPoonia Dec 1, 2026
4ab25b3
The SDK surface snapshot lists the report methods
VanshajPoonia Dec 1, 2026
b231b3c
Merge remote-tracking branch 'upstream/main' into issues/1147-knowled…
VanshajPoonia Dec 1, 2026
c09ea15
Repeated evidence does not count toward the cap
VanshajPoonia Dec 1, 2026
5ae937e
A reporter the directory cannot fold is refused
VanshajPoonia Dec 1, 2026
f915b21
A maintainer reads another reporter's report by their live grant
VanshajPoonia Dec 1, 2026
4775dc7
A memory report's id names the row its key is read in
VanshajPoonia Dec 1, 2026
8c2fdf9
A resolution names a published revision that corrected the target
VanshajPoonia Dec 1, 2026
e218525
Report version checks read the head with sequential consistency
VanshajPoonia Dec 1, 2026
445e214
A user erasure clears what a maintainer wrote on every report version
VanshajPoonia Dec 1, 2026
23986bd
Report writes and report erasures share a durable write fence
VanshajPoonia Dec 1, 2026
8145cf4
A report's references are checked on write and on every read
VanshajPoonia Dec 1, 2026
728eb89
A maintainer reads a report when their own identity cannot be folded
VanshajPoonia Dec 1, 2026
bf47805
Merge remote-tracking branch 'upstream/main' into issues/1147-knowled…
VanshajPoonia Dec 2, 2026
eee5334
The cell scan counts knowledge reports as data whose org the request …
VanshajPoonia Dec 2, 2026
1333a1e
Knowledge report versions are written whole from a column set held to…
VanshajPoonia Dec 2, 2026
2e36a52
The report queue is named among the lists read whole
VanshajPoonia Dec 2, 2026
a6503b9
An unfolded reporter is refused with Loom's own text, not the caught …
VanshajPoonia Dec 2, 2026
011c94f
A resolution revision with a non-ASCII digit is refused, not a 500
VanshajPoonia Dec 2, 2026
525fa08
A resolution names the revision readers are served, not any number be…
VanshajPoonia Dec 2, 2026
e7691a3
A report write that carries a reason waits for its author's erasure
VanshajPoonia Dec 2, 2026
75e9968
A user erasure finds an end user's name in a report version's writer
VanshajPoonia Dec 2, 2026
d334e44
A memory report is bound to the row its key was found in
VanshajPoonia Dec 2, 2026
e58f75a
The read scope walk builds a body for adding evidence to a report
VanshajPoonia Dec 2, 2026
8705534
The report handlers test begins its cited run with a goal
VanshajPoonia Dec 2, 2026
8d88749
The statement corpus lists the knowledge report erasure statements
VanshajPoonia Dec 2, 2026
1223d02
Merge remote-tracking branch 'upstream/main' into issues/1147-knowled…
VanshajPoonia Dec 2, 2026
1d66723
A report's target version above UInt64 is refused before the write fence
VanshajPoonia Dec 2, 2026
a5a5cfb
A memory report found under agent * stays on a row of its own user
VanshajPoonia Dec 2, 2026
b98a4d3
A resolution with no target names its maintainer and goes with their …
VanshajPoonia Dec 2, 2026
cec8aef
A user erasure finds the report versions their service account wrote
VanshajPoonia Dec 2, 2026
56d6ccf
Reports wait for older replicas of every deployment kind sharing the …
VanshajPoonia Dec 2, 2026
254f8df
The Go SDK reads a report's target_version as uint64, the column's range
VanshajPoonia Dec 2, 2026
6cbb240
Rolling-upgrades rule 70 counts replicas in every deployment sharing …
VanshajPoonia Dec 2, 2026
a242eb8
The Go SDK keeps a marked UInt64 field as uint64 when it also takes a…
VanshajPoonia Dec 2, 2026
1c0196f
A report's target_version takes a decimal string and reads back as ta…
VanshajPoonia Dec 2, 2026
b46e72e
The TypeScript client files and reads a report above 2^53 without rou…
VanshajPoonia Dec 2, 2026
634c1e8
A report links only reports its caller can read, refused as missing o…
VanshajPoonia Dec 3, 2026
3d5a596
Merge remote-tracking branch 'upstream/main' into issues/1147-knowled…
VanshajPoonia Dec 3, 2026
735cb49
A report serves related reports and a maintainer's reason only to cal…
VanshajPoonia Dec 3, 2026
31c3224
A report queue row carries no target_changed, since it reads no target
VanshajPoonia Dec 3, 2026
22db0e4
A report names a document only to callers who may know of it
VanshajPoonia Dec 3, 2026
da1d7c2
The reports page names the synchronous insert, and that deleting a ta…
VanshajPoonia Dec 3, 2026
6777777
A report decides a mirrored document's address from its metadata, onc…
VanshajPoonia Dec 3, 2026
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
186 changes: 186 additions & 0 deletions docs/architecture/knowledge-reports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# Knowledge reports

A knowledge report says that a memory claim or a document is incorrect or outdated, or
that the namespace is missing knowledge. Agents and clients file one with
`knowledge.reports.submit` when they find the problem while they work. A namespace's
admins are its maintainers: they read the queue with `knowledge.reports.list`, take a
report, ask for evidence, resolve it with the revision that corrected the target, or
dismiss it with a reason. A report never edits its target; the fix is an ordinary memory
or document write.

```mermaid
flowchart LR
A["agent or client"] -->|"knowledge.reports.submit"| R["loom.knowledge_reports"]
R -->|"knowledge.reports.list / get"| M["maintainers (admins)"]
M -->|"knowledge.reports.update"| R
A -->|"knowledge.reports.evidence"| R
```

## Filing a report

A report has a kind (`missing`, `incorrect` or `outdated`), the problem in the reporter's
words, an optional suggested correction and, except for missing knowledge, a target:

| Target | `target_key` | `target_version` | `target_sha256` |
| ---------- | -------------- | ------------------ | ----------------------- |
| `memory` | the memory key | the memory version | the served content hash |
| `document` | the source URI | the revision | SHA-256 of its content |

A target the reporter did not say they read is stamped with what is there at submit. A
memory version is a nanosecond timestamp above 2^53, which a JavaScript number rounds, so
`target_version` also takes a decimal string and a report carries `target_version_text`,
the same version as a string, as `memory.get` carries `version_text`.
Evidence is references only, `gap:<id>`, `reflection:<id>` or `run:<id>`, at most 20
distinct ones, never copied text. Each reference, and the report's `run_id`, is checked as
the caller would read what it points at (`server/knowledge/app/report_refs.py`): a run of
the namespace, the reflection memory at that key under the report's identity tuple, and a
gap of the latest build, which only namespace admins read. A write that cites one the
caller cannot read is refused as not found, and a read serves only those the caller can
read then. Related reports name other report ids of the namespace that the caller reads
as `get` decides it: their own, or any for a maintainer. Another reporter's report is
refused as a missing one is, so a link never says whether an id exists. The rules are in
`server/knowledge/domain/reports.py`; a broken report is a 422.

The reporter is the person the token stands for, as knowledge gaps count askers
(`token_person` and `folded_person` in `server/knowledge/app/people.py`): the token's end
user, else its creator, folded onto one spelling per person. A token no person stands
behind, such as an agent's own account, reports under its own principal. When the
directory cannot be read the request is a 503 to retry, and a token tied to two accounts
is a 403; neither is filed or matched under another spelling, since the report id and the
reporter checks would stop matching once the person folds. Reads and evidence resolve the
caller before the report, so neither answer says whether it exists; a namespace admin whose
person cannot be folded still reads as a maintainer, unmatched as the reporter. With auth
off no token names a caller, so every caller is the reporter, as every caller is a
maintainer.

The caller must be able to read the target: a memory key is read as `memory.get` reads it
under the body's identity tuple (`readable_version` in `server/memory/app/handlers.py`,
which serves nothing of the row), a document as `knowledge.get` reads it. A target the
caller cannot read answers 404, as a missing one does. `memory.get` falls back to the same
user's row under another agent or session, so a memory report takes the identity tuple of
the row the key was found in, and every later read of its target reads that row alone. An
`agent` of `*` reads the key across users, so only a row of the body's `user_id` counts:
another user's row answers 404, as the fallback never finds one. Any other report keeps
the body's `agent`, `user_id` and `session_id`. Neither tuple is the reporter.

The report id is a hash of the org, namespace, reporter, kind, target and problem text
(whitespace folded), and for a memory target the found row's identity tuple. The same
reporter filing the same problem about the same target gets the same report back, with or
without an Idempotency-Key, and two agents whose reads find one row file one report. A
repeat returns the report as it stands, resolved or dismissed included: a maintainer
reopens it. A repeat after its memory target is gone finds the report only when the key was
in the row of the body's own tuple, since no read then says which row it was.

## Reading reports

`knowledge.reports.get` serves a report to its reporter and to the namespace's admins;
anyone else is answered not found. Each get checks the target again: `target_changed`
is true when its version or hash differs from what the report holds, or it is gone. A
caller who cannot read the target now sees the report with `target_readable` false and
without the words written about it, which may quote it: the problem, the correction and
a maintainer's reason. The reporter still reads their own problem and correction.
Evidence and related reports are served only while the caller reads what they point at.

A mirrored document's address belongs to its readers ([document sources](document-sources.md)).
An admin who may not know of a report's document sees no `target_key`, revision or
resolution for it: `known_documents` (`server/knowledge/app/document_reads.py`) knows a
document of the namespace, deleted ones included, and a mirrored copy the caller's
access list admits now. A page's mirrored copies are checked together from their
metadata, without reading their text, and a failed check admits none. The reporter wrote
the address, so always reads it.

`knowledge.reports.list` is the admins' queue, newest change first, filtered by state,
kind, target, assignee or reporter. Its rows carry no one's words and read no target, so
they carry no `target_changed`: both are read one report at a time. A row about a
document the admin may not know of carries no address, and a `target_key` filter finds
no report about one.

## Maintainers' actions

`knowledge.reports.update` (admin, audited) applies one action and may link related
reports:

| Action | From | To | Needs |
| ------------------ | ----------------------------- | ---------------- | --------------------- |
| `take` | any but resolved or dismissed | `taken` | sets the assignee |
| `release` | `taken` | `open` | clears the assignee |
| `request_evidence` | any but resolved or dismissed | `needs_evidence` | a reason |
| `resolve` | any but resolved or dismissed | `resolved` | `resolution_revision` |
| `dismiss` | any but resolved or dismissed | `dismissed` | a reason |
| `reopen` | `resolved` or `dismissed` | `open` | a reason |

`resolution_revision` names the published revision that corrected the target, not a
draft or a recommendation: for a report about a memory claim or a document, the revision
number readers are served now, which must be newer than the reported one. Memory versions
come from the clock, so a number between the two may never have been published. An
unchanged or gone target is not resolved (dismiss it with a reason). A report with no
target has no revision to check, so its resolution is the maintainer's words, and
`reason_by` names who wrote them as it does a reason. `expected_version` refuses an update
made from a stale read (409).

`knowledge.reports.evidence` lets the reporter add references to their own report; any
other caller is answered not found. A report waiting for evidence goes back to `taken`
when a maintainer holds it, else to `open`.

## Storage

`loom.knowledge_reports` is a `ReplacingMergeTree(version)` sorted by
`(org, namespace, report_id)`: submit writes version 1 and every change the next version
of the whole row, read with `FINAL` (`server/knowledge/store/reports.py`). Each change is
a read, then a write, under the report's claim (`leases.holding`), so two writers never
both build on the same version; the second is told to retry (503). Each version is
inserted synchronously and read with `select_sequential_consistency`, so the next read on
any replica sees it.

Every version carries the `actor` and `source_class` of the write that made it, stamped by
the server from the token (`writer_actor`, `source_class_for(default="asserted")`), never
from the body: a maintainer's change names the maintainer, added evidence the reporter.
`written_by` holds the person that token stands for, folded as the reporter is, so a
service account's version names its creator while its `actor` names the account. With
auth off the writer is the agent that filed the report, or `-` for an update.

## Read scope

A token bounded below the namespace (`read_scope` `own_user` or `own_session`) cannot call
`knowledge.reports.*` (`NARROW_REFUSED_PREFIXES` in `server/identity/domain/read_scope.py`):
the queue and a report hold other people's words.

## Erasure

A user erasure deletes every version of the reports the user filed, as reporter or under
their `user_id`, by the same spellings it erases knowledge gaps with. On the reports the
user maintained it clears, in every version, what names them or is their words: the
assignee, the writer's `actor` and `written_by` (matched on `written_by`, so a write
through the user's service account or as an end user is found), a `reason`, and the
resolution of a report with no target. `reason_by` names who wrote those words, since
later versions carry them forward under another writer, such as a maintainer who only
links a related report. A target's resolution is a checked revision number and stays. The
reporter's words stay
(`delete_knowledge_reports_by_user` in `server/erasure/store/steps_ledgers.py`). A
namespace erasure deletes the namespace's reports. The residue census counts both scopes.
Deleting a memory, a document or a source deletes no report: a report copies nothing from
its target, which then reads as gone, so only the reporter reads the report's words.

Each write takes the org's durable write fence (`writer_lease_name` in
`server/knowledge/domain/reports.py`), which both report erasure steps take too. Inside it,
while an erasure is unfinished, or has finished since the request started (`erasure_since`,
as knowledge gaps use), that reaches the report's namespace, its reporter, its user, its
assignee, the author of a reason the write carries forward or the writing maintainer,
submit, update and evidence answer 409 `ERASURE_RUNNING`. An insert whose outcome is
unknown, a cancelled send included, keeps the fence until its send bound passes, so an
erasure step never runs before a version that may still land.

## Rolling upgrades

An older build's erasure saga has no step for `loom.knowledge_reports`, so no report is
written while such a replica serves: while any live replica of any deployment kind
sharing the database has a schema below the migration that adds the table, or no
heartbeat can be read, submit, update and evidence answer 503
(`every_replica_stores_reports` in `server/knowledge/app/reports.py`), as knowledge gaps
do ([rolling upgrades](rolling-upgrades.md)). Before a rollback, the
operator deletes the table's rows, and again after the first older replica serves.

## Dashboard

No dashboard page serves reports: maintainers read and act on them through the API, the
SDKs and `loom_op` (`NOT_IN_DASHBOARD` in `server/operations/dashboard.py`).
11 changes: 10 additions & 1 deletion docs/architecture/rolling-upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,6 @@ See the [participant lifecycle baseline](cells.md#participant-lifecycle-baseline
step leaves them until ClickHouse holds the head; an N-1 policy step that reads the
old head in that window drops them, and the linker then makes them `fresh`.
`renamed` is one more number in the pass outcome. No gate holds the rollout.

68. **Code store names are reserved** (migration `118_store_names_reserved.sql`): N's
gate refuses every request that names a namespace of the form `crs-` and 24 hex digits
(only a platform admin's `erasure.request` may name one), with auth on or off, as
Expand Down Expand Up @@ -1035,6 +1034,16 @@ See the [participant lifecycle baseline](cells.md#participant-lifecycle-baseline
mirrored sources' [procedure](document-sources.md#rolling-upgrades) says.
`tests/unit/test_crawl_fleet_migration.py` checks N's side, and the mixed-version
gate does not check this rule.
70. **Knowledge reports** (`loom.knowledge_reports`, migration
`120_knowledge_reports.sql`): N-1's erasure saga has no step for the table. So while
any live replica, in every deployment sharing the database, has a schema version
below 120, or no heartbeat has been read, `knowledge.reports.submit`, `update` and
`evidence` answer 503, as knowledge gaps do under rule 48; N-1 serves no
`knowledge.reports.*` op. Before a rollback, delete the table's rows, then delete
again after the first N-1 replica serves
([knowledge reports](knowledge-reports.md#rolling-upgrades)).
`tests/unit/test_knowledge_reports.py` checks the refusal; the mixed-version gate
does not.

## What checks them

Expand Down
Loading