Repository navigation
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 (59; 28,716 lines, 850 tests [measured: AST pass at 5c45b1e]): the 49 whose primary package is
ai/review/,test_review_admission(review/), and 9 more that importai/review/and that the census left unclaimed.test_ai_review_pool,test_category_metrics,test_common_hallucinations,test_common_hallucinations_hardening,test_construct_aware_location,test_contract_injection,test_executable_criteria,test_hallucination_catalog_learning,test_mitigated_perimeter,test_verdict_polarity,test_verdict_writers.test_review_*with these suffixes:adjudication,admission,advisory_backing,backend_activity,classification,console_report,defects,defects_comments,defects_infra,defects_languages,defenses_and_verification,exporter,history,judged_claims,loop_calibration,none_dereference_check,page_line_numbers,path,path_classes,path_routing,pipeline,profile,project_conventions,prompt_consistency,prompt_guardrails,report_integrity,report_summary,runner,sample_validation,samples,scope,static_analyzers,symbol_delta,taxonomy_and_severity,template_sweep,untrusted_tree,verification,verification_task,worktree_regression.- The 9 more (1,637 lines, 69 tests):
test_batch_2_review_defects,test_prompt_programmatic_functions,test_review_location_anchoring,test_review_loop_hardening,test_review_regression_harness,test_review_reply_caps,test_review_stages,test_review_verifier_self_refutationandtest_structural_positional_oracles.
- Coupling. 237 internal patch sites (one through an f-string,
test_review_adjudication.py:518) and 299 private imports in 44 files [measured].- Private imports reach
ai/review/verification132 times,runner78 andpipeline24;test_review_verification.pyimports 75 private names, andtest_review_runner.pyimports 42 and patches 48 internals. - Patched most often:
runner._run_subprocess12,runner._get_reviews_base_dir10,core.process.run_subprocess10,commands.review._make_review_clients7,_execute_review_workflow7,investigate_rag_context7,run_bandit_scan6,security.base.run_subprocess5,run_gitleaks_scan4,_run_mcp_cmd4,HostSandbox3,GitHubClient3.
- Private imports reach
- Product code shaped for tests (Q27).
_is_scannable_manifestreturns True for a missing path whenrun_kubelinter_scanis aNonCallableMock[code: ai/review/pipeline.py:708-715].run_subprocessis imported as_run_subprocess[code: ai/review/runner.py:72], the name tests patch. - Edges outside a seam.
LLMClientis built inline [code: ai/review/pipeline.py:2365; ai/review/runner.py:1607]; 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.- The OSV, Shodan and Cloudflare Radar clients are built inside a method [code: ai/review/pipeline.py:2791-2793].
shutil.whichandsubprocess.runare called directly [code: ai/review/template_sweep.py:103, :110].- The PR fetch reads the pull request through PyGithub [code: ai/review/runner.py:1975-1982], which speaks HTTP through
requests; refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891 moves it onto the GitHub session. - Waits use real time: the segment retry backoff sleeps with
time.sleep[code: ai/review/runner.py:904, :918], in the legacy segment engine that 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 deletes, and the worker pool's token wait sleeps withasyncio.sleep[code: ai/review/pool.py:58]. commands/review.pyimports eleven private runner and sanitization names [code: commands/review.py:83-94, :110].
- Dead code.
_terminate_process_grouphas no caller [code: ai/review/review_environment.py:396]; refactor(cli): one process runner owns execution, process groups and dry-run #775 consolidates the process-group copies. - Doubles and data.
- 12 files define their own
_finding(...);DummyClientis defined 5 times intest_review_path.py(:248-:395);_FakeGitHubappears attest_review_path_routing.py:111andtest_review_scope.py:28; 11 files build a module-levelrunner = CliRunner(). - The three
tests/goldenfiles have no regeneration:criteria_replay.jsonandcriteria_direction.json(test_executable_criteria.py:723,:751) andreview_findings.json(test_review_regression_harness.py:46).
- 12 files define their own
- Files and names.
test_common_hallucinations,test_common_hallucinations_hardeningandtest_hallucination_catalog_learninguse a term CONTEXT.md lists under Avoid for "Known false positive".- Files named after work rather than behaviour:
test_review_worktree_regression(a defect),test_batch_2_review_defects(a work batch) andtest_review_loop_hardening(a*_hardeningfile, which Q13 sends to the package that owns the behaviour). - Large files:
test_review_verification.py2,435 lines (72 tests),test_review_pipeline.py1,573,test_verdict_writers.py1,553,test_executable_criteria.py1,206,test_review_untrusted_tree.py1,169,test_review_adjudication.py1,136. - Catch-alls:
test_review_verification.py:907,test_review_pipeline.py:957,test_review_runner.py:58,:100,:194,:287.
- Code already being deleted. refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 deletes the model verifier, the hallucination catalog and the model-claim guards; 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 deletes the persona stage, the legacy segment engine and review-time RAG. 29 of these 59 files import a module refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 deletes or cuts (
verification,common_hallucinations,construct_validator,criteria_evidence,judged_claims,mitigations) [measured: grep at 5c45b1e].
Acceptance criteria
- No internal patches or private imports. The test files under
tests/ai/review/andtests/review/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 (237 and 299 at 5c45b1e, less whatever refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 and 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 delete first). - One public interface.
ai/review/exposes one public interface for running a review and reading its review session;commands/review.pyimports no privateai/reviewname, and tests reach the package only through that interface. - Mock detection is gone.
_is_scannable_manifest's mock branch and the_run_subprocessalias are deleted;rg -n "unittest.mock|NonCallableMock" src/devops_cli/ai/reviewprints nothing. 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 accommodation ceiling drops by the sites removed. - Edges only through seams.
- Scanners reach the orchestrator 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.
- Enrichers (OSV, Shodan, Cloudflare Radar), built inline today [code: ai/review/pipeline.py:2791-2793], reach it through feat(review): review tools run through one injectable executor in a network-less sandbox with CPU, memory and time limits #772's constructor as the real clients, and their HTTP goes through refactor(cli): Unify HTTP and DNS seams with shared fakes #1314's HTTP fake. No test passes a double of an enricher class (Q2). The clients' inline httpx2 builders [code: security/vulnerability_lookup.py:185, :307, :377] are test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332's to route through refactor(cli): Unify HTTP and DNS seams with shared fakes #1314's seam; if this item lands first, it routes them.
- Processes go through refactor(cli): one process runner owns execution, process groups and dry-run #775's fake, including
template_sweep.py's checkers andshutil.which. - The model goes 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 two inline constructions through its factory and lands first; this item confirms
rg -n "LLMClient\(" src/devops_cli/ai/reviewprints nothing. - GitHub goes through refactor(github): the github session owns transport, ledger, error classes and link pagination #983's session fake, including the PR fetch that refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891 has moved off PyGithub.
- Any review-time RAG still present goes through refactor(ai): Valkey, Qdrant and the embedder each have one seam, with shared fakes and contract suites #1317's fakes.
- Waits go through refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320: the pool's token wait, and the segment retry backoff if 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 has not deleted it, are waits recorded by refactor(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320's clock fixture. No test sleeps for real or patches
timeorasyncio.sleep. - No test patches
run_subprocess,_run_subprocess,_make_review_clients, a scanner entry point orHostSandbox.
- Process-group copy. This item confirms that
_terminate_process_groupis gone fromreview_environment.py(refactor(cli): one process runner owns execution, process groups and dry-run #775 consolidates the copies):rg -n "os\.killpg" src/devops_cli/ai/reviewprints nothing. - 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. - Behaviour files and names.
- The six large files are deleted, and their tests live in behaviour files, for example
test_finding_admission.py,test_verdicts.pyandtest_review_session_markdown.py. - The three work-named files above, and the three catalog files if refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 leaves any of them, are dissolved into behaviour files.
- Names use CONTEXT.md terms (Q8), for example "known false positive", not "common hallucination".
- The catch-alls are dissolved.
- The six large files are deleted, and their tests live in behaviour files, for example
- Builders, snapshots and assertions.
- Tests build findings and verdicts with the shared
make_findingandmake_verdictthat 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). This item adds no builder of its own. - The 12 local
_findingfactories and 5DummyClientclasses are deleted. - Prompts and the rendered
review.mdare 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). - Each of the three
tests/goldenfiles that refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 and 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 leave becomes a syrupy snapshot, and this item ownstest_review_regression_harness.py, the reader ofreview_findings.json. A golden file whose tests those items delete goes with them.tests/golden/no longer exists. - Assertions compare whole values (Q7).
- CLI tests use 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
clifixture in place of the 11 module-level runners (Q14).
- Tests build findings and verdicts with the shared
- The fixture path class follows the snapshots. In
.devops/review.toml[code: .devops/review.toml:5] and in the.devops/review.mdnote on synthetic vulnerability exemplars [code: .devops/review.md:93],tests/golden/**gives way totests/**/__snapshots__/**, where syrupy stores snapshots. The snapshots that replace the golden files then stay out of scanning and chunking, as the golden files did [code: ai/review/pipeline.py:1393, :2133; ai/review/chunker.py:463]. The default path classes [code: config/constants.py:494-499] add**/__snapshots__/**to the fixture class and keep their genericgoldenpatterns, which projects without a.devops/review.tomluse. - Dead code. Every line that no public behaviour reaches is deleted (Q22); 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.
test_review_*files that mostly testai/review_schema.pybelong to test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331, andtest_review_reposbelongs to test(ai): devops review, devops analyze and the devops ai commands are thin adapters tested over the model seam and edge fakes #1326. - Before or after refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 and 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? (proposed) After: migrating tests of code they delete is wasted work. 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; 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(cli): tests control time: time-machine fakes wall-clock reads, and retry and rate-limit waits return at once and are recorded #1320. 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); fix(ci): tests touch no state outside their temporary directories #1311 (worktrees under the real home,
test_review_worktree_regression.py:80); test(ai): devops review, devops analyze and the devops ai commands are thin adapters tested over the model seam and edge fakes #1326 (devops reviewCLI tests); test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332 (removes the scanner modules' patch-target re-imports and rewrites the patch sites here that rely on them; whichever lands first rewrites those sites); feat(review): evidence-first code review — tools find, version-pinned facts ground, models explain and plan, fixes are re-checked #1137 (evidence-first review); refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 and 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 (land first where possible). - Parent: test(cli): tests double only process edges and mirror the source tree #1307 (phase E).
Proposed design
Problem statement
The 59 test files for ai/review/ and review/ reach into package internals with 237 patch sites and 299 private imports. Product code in ai/review/ contains a mock-detection branch and a test-only alias. Edges (model, scanners, enrichers, processes, GitHub, RAG, waits) are built inline or called directly, so tests must patch them. Test files are organized by work batch rather than behaviour, and they define local builders and fakes that duplicate shared support. This item routes every edge through its established seam, removes all internal patches and private imports, reorganizes tests by behaviour, and deletes the mock-detection code and dead code it exposes.
Acceptance criteria
- Criterion 1: No test file under tests/ai/review/ or tests/review/ patches a devops_cli internal or imports a private name.
Verification: Run rg -n 'monkeypatch.setattr|unittest.mock.patch|from devops_cli.ai.review.[a-z_]+ import _' tests/ai/review/ tests/review/ and confirm zero matches. - Criterion 2: ai/review/ exposes one public interface for running a review and reading its session; commands/review.py imports no private ai/review name.
Verification: Run rg -n 'from devops_cli.ai.review.[a-z_]+ import _' src/devops_cli/commands/review.py and confirm zero matches. - Criterion 3: The NonCallableMock branch in _is_scannable_manifest and the _run_subprocess alias are deleted.
Verification: Run rg -n 'unittest.mock|NonCallableMock' src/devops_cli/ai/review and confirm zero matches. - Criterion 4: Scanners reach the orchestrator through the tool-executor seam; no test patches run_subprocess, _run_subprocess, a scanner entry point, or HostSandbox.
Verification: Run rg -n 'run_subprocess|_run_subprocess|HostSandbox' tests/ai/review/ tests/review/ and confirm zero matches. - Criterion 5: Enricher clients (OSV, Shodan, Cloudflare Radar) are built through the constructor seam and their HTTP goes through the HTTP fake; no test passes a double of an enricher class.
Verification: Run rg -n 'OSVClient(|ShodanClient(|CloudflareRadarClient(' src/devops_cli/ai/review and confirm zero matches outside the factory. - Criterion 6: Processes in template_sweep.py go through the process fake; shutil.which and subprocess.run are not called directly.
Verification: Run rg -n 'shutil.which|subprocess.run' src/devops_cli/ai/review/template_sweep.py and confirm zero matches. - Criterion 7: The model goes through the model seam; no inline LLMClient construction remains in ai/review/.
Verification: Run rg -n 'LLMClient(' src/devops_cli/ai/review and confirm zero matches. - Criterion 8: GitHub access goes through the session seam; the PR fetch does not use PyGithub.
Verification: Run rg -n 'PyGithub|github.PyGithub' src/devops_cli/ai/review/runner.py and confirm zero matches. - Criterion 9: Waits go through the clock fixture; no test sleeps for real or patches time or asyncio.sleep.
Verification: Run rg -n 'time.sleep|asyncio.sleep' tests/ai/review/ tests/review/ and confirm zero matches. - Criterion 10: _terminate_process_group is gone from review_environment.py.
Verification: Run rg -n 'os.killpg' src/devops_cli/ai/review and confirm zero matches. - Criterion 11: The six large test files are deleted and their tests live in behaviour-named files.
Verification: Confirm test_review_verification.py, test_review_pipeline.py, test_verdict_writers.py, test_executable_criteria.py, test_review_untrusted_tree.py, and test_review_adjudication.py do not exist under tests/. - Criterion 12: Work-named and catalog-named files are dissolved into behaviour files; names use CONTEXT.md terms.
Verification: Confirm test_review_worktree_regression.py, test_batch_2_review_defects.py, test_review_loop_hardening.py, and the three hallucination-catalog files do not exist under tests/. - Criterion 13: The 12 local _finding factories and 5 DummyClient classes are deleted; tests use the shared make_finding and make_verdict from tests/support/builders.py.
Verification: Run rg -n 'def _finding|class DummyClient' tests/ai/review/ tests/review/ and confirm zero matches. - Criterion 14: Prompts and rendered review.md are syrupy snapshots; the three golden files are converted; tests/golden/ no longer exists.
Verification: Run ls tests/golden/ and confirm the directory does not exist. Run rg -n 'syrupy' tests/ai/review/ tests/review/ and confirm snapshot assertions are present. - Criterion 15: CLI tests use the cli fixture; the 11 module-level CliRunner() instances are removed.
Verification: Run rg -n 'CliRunner()' tests/ai/review/ tests/review/ and confirm zero matches. - Criterion 16: The fixture path class in .devops/review.toml and config/constants.py uses tests//snapshots/ instead of tests/golden/**.
Verification: Run rg -n 'tests/golden' .devops/review.toml src/devops_cli/config/constants.py and confirm zero matches; confirm snapshots is present in both. - Criterion 17: No interim unreachable(...) marker from 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 remains in this item's test files.
Verification: Run rg -n 'unreachable(' tests/ai/review/ tests/review/ and confirm zero matches. - Criterion 18: The 90% coverage gate passes and uv run devops ci succeeds.
Verification: Run uv run devops ci and confirm it exits 0.
Key questions
- Which files belong to this item?: The 59 files named in the body: 49 whose primary package is ai/review/, test_review_admission (review/), and 9 unclaimed files. test_review_* files that mostly test ai/review_schema.py belong to test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331, and test_review_repos belongs to test(ai): devops review, devops analyze and the devops ai commands are thin adapters tested over the model seam and edge fakes #1326. (proposed)
- Before or after refactor(review): the model verifier, the hallucination catalog and the model-claim guards are deleted, and person-recorded verdicts become suppressions #1150 and 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?: After. Migrating tests of code they delete is wasted work. This is an ordering preference, not a native dependency link. (proposed)
- Is this one pull request?: No. The scope of 59 files, 28,716 lines, and 850 tests across seam wiring, file reorganization, builder consolidation, snapshot migration, and config changes exceeds one pull request. Refinement applies needs-split. (proposed)
Fit
Needs splitting into 4 items:
- Remove mock detection from ai/review/ src: delete the NonCallableMock branch in _is_scannable_manifest (pipeline.py:708-715) and the _run_subprocess alias (runner.py:72).
- Wire all edges through their seams (model, scanners, enrichers, processes, GitHub, RAG, waits) and remove all 237 internal patch sites and 299 private imports from the 59 test files.
- Reorganize test files by behaviour: split the 6 large files, dissolve the 3 work-named files and 3 catalog files, rename per CONTEXT.md, consolidate local builders and fakes into shared support, and replace 11 module-level runners with the cli fixture.
- Migrate the 3 golden files to syrupy snapshots, update fixture path classes in .devops/review.toml and config/constants.py, and delete _terminate_process_group from review_environment.py.
Suspected block
None.
Dependencies
Alternatives check of 2026-10-31: not-applicable.
Tool: none found.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
- StatusShow more project fieldsNew
Activity
dan-petty-bot commentedon Oct 8, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
Large test-coupling debt that hinders maintenance but does not block a release or cause user-facing defects.237 internal patch sites, 299 private imports, and mock-detection in src make the suite brittle and the product code test-shaped, so decoupling yields major maintainability gains.59 files, 28,716 lines and 850 tests must be rewritten against public seams, plus product-code edges (inline client construction, direct subprocess calls, real sleeps) must be refactored first.1 remaining item
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 item is important for code quality but not critical.Improves testing of ai/review and review/ which are core components.Requires moderate effort to implement proper testing with fakes.ai/review and review/ are tested through one public interface over the model, tool-executor and process fakes, with no mock detection in srcas the change that both ask for.Both items ask for testing ai modules through public interfaces with fakes.A person closes one of the two if that is so.dan-petty commentedon Oct 28, 2026
The proposal at 0b76871 needs splitting into 4 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.
refactor(security): the scanners stop looking for mocks, and their te…
devops-cli-service commentedon Oct 31, 2026
Alternatives check: not-applicable
Tool: none found
Checked on 2026-10-31. A person decides what this means for the item. The check changes no label and closes no issue.