Skip to content

Agents report wrong, outdated or missing knowledge with knowledge.reports.* - #1947

Open
VanshajPoonia wants to merge 92 commits into
ClickHouse:mainfrom
VanshajPoonia:issues/1147-knowledge-reports
Open

VanshajPoonia wants to merge 92 commits into
ClickHouse:mainfrom
VanshajPoonia:issues/1147-knowledge-reports

Conversation

@VanshajPoonia

@VanshajPoonia VanshajPoonia commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Related: #1147
Related: #1232

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

Agents and clients report a memory claim or a document as incorrect or outdated, or report missing knowledge, with knowledge.reports.submit. Namespace admins review the reports with knowledge.reports.list, knowledge.reports.get and knowledge.reports.update, and a reporter adds evidence with knowledge.reports.evidence.

Why

Step 1A of #1232. An agent that finds a claim wrong or a passage outdated has no way to say so short of editing the target, and maintainers have no queue of such findings. A report records the problem and points at its target; it never edits it. The fix stays an ordinary memory or document write, and resolving a report names the published revision that made it.

Memory proposals and definition drafts were checked first and cannot hold this: both are candidate memory rows decided by accept or reject, while a report points at someone else's claim, or at nothing, and must never be recalled. So reports get their own table, loom.knowledge_reports, modelled on the knowledge gap tables.

Design, in docs/architecture/knowledge-reports.md:

  • The reporter is the person the token stands for, folded as knowledge gaps fold askers, so a user erasure finds a user's reports by the same spellings. Each version also records its writer's person in written_by, which lets the erasure find a version written through the user's service account. A resolution on a report with no target is the maintainer's words: reason_by names their author as it does for a reason. An action with words of its own replaces the reason and reason_by, and one without, such as take or release, carries them forward. The gap helpers move to server/knowledge/app/people.py. A failed service-account registry read is told apart from an account with no person behind it (read_sa_creator): a report answers 503 and writes nothing, and a gap still counts no asker.
  • The caller must read the target: a memory key through readable_version, which reads as memory.get does and serves nothing of the row; a document through knowledge.get's read path. A target the caller cannot read answers 404. A memory report takes the identity tuple of the row its key was found in. That row may belong to another agent or session of the same user. It never belongs to another user, even under agent *. Later reads look in that row only. A first filing whose version or hash the row found now does not hold answers 409, so a version read in one row never binds to another.
  • A related report must be one the caller reads, as get decides it. A missing report and an unreadable one get the same refusal, so a link never says whether an id exists.
  • The report id hashes the reporter, kind, target and problem text, and for a memory target the found row's identity tuple. A retry files one report with or without an Idempotency-Key, and two agents that read one row file one report. Without a key, a memory report filed on another agent's row is not found once the caller's own row is written at the key. A document target is named by its address alone, so a retry finds the report after another copy appears at the address or its copy is gone.
  • Each change is a read and a write under a per-report claim (leases.holding), so two maintainers never build on the same version.
  • Writes take the org's durable report write fence, which both erasure steps take too. Inside it, an erasure that reaches the report's namespace or anyone the version names (reporter, user, assignee, the author of a carried reason, the writing maintainer), unfinished or finished since the request began, answers 409 (erasure_since, as knowledge gaps use).
  • get serves a report to its reporter and the namespace's admins. A caller who cannot read the target now sees it without the problem, the correction and a maintainer's reason. The reporter keeps reading their own words. Evidence and related reports are served only while the caller reads them. list rows carry no one's words and no target_changed.
  • A mirrored document's address belongs to its readers. An admin who may not know of a report's document (known_documents in document_reads.py) sees no address or revision for it in get or list, and a target_key filter on it finds nothing.
  • A document report keeps the copy it was read in (target_copy): the namespace's own document or one mirrored copy. Every later read of its target reads that copy alone, so another document at the same address never releases the report's words or address. A document report names target_doc_id, the doc_id knowledge.get returned, and a first filing answers 409 unless the document found now has that doc_id, so a read of one copy never binds to another. Copies at one address can share a revision and text, so neither tells them apart. Each mirrored copy a read admits keeps its proof with the response, and access that ends before the response is sent refuses it.
  • Tokens narrowed below the namespace cannot call knowledge.reports.*, as with knowledge.gaps.*.
  • A memory version is a nanosecond timestamp above 2^53, which a JavaScript number rounds. target_version takes it as a number or a decimal string, and a report carries target_version_text, as memory.get carries version_text. Go reads target_version as uint64.

Scope and risk

Touches: a migration and the report table, its erasure steps and census rows, five ops, memory.get's read-scope narrowing (moved into _within_read_scope, behaviour unchanged), and the gap person helpers (moved, behaviour unchanged).

Left for a follow-up: the dashboard's report queue, so #1147 stays open for it. Until it exists get, list and update are named in NOT_IN_DASHBOARD. Also left out: #1766 (a search verdict on a missing-knowledge report).

Risk: a report holds people's words, so every read checks the target and the role, list rows carry no text, and both erasure scopes cover the table. The migration is 122, after main's 121 for a branch's base namespace.

Compatibility, rollout and rollback

  • Wire: adds knowledge.reports.submit, get, list, update and evidence, all experimental. No existing op or field changes. knowledge.reports.submit takes target_doc_id, required for a document target. knowledge.reports.list is not idempotent, so its answer never enters the replay cache (as for knowledge.source.push_status).
  • Operator steps: none. While a replica without the table serves, in any deployment sharing the database, the three write ops answer 503 (rolling-upgrades rule 74).
  • Rollback: the table and its rows stay. Before rolling back, delete its rows, and again after the first older replica serves, since an older build's erasure has no step for it.

Tests

  • tests/unit/test_knowledge_reports.py (59 tests): the reporter comes from the token, the target read check, the id a retry repeats (also after the target or a linked report is gone, and for a document after another copy appears or its copy is gone), the one report two agents file when they read one row, a wildcard agent kept to its own user's row, the served revision a resolution names, the author of a resolution with no target, a target_version above UInt64 or sent as a malformed string, a memory version above 2^53 that stays exact from submit to get and list, a blank problem, the refusals, a failed service-account registry read that files nothing, who reads a report, a changed or unreadable target, related reports and a maintainer's reason served only to callers who read them, a document's address served only to whoever may know of it, a filter on an address that keeps the copy the caller sees before the limit, a report that stays bound to its copy when another document appears at the same address, a mirrored address checked again before the response is sent, a submit or resolve that landed still answered after access to its target ends, the queue without words or target state, every maintainer action, the person behind a service account's version, expected_version, the claim held elsewhere, the reporter's evidence, both sides of the erasure fence, a link to an erased report, a link only to a report the caller reads, the rollout gate with an older replica of the other deployment kind, a replica at schema version 121 that holds writes, narrowed tokens, readable_version serving nothing, a filter that reads no copies for a memory key, a page that keeps proofs only for the copies it lists and drops one its caller stopped knowing, a queue retry that reads source access again instead of replaying, a document report refused unless it names the doc_id of the copy found now, also when both copies hold the same revision and text, a memory report refused when its version came from another row, a reason kept by actions that bring none, and evidence from another caller answered not found while the report is busy. tests/unit/test_knowledge_reports_store.py checks the statements copies_at and the queue send. The domain rules keep their tests in tests/unit/test_knowledge_reports_domain.py.

  • tests/integration/test_knowledge_reports.py (8 tests) against a ClickHouse started with dev/ci_start_clickhouse.sh and make migrate: a version read back with every column, the latest version winning, the queue's filters, a copy filter applied before the limit, the copies at an address, the handlers' submit, update and evidence under the claim, a real memory's version above 2^53 filed from its version_text and read back unchanged, and both erasure steps, including a resolved missing-knowledge report another maintainer linked and a version written through a service account.

  • tests/unit/test_erasure_knowledge_reports_sql.py (2 tests) runs the user erasure step and the census as real SQL on clickhouse-local: an end-user maintainer who did not file the report, a maintainer's service account, and a resolution with no target that another maintainer's link carried forward. Every version goes in as one unfolded part. No merge can then drop an older version before the test reads it.

  • sdk/go/wire/models_test.go: a get and a list response with the largest target_version decode in the Go SDK.

  • sdk/typescript/src/client.test.ts: the TypeScript client files a report with a memory's version_text and reads target_version_text back exactly. tests/unit/test_sdk_go_codegen.py: the Go SDK keeps a marked UInt64 field that also takes a string as uint64.

  • The erasure census counts and step order (test_erasure_verify.py, test_erasure_step_order.py) include the new table and step, and every report count reads with sequential consistency.

  • make lint and make typecheck pass; schemas/schema.sql drops the unwritten deleted column with migration 122; every generator in docs/development/adding-an-operation.md was run, and the reach census, SDK, docs and op-gate tests pass.

  • tests/unit/test_knowledge_ingest.py and tests/integration/test_knowledge_gaps.py::test_gap_draft_rereads_eligible_questions_and_claims_one_model_attempt fail on this machine on main too (the first needs the local job runner, the second a server heartbeat), so they were not part of this check.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code wrote the diff and ran the checks listed under Tests.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

Note

Medium Risk
New experimental API stores user and maintainer text with layered ACL, erasure, and mixed-version gates; behavior is intricate but follows existing knowledge-gap patterns rather than changing core auth or writes on targets.

Overview
Introduces knowledge reports: writers file problems on memory keys or documents (or flag missing knowledge) via knowledge.reports.submit, without mutating the target. Namespace admins work a queue through list, get, update, and reporters can add reference-only evidence with evidence.

Persistence is a new ClickHouse table loom.knowledge_reports (migration 123), versioned like gaps, with idempotent submit keyed by reporter/target/problem, precondition checks on target version/doc_id/copy, maintainer state machine (take, resolve with revision, dismiss, reopen), read-path redaction when the caller cannot read the target, rolling-upgrade 503 gates when any replica is pre-migration, and user/namespace erasure steps plus census counting.

Supporting changes wire knowledge.reports.get into read rate limits, block narrowed read scopes, move gap “person” resolution to people.py with read_sa_creator / 503 on registry failure for reports, and extend document read helpers (document_copy, known_documents) for mirrored-copy binding. Docs, op reference, storage layout, and all SDKs are regenerated; Go/TS handle target_version as uint64 / decimal string for memory versions above 2⁵³.

Reviewed by Cursor Bugbot for commit 0bcf3e5. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Knowledge gaps resolved the asker in private helpers. Knowledge reports need
the same person for the reporter, so a user erasure finds both by the same
spellings. The helpers move to server/knowledge/app/people.py unchanged.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
memory.get's read-scope narrowing moves into _within_read_scope, and
readable_version uses it to answer the version and content hash of the row
memory.get would serve, recording no read exposure or sensitive-read audit.
Knowledge reports check their memory target with it.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…orts.*

submit files a report about a memory claim, a document or missing
knowledge under the token's person, after checking the caller can read the
target; the id repeats for a retry. get serves it to its reporter and the
namespace's admins, list is the admins' queue without anyone's words,
update takes, asks for evidence, resolves, dismisses or reopens it, and
evidence lets the reporter add references. Writes wait for every replica
to know the table, run under a per-report claim, and narrowed tokens are
refused. SDKs and the operations reference are regenerated.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
A version is written and read back with every column, the latest wins,
the queue filters, the handlers file, take and add evidence under the
claim, and both erasure steps remove what they own.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Submit, update and evidence check for an unfinished erasure that reaches
the report's namespace or its people before the insert and again once the
version is visible, as knowledge gaps record a miss, and delete a version
that landed as one started. A link an update keeps is no longer checked
again, so a related report erased since it was linked does not block new
links.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 5, 2026 7:57am UTC
loom-telemetry Ready Ready Preview Dec 5, 2026 7:57am UTC

Request Review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/knowledge/app/reports.py Resolved
Comment thread server/knowledge/app/reports.py Resolved
Submit looked up the existing report only after it checked the related
reports and the target again, so a retry after either changed was refused
instead of answered with the report. It now answers a repeat first. A
problem that is blank once trimmed is refused instead of stored empty.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
@zlareb1 zlareb1 self-assigned this Dec 1, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Report versions need the write provenance required by the repository. The document target field also needs to describe the identifier the lookup accepts.

Comment thread server/knowledge/store/reports.py Resolved
Comment thread server/knowledge/api/models_reports.py Resolved
A maintainer's update stored the reporter's identity tuple and an
assignee, so a version could not say which token principal wrote it.
loom.knowledge_reports now has actor and source_class columns, and
submit, update and evidence stamp them from the token with writer_actor
and source_class_for, never from the body. With auth off the writer is
the identity's agent, or "-" for an update, as the reporter and the
maintainer are.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
The handler looks a document target up by source URI, so the field
description and the refusal now say source URI instead of document id.
The Go and TypeScript wire models and the operations reference are
regenerated.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
knowledge.reports.get is a VIEWER read, so it joins the reads that
spend knowledge.read instead of the write-shaped knowledge.add bucket.
The admin queue read stays in knowledge.add, as the read bucket test
expects for any op that is not read-only.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
delete_version drops a report version that landed as an erasure
started. It writes no cell control row, so it goes with the other
knowledge store deletes.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Regenerated with LOOM_UPDATE_SNAPSHOT=1. The only change is the five
knowledge.reports methods.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…ge-reports

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>

# Conflicts:
#	docs/reference/operations.md
#	docs/reference/status.md
#	sdk/go/wire/models.gen.go
#	sdk/ruby/lib/clickhouse/loom/generated/ops.rb
#	sdk/typescript/src/generated/ops.ts
@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

The unit jobs have not run on this fork yet. A local run found three failures from the PR: the read bucket for knowledge.reports.get, the cell control census and the SDK snapshot. They are fixed, and main is merged with the generated files rerun.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/knowledge/app/reports.py Resolved
Comment thread server/knowledge/domain/reports.py Resolved
The cap of 20 references was checked before repeats were dropped, so
adding evidence the report already cites could be refused while the
distinct references still fit. The cap now counts distinct references.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
When the directory could not be read or tied the token to two accounts,
the reporter fell back to the token's raw principal. The report id was
hashed with that spelling, so once the person folded again a retry filed
a second report and get and evidence no longer matched the reporter. A
directory failure is now a 503 to retry and a tie is a 403. Get and
evidence resolve the caller before the report, so neither answer says
whether it exists.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provenance and source URI fixes are in this head. The remaining blockers include report access after a grant downgrade, erasure of maintainer-authored data, and version checks across replicas. The existing reporter identity thread also needs a fix because a directory failure can change who owns the report.

Comment thread server/knowledge/app/reports.py Resolved
Comment thread server/erasure/store/steps_ledgers.py Resolved
Comment thread server/knowledge/app/reports.py Resolved
Comment thread server/knowledge/store/reports.py Resolved
Comment thread server/knowledge/app/reports.py Resolved
Comment thread server/knowledge/app/reports.py Resolved
Comment thread server/knowledge/app/reports.py Resolved
Get decided a maintainer from the token's claims, so a token minted while
its subject was an admin kept reading other reporters' reports after the
grant fell to viewer. It now asks the namespace gate at admin, which caps
the claim at the live grant. The report tests run on real tokens.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/knowledge/app/reports.py Resolved
The id hashed the target key without the identity tuple the key is read
under, so a reporter who filed the same problem about the same key in two
users' rows got the first report back for the second. A memory target's
agent, user and session are now part of the id. A document is read by its
URI alone and keeps one id across tuples.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Resolve took any nonblank text, so a draft id or a revision of a target
that never changed closed the report. For a report about a memory claim
or a document, resolution_revision is now a revision number newer than
the reported one and no newer than what readers are served now. A target
that is gone has no published correction, so its report is dismissed.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This head fixes the unstable reporter identity and counts unique evidence references toward the cap. The previous blocking findings still apply. I verified that a downgraded maintainer is still authorized from the token role and that maintainer-authored reasons are still outside user erasure. The new identity-folding thread also reproduces from the call order. Report detail refuses an already-authorized maintainer when the reporter identity lookup fails, while the queue remains available.

A writer could answer with version 2 and release its claim before another
replica held the insert. The next writer's FINAL read could then return
version 1, pass expected_version=1 and write a second version 2. Head
reads now use select_sequential_consistency and each version is inserted
synchronously, as the task inboxes do.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
take, release and a resolution of a report about a target sent the reason
empty and wrote that over the stored one. A report released after its
evidence came in lost the question get served. An action now replaces the
reason and reason_by only with words of its own, and reopen clears the
resolution.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Copies at one address count revisions from 1 and can hold the same text, so
neither the revision nor the content hash says which copy a reporter read,
and a body without them was not checked at all. A first filing about a
document now names target_doc_id, the doc_id knowledge.get returned, and is
refused with 412 unless the document found now has that doc_id. The SDKs and
the reference are regenerated for the new field.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…ge-reports

Main's rule 73 covers worker sources, so the knowledge reports rule in
rolling-upgrades.md is now 74. The generated Go wire models conflicted on
their schema hash line only: they are main's copy with every generator rerun
on the merged tree.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…there now

memory.get falls back to another agent's row of the same user, so the row a
reporter read can stop being the one a fresh lookup finds once the caller's own
row is written. The report then held the read version beside the identity of
the other row, and a retry filed a second report under that row. A first
filing whose version or hash the row found now does not hold answers 409, as
a document read in another copy does. The page also names the 409 that the
document check answers.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
The handler took the report's claim before it checked the reporter. Another
caller who hit a report held by a slow change got 503 instead of 404, which
said the id exists. The reporter is now checked before the claim and again
inside it.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…ure clears

reopen has always cleared the assignee, which the actions table left out. The
storage layout note said a user erasure clears only the assignee, while it
also clears the reason, its author, the writer and a resolution with no
target; the note now points to the erasure section.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Erasure removes report rows with DELETE and no op withdraws a report, so no
version was ever written deleted and every NOT deleted filter guarded a state
the code cannot reach. Migration 122 is not released, so the column goes from
the migration, the reference schema and the reads. shapes.txt picks up the
new schema dump.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
A memory report compares memory.get's content_sha256, the hash of the
canonical JSON, and a document report the SHA-256 of knowledge.get's content.
The field said only "hash of the content", and a client that hashed a memory's
text got a 409 that reading again never cleared.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…y report

A report filed on another agent's row is not found once the caller's own row
is written at the key: the repeat then answers 409 when it names the version
it read, or files a report on the new row when it names none. The page
promised the same report back without a key, and the op's comment said a
retry always files the same report.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

Thank you for the review and for pointing at the admitted document id, which is what the copy check now uses. Round 15 is up.

  • 426728e: a document report names target_doc_id, the doc_id knowledge.get returned. A first filing binds only to the copy with that doc_id and answers 409 otherwise. My round 14 reply claimed the hash tells two copies apart, and that was wrong.
  • f781069: take, release and the resolution of a report about a target keep the stored reason and its author.
  • eb372d7: the queue reads with sequential consistency.
  • 830645d: degraded_unnoted.txt no longer lists gaps.py::_person. That fold moved to people.py and raises instead of falling back. This was the exception inventory failure in unit part 4 on c453012, and it came from this PR.
  • e9c917b: merges main. Main's new rule 73 covers worker sources, so the reports rule is now 74. The only conflict was the schema hash line of the generated Go wire models. I took main's file and reran every generator.

Before pushing I went through every place a document or memory report picks, binds or rereads its target, and every update action against each column get serves. That found more, each in its own commit:

  • d0bc2d0: a memory report whose version or hash came from another row of the key answers 409 instead of binding to the row found now. A retry no longer files a second report under that row.
  • fc1fcc6: evidence checks the reporter before it takes the report's claim. Another caller who hit a busy report got 503 instead of 404, which said the id exists.
  • b259e43: the pages say reopen clears the assignee, and the storage layout note lists everything a user erasure clears on a report.
  • 06f9ed2: loom.knowledge_reports drops its deleted column. Nothing ever wrote it, since erasure deletes rows and no op withdraws a report. Migration 122 is unreleased, so the column goes from the migration, schema.sql and every read. shapes.txt picks up the new schema dump.
  • 97080b9: the target_sha256 description says which hash it takes. A memory report compares memory.get's content_sha256 and a document report the SHA-256 of knowledge.get's content. A client that hashed a memory's text would get a 409 that reading again never clears.
  • 66bd149: the page says when a repeat without an Idempotency-Key cannot find a memory report. Once the caller's own row is written at the key, a repeat of a report filed on another agent's row answers 409 when it names the version it read, and files a report on the new row when it names none.

The other red jobs on c453012 fail on main too. test_no_new_tunable_constant is the worker approval bound that #2138 fixes. The isolation and integration jobs fail on test_read_scope_isolation.py::test_ops_that_cannot_bound_their_answer_are_refused for knowledge.source.worker_approve and worker_enroll, the same way main's run at 502a008 does.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document filings now check the admitted copy ID. The queue reads acknowledged changes and release preserves the maintainer’s reason. Gap references still bypass the gap availability checks.

Comment thread server/knowledge/app/report_refs.py Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The read-scope isolation test cannot build the worker approval and enrollment requests on this run or on the earlier main run. #2156 adds those request fields and keeps the refusal assertion. The failed run still blocks this head. PR job · Main job · Merged fix

…ge-reports

The Go and Rust wire models were the only conflicts. They are main's copies
with every generator rerun on the merged tree. Main brings ClickHouse#2156, which the
read-scope isolation gate needs.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

Thank you for tracing the isolation failure to #2156. Main is merged in 7ef2d1a, which brings #2156 in. The Go and Rust wire models were the only conflicts. They are main's copies with every generator rerun on the merged tree. The report, store, schema baseline, read scope, tunable constant, SDK parity and docs tests pass on the merge (724).

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gap availability finding remains. A current proof for a replacement document also exposes report text about the private revision it replaced. GitHub reports a merge conflict in the rollout notes and generated references and SDKs.

Comment thread server/knowledge/app/reports.py Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python SDK adapter job fails during test collection with agent-framework-core 1.26.0 and opentelemetry-api 1.46.0. Clean main fails with the same versions and traceback. A separate PR constrains the incompatible dependency. PR job · Main job · Fix #2164

@zlareb1

zlareb1 commented Dec 5, 2026

Copy link
Copy Markdown
Member

One more design note from the work that builds on reports (#1232). It does not block this pull request. It is only cheap before reports are stored, so I am raising it now.

What a document report's target_sha256 covers. At 7ef2d1a, _target_now in server/knowledge/app/reports.py computes it as hashlib.sha256(doc.content.encode()), and the field description asks a client to compute the same over knowledge.get's content. loom.documents already stores a hash of every document: content_sha256, written by the row builder on each text write and refused from a caller (sha256_document_text over the title and the content in server/knowledge/store/documents.py). knowledge.dedup_list serves it under that name, and DocumentRow, which document_copy returns, carries it.

Suggestion. Use the stored column as a document target's hash:

  • _target_now returns doc.content_sha256 instead of hashing the text. That removes a SHA-256 over the full text from every read that checks a report's target, lists included.
  • A document's content hash then means one thing on every op, and a changed title also marks the report's target as changed.
  • The field description becomes: the content_sha256 an op returned for the document, empty when you have none. A client computes nothing. The handler already stores its own hash when none is sent, and target_doc_id already binds the report to the write that was read, because every text write gives the document a new doc_id.
  • A row with an empty stored hash needs a decision: either the report carries no hash for it, or the handler falls back to the hash of the content. The first is simpler.

Why before the merge. Once reports are stored, changing what the field covers marks every stored document report as changed, and during a rolling upgrade one build would compare one hash with the other.

If you keep the SHA-256 of the content, nothing that builds on this breaks: the later step that adds content_sha256 to knowledge.get will say in its field description that it is not a report's target_sha256.

…ge-reports

Main's 122_read_receipts.sql took number 122, so the reports migration and
its gate move to 123, the rolling-upgrades rule is now 79 and the version
test holds a replica at 122. The erasure steps, census and predicates keep
both tables, and the census counts are 77 and 58. Generated SDKs, the
operations reference, the status page and shapes.txt are main's copies with
every generator rerun on the merged tree.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
… a build

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…ds the reported revision

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…ion it reports

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…ge-reports

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>

# Conflicts:
#	sdk/go/wire/models.gen.go
#	sdk/rust/src/wire_models.rs
@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

Thank you for the note on target_sha256. I took it in 23806c6. A document target's hash is now the content_sha256 its row stores, and _target_now reads it from the row instead of hashing the text. The field description now says it is the content_sha256 an op returned, empty when you have none. I checked three things first.

  • target_doc_id already names the write the reporter read, and the revision is always stored. So the hash never bound a filing, and nothing the earlier rounds relied on needs a hash of the text.
  • The stored hash is the dedup form, which is NFKC with whitespace collapsed and the title included. An edit that changes only whitespace keeps the hash but gets a new revision, so it still reads as changed. A title edit keeps the revision and now reads as changed through the hash.
  • A row with no stored hash gives the report none, your first option, and its revision alone says whether it changed. The row builder sets the column on every write, so only a row written outside it can lack one.

test_a_document_report_holds_the_document_s_stored_content_sha256 sends a SHA-256 of the text, which now answers 409, then the stored hash, then no hash. Both reports hold the stored hash, and a title edit marks the target changed while the words stay. Before the change the SHA-256 of the text was accepted. test_a_document_row_with_no_stored_hash_is_followed_by_its_revision covers the empty case. No report is stored yet and no older build serves the reports ops, so no replica compares one hash with the other.

One gap remains. knowledge.get doesn't return content_sha256 yet, so a document reporter usually sends no hash and submit stamps the stored one. Should knowledge.get return it too?

Drafted with AI help and reviewed by me manually.

@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

Thank you for the review. Round 15 is up.

  • 55900b9: a gap: reference is read only while knowledge.gaps.list would show a build, with the list's own checks.
  • f1a133a: a mirrored document's words are served only while the copy holds the reported revision. ffac409 says so in the knowledge.reports.get description.
  • 23806c6: a document report's target_sha256 is the stored content_sha256, as your design note suggested (answered above).
  • cc82a77: merges main. Main's 122_read_receipts.sql took 122, so the reports migration and its gate move to 123 and the rolling-upgrades rule is now 79. The erasure steps, census and predicates keep both tables, and the census counts went from 76 and 57 to 77 and 58. The generated SDKs, the operations reference, the status page and shapes.txt are main's copies with every generator rerun. schema.sql keeps main's dump plus the reports table, and its count line reads 199 tables.
  • 0bcf3e5 merges main again at d76e76b. Only the generated Go and Rust wire models conflicted. They are main's copies with sdk_go_gen and sdk_rust_gen rerun.

The python sdk adapters jobs were #2164, which the merge brings in. The Postgres 18 storage job on 7ef2d1a failed on test_cell_prepared_bot_native.py::test_normal_prepared_later_cell_proves_both_bootstrap_keys (Private fixture command ['server.cli'] failed). Main's own push runs fail the same test: a6e72fdc6 on Postgres 18, and 4e8978f, 6e5b213 and a3f350d. This PR does not touch cell automation.

Drafted with AI help and reviewed by me manually.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stored gap references honor the availability check, and mirrored report prose requires admission to the reported revision. Two other report behaviors need changes. GitHub reports conflicts with main.

plan = await source_access.prepare(org, [namespace])
own = [uri for uri, copy in wanted if not copy]
rows = (
await documents_repo.get_many_by_uris(org, namespace, own, include_superseded=True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — Report queue pages fetch full document bodies in both storage authorities just to decide which ordinary addresses to show. A page can fetch up to 200 bodies even though this code only reads source_uri. Use an authority-aware address lookup that keeps the superseded-row behavior.

if now is None:
return True
return bool(
(row["target_version"] and int(row["target_version"]) != now.version)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — A legacy document can have revision zero and an empty content hash. After its first numbered revision, both guards are false and target_changed stays false. Compare the stored revision directly for a report with a target, and cover the transition from zero with an empty hash.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants