Repository navigation
fix(guards): mypy resolves autobot_shared so enum aliases stay types; the embedding-literal guard covers namespaced ids and the infra builders (#18345) - #18393
Conversation
… stay types (#18345) The backend mypy run is rooted in autobot-backend/, where autobot_shared did not resolve; ignore_missing_imports made Severity Any and every X = Severity alias a variable (valid-type). mypy_path = $MYPY_CONFIG_FILE_DIR fixes all six at once. Pinned by a fixture run with a contrast config lacking the path.
…gte/jina and the infra builders (#18328) The matcher reads one list, KNOWN_EMBEDDING_MODEL_PREFIXES in autobot_shared/embedding_model.py. Roots gain populate_kb_chromadb.py and shared/tools/index_documentation.py; both now take active_embedding_model(). Reach floor re-pinned 2595 -> 2604 (window 2454..2754, population 2754).
…atcher excludes rerankers (#18328)
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to The documentation indexing scripts now follow the configured embedding model but do not check the model used to build their existing collections. Changing the model without rebuilding can break indexing or degrade search results. Resolve this before merging, or confirm that a rebuild is enforced when the model changes. The new mypy test also needs a timeout so a stalled run cannot hang the test suite. Pre-merge checks |
|
|
Merge-gate review at 1b6ecea: approve, on top of the author's Sonnet gate. |
✅ SSOT Configuration Compliance: Passing🎉 No new hardcoded values of either class — Known backlog in |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: mrveiss/AutoBot-AI/.coderabbit.yaml
- Review profile: ASSERTIVE
- Plan: Advanced
- Run ID:
3deb7662-0a4f-4f6c-95b3-97b0abd8d639
📒 Files selected for processing (7)
autobot-infrastructure/shared/scripts/populate_kb_chromadb.pyautobot-infrastructure/shared/tools/index_documentation.pyautobot_shared/embedding_model.pypyproject.tomlrepo_tests/embedding_model_literal_guard_18143_test.pyrepo_tests/mypy_enum_alias_resolution_18345_test.pyrepo_tests/reach_scope_claim_17844_test.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
| llm = LlamaIndexOllamaLLM(model=default_model, base_url=ollama_base_url) | ||
|
|
||
| embed_model = OllamaEmbedding(model_name="nomic-embed-text", base_url=ollama_base_url) | ||
| embed_model = OllamaEmbedding(model_name=active_embedding_model(), base_url=ollama_base_url) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Check the embedding model recorded for each persistent collection. If the configured model changes after a collection has been populated, both scripts can write or query vectors using an incompatible embedding space. A dimension mismatch can reject writes; equal dimensions can conceal incorrect search results.
autobot-infrastructure/shared/scripts/populate_kb_chromadb.py#L148-L148: check theautobot_docscollection’s recorded model before selecting it for indexing, and rebuild when the model differs.autobot-infrastructure/shared/tools/index_documentation.py#L375-L375: apply the same check toChromaDBIndexerbefore upserts or searches.
📍 Affects 2 files
autobot-infrastructure/shared/scripts/populate_kb_chromadb.py#L148-L148(this comment)autobot-infrastructure/shared/tools/index_documentation.py#L375-L375
| cwd=cwd, | ||
| capture_output=True, | ||
| text=True, | ||
| encoding="utf-8", | ||
| check=False, | ||
| ) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Set a timeout for the mypy subprocess.
If mypy stalls, this test waits indefinitely and can block the test run. Set a timeout on subprocess.run and handle subprocess.TimeoutExpired with a useful failure message. Based on learnings, process-spawning calls must have a timeout.
🧰 Tools
🪛 ast-grep (0.45.3)
[error] 35-50: Command coming from incoming request
Context: subprocess.run(
[
sys.executable,
"-m",
"mypy",
f"--config-file={config}",
"--follow-imports=silent",
f"--cache-dir={cwd / 'cache'}",
"alias.py",
],
cwd=cwd,
capture_output=True,
text=True,
encoding="utf-8",
check=False,
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
(subprocess-from-request)
Source: Learnings
Thinking Path
Two guard and enum issues in one batch (same scope, no shared files with anything in flight):
X = Severity) were reported by the backend mypy run asVariable "…" is not valid as a type, which silently disabled type checking on those fields.What Changed
autobot-backend/, mypy cannot resolveautobot_shared.ignore_missing_imports = truethen turnsSeverityintoAny, so a module-level alias reads as a variable. Run from the repo root, the same files are clean.mypy_path = "$MYPY_CONFIG_FILE_DIR"inpyproject.toml[tool.mypy]. No per-site changes.X: TypeAlias = Severityform the issue suggested hides the bug: it reports success whileXis silentlyAny. So it was rejected.KNOWN_EMBEDDING_MODEL_PREFIXESandis_embedding_model_id()inautobot_shared/embedding_model.py, now the only embedding-family list (the guard's old regex is deleted). It allows an optionalorg/namespace and covers the e5/gte/jina,multi-qa-andcodebertfamilies. A reranker (bge-reranker-*) shares thebge-prefix but is excluded.autobot-infrastructure/shared/scripts/populate_kb_chromadb.pyandautobot-infrastructure/shared/tools/index_documentation.py. The issue named a wrapper with no literal; the real collection builder is theshared/toolscopy.active_embedding_model()instead of"nomic-embed-text". They writeautobot_docs, which is not inknowledge/index_embedding_space.pyand is read bydoc_searcher.pywithactive_embedding_model()plus a stored-dimension check. The old literal is what could mismatch.code_embedding_generator.pymicrosoft/codebert-base→ index-bound (CODE_INDEX).pinned_model_registry.py→ not-a-choice (a revision/digest pin).reach_scope_claim_17844is updated for the new roots.Verification
repo_tests/mypy_enum_alias_resolution_18345_test.py(3 tests, about 11 s) runs mypy on a fixture from a non-root cwd with the repo config and asserts novalid-type. Its contrast (a config withoutmypy_path) assertsvalid-typeappears.autobot_shared/mypy gate unchanged: over all 391 files, origin/main and HEAD both give "86 errors in 17 files", with identical sorted error lists.sentence-transformers/all-MiniLM-L6-v2,BAAI/bge-small-en-v1.5,microsoft/codebert-base,intfloat/e5-large-v2,thenlper/gte-baseandjinaai/jina-embeddings-v2-base-en. Not matched aremeta-llama/…,mistralai/…,microsoft/phi-3-mini,BAAI/bge-reranker-v2-m3,llama3:8band a baregte. Mutation (removing the reranker exclusion) fails that case.embedding-model-literal-sitesis re-pinned mid-window, 2595 → 2604 (population 2754, window 2454..2754).reach_declarations+reach_scope_claim+ both guards: 559 passed.code_intelligencetests for the six modules: 207 passed.Risks
autobot_shared. That is not a gate (GH#7105), so their counts may shift; this was not measured.Model Used
Anthropic Claude Opus 5.5 (claude-opus-5-5), coordinating. Anthropic Claude Sonnet 5.5 (claude-sonnet-5-5) subagents for implementation and the gate.
Issue Link
Closes #18345
Closes #18328
Follow-up: #18382, the remaining infra
nomic-embed-textliterals outside the guard's roots.Changelog fragment
Summary by CodeRabbit