Skip to content

refactor(ai): RAG components are wired once in ai/rag - #3856

Merged
dan-petty merged 3 commits into
mainfrom
refactor/1329-rag-components-wired-once
Nov 6, 2026
Merged

dan-petty merged 3 commits into
mainfrom
refactor/1329-rag-components-wired-once

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

One public function, resolve_rag_components, now builds the Qdrant client, the embedder and the collection names from the settings. The devops ai rag commands, retrieve_rag_context and the RAG investigator call it. build_library_vector_store moves to ai/rag/library_store.py, and commands/ai_ingest.py only calls it.

Three copies of this wiring existed, and the investigator built QdrantClient and EmbeddingsEngine by hand, so it skipped the test seams. One function keeps every caller on the seams. The private aliases _get_rag_components, _build_runtime_vector_store and _load_local_contracts, and the pass-through load_settings of commands/rag.py, are gone.

Closes #3850

Change: openspec/changes/archive/2026-11-06-3850-rag-components-wired-once/

@dan-petty dan-petty added type/refactor Type refactor: a new structure, same behavior scope/ai AI review pipeline, personas, prompts, LLM client, or RAG labels Nov 6, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test and check results (local):

  • Full devops ci before the last test edits: 20044 tests passed. Two known host failures fail the same way on origin/main: test_mark_only_commands_under_global_dry_run and the popeye executor contract test. The startup-imports check failed under the load of 16 test workers and passes alone (38 s).
  • After the review fixes and the rebase: focused RAG tests pass (37), and the lint, format, mypy, docs, openspec, test-tree and swallowed-failures checks pass.

Differences from the old behavior, on purpose:

  • build_library_vector_store catches DevOpsCLIError only. The old helper caught Exception. The swallowed-failure ceiling of commands/ai_ingest.py drops by one. No real path raises another error type: Qdrant.is_alive catches everything.
  • A missing qdrant.url ends a devops ai rag command through the one error report of the CLI (exit 1, same message). retrieve_rag_context skips RAG without a message in that case.
  • resolve_rag_components builds the embedder before the investigator checks is_alive. The constructor opens no connection.

Review fixes: the investigator test now checks the embedder, the Qdrant client and the collection names that reach SemanticRetriever. The rag clear test checks the collection names. retrieve_rag_context reads the components by name, so the order cannot be wrong.

@dan-petty
dan-petty marked this pull request as ready for review November 6, 2026 22:11
resolve_rag_components in ai/rag/indexer.py builds the Qdrant client, the embedder and the collection names from the settings. The rag commands, the RAG investigation and the ai commands call it, so the investigator now uses the Qdrant and embedder seams. build_library_vector_store in ai/rag/library_store.py replaces the wiring in commands/ai_ingest.py. The pass-through load_settings and the private aliases are gone.
@dan-petty
dan-petty force-pushed the refactor/1329-rag-components-wired-once branch from 5878152 to c125c45 Compare November 6, 2026 22:23
@dan-petty
dan-petty merged commit d175616 into main Nov 6, 2026
24 checks passed
@dan-petty
dan-petty deleted the refactor/1329-rag-components-wired-once branch November 6, 2026 22:29
dan-petty pushed a commit that referenced this pull request Nov 6, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.74.0](v0.73.0...v0.74.0)
(2026-11-06)


### Features

* **roadmap:** Add reason and queries to the alternatives comment
([#3846](#3846))
([86b6ed7](86b6ed7)),
closes [#2944](#2944)
* **roadmap:** build job pull request text with pull_form
([#3847](#3847))
([a7aacea](a7aacea)),
closes [#3215](#3215)


### Code Refactoring

* **ai:** RAG components are wired once in ai/rag
([#3856](#3856))
([d175616](d175616))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/ai AI review pipeline, personas, prompts, LLM client, or RAG type/refactor Type refactor: a new structure, same behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(ai): RAG components are wired once in ai/rag

1 participant