Skip to content

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

Closed

Description

@dan-petty

Problem

Item 1 of the Fit note of #1329. Three places turn settings into a Qdrant client, an embedder and the collection names:

  • _get_rag_components in commands/rag.py. commands/ai.py imports it by its private name.
  • _resolve_runtime_qdrant_and_embedder in commands/ai_ingest.py.
  • _get_or_create_retriever in ai/rag/investigator.py. It builds QdrantClient and EmbeddingsEngine inline, so it skips the Qdrant and embedder seams.

build_runtime_vector_store is library logic. It lives in commands/ai_ingest.py and has a private alias, _build_runtime_vector_store. ai/rag/library_store.py has a private alias, _load_local_contracts, with no user. commands/rag.py has a pass-through load_settings.

The tree has moved since #1329 was written. load_local_contracts is public in ai/rag/library_store.py (#848). commands/ai_ingest.py no longer imports the private commands.valkey._resolve_client: it uses shared_cache_tier.

Expected

  • One public function in ai/rag/indexer.py, resolve_rag_components, builds the Qdrant client, the embedder and the two collection names from the settings. commands/rag.py, commands/ai.py, the investigator and the library vector store call it.
  • build_library_vector_store is a public function in ai/rag/library_store.py, next to LibraryVectorStore and load_local_contracts. commands/ai_ingest.py only calls it.
  • The private aliases _build_runtime_vector_store and _load_local_contracts are gone.
  • The pass-through load_settings in commands/rag.py is gone.
  • Commands are thin adapters: they turn a ConfigurationError into the exit code and the output.

Acceptance criteria

  • resolve_rag_components has tests that use the Qdrant and embedder fakes. They check the collection names, the missing URL error and the settings it is given.
  • build_library_vector_store has tests that use the Qdrant, embedder and Valkey fakes.
  • rg -n "_get_rag_components|_build_runtime_vector_store|_load_local_contracts|_resolve_runtime_qdrant_and_embedder" src tests docs prints no stale name.
  • commands/rag.py defines no load_settings.
  • The investigator builds no QdrantClient and no EmbeddingsEngine.
  • The behavior of devops ai rag and devops ai index-libraries does not change.
  • uv run devops ci passes.

Existing tool considered

No open tool covers this. It is a move of project code into one function. The cost of the move is lower than the cost of three copies that drift apart.

Related

Related: #1329 (parent item). Not in this item: the 23 ai/rag test migration, the ai/library and command tests, and the docs ingester rewrite. Those are items 2 to 4 of the Fit note.

Activity

  1. added
    source/agent
    type/refactor
    scope/ai
    status/new
    value/medium
    effort/medium
    on Nov 6, 2026
  2. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/refactor. The refactor prefix of the title gives the type.
    • Scope: scope/ai. The (ai) scope of the title gives the scope.
    • Priority: P2-Medium. Three copies of the same wiring can drift, but no user-facing defect is reported.
    • Value: Medium. It removes three duplicated code paths that risk silent divergence, but user-visible behaviour does not change.
    • Effort: Medium. It touches four source files, adds two public functions, removes three aliases, and requires new tests with fakes.
    • Related: test(ai): Wire rag once in ai/rag, test with edge fakes #1329, which asks for a different change. Both target ai/rag wiring, but #1329 owns the test migration while this item owns the code consolidation that #1329's Fit note lists as item 1.
  3. added
    priority/p2-medium
    on Nov 6, 2026
  4. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 6, 2026
  5. removed
    status/in-review
    on Nov 6, 2026
  6. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 22:51 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/aisource/agenttype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions