Repository navigation
Search under a code scope reads the repository's decisions - #165
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/search-code-scope-decisions
branch
from
November 2, 2026 03:13
d2fbf27 to
abf00d1
Compare
…n base failure 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]>
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]>
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/search-code-scope-decisions
branch
from
November 2, 2026 05:20
42363f5 to
8dd351c
Compare
… helper Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
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.
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):
loom_searchfrom an indexed checkout now returns the decisions recorded in the repository's trunk code namespace in its memory section. The caller must be allowed to read that namespace. Rows thatloom_searchand HTTPsearch.querywithhold from the memory section now leave its reader block too.Why
A decision written in a repository's trunk code namespace (a
memory_type='decision'row) never reachedloom_search. The memory leg'sall_minefan-out starts from the caller's own namespaces and keeps only memory-kind namespaces, so a code namespace is never searched. A "why is it done this way" question asked in the checkout came back with nothing, even when the repository had recorded the answer.The repository's documents already reach the knowledge section this way (
knowledge_with_repo_docs+search_repo_docs+merge_hits). This PR gives the memory section the same treatment. UnderX-Loom-Code-Scope,memory_with_repo_decisions(server/memory/app/loom_search/repo_decisions.py;fanout.pykeeps the assembly) runs one extra in-processhandle_memory_searchover the scope's trunk code namespace (namespace_scope="this",agent="*",memory_type="decision", the same query,top_kand tags, LLM-free) and merges its hits into the memory section. The gate that admits the namespace also decides the repository-docs leg, so one check covers both legs and capture consent.Scope and risk
handle_memory_searchperforms no authorization, so the leg is gated.repo_namespace_in_scope(server/code/app/repo_scope.py) runs once per request inhandle_search. It returns the trunk namespace only when the scope's org is the request's org androw_in_scope(org, trunk_ns, VIEWER)admits it (fail closed). Both repository legs (memory_with_repo_decisions,knowledge_with_repo_docs) take that result and run no gate of their own. The docs leg used to run its own gate, which lacked the same-org check.readable_repo_namespaceandtrunk_namespace_of(renamed fromreadable_docs_namespaceanddocs_namespace_of) moved there fromrepo_docs.py.handle_memory_searchpins the token's read scope on the decision pass as on every search. A user- or session-bound token reads only its own rows, and a scope that does not resolve is refused, which the leg treats as no answer.handle_searchnarrows consent to the most restrictive level of the fan-out namespaces plus the repository namespace, before the legs start. This also closes the gap where the docs leg ran at the home namespaces' level.memory_repo_decisions_timeout_s, a new LIVE setting, 1.5 s), an exception or an abstaining decision search adds no hits, and the section answers as before. Only the base search can fail the leg; when it does, the decision pass is cancelled.retrieval_defaultscannot change it:retrieval_budget="fast",search_mode="semantic",hyde=False,rerank="none",legs=["memory"],memory_type="decision",quality_filter=False,floor_mode="drop"(an additive leg adds only rows that clear the floor; padding totop_kis the home search's job). It is served at the stored clip (bodies="full"), because a recorded decision is a statement that ends with its reason, which a 200-character excerpt cuts. Underbodies="none"it serves keys only. The junk filter is off because it targets captured session rows, and two decisions under different keys stay two decisions however alike they read. Only hits withmemory_type == "decision"andsource == "fact"are kept._merged_into_parentand writes no trace row, exposure, recall credit or page of its own. After the merge,credit_merged_hitsrecords exposure and recall credit once for the decisions that were merged in. It uses the pass's settled input (MemorySearchOutput._settled_input), so the token's user pin and the namespace'sauto_touchapply.(namespace, memory_key). Decisions do not count againsttop_k: at most the pass's owntop_kjoin, and a home row pushed past the cut would be served on no page, because the parked tail starts after the home search's own rows.candidates_totalis the home count plus the decisions added. If the home search abstained and a decision answers, the section carries the decision search's calibration. Later pages continue the home search alone and count its matches only. Underexplain=true, every served row gets awhyline, decisions abovetop_kincluded.answer_firstand its precision floor removed rows frommemory.results, but the reader block still printed them. This applied to any row, on MCPloom_searchand HTTPsearch.queryalike.search_sectionsnow renders the block once, from the models of the rows that remain. A served row that has no model raises an error instead of silently leaving the block. No paired benchmark was run for this: the block now holds exactly the rows the section already served, so a reader sees no row the results withheld; the change removes text, not ranking.docs/features/unified-search.md, Limits).tools/call loom_searchrequests per run, one fresh connection per call, to a private server from source (fake providers, auth off), with and withoutX-Loom-Code-Scope, two runs each: the code scope adds 9 to 26 ms at p50 with an empty trunk and 0 to 14 ms with one matching decision. The p99 differences are within run-to-run noise, far below the 3500 mssearch.querybudget. No ranking benchmark was run.answer_first's rules,context.pack, prompt recall and the session primer.Compatibility, rollout and rollback
loom_searchdescription names the repository's docs and decisions, and its paging sentence followsmemory.next_page. New settingLOOM_MEMORY_REPO_DECISIONS_TIMEOUT_S(live, 1.5); the generated reference, settings schema and example file follow.Tests
tests/unit/test_loom_search_repo_decisions.py:candidates_totaland the paging text.bodies="none"passed through,quality_filteroff, and a failing base search cancelling the pass.answer_firstand the flags, and a withheld decision absent from the MCP text.tests/unit/test_repo_docs.py: the shared gate and the docs leg's use of it.tests/integration/test_cross_principal_leakage.py:decision.recordin the deployment's code namespace (LOOM_CODE_ORG/LOOM_CODE_NAMESPACE, as CI sets them), deleted afterwards.mainafter the decision-record changes (decision rows are statements). The fulltests/unitpassed at8dd351c4(24541 passed, 20 skipped, 1 xfailed); the last commit rewords a comment and inlines a test helper. The integration file passed against a private server, auth off and on, before the rebase and the canary change; it has not been re-run since.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: the gate runs before any read of the trunk namespace, and the mutation check above.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed. (Format, lint, typecheck and the full unit suite pass; the integration file has not been re-run since the canary change, see Tests.)docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.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