Skip to content

The curation loop's design: knowledge gaps, governed definitions and definitions from query history - #552

Merged
zlareb1 merged 111 commits into
mainfrom
docs/curation-loop
Nov 13, 2026
Merged

zlareb1 merged 111 commits into
mainfrom
docs/curation-loop

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Documentation (changelog entry is not required)

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):

...

Why

Searches that find nothing say what an organization has not written down, and the queries a team runs most often on its own ClickHouse say which metrics it relies on. Neither reaches anyone today. This page is the design for the loop that turns both into definitions a person promotes, and for serving a promoted definition above every other hit (a derived aggregate's count aside) when a query names its term. The three implementing PRs follow it: knowledge gaps, governed definitions, and then knowledge.gaps.draft with definitions from query history.

The calls this page makes, and why:

  • A misses-only table instead of search_trace_log or query_nodes. The trace log records every query, its actor is the token's principal rather than the resolved person, and it has no user-scope erasure step; query_nodes counts sessions and covers memory only; knowledge searches are not logged at all. A narrow table written only on a miss, by the op the caller invoked, from searches that read the namespace-wide rows with no narrowing filter, is smaller and erasable per user. Recording is an operator opt-in, off by default, and follows the trace log's rule for query text: nothing is recorded while the request's capture level is off.
  • The asker is the person the token stands for, never a body field: the end user of an end-user token, else the root of a delegated token's chain, else a service account's creator, else the subject, so self-minted tokens count as one person. Misses keep no memory key or document URI, so nothing in them outlives another user's erasure.
  • A privacy threshold of k distinct askers (the resolved person behind each token; default and floor 3), applied to each normalised query before merging, so every query a gap shows was asked in that form by k principals. It is as strong as the principals behind it: the page names where it does not bind (the signing key, end-user issuers, trusted callers, self-created accounts), and an asker that cannot be resolved records nothing. Gaps keep counts, never who asked; a user erasure drops the derived builds of the namespaces the user asked in, which the next daily pass rebuilds. Misses keep the normalised query beside the identity tuple, the asker and the plane, and no memory key or document URI.
  • Governance is the shared layer. A governed definition is a live loom.shared row promoted by an admin (memory.promote / memory.demote), which records its source and, on the review path, its candidate, is walked by memory.lineage, and is known to every build. The term leg serves shared rows to every reader, so the shared layer gains a redact that reaches it, a token-stamped promoted_by, a promotion conflict check that skips definition, a refusal to promote a definition from anything but the namespace-wide row under the shared row's key, and a retirement of the shared copy's embedding when its source is relabelled medium or high. Namespace erasure reaches loom.shared (a change of its own, already on main). The guarantee itself is a read-time check: the term leg serves a shared definition only while its provenance names the namespace-wide row and that row is live, neither labelled nor graded medium or high, and holds the same text, so every writer, worker and older build is covered, except what the page's rolling-upgrades section names (an older build's promotion skips the hash check and takes promoted_by from the body, so every earlier definition is promoted again once no older replica serves). An earlier draft of this page added a governance table of its own; every review round found another edge of its state, and the shared layer has none of them.
  • Definitions are namespace-wide and served under any read scope through the term leg, as knowledge documents are: an admin publishes them for every reader of the namespace.
  • definition is key-identified, like decision, and never judged against a definition under another key, so MRR is not a revision of ARR.
  • The term leg covers memory only and reads the addressed namespace's live shared definitions. Knowledge already has an exact-key leg. The leg lives in memory.search; loom_search serves it through its memory section, whose repository-decision merge and answer-first rules never move or withhold a governed hit.
  • Promotion is the approval. Promoting a drafted definition writes it for the whole namespace and promotes it into the shared layer as the reviewer.
  • Query history has a registration of its own that reuses the tracker's connection checks, not a document-source kind (whose config never holds a host) and not a tracker source (which needs the record contract).
  • One rollout gate. Every op the design adds that writes or reads a new table answers 503 while an older replica serves, as namespace.guide_set does (memory.definitions.list, which reads only tables an older build knows, is not gated), so the new tables hold nothing an older erasure could miss; a rollback's clean-up is named.

Scope and risk

One page, docs/development/curation-loop-design.md, linked from the contributor section of docs/index.md; llms.txt regenerated. No code. It sits under docs/development/, which help.search and help.get do not index, so no agent is served ops that do not exist yet; the docs site publishes it under Development and llms.txt lists it, both with its first sentence, which says none of it is built yet; each implementing PR moves its part into docs/architecture/, written as what Loom does, and removes it from this page.

Compatibility, rollout and rollback

  • Wire: none in this PR. The design adds knowledge.gaps.list, knowledge.gaps.draft, memory.definitions.list, knowledge.query_history.add/.list/.remove, a governed output field on memory hits, and an approved-content hash on memory.promote and, for a definition promotion, refusals of a source that is not the namespace-wide row, a target_key that is not the source's key or lies outside definition/, a term or alias another live shared definition holds, a promotion that adds a key at the memory_term_leg_max_definitions ceiling, and any definition promotion past it (breaks for definition promotions); an if_absent precondition on memory.set and an if_match_sha256 precondition on memory.delete, a term_leg output field, promoted_from_candidate_id ignored and named in ignored_args on a direct memory.promote of a definition, approver ignored and named in ignored_args by memory.promote and learnings.review on every promotion of a definition, and learnings.review refusing a definition candidate that is not a knowledge_gap or query_history draft; each lands with its implementing PR.
  • Behaviour changes the design brings, each in its implementing PR: memory.set and memory.bulk_set give a definition no merge, duplicate or refinement verdict and no bulk fold into a byte-identical row under another key; memory.consolidate leaves definition rows out; under newest_wins neither a write by another identity nor the named-fact path retires a definition's namespace-wide row; memory.redact reaches the shared row and the drafts holding the redacted text; memory.promote refuses a definition whose value is labelled or graded medium, and a relabel to medium retires its shared embedding as one to high does; memory.outcome's quarantine skips a definition's namespace-wide row; learnings.list, a viewer op today, shows knowledge_gap and query_history candidates (drafts that may repeat users' queries, and a team's SQL shapes) to admins only; learnings.review refuses a definition candidate of the memory_supporters or conversation_seeder kind; a memory.search with the default scope = "private" is served governed shared rows; and a read-bounded token is served governed definitions, namespace-wide rows, through the term leg (an exception to the read-scope rule the page states and argues).
  • Operator steps: none.
  • Rollback: none.

Tests

tests/unit/test_doc_links.py, tests/unit/test_public_copy.py, tests/unit/test_agent_instructions.py, tests/unit/test_docs_reference.py, tests/unit/test_help_docs.py: pass. [email protected] --check on the changed pages: clean.

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. Every path, op, column and setting the page names that exists today was checked against the tree; the ones it adds are marked as the design.

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

Checklist

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

🤖 Generated with Claude Code

zlareb1 and others added 24 commits November 13, 2026 00:57
…definitions from query history

One page for the three parts of the loop: the data model, the ops, the term leg in memory.search, erasure and audit, rolling upgrades, the privacy threshold and the cost bounds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Definitions are namespace-wide and published like documents; pin and attest of a definition take admin; the pinned-peer claim matches the same-type conflict check; gaps show only queries k people asked in that form; query history uses the tracker's source registry; gap ops stay out of read-narrowed tokens; census rows, an Invariants section, and the page says it is a design.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Gap ops refuse narrowed tokens before the knowledge. prefix; governed needs the namespace-wide definition/ row; promotion writes unpinned then pins; N-1 promotions and writer pins are named with what the admin does after; query history keeps only normalised text; every build writes a marker and builds expire; the slug carries a hash of the term; definitions promote to memory only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Misses are an operator opt-in recorded only for a named end user, so every asker is erasable by user_id; asker counts show writers beside users; a build is deleted when a user erasure began since its read; case-aware term matching and unique terms; governed definitions only cross the read scope through the term leg, which honours filters and sensitivity; definitions are not marked conflicting with each other; query history has a registration of its own; the N-1 knowledge-destination residue is named.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Governance is an admin-only record (loom.governed_definitions) bound to the approved content hash, so no memory write can make a row governed; uniqueness is checked on every govern; the build fence covers any erasure reaching the namespace; drafts hold no asked query; misses exclude a term-leg or exact-key answer; the read-scope change links its owning page; N-1 conflict marks are named with their clean-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Promotion checks term uniqueness before it writes; the N-1 verdicts (merge, duplicate, conflict) and their clean-up are named, and the term leg serves only active rows; case rule exact only for all-caps or inner-capital terms; the namespace-wide tuple includes session_id; live_sha256; lexical-mode knowledge hits are not misses; grouping runs in ClickHouse; existing definition rows stay plain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Misses count only from searches that read the namespace's shared rows, and the asker comes from the token, never a body field; page-expired and degraded answers are not misses; the resolver neither flags nor retires a definition; tombstone or redact ends its record; uniqueness is case-folded; N-1 supersedes are named with memory.restore.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Governance binds to the approved row version, so any later write on any build ends it; gaps recording is turned on only once N-1 is gone and off before a rollback; misses and the term leg skip hard-filtered searches; pending extraction is not a miss; drafts' threshold protection is stated; query-history registration erasure, snapshot behaviour and fail-closed cost reads are named.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
One rollout gate: every op the design adds, and promotion of its candidates, answers 503 while an N-1 replica serves, as namespace.guide_set does; a rollback's clean-up is named; the threshold never goes below two; the term leg honours exclude_keys and runs on the first page; any narrowing field excludes a miss; the marker is written last; nearest keeps document URIs only; definition.list shows lapsed governance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Gaps keep counts, not askers, and a user erasure drops the org's derived builds; the term leg has its own filter rule and stays on for read-scope pins, exclude_keys and min_similarity; a redact writes no version, deletes the record on N, and a rollback drops governed records; promotion approves the committed version; narrowing fields are a rule with examples.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Governance binds to the approved text's hash again, so the entity pass and other copies keep it, while a tombstone or redact deletes the record; a rollback also drops pending definition drafts, as rule 23 does; the slug rule names the kept characters.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A tombstone or redact deletes the governed record before it commits and is refused if that fails; a rollback deletes every definition draft whatever its status, and again once the gate closes; the gate also stops the gaps pass and query-history turns; the write-time change for existing definition rows is named; the invariant counts askers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Misses and gaps keep no document URI, so nothing outlives a user's erasure or a document's delete; the draft op finds live documents when it drafts; the term leg reads the addressed namespace only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A namespace that refused capture records no misses; a gap draft is written from its queries alone; a govern re-reads the row and drops a record a racing delete or redact left; recording sits behind the rollout gate; the threshold's floor is three and last_at keeps the day.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Governance moves onto loom.shared (memory.promote / demote), which already records the approver and candidate, has lineage, and is known to erasure and every build; the governance table, its erasure, tombstone hook, race repair and rollback delete go. The asker is the person a token stands for, so self-minted tokens count once; the threshold's limits are stated; a held list names the erasure to finish.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The shared layer gains what governing on it needs: a namespace-erasure step, a redact that reaches it, a token-stamped promoted_by, and a promotion check that skips key-identified types; sensitivity holds through promotion's refusal; a held list names its erasure by id; audit rows and excerpts are described as they are.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
memory.promote refuses a definition from anything but the namespace-wide row, and a relabel to high demotes one; promotion pre-checks a credential-shaped draft; the term leg drops other hits under its key; a loom_search miss needs every section empty and no tags; the asker reads the creator claim.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Governance is checked when the term leg reads: provenance names only the namespace-wide row, which is live, not high and holds the same text, so pre-existing rows, N-1 and every relabel path are covered; promotion also requires the key to be the term's slug; the relabel-demote hook goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The term leg reads the source from the memory authority and fails closed; the promotion conflict check skips definition only; memory.promote refuses an overlapping term on every path; the memory_type rule is unambiguous; the page is reflowed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A service account's token without the creator claim resolves its creator from the registry; a user erasure drops only the gap builds of namespaces the user asked in, and the fence covers only erasures of askers the pass read; misses keep only the normalised query; an expired source ends governance; a loom_search miss also needs nothing withheld, no tracker verdict and no skipped namespace; the invariant matches the last-promoted rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A definition's promotion carries the content hash it approves and is refused if the source changed; a redact also blanks the candidate's text; governed keys stay out of later pages; N-1 retirements of a definition are found through memory.auto_retirements; misses expire after the seven days a pass reads, and the window setting goes; a claimed agent counts through its service account's creator.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Misses live 14 days, the window is 7 and a build lives 7, so a user erasure always finds the namespaces to clear, and an empty build replaces an expired window; N-1 promotions are named for promotion again; a promotion refused after the write leaves a pending candidate a retry completes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
loom_search's decision merge and answer-first rules never move or withhold a governed hit; PUBLICATION_PENDING leaves the candidate pending and the approved hash is the drafted value's; the shared layer needs seven changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
The privacy threshold names where it does not bind (signing key, issuers, trusted callers, self-created accounts); an unresolvable asker records no miss; the normalised form is defined; a redact blanks every draft for the key; query history reads every replica when the cluster is named; the term leg's filter list is complete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
zlareb1 and others added 10 commits November 13, 2026 00:57
…tes first; mark rule precedes the script rules; invalid-Unicode query skips the leg

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…rison only; marks continue either edge

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… name, refused on several; mark rule by script; demoted source stays a plain row

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…definition/ in the breaks; revision key wording; Inherited marks

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…acts as its base; finding a revision's key

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…t; definitions.list entry fields

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…s every definitions.list field

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…se mark rule; word of a name excludes stray marks

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…d per name; miss form treats stray marks as the term leg does

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…tion past the ceiling; bounded definitions.list; entry verdict fields

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
zlareb1 and others added 8 commits November 13, 2026 01:04
…apped entries carry only ordering fields; read limited to ceiling plus one

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…otion; the bounded read re-applies both ceiling rules; list entry shapes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…count and read twice

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ised too

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…d_from_candidate_id named in ignored_args

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ts the draft first

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
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.

1 participant