Add an off-by-default glossary match to `knowledge.search`

Open
#1,764 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
clickhouse, python

Research direction

Start with server/memory/app/search/term_leg.py, server/memory/domain/definitions.py, and server/memory/domain/definition_check.py to understand governed name matching, then inspect the lexical leg in server/knowledge/api/models_knowledge.py. The issue defines five acceptance cases, but leaves a broad design and rollout evidence open. Done means the optional behavior meets those cases, preserves the context budget, and has the paired comparison and latency evidence described.

Written by the indexing model from the issue text.

Description

enhancement
Company

ClickHouse

Component

Knowledge (documents)

Use case

In #1457 a team asks for the rule for an active account using an internal abbreviation. The authoritative definition uses the full term, and another team uses the same abbreviation for a different metric. That issue specifies the comparison against hybrid document search and its fixture, and leaves the mechanism open.

A comparison needs a defined treatment. memory.search already serves a governed definition when the query names its term or an alias. knowledge.search has no such step, so a query that uses only the abbreviation finds a passage only where the source text happens to contain it.

Describe the solution you'd like

An option on knowledge.search, off by default, as the treatment #1457 measures. This is a proposal; nothing is implemented or measured.

  • Match. The query runs through the exact name matching memory.search has for governed definitions. It adds no model call and no table.
  • Expand. A named definition adds lexical candidates for its other names. Passages that enter only this way take at most a fixed share of top_k and never displace a direct match. The context budget is unchanged.
  • Ambiguity. When more than one scope, within the caller's access and the reply's audience, defines the matched alias differently, the reply returns the alternatives and expands nothing. The request names the scopes compared, because the existing match reads the addressed namespace only.
  • Receipt. The reply carries the definition's key, version and content hash, and marks each passage that entered through an added name.
  • Nothing stored. No retrieval hint is kept, so a demotion, a revoked grant or an erasure needs no cleanup path: each search reads the definitions as they are then. The existing match reads without sequential consistency, so a promotion on another replica a moment earlier can miss one search.
  • The definition is navigation evidence. An answer still needs a current, authorized source passage, as #1457 requires.

What Loom has that this builds on:

  • server/memory/app/search/term_leg.py matches a query against governed names within a work budget.
  • server/memory/domain/definitions.py folds and compares names; server/memory/domain/definition_check.py decides which definitions are governed.
  • The lexical leg of knowledge.search (server/knowledge/api/models_knowledge.py) takes the added candidates.

Acceptance fixture, the four cases #1457 names plus one:

  1. An alias absent from the source text returns the required passage with the option on and not with it off.
  2. An alias two scopes define differently returns both alternatives and expands nothing.
  3. After a definition is promoted again with a changed alias list, a search that reads the new promotion uses the new revision only.
  4. A query with no glossary term returns the baseline's hit list, unchanged.
  5. After a demotion or a revoked grant no passage is marked.

Evidence still needed before rollout:

  • The comparison #1457 specifies, on the same fixture and context budget, as a paired result with an interval. Proposed rule: widen exposure only if the lower bound of the recall gain is above zero and wrong-source matches do not rise.
  • Wrong-source matches from a short alias that is also a common word.
  • p95 latency with the added candidates.
  • Whether memory_shared_definitions_max caps a glossary of the size a team maintains.
Describe alternatives you've considered
  • Put the glossary in the reader's prompt. That spends the context budget on every query and ignores scope.
  • Ask a model which glossary entries the query uses. That adds a model call to each search, and #1457 asks for exact matches.
  • Keep a separate glossary table for documents. That is a second copy of the governed definitions with its own review and erasure path.
Where the need comes from

An AI tool suggested this feature

Additional context

Found by source review; no search was run and no comparison was made.

Related: Proposed as part of #1457. Roadmap: #1232.

Dominant language
Python
Stars
221
Forks
35
Avg merge
14h 21m
Merged PRs (30d)
873

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ClickHouse/loom

All issues in ClickHouse/loom

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.