Skip to content

test(ai): ai/rag tests run on edge fakes, one file per behavior #3862

Closed

Description

@dan-petty

Problem

Item 2 of the Fit note of #1329. The tests of src/devops_cli/ai/rag/ still double devops-cli code instead of edges. The count in the tree at a0f9557 (measured with an AST pass over tests/ai/rag/, tests/ai/test_rag_chunker.py and tests/ai/agents/test_embedding_config_retention.py):

  • 128 patch sites. Most patch a devops-cli name (SemanticRetriever, QdrantClient, EmbeddingsEngine, get_qdrant_api_key, kube_configuration, load_settings, _embed_search_query) or the tracer.
  • 21 imports of a private name from devops_cli, 9 of them in test_rag_embeddings.py.
  • 10 hand-rolled doubles: FakeQdrantClient, RecordingQdrant, StubFailingSecondBatchEmbedder, FakeEmbedder, StubEmbedder, StubQdrant, DummyQdrant, RecordingQdrant, _MockValkey. The shared fakes in tests/support/fakes/ (Qdrant, embedder, Valkey, web, clock, OTLP, keyring, Kubernetes) now exist.
  • Files named after a source module or after the work that produced them, and one catch-all (test_rag_error_branches).
  • No Hypothesis test for the chunkers in ai/rag/chunker.py.

Already done by earlier items (RAG wiring in #3850, the seams): resolve_rag_components, test_rag_qdrant.py contract suite, test_rag_components.py.

Expected

The ai/rag tests double only edges, through the shared fakes. Each behavior has one file in tests/ai/rag/, named after the behavior. The hand-rolled doubles are gone. The chunkers have Hypothesis property tests.

Acceptance criteria

  • No migrated test patches a devops_cli name or imports a private one.
  • The hand-rolled Qdrant, Valkey and embedder doubles in these files are deleted. The tests use qdrant, embedder, valkey, web, clock, otlp, keyring_store and cluster.
  • One file for each behavior. The catch-all test_rag_error_branches is split. test_rag_cli.py keeps only CLI cases.
  • Hypothesis tests for chunker.py check: chunks cover the input, no chunk is over the size limit, the overlap is respected. They use a small max_examples and no timing.
  • The Qdrant contract suite (test_rag_qdrant.py) stays intact.
  • A scratch mutation of the product code makes the migrated tests fail (recorded in the change folder).
  • Every document and spec that the change makes wrong is fixed.
  • uv run devops ci passes.

Not in this item: the ai/library and command tests (item 3 of #1329) and the docs ingester (item 4).

Existing tool considered

Hypothesis (a dev dependency already) for the chunker properties. The shared fakes of #1317, #1314, #1318, #1319 and #1320 for the edges. No new tool.

Related

#1329 (parent), #1307, #3850.

Activity

  1. added
    source/agent
    type/test
    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/test. The test prefix of the title gives the type.
    • Scope: scope/ai. The (ai) scope of the title gives the scope.
    • Priority: P2-Medium. It is a planned test refactor within a larger effort, not a defect or security fix.
    • Value: Medium. It removes brittle test doubles and adds property tests, improving long-term maintainability of the ai/rag suite.
    • Effort: Medium. Migrating 128 patch sites, deleting ten hand-rolled doubles, splitting files, and adding Hypothesis tests is bounded but multi-file work.
    • Related: test(cli): tests double only process edges and mirror the source tree #1307, which asks for a different change. Both share the goal of making tests double only process edges through shared fakes, but #1307 is the umbrella for all packages while the candidate is one child scoped to ai/rag.
  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 7, 2026
  5. removed
    status/in-review
    on Nov 7, 2026
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/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions