Skip to content

Index embed-excluded paths without a description or a vector - #1564

Open
KaloyanNaumov wants to merge 11 commits into
ClickHouse:mainfrom
KaloyanNaumov:embed-exclude
Open

KaloyanNaumov wants to merge 11 commits into
ClickHouse:mainfrom
KaloyanNaumov:embed-exclude

Conversation

@KaloyanNaumov

@KaloyanNaumov KaloyanNaumov commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #1559

TL;DR: Adds embed_exclude globs (LOOM_CODE_EMBED_EXCLUDE for the scalar entry): matching files stay in the index with their symbols, edges and test map, but nothing describes or embeds their chunks or writes them a summary card. Their rows carry a marker that extends the reference fixtures' one, so the previous build's recovery and coverage reads skip them too, and loom code reembed and the provider rebuild keep them without a vector. Empty by default, so nothing changes unless set.

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):

A repository entry's embed_exclude globs (LOOM_CODE_EMBED_EXCLUDE for the scalar entry) keep matching files in the code index, with their symbols, edges and test map, while their chunks are neither described nor embedded and they get no summary card; code.search finds them through its lexical leg.

Why

The only way to keep a path out of the embedder was exclude, which drops the file from the index with its symbols, call edges, impact and test map. Test files are often a large share of a repository's chunks: on our deployment, 45% of the live chunks of OpenClaw (343,578 of about 762,000, a ClickHouse GROUP BY over loom.code_chunks FINAL) come from *.test.* and *.spec.* files. An agent reaches a test from the source it covers through the test map, so the vectors buy little for their embedder time and storage.

The index already holds rows that are indexed and unembedded on purpose, the reference fixtures, marked embed_last_error = "unembedded by design: reference", which every read matches as a prefix. An embed-excluded chunk is stored as "unembedded by design: reference (embed_exclude)". Recovery, the backfill embed phase and the coverage counts keep their parameter, so this build and the one before it skip the row alike.

Writer What it does with an embed-excluded path
File ingest (ingest_file → _chunk_stage) No description, no embed call; rows get the marker, embed_attempts = 0, no stub count. Symbols, edges, guards, lexemes and the file row as for any file. A reference fixture keeps its own marker; exclude wins over embed_exclude.
Round model prefetch (pass_commit._ingest_commit_files) Not given the file.
Embed recovery, the backfill embed phase, coverage counts Unchanged: the marker extends the prefix they already skip.
loom code describe Skips a marked chunk.
loom code reembed Copies a marked row under the target label with no vector and its marker, so that label's recovery skips it too (reference fixtures included).
Provider rebuild (provider_rebuild_batch.py) Stages a marked code_chunks or code_summaries row with no vector and keeps the marker.
code_summary cards (workers/summary.py) No card is written for the file or carried to it across models; a card written before the glob is tombstoned once the file's content hash no longer matches it.

unembedded_by_design() in lang_reference.py is the one Python predicate. The lexical leg has no embedding_dim filter, so the rows are found by code.search's lexical leg, grep, code.files, code.outline and the test map; the vector legs skip them.

Scope and risk

server/code/app/index/denylist.py, ingest.py, pass_commit.py, reembed_model.py, server/code/domain/extract/lang_reference.py, server/code/domain/index/repos.py, server/code/workers/summary.py, server/code/workers/graph_stats.py, server/insights/app/provider_rebuild_batch.py, server/cli/code_maintenance.py, the setting in server/settings/catalog.py, and the docs. With no glob configured nothing changes: the denylist's embed_patterns is empty and every path is embedded as before.

The globs apply to chunks written after they change. This answers the two open questions in #1559, and the operations guide documents it:

  1. Adding a glob leaves a path's existing vectors in place until a chunk's content changes, and its existing card in place until the file changes. Then the card is tombstoned (the rank copy code_graph_stats mirrors from a card is written at the version it read plus one, so a tombstone landing meanwhile is not undone), and the next code_graph_stats pass writes the file's rank row back without one. Until that pass the file is missing from code.map and the hub query, a gap that closes by itself and only on paths the operator chose to exclude.
  2. Removing a glob leaves the path's chunks without a vector and outside the coverage denominator, so code.repos still reports them covered. No writer re-embeds an unchanged chunk: a chunk is embedded when its content changes, and embedding all of them means indexing the repository into a new namespace. The card comes back at the next code_summary pass. Should recovery instead treat a marked row whose path no longer matches as a stub (the issue's proposal)? I left that mechanism for your call.

embed_exclude applies to configured entries only. The registry table (loom.code_repos) has no column for the list, so a self-service entry is embedded in full until a migration adds one.

Compatibility, rollout and rollback

  • Wire: none. One new setting, LOOM_CODE_EMBED_EXCLUDE (default empty), and one new optional repository-entry key, embed_exclude.
  • Operator steps: none to keep today's behaviour. To use it, set the globs; new and changed chunks pick it up, and indexing into a new namespace applies it to the whole repository.
  • Rollout and rollback (rolling-upgrades rule 63): the previous build's recovery, backfill embed phase and coverage counts skip the stored marker, so a mixed fleet or a rollback neither embeds the marked rows nor drops coverage. The previous build reads neither the setting nor the entry key: where it runs, its ingest embeds a matching path's new chunks, its card pass writes their cards, and its reembed and provider rebuild embed marked rows under the target model.

How this was found

Found and reproduced on our deployment with AI assistance. Fixed on a fork, PR submitted.

Tests

  • tests/unit/test_code_embed_exclude.py (new):
    1. test_an_embed_excluded_file_is_chunked_but_never_described_or_embedded: symbols and lexemes kept, no embedder or LLM call, the marker with no attempt and no stub; a path outside the globs is embedded as before.
    2. test_the_scalar_setting_and_a_repo_entry_carry_the_globs: the glob semantics, LOOM_CODE_EMBED_EXCLUDE and a LOOM_CODE_REPOS_JSON entry's embed_exclude.
    3. test_the_reference_marker_is_the_previous_builds_literal pins unembedded by design: reference, written out.
    4. test_the_recovery_of_either_build_skips_a_stored_embed_excluded_row: the row ingest stores passes the previous build's recovery predicate (its literal, NOT startsWith(embed_last_error, …)) and this build's (the parameter its pending read binds). It fails with the earlier unembedded by design: embed_exclude marker.
    5. test_a_reference_fixture_keeps_its_marker_and_exclude_wins.
    6. test_the_round_prefetch_is_not_given_an_embed_excluded_file.
    7. test_loom_code_describe_leaves_a_marked_chunk_alone.
  • Beside the existing fakes: test_reembed_model_wide_path.py::test_a_row_unembedded_by_design_is_copied_with_its_marker_and_no_vector, test_provider_rebuild_batch.py::test_a_code_row_unembedded_by_design_is_staged_without_a_vector (chunks and cards) test_code_card_selection.py::test_worker_writes_and_carries_no_card_for_an_embed_excluded_file, and test_code_card_selection.py::test_an_embed_excluded_files_card_goes_once_the_file_changes (a changed and a deleted file's cards are tombstoned, a matching card and a rank row without a card stay; without the tombstone step it fails, nothing written). test_code_graph_stats_light_ranks.py::test_rank_write_does_not_restore_a_card_retired_after_the_read: the ranks leg reads a live card, a tombstone lands, and FINAL still keeps the tombstone; it fails without the change.
  • test_code_card_selection.py, test_code_summary_cancel.py, test_model_calls_held_mid_pass.py, test_model_calls_switch_workers.py and test_model_call_customer.py give the card pass real entry configs (repo_config), since it now reads their globs.
  • The touched test files with test_code_reference_files.py pass; ruff check, ruff format --check, the mypy gate and the function-length gate are clean. The full suite is left to CI.
  • The settings reference, schema, example and docs/reference/ tables were regenerated with scripts.codegen.settings_reference, settings_schema, settings_example and docs_reference.

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 wrote the diff and the tests. Checked: I reviewed the whole diff and its tests; the gate runs listed under Tests are the agent's, against main at the same commit.

  • 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) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.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.

Note

Medium Risk
Touches core ingest, embed recovery, reembed, and summary paths; misconfigured globs change what is embedded and what counts toward readiness, though defaults preserve current behavior.

Overview
Adds embed_exclude globs (per-repo and LOOM_CODE_EMBED_EXCLUDE on the scalar entry) so matching files stay fully indexed—chunks, symbols, edges, lexemes—while no LLM descriptions, no embeddings, and no code_summary cards are written. Those chunks get unembedded by design: reference (embed_exclude), extending the existing reference-fixture marker so recovery, coverage, loom code describe, loom code reembed, and provider rebuild all treat them like intentionally unembedded rows.

Ingest and round prefetch skip describe/embed for excluded paths; summary skips candidates and tombstones cards when content changes; graph_stats bumps rank-copy version so a retired card is not revived by a concurrent rank refresh.

Docs, settings schema, and rolling-upgrade notes document mixed-version behavior (older builds may still embed paths that this build marks).

Reviewed by Cursor Bugbot for commit 7c4f87c. Bugbot is set up for automated code reviews on this repo. Configure here.

A repository entry's `embed_exclude` globs (`LOOM_CODE_EMBED_EXCLUDE` for
the scalar entry, the `exclude` glob semantics) keep a path in the index:
it is chunked, its symbols, edges and test map are derived, and code.search
reaches its chunks through the lexical leg. Its new chunks are neither
described nor embedded, in the file ingest and in the round's prefetch, and
`loom code describe` leaves them alone. The rows carry
`unembedded by design: embed_exclude`.

Embed recovery and the coverage counts now match the shared prefix
`unembedded by design`, so reference fixtures and embed-excluded chunks
are neither stubs to fill nor counted in the embeddable denominator. Rows
already stored under the reference marker match it unchanged.

Test files are often a large share of a repository's chunks; this lets an
operator spend the embedder on source and reach tests from the source hit
through the test map.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
@vercel

vercel Bot commented Nov 26, 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 Nov 26, 2026 9:00pm UTC
loom-telemetry Ready Ready Preview Nov 26, 2026 9:00pm 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.

Stale Bugbot comment from a previous run.

`loom code reembed` copies a row that carries the `unembedded by design` marker under the second label with its marker and no vector, so an embed-excluded path or a reference fixture is not embedded there and that label's recovery leaves it alone.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
@zlareb1 zlareb1 self-assigned this Nov 26, 2026
The provider rebuild embedded every live `code_chunks` row and cleared
`embed_last_error`, so a staged embedder switch gave embed-excluded chunks
and reference fixtures a vector and erased their marker. It now stages a
row marked unembedded by design without a vector and keeps the marker.

The `code_summary` pass wrote an LLM card and a card vector for an
embed-excluded file, and could carry a twin's card across models. It now
takes the entry's `embed_exclude` globs (`denylist_for`), writes and carries
no card for a matching file, and clears a card written before the glob: the
row keeps its rank and carries the marker, so recovery and the card leg of
code.search skip it. Removing the glob lets the next pass write the card.

`unembedded_by_design` is the one predicate the Python writers read the
marker with. A test discovers every code-plane module that calls an
embedder or an LLM and fails until a new one is declared as a writer gated
on the marker or the globs, or as a query-side reader; the round prefetch
filter, the describe skip and the marker precedence get their own tests.
`ReembedStats.rows_unembedded` had no reader and is dropped.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
`ingest_file` resolved `default_denylist()` in `_refused` and again for the
embed rule; it now resolves it once and passes it down. The chunk stage's
`embed_excluded` has its one caller pass it, and the marker choice reads as
one expression.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
… entries

The operations guide states what a changed glob does: adding one leaves
existing vectors until a chunk changes, and removing one leaves the chunks
unembedded and outside the coverage denominator, embedded again when their
content changes or when the repository is indexed into a new namespace.
`embed_exclude` applies to configured entries only. A rolling-upgrades entry
records how an older build reads the marker as a stub. The coverage
comments name both kinds of rows unembedded by design, and the setting's
comment is cut to two lines; the generated references are regenerated.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exclusion needs to survive mixed-version recovery and model migration. loom code reembed selects all live source chunks, then embeds each missing target row. Preserve the marker and the vectorless row when copying to another model label. Existing reembed thread

The embed_exclude marker now extends the reference fixtures' marker
(`unembedded by design: reference (embed_exclude)`), so the previous build's
recovery, backfill embed phase and coverage counts, which match
`unembedded by design: reference` as a prefix, skip it as this build's do.
The recovery and coverage reads keep main's parameter.

A test pins the reference literal, and a cross-version test checks that the
row ingest stores is skipped by the previous build's recovery predicate and by
this build's.

The code_summary pass no longer clears a card written before its file's glob:
a card, like a chunk, keeps the state it had when the glob was set. The
candidate and carry filters stay.

The model-caller enumeration test is gone: it was a closed list that every new
caller had to edit, and it passed with the ingest gate removed. The reembed,
provider rebuild and card tests move beside their existing fakes, and the
recovery parameter check already in test_code_reference_files.py stays the
only one. reembed partitions its rows in one loop and reads the column it
always selects. Rule 63 and the operations guide say what is true now.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
The operations guide's CA-bundle paragraph and the embed_exclude paragraph
both follow the same paragraph; both are kept, CA bundle first.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
@KaloyanNaumov
KaloyanNaumov deleted the embed-exclude branch November 26, 2026 17:57
@KaloyanNaumov
KaloyanNaumov restored the embed-exclude branch November 26, 2026 17:59
@KaloyanNaumov KaloyanNaumov reopened this Nov 26, 2026
@KaloyanNaumov

Copy link
Copy Markdown
Contributor Author

Agreed, a marker the previous build reads as a stub was the wrong representation. An embed-excluded row is now stored as unembedded by design: reference (embed_exclude), which extends the reference marker, so both builds' recovery, backfill embed phase and coverage reads skip it with no change to their SQL. test_the_recovery_of_either_build_skips_a_stored_embed_excluded_row checks the row ingest stores against the previous build's predicate (its literal written out) and against this build's; it fails with the old marker. For model migration, loom code reembed and the provider rebuild copy a marked row with its marker and no vector (tests beside their existing fakes). I also dropped the retroactive card clear and the model-caller enumeration test, and rule 63 now says only what the previous build still does.

On the Bugbot reembed thread: Fixed: loom code reembed copies a row unembedded by design under the target label with its marker and no vector, so that label's recovery skips it too. test_a_row_unembedded_by_design_is_copied_with_its_marker_and_no_vector covers it.

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

Stale Bugbot comment from a previous run.

Comment thread server/code/workers/summary.py Resolved
The code_summary pass leaves embed-excluded paths out of its candidates, so a
card written before the path's glob was never rewritten or removed after the
file changed: code.map and the cards leg kept serving a description of the old
content.

The pass now tombstones the live card of an excluded path whose inputs_hash no
longer matches the file's content hash, a deleted file included. A card that
still matches the file stays, as before, and a rank row without a card is left
alone. The next code_graph_stats pass writes the file's rank row back. The
operations guide says the card stays until the file changes.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — An existing file card stays live when an embed-excluded file changes. I verified that the worker skips the card, while both the map and card search still read it without checking the file's current hash. Retire the stale card when the source changes and cover the case with an existing card. The stored marker and the model-copy paths address the previous findings. Existing stale-card finding

@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 high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 6b38f60. Configure here.

Comment thread server/code/workers/summary.py Resolved
zlareb1
zlareb1 previously approved these changes Nov 26, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excluded files keep their index entries, and stale cards are retired after the file changes. Both builds' recovery reads skip the stored marker. All 109 focused tests passed, including card retirement, model migration, and settings defaults.

code_ready_embed_coverage named embed_exclude by its suffix; it now
names code_embed_exclude, and the example file and schema follow.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
scripts/codegen/settings_reference.py after 59fc101's catalog wording change.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The graph-stats race in the existing thread still applies. graph_stats.py:590–618 can read the old card before its retirement and write it afterward with a higher version and no tombstone. Keep rank updates from restoring stale summaries and cover that ordering in the regression test.

@KaloyanNaumov
KaloyanNaumov marked this pull request as draft November 26, 2026 20:49
@KaloyanNaumov

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Converting to draft while I address it; a new head and the replies will follow, so no need to look at this head again.

The ranks leg reads a live file card, then inserts a mirror of it with the
new rank at the clock version. A tombstone or a new summary written in
between carries an earlier version than that copy, so the copy won under
FINAL and brought back a card retired meanwhile.

The copy now takes the read card's version plus one. Every other writer
takes its version from the clock, so a later tombstone or summary is
higher and wins; with no write in between the copy is still the newest
row.

The test reads a card, lets the tombstone land during the read and checks
that FINAL keeps the tombstone. It fails without the change.

Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
@KaloyanNaumov

Copy link
Copy Markdown
Contributor Author

Fixed in 7c4f87c. The rank copy graph_stats mirrors from a card is now written at the version it read plus one, so a tombstone or a new summary landing after the read carries a later clock version and wins. This closes the race on main too. test_rank_write_does_not_restore_a_card_retired_after_the_read lets the tombstone land during the read and fails without the change.

@KaloyanNaumov
KaloyanNaumov marked this pull request as ready for review November 26, 2026 20:59

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rank writer now advances the version it read by one. The real query returns that version, and the regression verifies that a tombstone written after the read wins over the delayed rank copy.

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.

Index test files without embedding them: an embed_exclude that keeps symbols, edges and the test map

2 participants