Skip to content

fix(embeddings): every embedding model resolves from the index's recorded space or the active model; unrecorded docs collections keep working and propose a stamp (#18143) - #18327

Merged
mrveiss merged 6 commits into
mainfrom
issue-18143-pattern-space
Oct 11, 2026
Merged

mrveiss merged 6 commits into
mainfrom
issue-18143-pattern-space

Conversation

@mrveiss

@mrveiss mrveiss commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Thinking Path

#18143 was reopened on its AC1, "one resolver for the generator and every cache key": several pipelines still hard-coded nomic-embed-text. Swapping every literal to active_embedding_model() would reintroduce the bug #18230 fixed: a pipeline with stored vectors would query in a different space after an active-model change. So each embedding-model literal was classified:

  1. Index-bound (embeds into or queries a stored index): its space is recorded in knowledge/index_embedding_space.py, and the generator and cache key resolve from that table.
  2. Active (fresh embeddings, nothing stored): active_embedding_model().
  3. Not a model choice (pricing tables, catalogue lists, defaults): allowlisted, each with a reason.

What Changed

  • Index-bound: the pattern analyzer, cross-language patterns (detector and endpoint) and the code-analytics collections (analytics_infrastructure via a CollectionEmbeddingSpace mixin) resolve their model and cache key from the table (make_key(space.space_id, …)).
    • Ten collections are recorded, each nomic-embed-text/768, taken from its own build path.
    • A collection missing from the table refuses (EmbeddingUnavailableError).
    • The cache keys change, for example nomic-embed-text becomes nomic-embed-text/768, so old entries miss once.
  • Active: NPU embeddings and the accelerator use active_npu_worker_model() (new, in autobot_shared/embedding_model.py). The memory-graph config reads active_embedding_model() at call time. The cognition seeder embeds with the active model, records the (model, dim) it creates, and refuses a collection recorded in a different space. The doc indexer's hard-coded fallback default is removed, so an empty model now fails loudly.
  • Docs search (services/knowledge/doc_searcher.py) uses the space the collection records. For a collection that records none (the live autobot_docs records none, verified read-only), the owner chose on 2026-10-11:
  • One HNSW reader (knowledge/backends/hnsw_params.py): a ChromaDB modify drops hnsw:* from metadata but keeps it in configuration. So the helper reads configuration["hnsw"] first, with the metadata fallback. knowledge/index.py uses it, and the in-memory backend mirrors real ChromaDB.
  • Guard (repo_tests/embedding_model_literal_guard_18143_test.py): no bare embedding-model literal in production code outside the table, the SSOT defaults and a reasoned allowlist. Contrast fixtures, a reach floor, and stale entries fail.

Behaviour changes

  • A changed active model no longer moves the query space of the pattern, cross-language or code-analytics pipelines.
  • CrossLanguagePatternDetector and _init_infrastructure no longer take an embedding_model argument.
  • Docs search on an unrecorded collection with a matching dimension keeps working, warns, and proposes a stamp. With a mismatched dimension, it refuses.

Verification

  • Services, knowledge backends, codebase analytics, the new tests, the literal guard and the size ratchet: 3644 passed. The HNSW and stamp follow-up set: 156 passed.
  • Hand check, not a repo test (chromadb is stubbed in the test conftest): against a temporary PersistentClient on the pinned chromadb, the existing metadata keys survived modify_metadata; hnsw:space left metadata but stayed in configuration.hnsw; queries still returned cosine distances.

Not done, stated rather than implied

Closes #18143

Model Used

Claude Opus 5.5 (master session: classification decision, host check, PR). Implementation by a Claude Sonnet subagent.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: mrveiss/AutoBot-AI/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 2c369f0a-132d-4922-b645-ce369ab2750c

📥 Commits

Reviewing files that changed from the base of the PR and between 6c68345 and c7771ad.


⛔ Files ignored due to path filters (2)
  • repo_tests/python_file_size_ratchet_baseline.py is excluded by !repo_tests/python_file_size_ratchet_baseline.py
  • scripts/python_file_size_known_large.py is excluded by !scripts/python_file_size_known_large.py

📒 Files selected for processing (26)
  • autobot-backend/ai_hardware_accelerator.py
  • autobot-backend/api/approval_gates.py
  • autobot-backend/api/codebase_analytics/endpoints/cross_language_patterns.py
  • autobot-backend/api/codebase_analytics/endpoints/cross_language_scoping_test.py
  • autobot-backend/api/codebase_analytics/npu_embeddings.py
  • autobot-backend/autobot_memory_graph/core.py
  • autobot-backend/code_intelligence/analytics_infrastructure.py
  • autobot-backend/code_intelligence/cross_language_patterns/detector.py
  • autobot-backend/code_intelligence/pattern_analysis/analyzer.py
  • autobot-backend/code_intelligence/pattern_analysis/embedding_test.py
  • autobot-backend/initialization/lifespan.py
  • autobot-backend/knowledge/backends/base.py
  • autobot-backend/knowledge/backends/chromadb_adapter.py
  • autobot-backend/knowledge/backends/hnsw_params.py
  • autobot-backend/knowledge/backends/memory_adapter.py
  • autobot-backend/knowledge/index.py
  • autobot-backend/knowledge/index_embedding_space.py
  • autobot-backend/services/knowledge/cognition_seeder.py
  • autobot-backend/services/knowledge/collection_space_proposal.py
  • autobot-backend/services/knowledge/collection_space_stamp_action.py
  • autobot-backend/services/knowledge/doc_indexer.py
  • autobot-backend/services/knowledge/doc_searcher.py
  • autobot-backend/tests/test_index_bound_embedding_space_18143.py
  • autobot_shared/embedding_model.py
  • autobot_shared/paths.py
  • repo_tests/embedding_model_literal_guard_18143_test.py

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@mrveiss
mrveiss merged commit 63f4293 into main Oct 11, 2026
58 of 79 checks passed
@mrveiss
mrveiss deleted the issue-18143-pattern-space branch October 11, 2026 21:45
neoneye pushed a commit to agent-memory-atlas-archive/mrveiss--AutoBot-AI that referenced this pull request Oct 13, 2026
…ration (mrveiss#18143)

Measured on this train tree (main 5efe902 + 6 constituents):
- credential-field-name-only-callers 6394 (population 6544), kb-admin-read-bypass 2652 (2752),
  response-model-secret-scan 5137 (5212), no-created-by-admin-literal 3635 (3785), mid-window.
- mrveiss#18327 embedding-model-literal-sites: scope recorded in reach_scope_claim and its
  ALLOWANCE_VERDICTS row added.

reach_declarations + reach_scope_claim: 529 passed locally before push.
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.

bug(kb): embedding cache key and generator resolve the embedding model from different config fields

1 participant