Repository navigation
Description
Friction
- After the page-cap test, the slowest tests in every full run are the ones that start real external tools. Together they cost about 186 worker-seconds per full run at load 27, and they grow 2-6x as load rises.
- Several of them reach the network from a child process, which the in-process network guard does not see. The gate then depends on PyPI, OSV and the Semgrep registry being up, against the owner's rule that tests never touch the network or real scanners.
- They also run on pre-commit whenever a change selects them.
Evidence
Checked at release/v0.2.37 30b8fdd with strace and a PATH-shim sweep of a gate-shaped full run.
-
The guard covers only the test process (
tests/conftest.py:130-131). -
tests/test_ci_maintain.py:21-26patches_run, butmaintainaudits through_returncode(src/devops_cli/commands/ci.py:1835), which spawns a realuv audit(51 HTTPS connects, 4-6 s). The test beside it (:45-49) patches_returncode. -
tests/test_review_security_tools.py:53-56and:143patch trivy, kube-linter, pluto and bandit, but the pipeline still runs its gitleaks and semgrep scanners (src/devops_cli/ai/review/pipeline.py:2208-2212). Semgrep uses the registry packp/default(src/devops_cli/config/defaults.py:128), about 9 HTTPS connects per run. -
Real semgrep runs in five tests: three in
tests/test_review_security_tools.py,test_a_branch_cannot_loosen_its_own_reviewintests/test_review_project_conventions.py, and two intests/test_gateway_review_stall.py(which also run real bandit). Real gitleaks runs in those five and intests/ai/review/test_runner.py::test_routed_files_only_branch_diff_makes_no_model_calls. -
tests/test_instruction_generator.py::test_devcontainer_post_create_scaffolds_agent_instructionsruns a realuv venvanduv pip sync --require-hashesof the review tools: 110 HTTPS connects and 20.2 s under the gate's environment. -
tests/test_devcontainer.py::TestDevcontainerCli::test_ensure_path_ownership_and_mount_edge_casesruns a realsudo chown -R. -
Alone, at load 25-37: a_branch 27-32 s, admit_inline_suppression 14-28 s, multi_scanner_aggregation 6-28 s.
-
Other tests already patch these runners:
devops_cli.security.semgrep.run_semgrep_scananddevops_cli.security.gitleaks.run_gitleaks_scan(tests/test_review_path_routing.py:204-205).tests/fixtures/review_canary/recorded_outputs.jsonholds recorded semgrep and bandit results. -
Related: this is the speed-first slice of 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 (the hermetic floor already names the gateway-stall scanners and the sudo call), test(ci): devops ci, test, devcontainer, workspace, install-tools, uv, branches and pipeline are tested over edge fakes, with no lazy patch targets or PYTEST_CURRENT_TEST checks #1325, 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 and test(security): scanner, secret and crypto tests run on the executor, process, http and keyring fakes, and scanners stop looking for mocks #1332. fix(review): Semgrep runs pinned and offline with metrics off, from a cached registry ruleset plus devops-cli's tested rule pack #1144 makes Semgrep offline in the product; it does not stop these tests from running it.
-
The real
ghleaks the same way. On 2026-10-18, while refactor(github): the github session owns transport, ledger, error classes and link pagination #983 PR 2 was being built, four tests run against the old code reachedrun_ghunmocked. They started/usr/bin/gh, which called GitHub with the pinned fake token and got "Bad credentials (HTTP 401)". The in-process network guard (prevent_external_network_calls) does not see a child process, andisolate_gh_configonly points gh at an empty config.
Remedy
test_ci_maintain_live: also patchdevops_cli.commands.ci._returncode, as the neighbouring test does.- The six scanner-running tests: patch
run_semgrep_scanandrun_gitleaks_scan(and bandit in the gateway tests) astests/test_review_path_routing.py:204-205does, and feed recorded outputs where a test needs findings. test_devcontainer_post_create_scaffolds_agent_instructions: pass--skip-toolsor patchdevops_cli.commands.install_tools.install_managed_tools.test_ensure_path_ownership_and_mount_edge_cases: stub the chown subprocess.- The test conventions say the no-network rule covers every process a test starts, and that the gate's
uv audit,uv tree --outdatedanduv checkare its intended network checks. They go indocs/TESTING.mdif docs(cli): docs/TESTING.md holds the test conventions, ADR 0005 records that tests double only process edges, and AGENTS.md and the contributor docs point to them #1308 has created it by then (AGENTS.md:111 already links it, but it does not exist at 30b8fdd), otherwise indocs/SDLC.mdPhase 2 beside its mock-isolation rule (docs/SDLC.md:105). - Every test and assertion stays.
Acceptance criteria
- Tests first, offline: an autouse guard in tests/conftest.py wraps
run_subprocessand fails a test that would start a scanner binary. It reads the binaries from thebinary_nameof everyBaseSecurityScannersubclass (src/devops_cli/security/base.py:415), not from a hand-kept list. It does not use everyBIN_*constant insrc/devops_cli/config/commands.py, which also names git, uv, find and kustomize that tests run legitimately. It fails on today's tree for the scanner-running tests above and passes after the patches. The same guard fails a test that would start the realgh(CONST_GH_CLI) through the process edgerun_ghuses; a test that needs gh output scripts it with the existing gh fakes. Any other test it catches, for example one that starts ruff or mypy through a scanner class, is named in the PR and patched the same way. - 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 hermetic floor, when it lands, denies processes in general and replaces this guard; the guard says so in its docstring.
- Each changed test keeps its assertions and passes with no network (run under
unshare -nor with the guard). - In a full run,
--durationsshows none of the named tests above 5 s at load under 20.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 18, 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.
The candidate is about improving test performance and reliability by patching external tool calls.Improves CI performance and test stability, but does not block other work or introduce critical issues.Improves developer experience and CI speed for a subset of tests that currently run slow external tools.Requires patching multiple test files, updating mock setups, and ensuring recorded outputs work correctly.dan-petty commentedon Oct 20, 2026
Intake marked #1725 a duplicate of this item on 2026-10-20 and folded it. That was a misjudgement: #1725 holds v0.2.38 to the owner's timing targets (gate at most 2 minutes, PR CI at most 3, no test over 5 seconds, no test touching the network, real tools or localhost services) and lists every measured cost with its owner. This item owns one row of that table, the real semgrep, gitleaks and bandit runs (6 tests, about 82s, with semgrep downloading
p/defaultfrom inside tests). #1725 was created directly and links back here.test(ci): the review tests run on recorded scanner results, and no te…
test(ci): the review tests run on recorded scanner results, and no te…
dan-petty commentedon Oct 20, 2026
What changed
#1738, merged into
release/v0.2.38as 84ee9ca.15 file(s) changed.
How it was verified
Check runs at 63951cc:
Acceptance Criteria of
docs/agent/tasks/task-1666-recorded-scanner-results.md:subprocess.Popenrather than wrappingrun_subprocess, so it also coversrun_gh, a directsubprocess.runand asyncio, and reads the names from the scanner registry rather than from everyBaseSecurityScannersubclass, which would refuse the ruff the swallowed-failures ratchet runs. Before the refusal existed, every refusal case intests/test_suite_refuses_real_programs.pyfailed (FileNotFoundErrorfor each program named at/usr/local/bin,DID NOT RAISEfor the shell command and the handler of every exception), and the git case passed. Under the refusal and before the fake, the six scanner tests failed, each naming the real Bandit or Gitleaks it started; withscanner_fakethey pass. No test started gh. One full run under a stricter list that also named uv and sudo caught one other test,tests/test_release.py::test_uv_lock_check_offline_passes_after_bump, which runsuv lock --check --offlineon purpose.unshare -rn.-n 0beside other agents' work (load average 12-25 on 16 CPUs):test_a_branch_cannot_loosen_its_own_review14.66 s to 2.15 s,test_review_pipeline_admit_inline_suppression_added_by_change11.89 s to 0.74 s,test_five_personas_with_one_transient_503_sees_exactly_six_calls7.42 s to 0.86 s,test_pipeline_multi_scanner_aggregation7.34 s to 0.77 s,test_transport_answers_400_once_fails_without_second_attempt_and_reports_status7.30 s to 0.59 s andtest_routed_files_only_branch_diff_makes_no_model_calls1.00 s to 0.06 s: 49.6 s to 5.2 s. In a full run at load average 41-52, none of them was among the 60 slowest (7.35 s and up).uv run pytest -q --durations=0 tests | grep -E 'loosen_its_own_review|admit_inline_suppression|multi_scanner_aggregation|five_personas_with_one_transient|400_once_fails|routed_files_only_branch'; each should show under 5 s.feat(release): v0.2.38 (#1799)
feat(release): v0.2.38 (#1798)
fix(roadmap): intake calls a candidate a duplicate only when it asks …