Skip to content

ci(gate): checks of committed files and tool configuration run as devops ci rows, not as pytest tests that start the tool #2164

Closed

Description

@dan-petty

Problem

Some pytest tests check committed files and tool configuration, not the behaviour of src/. They start the tool itself (ruff, ast-grep, kubectl, python) or parse every file under tests/. Under the owner's rule of 2026-10-24, which #2143 records, a check of committed files is a row of devops ci, and a test of src/ starts no program. These checks also cost time in every pytest run and on every xdist worker.

What the test-suite audit of 2026-10-24 at df8e2ee saw:

Check Where it runs now Programs started
ruff configuration holds the complexity cap and the banned APIs tests/test_ruff_complexity_cap.py, tests/test_net_construct_rules.py:159 ruff, 18 tests
ast-grep rule tests tests/test_net_construct_rules.py:118-121 runs ast-grep test --skip-snapshot-tests ast-grep, 34 tests
construct-gate escapes tests/test_architectural_invariants.py:1650-1730 git and ast-grep, about 30 tests
kustomize renders of k8s/ tests/test_k8s.py, tests/test_k8s_argocd_apps.py, tests/test_k8s_argocd_gate.py, tests/test_k8s_argocd_overrides.py, tests/test_k8s_llm_gateway.py, tests/test_k8s_network_policies.py, tests/test_k8s_monitoring_integration.py, tests/test_k8s_devops_runtime.py, tests/test_k8s_argo_workflows.py kubectl, 30 tests (test_k8s_network_policies.py:115 alone: 9 renders, 3.16 s)
the startup-import budget tests/test_cli_startup_imports.py python, 55 tests, 117 s summed
the swallowed-failures ratchet tests/test_swallowed_failures_ratchet.py:360 ruff over src/, 9.21 s
invariants that parse every file under tests/ tests/test_test_module_independence.py (12.4 s); the tests/-parsing cases of tests/test_architectural_invariants.py (23.9 s for 10 items) none, but each run parses the whole tree

Proposed solution

  • Each check becomes a row of devops ci, or joins a row that already runs the tool: ast-grep test joins the constructs row, the ruff configuration checks join the lint row, and the kustomize renders become one k8s row that renders each application once.
  • The startup-import budget becomes a row that runs each argv once.
  • The ratchet and the tests/-parsing invariants become rows. test(cli): Convert ratchets to bans and merge invariant tests #1336 then turns the ratchets into bans in the same place.
  • The pytest files keep only the cases that test src/ behaviour, with fakes. The rest of each file goes.
  • Every new row runs on the stock runner with no install: ruff, ast-grep and python come from uv sync, and kubectl is on the runner image. Each CI job stays under 5 minutes on average.

Existing tool considered

devops ci rows, ruff, ast-grep test (its built-in rule tester, configured in sgconfig.yml testConfigs) and kubectl kustomize cover the need. Nothing is built.

Evidence

  • .data/agent/scratch/audit/full_list.txt of the 2026-10-24 audit: sections 1.ast-grep, 1.kubectl, 1.ruff, 1.python and class 6.
  • At b170358: sgconfig.yml holds testConfigs: .ast-grep/rule-tests; src/devops_cli/commands/ci.py:767-771 is the constructs row.

Acceptance criteria

  • No pytest test starts ruff, ast-grep, kubectl or a fresh python interpreter to check a committed file or a configuration.
  • Each check in the table runs as a devops ci row and fails on the same input that failed its test. The pull request shows one failing case for each row.
  • uv run devops ci --help and the generated references name the new rows (uv run devops docs generate --sync-readme).
  • The rows run on the stock runner with no install step. The pull request gives the time of each CI job before and after; each job averages under 5 minutes.
  • The pytest run of the Tests & Coverage job gets faster, and the pull request gives the figure.
  • uv run devops ci passes.

Follows ADR 0007 as #2143 amends it. Related: #1336 (the ratchets become bans, and the invariant tests merge into subject files).

Source: #2143

regression of #1725

Scope from #2369

The startup-import file is now tests/commands/test_cli_startup_imports.py, not tests/test_cli_startup_imports.py. The row keeps the same 56 probes, so this issue moves their cost and does not cut it. The row cost counts against the 5-minute bound.

Rules for the row:

  1. The four limit values stay: DEFAULT_STARTUP_IMPORT_MODULE_LIMIT_MAIN_AND_VERSION, DEFAULT_STARTUP_IMPORT_DEVOPS_MODULE_LIMIT_MAIN_AND_VERSION, DEFAULT_STARTUP_IMPORT_MODULE_LIMIT_COMMAND_HELP and DEFAULT_STARTUP_IMPORT_DEVOPS_MODULE_LIMIT_COMMAND_HELP (lines 33 to 36 of that file).
  2. The control stays: test_startup_structural_budget_fails_when_extra_heavy_package_imported proves that the budget fails when a heavy package is imported.
  3. A failure message reports the ten slowest imports.
  4. Each argv keeps its own interpreter. A module that one argv imports stays in sys.modules, so two argvs cannot share one.

New criterion: the pull request states the CPU time (user plus system) of the row over three runs on one host, before and after. Use CPU time and not wall time, because a loaded host moved the wall time of the suite from 3 m 28 s to 6 m 27 s on 2026-10-27. The goal of #2369 moves here: at most half of the present CPU time of the probes, by a cut of the import of the main module or of the work of the help. If this pull request does not reach that goal, it files one new item for it.

Do not drop -X importtime to save time. Paired, alternating runs gave these CPU seconds per probe, without the flag and with it, at a host load of about 26:

Probe Without With
--version 1.222 1.205
--help 1.125 1.160
ci --help 1.479 1.510
ci --help (second run) 1.025 1.047
ai agents --help 3.359 3.304

The ratio is 0.97 to 1.02, which is noise. The cost split: a bare interpreter costs 0.03 s, and import devops_cli.entry costs 0.25 to 0.36 s. The rest is the work of main and the command help.

Earlier figures, from a full run of 2026-10-27 on a 16-CPU host (11,285 tests, 287 s of pytest): the file took 204 s of the 2,423 s of all tests. In one process it took 233 s of CPU (203 s user, 30 s system) for 56 probes, about 4.2 s each, at a load of 26 to 29. A bare import devops_cli.main took about 1 s of CPU on that host. Three of its tests were among the 13 slowest of the run: test_ai_agents_and_providers_import_no_model_sdks (16.8 s), test_pydantic_ai_exceptions_lazy (11.6 s) and the control test (9.4 s).

Alternatives check of 2026-11-02: not-applicable.
Class: ci, no search.
Tool: none found.

Proposed design

Problem statement

placeholder

Acceptance criteria

Existing Tool Considered

placeholder

Key questions

None.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/infra
    on Oct 24, 2026
  2. dan-petty commented on Oct 24, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/infra. The change involves moving checks from pytest to devops ci rows which affects infrastructure and CI processes.
    • Priority: P1-High. This change directly impacts CI performance and follows the project's established rules for test organization.
    • Value: High. Improves CI performance significantly by reducing test run times and eliminating unnecessary tool startups.
    • Effort: Medium. Requires moving tests from pytest to devops ci rows and updating documentation, but doesn't involve major architectural changes.
    • Related: test(git): one git seam answers tests from recorded git transcripts, with a contract suite that replays them #2146, which asks for a different change. Both items deal with running tools in CI, but the candidate moves tests to devops ci rows while #2146 focuses on using git fakes for tests.
  3. dan-petty commented on Oct 27, 2026

    @dan-petty
    OwnerAuthor

    Refine cannot set this item to Ready at 0abf552 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

  4. added
    priority/p1-high
    status/new
    effort/medium
    value/high
    on Oct 28, 2026
  5. added a commit that references this issue on Nov 1, 2026
  6. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: ci. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-02. A person decides what this means for the item. The check changes no label and closes no issue.

  7. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 46cf288 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • The proposal has no problem statement, no acceptance criterion with its requirement, scenario, WHEN and THEN, or no answer to the existing-tool question. State the problem, the requirements with their scenarios, and the open tool that covers the need or the cost of building it.
  8. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 4, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 5, 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/p1-highsource/agenttype/infravalue/high

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions