Repository navigation
A request that joined a per-reader mirror records no knowledge miss - #2343
Merged
Merged
Conversation
`record_miss` returns before it reads a setting, builds a row or touches a counter when the request is marked as touching a mirror, or runs inside such a request. Nothing a marked request writes outside the mirror depends on what the mirror holds, and a miss is judged on the answer. With auth on, a `knowledge.search` or `loom_search` over a namespace with an active `mirrored` source, a `loom_search` whose live leg ran, and a search the assistant runs for an answer in such a namespace record none. A `memory.search` the caller invokes is not marked and records its misses. A mark that cannot be read records none. No op, field, setting, CLI command, MCP listing or dashboard view changes. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #2152
Changelog category (leave one):
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):
A request that joined a per-reader mirror records no knowledge miss. With auth on, a
knowledge.searchorloom_searchover a namespace with an activemirroredsource records none, so the knowledge gaps of such a namespace form from thememory.searchcalls a caller invokes.Why
Nothing a request that touched a mirror writes outside the mirror may depend on what the mirror holds (document sources: the mirror), and a knowledge miss is judged on the answer a search returned. So a marked request records none.
record_miss(server/knowledge/app/gaps.py) returns first inside itstry:, before the settings read, the row and both counters, whenrequest_work.mirror_marked() or not public_diagnostics(). This is the expression of the read-receipt gate (_recordinserver/memory/app/read_receipts.py).mirror_marked()reads the bound bag.public_diagnostics()is false underprivate_work(), on a marked HTTP owner whose current bag is fresh, and when the mark cannot be read, so it catches a call made inside a marked request under a bag of its own.record_miss, not in its three callers (knowledge.search,loom_search,memory.search), so every caller gets it.With auth on:
knowledge.searchorloom_searchover a namespace with an activemirroredsource records no miss;loom_searchwhose live leg ran records none;memory.searchthe caller invokes is not marked and records its misses;_invoked(op).The refusal writes no log line, metric or counter and takes no in-flight slot.
Scope and risk
server/knowledge/app/gaps.py, two tests intests/unit/test_knowledge_gaps.py, four docs pages._record_gap_miss'sif payload.get("live"): returninserver/memory/app/loom_search/handler.py, the three callers, the worker andknowledge.gaps.list. Judging a marked request's miss on its ordinary answer is not built: gaps in a namespace with an active mirrored source form frommemory.search.except;tests/unit/degraded_unnoted.txtkeeps its onerecord_missline.loom.search_missesgets fewer rows. No table, erasure step or census row changes.memory.searchcontributes there.loom.search_misseshas one writer,_insert, scheduled only byrecord_miss. A marked request'sagent_eventsrow is written toloom.agent_events_privatewith reduced arguments and no memory key.memory.askskips its cited-used credit, contradiction record and deferred consistency when its plan is marked. Spans, metrics, log records and captured generation text are dropped underprivate_work(), and the caches shared across readers are bypassed for text a mirror leg gave. The docs page linked above states the rule for each.server/knowledge/app/gaps.py,docs/features/knowledge.mdandtests/unit/test_knowledge_gaps.py.git merge-treeof its head with this branch merges those three files without conflict, so either order merges.Compatibility, rollout and rollback
docs/reference/status.mdstays at 419 operations, 305 of them experimental.Tests
No ClickHouse or server was started: no statement changes, and the tests are unit tests on the file's
scheduledfixture.test_a_request_that_joined_a_mirror_records_no_miss, parametrized over a marked bag,private_work()alone, a mark on the HTTP owner with a fresh bag, andhttp_mirror_markedraising. It fails when a shape schedules an insert, counts a drop atknowledge_gaps_max_in_flight = 0, or takes an in-flight slot; each case ends with the same call outside the request, which records one row.test_a_loom_search_that_joined_a_mirror_records_no_missfails whenhandler._record_gap_missschedules a row under a marked bag, or records none outside it.record_miss(5 failed) and pass with the change (5 passed).pytest -n 2 -p randomly tests/unit/test_knowledge_gaps.py tests/unit/test_live_source_search.py tests/unit/test_source_search_handler.py tests/unit/test_source_search_provider_boundaries.py tests/unit/test_loom_search_fanout_kinds.py tests/unit/test_loom_search_mcp_render.py tests/unit/test_loom_search_repo_decisions.py tests/unit/test_loom_search_tracker_general.py tests/unit/test_search_op.py tests/unit/test_admission_parity.py tests/unit/test_memory_search_kinds.py tests/unit/test_read_receipts.py tests/unit/test_memory_search_handler_gates.py:564 passed, 1 xfailed.pytest -n 2 tests/unit/test_package_contracts.py tests/unit/test_op_transport_contract.py tests/unit/test_tunable_constants.py tests/unit/test_store_names_refused.py tests/unit/test_degraded_unnoted.py tests/unit/test_public_copy.py tests/unit/test_doc_links.py tests/unit/test_agent_instructions.py tests/analyzer:614 passed, 12 skipped(the analyzer's live cases skip without a ClickHouse).ruff format --check .andruff check server extractor sdk/python tests scripts .claude: clean.make typecheck: clean.scripts/gates/function_length_gate.py: at its baseline.python -m scripts.codegen.docs_reference --check: every page current.prettier@3.9.9 --checkon the four docs 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. Checked by hand: where the mark is set for a mirror leg, the live leg and the assistant's answer; that
memory.searchprepares no mirror plan; thatloom.search_misseshas one writer; and that both new tests fail on the unchanged function.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/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).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code
Note
Low Risk
Narrow recording gate on background gap inserts; namespaces with mirrored sources will show fewer gaps unless callers use
memory.search.Overview
Mirror-marked requests no longer write knowledge-gap misses.
record_missingnowledge/app/gaps.pyreturns immediately whenrequest_work.mirror_marked()ornot public_diagnostics(), matching the mirror rule that nothing outside the mirror may depend on mirrored content—and a miss is tied to the search answer, not a hidden leg.With auth on,
knowledge.search,loom_search, and assistant-driven searches in namespaces with an active mirrored source stop contributing toloom.search_misses; gaps there come only from caller-invokedmemory.search. The check lives in one place so all three callers stay aligned.Docs (
document-sources,knowledge-gaps,curation-loop-design,knowledgefeature) document the rule and invariants. Unit tests cover marked bags,private_work, HTTP-owner marks, unreadable marks, andloom_search's_record_gap_miss.Reviewed by Cursor Bugbot for commit 49e94d7. Bugbot is set up for automated code reviews on this repo. Configure here.