Skip to content

test(ai): library and rag command tests run on edge fakes #4002

Closed

Description

@dan-petty

Problem

Item 3 of the Fit note of #1329. Four test files still test the library tools and the RAG command helper through internals. The files are tests/ai/library/test_docs_ingester.py, tests/ai/library/test_library_ingest.py, tests/ai/analyze/test_library_drift_auditor.py and tests/ai/rag/test_ai_subcommands_rag.py. Counts in the current tree [measured: grep at 734e060]:

  • test_ai_subcommands_rag.py imports the private commands.ai._try_retrieve_rag_context and patches load_settings, QdrantClient.is_alive and SemanticRetriever.retrieve_context (3 patch sites, plus a time.sleep patch). The investigator cases are already covered by tests/ai/rag/test_investigation_context.py, and the dry-run case is already covered by tests/commands/test_ai_cmd.py.
  • test_library_drift_auditor.py patches devops_cli.ai.analyze.cache.analysis_directory (2 sites), imports the command function audit_library_usage_cmd to build a private Typer app, and patches Path.write_text. It lives in tests/ai/analyze/ but tests ai/library/drift_auditor.py.
  • test_docs_ingester.py and test_library_ingest.py mix domain tests with CLI tests in one file. Both keep a module-level CliRunner() and invoke the private ai_app. They hold three tests that only check that a pydantic model keeps the values it was given.

Expected

The tests of the four files use only the shared fakes (web, qdrant, embedder, keyring) and the cli and config fixtures. Library tests mirror src/devops_cli/ai/library/, one file per behavior. Command tests live in tests/commands/ and use the cli fixture. No test patches a devops_cli name, imports a private name, or builds its own CliRunner.

Acceptance criteria

  • No test of the four files patches a devops_cli name, imports a private name, or creates a CliRunner.
  • tests/ai/library/ holds one file per behavior: local docs ingest, remote docs ingest, signature extraction, contract store, package introspection, drift findings, drift report saving.
  • tests/commands/ holds the CLI tests: devops ai ingest docs, devops ai ingest library, devops ai audit-library-usage, and the RAG context helper of commands/ai.py.
  • The docs ingester tests use the public methods only, so a later change of the HTML conversion (test(ai): Wire rag once in ai/rag, test with edge fakes #1329 part 4) needs no test change.
  • Mutating the product code makes the migrated tests fail (checked in a scratch copy).
  • tests/ai/rag/test_ai_subcommands_rag.py is gone.
  • uv run devops ci passes.

Existing tool considered

The shared fakes and fixtures of #1307 (web, qdrant, embedder, keyring_store, cli, config). No new tool is needed.

Related

#1329 (parent), #1307.

Activity

  1. added
    source/agent
    type/test
    scope/ai
    status/new
    value/medium
    effort/medium
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 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 removes test coupling to internals but does not block a release or fix a user-facing defect.
    • Value: Medium. It makes the library and RAG command tests resilient to internal refactors, reducing future maintenance cost.
    • Effort: Medium. Four files must be reorganised and rewritten against existing fakes, but no new fakes or fixtures are needed.
    • Related: test(ai): ai/rag tests run on edge fakes, one file per behavior #3862, which asks for a different change. Both are items from the #1329 Fit note migrating AI tests to edge fakes, but #3862 covers the ai/rag module tests while this candidate covers ai/library tests and the RAG command helper test.
  3. added
    priority/p2-medium
    on Nov 7, 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