Repository navigation
Conversation
code.repo.add_branch registered the branch in loom.code_repos without a vector source, and only an operator entry could set embed_reuse_from, so a branch added from the page embedded every chunk its source namespace already held. loom.code_repos records the namespace a branch was added from (base_namespace, migration 118). row_to_config maps it onto embed_reuse_from, the registry read selects it, and the first-index slice passes it to ingest_file as the indexing passes and the backfill do. answers_cache reads embed_reuse_from too, so such a branch now also reads its source's cached answers, behind the existing access and file-hash checks. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zlareb1
left a comment
There was a problem hiding this comment.
The registry field also turns on source answer reuse for branches added from the Repositories page. A copied answer can outlive its source access check.
The statement corpus renders schemas/schema.sql as one shape, and the dump gained the base_namespace column, so the committed shape list named the old digest. Rewritten with python -m tests.analyzer.corpus --write; the only change is that one shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
answers_cache._trunk_of read embed_reuse_from for every entry, so a page branch, whose registry row now sets it, borrowed its source's cached answers. A borrowed answer is copied into the branch, and later hits on the copy check the branch alone, not the source grant: a viewer who lacks that grant, or loses it after the copy, would read it. _trunk_of now reads embed_reuse_from only for an operator entry. A page branch takes vectors from its source and synthesizes its own answers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
CI: This was ours. The analyzer corpus hashes |
zlareb1
left a comment
There was a problem hiding this comment.
Branches added from the Repositories page copy matching vectors and use their own answer cache. The two-viewer regression and 223 other focused tests passed.
|
Fix merge conflicts |
Main took migration number 118 for 118_store_names_reserved.sql, so this branch's 118_code_repo_base_namespace.sql is now 119. Its content is unchanged; test_schema_baseline.py lists both files in order. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Merged main (97a2a81) into the branch; one conflict.
The schema dump, docs and code merged without a conflict. The row-to-config, answers cache and self-service tests pass, as do the schema baseline, journal and numeric-order tests. |
zlareb1
left a comment
There was a problem hiding this comment.
The migration and journal use 119, and the 224 focused tests pass. Update the two references to migration 118 in the PR description before the squash merge.
zlareb1
left a comment
There was a problem hiding this comment.
GitHub reports a merge conflict in tests/unit/test_schema_baseline.py. Please reconcile the migration baseline with main so CI can test the combined tree.
Main took migration 119 for workspace crawl, so the base namespace column moves to 120_code_repo_base_namespace.sql, and the journal list in the baseline test names both. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Round Merged main in f8862bd. Main took migration 119 for workspace crawl, so the base namespace column moves to |
zlareb1
left a comment
There was a problem hiding this comment.
Migration 120 follows the workspace crawl migration and the schema baseline includes both. The vector reuse and answer-cache changes match the previously reviewed implementation. Before squash merge, update both references to migration 118 in the PR description.
zlareb1
left a comment
There was a problem hiding this comment.
The analyzer shape test fails on the exact CI merge and passes on its first parent. Update the snapshot for migration 120 and update the two migration numbers in the PR description. Failed analyzer job
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
Regenerated with python -m tests.analyzer.corpus --write on the merge of upstream main bd58b7b. The schema dump shape becomes 5201d159797b; 3e3256030728 and c25cec2435d6 are gone. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
Steady point: The snapshot is regenerated, not edited: and the diff is exactly what you named — The body is updated from migration 118 to 120 in both places. |
zlareb1
left a comment
There was a problem hiding this comment.
The analyzer snapshot carries the schema with base_namespace. The analyzer and schema checks passed. The PR description still names migration 118 in two places. Use 120_code_repo_base_namespace.sql before merging.
zlareb1
left a comment
There was a problem hiding this comment.
The pinned Biome check finds the same unformatted dashboard assertion in this run and on clean main. The separate repair formats that assertion. Failed job · Repair #2107
zlareb1
left a comment
There was a problem hiding this comment.
The branch migration conflicts with the migration number already on main. GitHub also reports a conflict in the migration baseline.
main took 120 for usage-label provenance, so this file becomes 121 and the journal baseline lists it after it.
…rations # Conflicts: # tests/unit/test_schema_baseline.py
b7aa6e2 to
6f1bb49
Compare
zlareb1
left a comment
There was a problem hiding this comment.
The branch copies vectors only for matching chunks in the same organization and keeps cached answers scoped to the branch. Migration 121 follows the current migration journal and preserves the field when an older build copies a registry row.
A branch added from the Repositories page (
code.repo.add_branch) now copies the vectors of identical chunks from the namespace it was added from, so its first index embeds only what differs. Before, only an operator'sLOOM_CODE_REPOS_JSONentry could setembed_reuse_from, and a page-added branch embedded every chunk again. The registry row gets abase_namespacecolumn that carries the source.Related: #1680
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 branch added from the Repositories page reuses the embeddings of identical chunks from the namespace it was added from, instead of embedding the whole branch again.
Why
code.repo.add_branchregisters the branch inloom.code_repos, androw_to_configbuilds itsRepoConfigfrom that row. Neither setembed_reuse_from, which only an operator entry could carry (server/code/domain/index/repos.py).bootstrap.index_slicethen calledingest_filewithout a reuse source, so the first index embedded every chunk although the source namespace holds the same vectors. The embed-recovery worker and the indexing passes already readcfg.embed_reuse_from, so they work once the config carries it.The fix has three parts:
loom.code_reposgetsbase_namespace(LowCardinality(String) DEFAULT '', migration 121).code.repo.add_branchwrites the namespace it was called on;code.repo.addwrites''.row_to_configmapsbase_namespaceontoRepoConfig.embed_reuse_from. The registry snapshot read selects the column, and a removed row reads it empty, like the other fields of a removed row.bootstrap.index_slicepassescfg.embed_reuse_fromtoingest_file, asreconcileandloom code backfillalready do.Scope and risk
Touches the registry row, its two readers, the first-index slice and the answer cache's trunk lookup. It leaves operator entries alone: their
embed_reuse_fromstill comes from the JSON entry, and an operator entry's access row records no base.The reuse covers vectors only.
answers_cache._trunk_ofalso readsembed_reuse_from, to let a release branch borrow its trunk's cached answers, and it now reads it only for an operator entry (source == "config"). A borrowed answer is copied into the branch, and later hits on that copy check the branch alone, not the source grant, so a viewer who lacks the source grant, or loses it after the copy, would read it. A page-added branch therefore never reads its source's cached answers; it synthesizes and caches its own.Second effect, throughput only: with a reuse source set,
pass_commitskips the round-wide embedding prefetch (embed=not embed_reuse_from), so later passes embed per file, as they do for an operator branch with a source. On the first index, the slice's prefetch passes no reuse source either, so the source's vectors are read with one statement per file rather than one per round asloom code backfilldoes. The result is the same; only the number of reads differs.A branch whose source namespace is later removed finds no vectors there (
reusable_vectorsreturns nothing) and embeds its chunks.Compatibility, rollout and rollback
schemas/migrations/121_code_repo_base_namespace.sql. A previous build reads the registry by column name and rewrites a row only by copying it whole (upsert_accesscopies the row read withSELECT *;deactivate_code_repoinsertsSELECT * REPLACE), so it keeps abase_namespacea newer pod wrote. A previous build that adds a branch writes no value; that branch reads''and embeds every chunk, as before. Rows written before the migration read''.Tests
Red on
main, then green with the change (focused, on a private ClickHouse for the integration file):tests/unit/test_code_repo_self_service.py::test_a_branch_added_from_the_page_embeds_no_chunk_its_source_holdsadds a repository and a branch throughhandle_code_repo_addandhandle_code_repo_add_branch, indexes the source with the realindex_sliceandingest_file, then indexes the branch, whose file is the source's. Onmainthe branch'sembed_reuse_fromis''and its embedder is asked for the chunk; with the change the embedder is asked for nothing and the branch's chunk rows carry the source's vectors. With only the registry part of the change (nobootstrapedit) the same test still fails on the embedder, so it covers the slice too.tests/unit/test_code_repo_self_service.py::test_row_to_config_reuses_the_vectors_of_the_namespace_a_branch_was_added_fromcovers the row mapping, and the existing add-branch test asserts the storedbase_namespaceof both rows.tests/unit/test_code_ask_cache_v2.py::test_a_branch_added_from_the_page_never_serves_its_source_answersis the two-viewer case: a viewer who may read the source asks a page-added branch, then a viewer without the source grant asks the same question. With_trunk_ofreading every entry, the first ask is served the source's entry and stores a copy that the second viewer then reads; with the change the first ask synthesizes and no stored row names a source. The operator release-branch reuse tests in the same file still pass.tests/analyzer/shapes.txtis rewritten for the schema dump's new digest (python -m tests.analyzer.corpus --write; one shape changed).tests/integration/test_code_repo_row_kind.py::test_a_branch_keeps_the_namespace_it_was_added_from_until_it_is_removedround-trips the field on ClickHouse: stored, read back as the entry's vector source, kept through an access change, empty once the branch is removed, and empty for a row written without the column.Also run:
ruff format --checkandruff check,function_length_gate,check_no_secrets,mypy_gate,docs_reference --check,op_reach_census --check,make schema-check(the dump differs frommainin the one added line), and the unit files for the add paths, bootstrap, the release-branch config, schema baseline, additive migrations, table settings, doc links and public copy.make test-mixed-versionneeds docker and is left to CI.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; I read the diff and ran the tests above.
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.schemas/schema.sql(make schema-dump); no op, setting or plugin file changed.main; no merged migration is edited.frontend/changed: not applicable, unchanged.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.Note
Medium Risk
Changes indexing embed reuse, registry schema, and ask-cache trunk borrowing; answer-cache gating reduces cross-namespace leakage but behavior differs for page vs operator branches.
Overview
Branches added via
code.repo.add_branchnow record the source namespace inbase_namespaceonloom.code_reposand map it toRepoConfig.embed_reuse_from, so the first index and ingest path copy vectors for identical chunks instead of re-embedding the whole branch.bootstrap.index_slicepasses that reuse source intoingest_file, matching backfill/reconcile behavior operators already had via config.Answer-cache cross-branch reuse is tightened:
_trunk_ofonly treatsembed_reuse_fromas a trunk for operator entries (source == "config"). Page-added branches still reuse embeddings from the source but do not serve or copy the source’s cachedcode.askanswers, avoiding cases where a branch cache could leak trunk answers to callers who lost trunk access.Docs and ops guides describe the new default for Repositories-page branches versus manual
embed_reuse_fromsetup. Migration 121 adds the column additively withDEFAULT ''for backward compatibility.Reviewed by Cursor Bugbot for commit 5d63451. Bugbot is set up for automated code reviews on this repo. Configure here.