Skip to content

An assist pass of the curator counts which repeated questions a shared document could answer - #2377

Open
zlareb1 wants to merge 3 commits into
mainfrom
feat/curator-question-walk
Open

zlareb1 wants to merge 3 commits into
mainfrom
feat/curator-question-walk

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Related: #2152
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):

In assist mode the curator's scheduled pass now decides, for each of the 20 questions people ask most without an answer, whether a shared document, one written for no one user, could answer it. curator.status and loom curator status show how many are draftable and why the others are not.

Why

A namespace's knowledge gaps list the questions several people asked and found nothing for. Some of them are answered by a document the namespace already shares, and an admin has no way to tell which without searching for each by hand. The pass already reads the namespace once a cadence, so it is the place to decide this, and the answer belongs on the surface that reports the pass.

The decision is made by code alone, in one order, and the first step that ends a question gives it its code:

  1. the gap may still be drafted from (gap_ineligible, erasure);
  2. no definition draft claims it (definition_draft_exists);
  3. no drafted answer claims it, under this wording or another of the gap, and no fact is stored under its draft key (already_drafted, drafted_other_wording);
  4. a shared document holds a passage that answers it, and one that does not read as high (no_evidence, sensitive_passage).

A question no step ended is draftable. With knowledge gaps off, a namespace that keeps no query text, or one that mirrors a document source, no step runs and every question is counted under that reason (gaps_off, capture_off, mirrored_source).

Scope and risk

  • One eligibility function. knowledge.gaps.draft and the walk both call gap_drafts.eligibility, which holds every rule the handler had. The handler's behaviour is unchanged and its tests pass as they were.
  • Shared documents only. A shared document is one written for no one user (user_id is -). HybridSearchQuery gains shared_only, which adds user_id = '-' to the filter every leg shares. It is set in process by the walk's read, and no operation's wire model carries it. A passage of a document written for one user never counts as evidence. Every member of a namespace reads every document in it, so the filter is about whom a document was written for and not about who can read it, and the shared_documents prerequisite says so: "The namespace holds a document written for no one user".
  • What counts as evidence. A passage answers a question by the rule that keeps a search from being recorded as a miss: it is as close as a hit that answers a query, or an exact-key match. A vector search always returns its nearest chunks, so without that rule any shared document would make every question draftable.
  • Model calls and spend. The walk asks no chat model. Its search embeds the question, which is a call made for the org: the embedder is sent the question's text, which the gap build sent it when it grouped the question. Each search is recorded as the namespace's spend under worker.curator. A walk that has a gap to decide, in a namespace where none of the three reasons above holds, therefore reads the org's model switch and the curator's share of the namespace's daily cost cap once, before its first question. While the calls are off, the share is spent or either cannot be read, it decides no question and the pass row holds no questions. The share is read once and not before each search, so a walk can pass it by the embeddings of at most 20 questions. The embedder itself refuses a call for an org switched off after that read, which fails the walk.
  • A search without an embedding was not built. Every leg's statement ranks by cosine distance to the query vector, and the rule that says a passage answers is a similarity floor. A walk on the BM25 and exact-key legs alone would need new statements on the search path and another evidence rule, and draftable would be counted by a rule no search of documents uses.
  • The read under the draft key. It is strong, which reads with sequential consistency first, and passes fresh=True as every point lookup outside the repository does.
  • Privacy of the pass row. Every viewer of the namespace can read a pass row. questions holds a count for each code and each question's code under 12 hex digits of a hash of its gap's id, keyed with the root secret under a label of its own. It holds no question, no gap id, no draft key and no passage. A gap's id is derived from its question, so the draft key curator/gap/<k> is keyed the same way under another label: a key must not reveal the question. With 20 opinions and 20 questions the metadata stays under its 6,000 characters.
  • Fail closed. A prerequisite that cannot be read is not met: an unreadable capture level counts every question as capture_off, an unreadable source list as mirrored_source, an unreadable eligibility rule as gap_ineligible. A walk that raises is noted as a failed leg of the worker, and the pass keeps its counts and opinions with no questions. An erasure that reached the namespace during the pass stores no question.
  • Bounds. 20 questions a pass and 4 passages a question, inside the pass's 120 s. The mode is read before each question, as it is before each model call.
  • Where the counts are served. They are in last_pass.questions, a list of code, title and count, and not in last_pass.counts: counts is keyed by section and carries no title, and a surface prints the title the server sends.
  • Dashboard. The unmet list of the Curator tab and of the settings dialog says what each entry is needed for: a pass, model opinions or a draftable question. In assist mode the list holds the four new prerequisites when one is unmet, and an entry a draftable question needs stops no pass and no opinion. The tab does not draw the question counts.
  • Left alone. The walk writes no fact and no candidate. A pass in findings mode never walks.

Compatibility, rollout and rollback

  • Wire: curator.status gains last_pass.questions[] (code, title, count), and setup[] gains four entries, gaps_on, capture_on, shared_documents and no_mirrored_source, with a new value of needed_for, drafts. The pass row's metadata gains questions. The fields are additive: an older worker does not walk, and an older reader ignores the fields. No operation, migration, setting or rolling-upgrade rule is added or changed.
  • Operator steps: none.
  • Rollback: reverting leaves pass rows whose metadata holds questions, which the older build ignores, and the regenerated SDK files revert with the commit.

Tests

  • pytest tests/unit/test_curator_questions.py: each code in step order, the walk-level reasons, an unreadable prerequisite, the draft key, the content of the pass row and its size at the largest mix of codes, the time bound, a changed mode, a failed walk and an erasure during the pass.
  • tests/unit/test_read_your_writes.py: the walk's point lookup asks for fresh rows.
  • tests/unit/test_knowledge_gaps.py::test_both_callers_share_one_eligibility_function: each rule closes both callers.
  • tests/unit/test_knowledge_search_service.py::test_shared_only_reads_no_user_document: fails with the filter removed from _common_where.
  • tests/unit/test_curator_status.py, tests/unit/test_cli_curator.py: the four prerequisites, each following its own read, and the questions line.
  • tests/integration/test_curator_pass.py, against a server and a ClickHouse started for this change: a repeated question with a shared document is draftable with a count of 1 and no memory row or candidate written; one answered only by a user's own document is no_evidence; one a definition draft claims is definition_draft_exists.
  • The existing gap-draft tests pass unchanged.
  • frontend/src/views/admin/Curator.test.tsx and frontend/src/flows/NamespaceSettingsDialog.curator.test.tsx: an unmet entry is listed with what it is needed for and who can change it, and a purpose or a role this build has no words for is shown as its code. npm --prefix frontend run build and npm --prefix frontend run budget pass. The rest of the dashboard suite runs in CI.
  • Every SDK generator, docs_reference, op_reach_census and plugin_eval_tools was run on the first commit and its --check passes. The second commit changes no operation and no wire model, and docs_reference --check passes on it. tests/analyzer/shapes.txt gains five shapes, and pytest tests/analyzer passes against the same ClickHouse.
  • make typecheck, ruff format --check and ruff check pass.
  • On the second commit, against a server and a ClickHouse started for it: the three integration tests of the walk and test_setup_says_why_no_opinion_was_given, the unit files above with the other curator and knowledge search unit files, and the repository scans (test_package_contracts, test_op_transport_contract, test_tunable_constants, test_store_names_refused, test_degraded_unnoted, test_public_copy, test_doc_links, test_agent_instructions).
  • The third commit changes two docstrings of tests/integration/test_curator_pass.py and no statement. On it, against a server and a ClickHouse started for it: every test of that file, the same repository scans and pytest tests/analyzer pass, with make typecheck, and ruff format --check and ruff check on that file.
  • tests/unit/test_degraded_unnoted.py fails on main merged with any branch: main holds an unlisted handler, server/code/app/index/review_brief_build.py::_history_section::gather::1, in a file this change does not touch. It passes on this branch alone.

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. The tests above were run as the Tests section says, and the diff was read against the area rules and the invariants.

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

🤖 Generated with Claude Code

…d document could answer

After the model step, a pass in `assist` mode takes the 20 most asked gaps of the
namespace's latest gap build and gives each one code. The first step that ends a
question decides it: the gap may no longer be drafted from, a definition draft or an
earlier draft claims it, no shared document answers it, or every passage that answers
it reads as sensitive. A question no step ended is `draftable`. The walk writes no
fact and asks no chat model.

- `knowledge.gaps.draft` and the walk decide whether a gap may be drafted from through
  one function, `gap_drafts.eligibility`.
- The walk's search reads only chunks of documents held for no one user
  (`HybridSearchQuery.shared_only`, set in process; no operation carries it), and a
  passage answers a question by the rule that keeps a search from being recorded as a
  miss.
- The search embeds the question, a call made for the org. The walk runs only while the
  org's model calls are on and the curator's share of the namespace's daily cost cap is
  unspent, and the spend is recorded under `worker.curator`.
- The pass row gains `questions`: a count for each code and each question's code under
  a keyed hash. It holds no question, no gap id, no draft key and no passage.
- `curator.status` serves the counts with their titles in `last_pass.questions`, and
  `setup` lists four more prerequisites, each needed for `drafts`: `gaps_on`,
  `capture_on`, `shared_documents` and `no_mirrored_source`.
- `loom curator status` prints a questions line with the server's titles.
- The draft key of a gap is `curator/gap/<k>`, with `k` from a keyed hash of the gap's
  id: a key must not reveal the question.

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 6, 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 6, 2026 10:39am UTC
loom-telemetry Ready Ready Preview Dec 6, 2026 10:39am 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit de32494. Configure here.

Comment thread server/memory/app/curator_questions.py Resolved
zlareb1 and others added 2 commits December 6, 2026 10:11
…y what a shared document is

- The walk's lookup of a fact under a gap's draft key passes `fresh=True`, as every
  point lookup outside the repository does. The read is the same: it is `strong`, which
  reads with sequential consistency first.
- The `shared_documents` prerequisite reads "The namespace holds a document written for
  no one user", and the comments and the curator page word the filter the same way.
  Every member of a namespace reads every document in it, so "a document every member
  can read" named no filter.
- The dashboard's unmet list says what each entry is needed for: a pass, model opinions
  or a draftable question. An entry a draftable question needs stops no pass and no
  opinion.
- The curator page says what the walk sends the embedder, that the walk reads the org's
  model switch and the curator's share of the cap once, before its first question, and
  when a pass row holds no `questions`. The runs page lists `questions` among what a
  pass in `assist` mode adds to its row.
- The size test checks the largest `questions` a walk can store. That is a mix of
  codes, because each code a question ends under adds a count.

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…en for

Two docstrings of tests/integration/test_curator_pass.py described the
documents the `_document` helper adds by who reads them. Every member of a
namespace reads both, so the docstrings now name the user each document was
written for: no one user, which is a shared document, or the user given.

Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

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.

1 participant