Repository navigation
Labels
effort/mediumEffort Mediumpriority/p2-mediumPriority P2: standard workscope/aiAI review pipeline, personas, prompts, LLM client, or RAGscope/cliCore CLI framework, Typer subcommands, options, and tablesscope/reviewMulti-persona code review engine, verification, and findingstype/testType test: a new or changed testvalue/highValue High: the delivery of the item matters much
Description
Problem
Counts come from one AST pass over tests/test_*.py at 5c45b1e, the head of release/v0.2.28, and [code: …] lines are at the same commit. A file belongs to the package it references most, as in the census.
- Files (11; 3,749 lines, 130 tests [measured: AST pass at 5c45b1e]).
test_ai_cmd,test_ai_prewarm,test_ai_ast_cli,test_ai_spend_cli,test_gateway_review_stall,test_llm_pool_metrics,test_library_vector_tier,test_review,test_review_pr_post,test_review_stage_flagsandtest_review_repos.test_review_repos(81 lines, 3 tests) mixes onedevops review pathCLI test with two tests ofai/review/runner.pythrough private names (:25,:35). The census left it unclaimed; this item names it.test_analyze.pymixesdevops analyzeCLI tests withai/analyze/scanner tests and referencesai/analyze/most (27 to 17 forcommands/), so it is test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331's, and test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313 places it intests/ai/analyze/. This item changescommands/analyze.pyand keeps that file's tests passing.- The
test_review_*files that testai/review/belong to test(review): ai/review and review/ are tested through one public interface over the model, tool-executor and process fakes, with no mock detection in src #1328, andtest_ai_subcommands_ragbelongs to test(ai): Wire rag once in ai/rag, test with edge fakes #1329.
- Coupling. The 11 files hold 136 internal patch sites and 20 private imports [measured]. One of the patch sites builds its target with an f-string [code: tests/test_review.py:496]. The most-patched targets:
load_settings20;LLMClientmethods 22 (preload_models8,chat7,list_models3,chat_messages_stream2,chat_messages2);commands.review._execute_review_workflow8;validate_service_url6;commands.review._find_session_dir5;_make_review_clients,investigate_rag_context,get_ai_api_keyand_init_logfire_if_enabled3 each.- The
_init_logfire_if_enabledpatches stub logfire set-up. fix(ci): review workflow tests start the logfire SDK's credential check, which the network guard blocks #965 found that the SDK still starts its credential check through another path, in fourtest_review.pytests and intest_review_stage_flags.py::test_review_cli_stage_flags_propagation. test_ai_prewarm.pypatchescommands.ai.record_metricandtrace_spanto see what prewarm records (:338,:353).test_review_repos.pypatches the runner's_run_subprocessto fake git (:37), and 10 of the files build a module-levelrunner = CliRunner().
- The
- Edges outside a seam.
- 11 inline
LLMClient(...)constructions [code: commands/ai.py:512, :542, :566, :662, :809, :864, :1060, :1251; commands/analyze.py:312, :401, :489]. refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 routes every inline construction through its factory. - PyGithub, which speaks HTTP through
requests:devops review prlists a pull request's files and posts its comment through it [code: commands/review.py:632, :664], anddevops analyze prreads the pull request [code: commands/analyze.py:506-510]. refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891 moves these calls onto the GitHub session. commands/ai.pyimports the privateconfig.settings._keyring_has[code: commands/ai.py:416].- An httpx2 client built inline [code: commands/ai_gateway.py:174].
ai_ingest.pyimports the privatecommands.valkey._resolve_clientand builds anEmbeddingsEngineinline [code: commands/ai_ingest.py:224, :244].
- 11 inline
- Logic living in commands/ (Q19).
commands/review.py(2,484 lines):- posts PR reviews [code: commands/review.py:625-750];
- judges verdicts [code: commands/review.py:1153-1192];
- tallies findings [code: commands/review.py:1292];
- scores corpus arms [code: commands/review.py:1689-1726];
- selects and scores samples [code: commands/review.py:1935-2053].
commands/ai.py(2,026 lines):- retrieves RAG context [code: commands/ai.py:190];
- collects project context [code: commands/ai.py:216];
- generates the agents file [code: commands/ai.py:852];
- resolves prewarm URLs [code: commands/ai.py:682];
- probes endpoints [code: commands/ai.py:558, :603].
commands/analyze.pyapplies symbol deltas to analysis metadata [code: commands/analyze.py:136].- Other items move two pieces: test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331 the gateway probe and its httpx2 client [code: commands/ai_gateway.py:165, :174], and test(ai): Wire rag once in ai/rag, test with edge fakes #1329 the runtime vector store wiring, with its private Valkey import [code: commands/ai_ingest.py:221-276].
- Names. Catch-all tests:
test_ai_cmd.py:196and:302,test_review.py:258. 7 test names end in_success,_failure,_basicor_command.
Acceptance criteria
- No internal patches or private imports. The test files this item owns under
tests/commands/, and any tests it adds elsewhere, have zero patch sites aimed at devops_cli internals and zero private imports. If test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 has landed, its two ceilings drop by the counts these files carry when the item starts (136 and 20 at 5c45b1e). - Model calls go through refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001's seam and fake.
- refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 routes the 11 inline constructions through its factory and lands first. This item confirms that no inline
LLMClient(remains incommands/:rg -n "LLMClient\(" src/devops_cli/commandsprints nothing. - No test patches an
LLMClientmethod,model_request,_make_review_clientsor aPydanticAgentmethod.
- refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001 routes the 11 inline constructions through its factory and lands first. This item confirms that no inline
- Other edges go only through their seams:
- HTTP and DNS through refactor(cli): Unify HTTP and DNS seams with shared fakes #1314:
validate_service_urlresolves names through the DNS fake, and the gateway commands' HTTP calls are answered by the HTTP fake. - Valkey, Qdrant and embeddings through refactor(ai): Valkey, Qdrant and the embedder each have one seam, with shared fakes and contract suites #1317's fakes.
- The keyring through refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318;
commands/ai.pyno longer imports_keyring_has. - Spans and metrics through refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319's OTLP fake; no test patches
record_metricortrace_span. - GitHub through refactor(github): the github session owns transport, ledger, error classes and link pagination #983's session fake, including the
devops review pranddevops analyze prcalls that refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891 has moved off PyGithub. kubectl(node_port_address[code: commands/ai_gateway.py:220; commands/ai_runs.py:154]) and the project-treefind[code: commands/ai.py:242] through refactor(cli): one process runner owns execution, process groups and dry-run #775.- Scanners through feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772's executor fake.
test_gateway_review_stall.pyandtest_review_stage_flags.pybuildReviewPipelineOrchestrator[code: tests/test_gateway_review_stall.py:272, :363; tests/test_review_stage_flags.py:118], and two of the first file's tests run Bandit and Semgrep for real today (test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310). These review-pipeline tests give the orchestrator feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772's executor fake with recorded tool output, and no test patches a scanner entry point. - git runs for real in a temporary repository: the base-branch and review-boundary rules that
test_review_repos.pyreaches privately are tested throughdevops review, or through test(review): ai/review and review/ are tested through one public interface over the model, tool-executor and process fakes, with no mock detection in src #1328's public interface once it exists. - Settings through test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310's
configfixture.
- HTTP and DNS through refactor(cli): Unify HTTP and DNS seams with shared fakes #1314:
- No test patches
_init_logfire_if_enabled. The logfire SDK stays off through test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310's telemetry-off floor or fix(ci): review workflow tests start the logfire SDK's credential check, which the network guard blocks #965's fix. - No interim markers. If test(cli): the hermetic floor fails a test that reaches an edge without a fake and resets all process-wide state after every test #1310 added its interim
unreachable(...)marker, none remains in this item's test files: each gives way to the fake of the edge it names, in the fake's refusing state where the test relies on the refusal. - Logic moves out of commands/ (Q19).
- The review command's own logic listed above moves into
ai/review/behind public functions. - The
aiandanalyzelogic listed above moves intoai/,ai/analyze/orai/rag/. - Each moved piece is tested in its package's mirror directory, and the commands become thin adapters.
- A move too big for this item gets its own item. Until then its logic is tested through the CLI with edge fakes.
- The review command's own logic listed above moves into
- CLI tests.
- They use the shared
clifixture in place of the 10 module-level runners andtest_review_repos.py's own runner fixture (:18), and check only parsing, wiring, output and exit codes (Q14). - Command output is compared as syrupy snapshots (Q18; test(cli): tests find the repository root and fixtures from any depth, import no other test module and build test data with shared builders, and devops test maps a change to its mirror directory #1312 adds syrupy).
- Findings are built with the shared
make_findingbuilder that test(cli): tests find the repository root and fixtures from any depth, import no other test module and build test data with shared builders, and devops test maps a change to its mirror directory #1312 puts intests/support/builders.py(Q20). - Assertions compare whole values (Q7).
- They use the shared
- Names. Test names state behaviour in CONTEXT.md terms (Q8), and the catch-alls are dissolved.
- Dead code. Every line that no public behaviour reaches is deleted (Q22), and the 90% coverage gate passes.
-
uv run devops cipasses.
Key questions
- Which files belong to this item? Decided 2026-10-07: under Q17, each file goes to the package that owns most of what it tests, and test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313 places it in that package's mirror directory. This item owns exactly the files named above;
tests/commands/is shared, and each file in it belongs to the one E item that names it. - Who makes public the ten runner names and
_build_promptthatcommands/review.pyimports privately [code: commands/review.py:83-94, :110]? (proposed) test(review): ai/review and review/ are tested through one public interface over the model, tool-executor and process fakes, with no mock detection in src #1328, because it owns theai/review/interface. This item moves only the review command's own logic, so the two items can land in either order. - Order against test(ai): Wire rag once in ai/rag, test with edge fakes #1329 and test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331? (proposed) They first where possible: they move the
ai_ingestandai_gatewaycode these commands call and route its clients through the seams. This is an ordering, not a native link. - Is this one pull request? Decided 2026-10-07: under Q33, it is filed now as one item, and refinement applies
needs-splitif it proves too big.
Strategic alignment
- Depends on: test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313, feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772, refactor(cli): one process runner owns execution, process groups and dry-run #775, refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891, refactor(github): the github session owns transport, ledger, error classes and link pagination #983, refactor(ai): one model seam: llmclient over three wire adapters behind one factory, no second provider stack #1001, refactor(cli): Unify HTTP and DNS seams with shared fakes #1314, refactor(ai): Valkey, Qdrant and the embedder each have one seam, with shared fakes and contract suites #1317, refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318, refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319. Blocks: test(cli): Convert ratchets to bans and merge invariant tests #1336. Related: test(cli): ratchets hold internal patches, private imports and test accommodations in src at today's counts and name each site that would raise one #1309 (the ratchets this item lowers), test(review): ai/review and review/ are tested through one public interface over the model, tool-executor and process fakes, with no mock detection in src #1328 (
ai/review/interface), test(ai): Wire rag once in ai/rag, test with edge fakes #1329 (moves theai_ingestwiring; ownstest_ai_subcommands_rag), test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331 (moves the gateway probe; ownsai/analyze/andtest_analyze.py), feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772 (rewritestest_review_repos.py::TestReviewReposSubdirectories::test_review_path_summary_in_repos_directory[code: tests/test_review_repos.py:47] over a temporary workspace and fakes), fix(ci): review workflow tests start the logfire SDK's credential check, which the network guard blocks #965 (logfire credential check), refactor(review): the persona review stage, the legacy segment engine and review-time RAG are deleted, and devops review builds a model client only for the explanation stages #1151 (devops reviewbuilds a model client only for the explanation stages). - Parent: test(cli): tests double only process edges and mirror the source tree #1307 (phase E).
Proposed design
Problem statement
The 11 test files for the devops review, devops analyze and devops ai commands hold 136 internal patch sites and 20 private imports. The command modules contain logic that belongs in the ai/ package. This item rewrites the tests over shared fakes and moves the command logic into its owning package.
Acceptance criteria
- Criterion 1: The 11 owned test files have zero patch sites aimed at devops_cli internals and zero private imports.
Verification: Runrg -n 'monkeypatch\.setattr|patch\(' tests/test_ai_cmd.py tests/test_ai_prewarm.py tests/test_ai_ast_cli.py tests/test_ai_spend_cli.py tests/test_gateway_review_stall.py tests/test_llm_pool_metrics.py tests/test_library_vector_tier.py tests/test_review.py tests/test_review_pr_post.py tests/test_review_stage_flags.py tests/test_review_repos.pyand confirm no hits target devops_cli internals. Runrg -n 'from devops_cli\..* import _'on the same files and confirm no hits. - Criterion 2: No inline
LLMClient(construction remains incommands/.
Verification: Runrg -n "LLMClient\(" src/devops_cli/commandsand confirm it prints nothing. - Criterion 3: No test patches an
LLMClientmethod,model_request,_make_review_clientsor aPydanticAgentmethod.
Verification: Runrg -n 'monkeypatch\.setattr.*(LLMClient|model_request|_make_review_clients|PydanticAgent)' tests/and confirm no hits in the 11 owned files. - Criterion 4: HTTP and DNS calls resolve through the refactor(cli): Unify HTTP and DNS seams with shared fakes #1314 DNS and HTTP fakes.
Verification: Confirmvalidate_service_urlcalls resolve through the DNS fake and gateway HTTP calls are answered by the HTTP fake. No test constructs a rawhttpx2.Clientfor an edge call. - Criterion 5: Valkey, Qdrant and embeddings calls use the refactor(ai): Valkey, Qdrant and the embedder each have one seam, with shared fakes and contract suites #1317 fakes.
Verification: Runrg -n 'ValkeyClient|QdrantClient|EmbeddingsEngine' tests/test_ai_cmd.py tests/test_ai_prewarm.py tests/test_ai_ast_cli.py tests/test_ai_spend_cli.py tests/test_library_vector_tier.pyand confirm no direct construction outside the refactor(ai): Valkey, Qdrant and the embedder each have one seam, with shared fakes and contract suites #1317 fake. - Criterion 6: The keyring uses the refactor(security): one keyring seam owns the keyring and the Secret Service lock check, with a shared keyring fake and its contract suite #1318 fake and
commands/ai.pyno longer imports_keyring_has.
Verification: Runrg -n '_keyring_has' src/devops_cli/commands/ai.pyand confirm it prints nothing. - Criterion 7: Spans and metrics use the refactor(telemetry): OTLP export goes through one exporter seam, and tests read exported spans and metrics from a shared fake #1319 OTLP fake; no test patches
record_metricortrace_span.
Verification: Runrg -n 'monkeypatch\.setattr.*(record_metric|trace_span)' tests/and confirm no hits in the 11 owned files. - Criterion 8: GitHub calls use the refactor(github): the github session owns transport, ledger, error classes and link pagination #983 session fake, including
devops review pranddevops analyze pr.
Verification: Runrg -n 'PyGithub|github\.PyGithub' src/devops_cli/commands/review.py src/devops_cli/commands/analyze.pyand confirm no hits. - Criterion 9: Scanners use the feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772 executor fake; no test patches a scanner entry point.
Verification: Runrg -n 'monkeypatch\.setattr.*(bandit|semgrep|scanner)' tests/test_gateway_review_stall.py tests/test_review_stage_flags.pyand confirm no hits. - Criterion 10: Git runs for real in a temporary repository; no test patches
_run_subprocess.
Verification: Runrg -n '_run_subprocess' tests/test_review_repos.pyand confirm no hits. - Criterion 11: No test patches
_init_logfire_if_enabled.
Verification: Runrg -n '_init_logfire_if_enabled' tests/and confirm no hits in the 11 owned files. - Criterion 12: No interim
unreachable(...)marker remains in the 11 owned test files.
Verification: Runrg -n 'unreachable\(' tests/test_ai_cmd.py tests/test_ai_prewarm.py tests/test_ai_ast_cli.py tests/test_ai_spend_cli.py tests/test_gateway_review_stall.py tests/test_llm_pool_metrics.py tests/test_library_vector_tier.py tests/test_review.py tests/test_review_pr_post.py tests/test_review_stage_flags.py tests/test_review_repos.pyand confirm no hits. - Criterion 13: The review command logic (PR review posting, verdict judgment, finding tally, corpus scoring, sample selection) lives in
ai/review/behind public functions.
Verification: Runrg -n 'def _execute_review_workflow|def _find_session_dir|def _judge_verdict' src/devops_cli/commands/review.pyand confirm the logic is insrc/devops_cli/ai/review/instead. - Criterion 14: The
aiandanalyzecommand logic lives inai/,ai/analyze/orai/rag/.
Verification: Runrg -n 'def _retrieve_rag_context|def _collect_project_context|def _generate_agents_file' src/devops_cli/commands/ai.pyand confirm the logic is in theai/package. - Criterion 15: CLI tests use the shared
clifixture and check only parsing, wiring, output and exit codes.
Verification: Runrg -n 'CliRunner\(\)' tests/test_ai_cmd.py tests/test_ai_prewarm.py tests/test_ai_ast_cli.py tests/test_ai_spend_cli.py tests/test_gateway_review_stall.py tests/test_llm_pool_metrics.py tests/test_library_vector_tier.py tests/test_review.py tests/test_review_pr_post.py tests/test_review_stage_flags.py tests/test_review_repos.pyand confirm no module-levelCliRunner()instances. - Criterion 16: Command output is compared as syrupy snapshots.
Verification: Runrg -n 'snapshot' tests/test_ai_cmd.py tests/test_review.py tests/test_review_pr_post.pyand confirm syrupy assertions are present. - Criterion 17: Findings are built with the shared
make_findingbuilder fromtests/support/builders.py.
Verification: Runrg -n 'make_finding' tests/test_review.py tests/test_review_pr_post.py tests/test_review_stage_flags.pyand confirm the builder is used. - Criterion 18: Test names state behaviour in CONTEXT.md terms; catch-all names are dissolved.
Verification: Runrg -n 'def test.*(_success|_failure|_basic|_command)\b' tests/test_ai_cmd.py tests/test_review.pyand confirm no hits. - Criterion 19: Dead code is deleted and the 90% coverage gate passes.
Verification: Runuv run devops ciand confirm it passes, including the coverage gate.
Key questions
- Which files belong to this item?: The 11 named files: test_ai_cmd, test_ai_prewarm, test_ai_ast_cli, test_ai_spend_cli, test_gateway_review_stall, test_llm_pool_metrics, test_library_vector_tier, test_review, test_review_pr_post, test_review_stage_flags and test_review_repos. Each file goes to the package that owns most of what it tests, per Q17 and test(cli): every test file sits in the directory mirroring the package it tests or in tests/invariants/, and the root conftest holds only the hermetic floor #1313. (proposed)
- Who makes public the ten runner names and
_build_promptthatcommands/review.pyimports privately?: test(review): ai/review and review/ are tested through one public interface over the model, tool-executor and process fakes, with no mock detection in src #1328, because it owns theai/review/interface. This item moves only the review command's own logic, so the two items can land in either order. (proposed) - Order against test(ai): Wire rag once in ai/rag, test with edge fakes #1329 and test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331?: They land first where possible: they move the
ai_ingestandai_gatewaycode these commands call and route its clients through the seams. This is an ordering, not a native link. (proposed) - Is this one pull request?: It is filed as one item. Refinement applies
needs-splitbecause the scope of 11 test files plus logic moves from three large command modules exceeds one pull request. (proposed)
Fit
Needs splitting into 5 items:
- Move
commands/review.pylogic (PR review posting, verdict judgment, finding tally, corpus scoring, sample selection) intoai/review/behind public functions - Move
commands/ai.pylogic (RAG retrieval, project context, agents file, prewarm URLs, endpoint probes) intoai/orai/rag/ - Move
commands/analyze.pysymbol-delta logic intoai/analyze/ - Rewrite the 11 test files to use shared fakes and seams with zero internal patches or private imports
- Wire all edges (HTTP, Valkey, keyring, OTLP, GitHub, kubectl, scanners, git, settings) through their named fakes in the rewritten tests
Suspected block
None.
Dependencies
#1313, #1314, #1317, #1318, #1319
Alternatives check of 2026-10-30: not-applicable.
Tool: none found.
Metadata
Metadata
Assignees
Labels
effort/mediumEffort Mediumpriority/p2-mediumPriority P2: standard workscope/aiAI review pipeline, personas, prompts, LLM client, or RAGscope/cliCore CLI framework, Typer subcommands, options, and tablesscope/reviewMulti-persona code review engine, verification, and findingstype/testType test: a new or changed testvalue/highValue High: the delivery of the item matters much
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
9 remaining items
dan-petty commentedon Oct 26, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The change improves test quality and reduces coupling in the codebase.Improving test coverage and reducing coupling benefits the overall project.The work involves refactoring tests and patching, which is moderate effort.Both items test AI-related commands, but the candidate focuses on devops commands while #1328 focuses on review commands.dan-petty commentedon Oct 28, 2026
The proposal at 0b76871 needs splitting into 5 items. A person splits the item into the items below, or replies in a comment or edits the body to keep one item, and the next refine round looks at the item again.
commands/review.pylogic (PR review posting, verdict judgment, finding tally, corpus scoring, sample selection) intoai/review/behind public functionscommands/ai.pylogic (RAG retrieval, project context, agents file, prewarm URLs, endpoint probes) intoai/orai/rag/commands/analyze.pysymbol-delta logic intoai/analyze/devops-cli-service commentedon Oct 30, 2026
Alternatives check: not-applicable
Tool: none found
Checked on 2026-10-30. A person decides what this means for the item. The check changes no label and closes no issue.
test(ai): test ai commands over edge fakes (#1326)
test(ai): test ai commands over edge fakes (#1326)
test(ai): test ai commands over edge fakes (#1326)
test(ai): test ai commands over edge fakes (#1326)
test(ai): test ai commands over edge fakes (#1326) (#2863)