Knowledge reports
A knowledge report says that a memory claim or a document is incorrect or outdated, or that the namespace is missing knowledge.
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.
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 content_sha256 memory.get serves |
document |
the source URI | the revision | the content_sha256 knowledge.get serves |
A document report also names target_doc_id, the doc_id knowledge.get returned,
which says which copy at the address the reporter read (below). A revision or hash the
reporter did not say they read is stamped with what is there at submit. A client sends
only a hash an op returned, never one it computes. A document’s is the hash its row
stores on every write, over its title and text in the form knowledge.add dedups on
(sha256_document_text in server/core/hashing.py), so an edit of the title alone also
marks the target changed. knowledge.get serves it as content_sha256; a report that
sends none takes the row’s at submit. A row with no stored hash gives the
report none, and its revision alone says whether it changed. That includes a legacy
document at revision 0, which reads as changed once it has revision 1. A reader of such a
document cannot name the revision they read: a target_version of 0 states none, as an
empty target_sha256 does. Their target_doc_id still binds the report to the text they
read: a first filing made after the document’s first numbered revision answers 409
(below), since every write that numbers a revision gives the document a new doc_id. It
does not bind the title: knowledge.update_metadata without reindex keeps the doc_id
and revision 0, so a filing made after such a title edit is not refused and takes the
edited row’s hash. 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, and only while
knowledge.gaps.list shows them one (listed in server/knowledge/app/gaps.py): with
gaps or query capture off, a build stored until its TTL ends is not 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
service-account registry or the directory cannot be read the request is a 503 to retry,
never filed under the account itself, 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. A first
filing whose target_version or target_sha256 the row found now does not hold answers
409 PRECONDITION_FAILED and writes nothing: the reporter read another row of the key,
such as the one the fallback found before the caller’s own row was written, or an older
version, and their words would be bound to this row.
knowledge.get answers an address with the namespace’s own document, else the newest
mirrored copy the caller may see, so the document at an address can change without any
write to it. A document report keeps the copy it was read in, target_copy: empty for the
namespace’s own document, else the mirrored copy’s <mirror>/<source id>
(document_copy in server/knowledge/app/document_reads.py). Every later read of its
target reads that copy alone, so a document that appears at the same address later is
never taken for it. A first filing answers 409 PRECONDITION_FAILED when the document
found now is not the target_doc_id the reporter read, or holds another revision or
hash than the body names: the reporter read another copy at the address, or an older
revision, and their words would be bound to this one. Each copy counts revisions from 1,
and two copies can hold the same text, so neither the revision nor the hash names a
copy. Every write of a document’s text gets a new doc_id, so the doc_id does.
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. A document’s copy is not part of it: the copies visible at an address change between a filing and its retry, so a repeat finds the report after its copy is gone or another copy appears, and never files a second report against that other copy. 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, bound to the copy or row it was filed about, 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. Nor does a repeat find a report filed on another agent’s or session’s row once the caller’s own row is written at the key: the read then finds the new row, so a repeat that names the version it read answers 409, and one that names none files a report on the new row. A retry with the same Idempotency-Key replays the first answer either way.
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 copy’s access list can change with each revision its source publishes, and no
copy keeps the list of an earlier revision, so reading the copy now does not prove the
caller could read the revision reported. Once the copy holds another revision or hash
(target_changed), its report’s words are left out for every caller, the reporter’s own
problem and correction aside, while target_readable stays true. A change to its access
list alone keeps the revision, and with it the words: they quote text the caller reads
now. The namespace’s own documents and memory rows have the same readers at every
version, so a change to one of them keeps the words.
A mirrored document’s address belongs to its readers (document sources).
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
report’s copy when it is the namespace’s own document, deleted ones included, or a
mirrored copy the caller’s access list admits now. Another document at the same address
does not count. A page’s own documents are checked from their row versions and its
mirrored copies together from their metadata, without reading any text, and a failed
check admits none. The reporter wrote the
address, so always reads it.
Each mirrored copy a read admits, for its words or only for its address, keeps its proof
with the response (source_publication). The proof is checked again before the response
is sent, as for knowledge.get and knowledge.list, so access that ends after the read
refuses the response. Submit and update read the target only to check it and answer
nothing of it, so no proof goes with their answer: a version already written is never
answered as refused.
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. That filter reads which copies of the address the reports are
about (copies_at, with sequential consistency, so no acknowledged report is missed),
keeps the ones the admin may know of and filters on them before the limit, so a newer
report about a hidden copy at the same address never empties a page. That check keeps no
proof. The copies of the rows on the page are checked again with their proofs, so access
to a copy the page leaves out never refuses it, and a row whose copy that second check
no longer admits leaves the page. A memory filter reads no copies. The queue is not
idempotent on the wire, so its answer never enters the replay cache: a stored page would
serve mirrored addresses without their proofs, and a retry reads the queue again.
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; clears the assignee |
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. An action with words of its own (a
reason, or that resolution) replaces the reason and reason_by. One without, such as
take, release or the resolution of a report about a target, carries them forward, so
a question asked with request_evidence stays after the report is released. reopen
clears the assignee and the resolution. 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, also while another change holds the report’s claim,
since the reporter is checked before the claim. 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 every read, the queue included, uses
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.
The steps and the census count reports with select_sequential_consistency: on a replica
that has not fetched an acknowledged report, a count of zero would skip the step’s
mutation and record no residue.
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). Before a rollback, the
operator deletes the table’s rows, and again after the first older replica serves.
Dashboard
The dashboard files a report from one place: a correction request in the
stewardship review dialog. It submits an incorrect report in
the reviewer’s words, then records the review, so a refused report records no review. A
memory’s report names the version_text and content_sha256 that memory.get served
with the text on screen, under the shared row’s identity tuple. A document’s names the
doc_id and revision that knowledge.get served and no hash, since the doc_id alone
names the write that was read. A 409 PRECONDITION_FAILED reads the content again before
anything is recorded. Words the reviewer filed about the item before answer with that
report: when it is resolved or dismissed the dialog records no review and asks what is
wrong now, since other words file a new report. A server that does not serve the op
answers 404 with no error code: the dialog then says reports are unavailable and records
the review alone on the next press, while the op’s own 404 RESOURCE_NOT_FOUND is shown
as a refusal.
No dashboard page lists reports: maintainers read and act on them through the API, the
SDKs and loom_op (NOT_IN_DASHBOARD in server/operations/dashboard.py).