Repository navigation
Description
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.pyimports the privatecommands.ai._try_retrieve_rag_contextand patchesload_settings,QdrantClient.is_aliveandSemanticRetriever.retrieve_context(3patchsites, plus atime.sleeppatch). The investigator cases are already covered bytests/ai/rag/test_investigation_context.py, and the dry-run case is already covered bytests/commands/test_ai_cmd.py.test_library_drift_auditor.pypatchesdevops_cli.ai.analyze.cache.analysis_directory(2 sites), imports the command functionaudit_library_usage_cmdto build a private Typer app, and patchesPath.write_text. It lives intests/ai/analyze/but testsai/library/drift_auditor.py.test_docs_ingester.pyandtest_library_ingest.pymix domain tests with CLI tests in one file. Both keep a module-levelCliRunner()and invoke the privateai_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_cliname, imports a private name, or creates aCliRunner. -
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 ofcommands/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.pyis gone. -
uv run devops cipasses.
Existing tool considered
The shared fakes and fixtures of #1307 (web, qdrant, embedder, keyring_store, cli, config). No new tool is needed.
Activity
dan-petty commentedon Nov 7, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
testprefix of the title gives the type.(ai)scope of the title gives the scope.It removes test coupling to internals but does not block a release or fix a user-facing defect.It makes the library and RAG command tests resilient to internal refactors, reducing future maintenance cost.Four files must be reorganised and rewritten against existing fakes, but no new fakes or fixtures are needed.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.test(ai): wire rag once in ai/rag, test with edge fakes (#4245)