Skip to content

perf(ci): the gate finishes in 2 minutes and pull-request CI in 3, with no test over 5 seconds and none touching the network, real tools or localhost services #1725

Closed

Description

@dan-petty

Friction

The gate and pull-request CI are slower than the owner's budget, and the release has paid for it in reruns and waiting.

  • Local gate: uv run devops ci took 3m11s on a quiet host. Its test row is the critical path, at 3m6s.
  • Pull-request CI: about 5 minutes per run.
  • Under load: the gate's test row median was 548s on 2026-10-18 (max 931s, at load 30-50).

The owner's targets for v0.2.38 (2026-10-20), which the milestone closes against:

  • Local gate: uv run devops ci at most 2 minutes on a quiet host.
  • Pull-request CI: at most 3 minutes.
  • Slow tests: no test over 5 seconds without a recorded reason.
  • Hermetic tests: no test touches the network, DNS, real scanners, real kubectl or a localhost service.
  • Flakes: zero flaky reruns.

Evidence

Measured on release/v0.2.37 at 4e61562 on 2026-10-20: a quiet-host devops ci, a --durations run with a per-test probe of subprocesses, sleeps and sockets, and the last 10 CI runs.

Cost Measured Owner
Real semgrep, gitleaks and bandit in review tests; semgrep downloads p/default from inside tests 6 tests, about 82s; 27 HTTPS connects #1666
Textual pilot.pause waits in tests/test_ui_reactive.py 73 tests, 109s of sleep this item
python -c import probes in tests/test_cli_startup_imports.py 62 tests, 70-97s this item
ai/review/test_pipeline.py::test_fake_scanner_results_with_absolute_paths_come_out_repository_relative sleeps 15s 15.07s on every run, CI too this item
Retry backoffs against refused localhost services: Valkey 6379, Ollama 11434, RAG (test_ai_subcommands_rag, test_builtin_tools, test_rag_embeddings, test_ai_cmd) about 4.5-5s each #1320 (retry waits return at once)
Real kubectl in tests 33 tests, 26s this item
Nested pytest in tests/test_isolation_tripwire.py 3 tests, 24s this item
xdist worker imbalance slowest worker 47s after the median this item
bandit over src and tests inside the gate 21s alone, 61s beside pytest this item
Coverage adds 26s (+20%) to the test row this item, measured only
Release pull request running item-only checks 20+ minutes fixed in v0.2.37 (#1721, #1723)

Half the summed test time (624 of 1,254s) is in the 239 tests of 1s or more. The top 50 tests take 320s.

Remedy

  • One Part-of pull request per cost this item owns. Each removes the cost at its source:

    • a fake or double at the edge in place of a real tool or service;
    • a condition the test waits on in place of a sleep or pause;
    • one shared probe in place of one import probe per test;
    • xdist --dist worksteal for the imbalance;
    • running bandit where it doesn't compete with the test row.

    Each says the time it removes, measured before and after.

  • No lowered bar: no check is dropped and no threshold lowered. A check that doesn't apply to a path stops running there.

  • The last pull request re-measures the gate and CI against the targets and closes the item. If a target is missed, it names the remaining cost and its owner.

Acceptance criteria

  • Every row this item owns is fixed, its time measured before and after.
  • On a quiet host, uv run devops ci takes at most 2 minutes, and the median of 5 pull-request CI runs is at most 3 minutes.
  • A probe of the full suite finds no test over 5 seconds without a recorded reason, and no test that opens a socket to anything but loopback test servers it starts itself, resolves DNS, or starts semgrep, gitleaks, trivy, kubectl or a real localhost service.
  • The last 10 CI runs needed no rerun.

Proposed design

Problem statement

The CI gate and pull-request CI are slower than the target times (2 minutes for local gate, 3 minutes for PR CI), with tests exceeding 5 seconds and some tests touching external services or networks. The goal is to optimize CI performance while maintaining quality checks.

Acceptance criteria

  • Criterion 1: Local gate uv run devops ci takes at most 2 minutes on a quiet host
    Verification: Run uv run devops ci locally and measure execution time, ensuring it completes within 2 minutes
  • Criterion 2: Median of 5 pull-request CI runs is at most 3 minutes
    Verification: Analyze the last 5 CI runs to calculate median runtime and verify it's <= 3 minutes
  • Criterion 3: No test exceeds 5 seconds without a recorded reason
    Verification: Run tests with --durations flag and verify no individual test exceeds 5 seconds
  • Criterion 4: No test touches the network, DNS, real scanners, or localhost services
    Verification: Audit test suite to ensure all tests run hermetically without external dependencies
  • Criterion 5: The last 10 CI runs needed no rerun
    Verification: Check the last 10 CI runs for any reruns and confirm none were required

Key questions

None.

Open questions

  • What are the main performance bottlenecks in the current CI execution? (missing verified source)
  • What is the current approach for addressing these bottlenecks? (missing verified source)
  • What is the target performance for CI execution? (missing verified source)

Fit

Needs splitting into 6 items:

  1. Replace real tools with fakes or doubles in tests that use semgrep, gitleaks, bandit, kubectl
  2. Replace textual pilot.pause waits with conditions that test waits on in tests/test_ui_reactive.py
  3. Use shared probes instead of one import probe per test in tests/test_cli_startup_imports.py
  4. Replace sleep in ai/review/test_pipeline.py with a condition that the test waits on
  5. Implement xdist --dist worksteal for worker imbalance
  6. Move bandit execution to avoid competing with test row

Suspected block

None.

Dependencies

None.

Activity

  1. added this to the v0.2.38 milestone on Oct 20, 2026
  2. added
    type/bug
    priority/p0-critical
    scope/ci
    source/agent
    on Oct 20, 2026
  3. dan-petty commented on Oct 20, 2026

    @dan-petty
    OwnerAuthor

    The kubectl row is narrowed after a per-test spawn audit.

    Finding: exactly 33 tests start a real kubectl, and none reaches a cluster. The suite runs with an empty throwaway KUBECONFIG.

    Group Tests What kubectl does
    G1 11 kubectl kustomize renders the committed k8s/ manifests, the tests' subject
    G2 2 kubectl's own behaviour is the subject (a JSON-patch test step must reject a build; kubectl patch --local checks a merge patch)
    G3 16 Renders a small kustomization the test builds
    G4 4 kubectl config get-contexts incidentally, from devcontainer post-start

    There is no maintained kustomize in Python. A recorded render would check the recording, not the repository, and a home-grown renderer is machinery this project doesn't build.

    Decision: kubectl's offline renderers (kustomize, patch --local) read only files and reach no cluster, so tests may run them like git. The row now does three things:

    • documents that in docs/TESTING.md;
    • fakes the incidental G4 calls;
    • renders each committed kustomization once per session, which removes the repeated renders of the same directories in G1.

    No kubectl guard is added. The suite's empty KUBECONFIG already keeps kubectl off any cluster.

    The hermetic criterion reads with this scope: no test starts kubectl against a cluster. Offline renders are allowed.

  4. 8 remaining items

  5. dan-petty commented on Oct 20, 2026

    @dan-petty
    OwnerAuthor

    Re-measured on release/v0.2.38 at 49c0c61, 2026-10-20, after these merged:

    #1730, which closes #1731, is still open.

    Target Before (2026-10-20, 4e61562) Now Met
    uv run devops ci on a quiet host, at most 2 minutes 3m11s, test row 3m6s 2m38s, test row 2m32s; pytest alone 110s no
    Pull-request CI, at most 3 minutes Tests & Coverage median 284s Tests & Coverage 3m55s on the tip's last run; 3m55s to 5m41s on the last 8 green runs no
    No test over 5s without a recorded reason top tests 25.7s, 19.3s, 15.1s slowest is 9.5s; nine others over 5s no
    No real scanner, gh, kubectl against a cluster, or unstarted localhost service about 82s of scanners; 8,116 OTLP connects refused by the floor's guards (#1666, #1741), with kubectl's offline renderers allowed (#1732) yes, in-process
    No flaky reruns three tests overran their bounds under load, filed as #1748 no

    Remaining costs and their owners:

    This item stays open until a re-measurement meets the targets.

  6. dan-petty commented on Oct 20, 2026

    @dan-petty
    OwnerAuthor

    Correction to the re-measurement above: #1730, which closes #1731, has merged too (e0618b7), and the measured tip includes it.

  7. dan-petty commented on Oct 20, 2026

    @dan-petty
    OwnerAuthor

    Proposal needs splitting into 6 items at 79eaacb (see proposed design in issue body).

  8. added a commit that references this issue on Oct 21, 2026
    83042c5
  9. dan-petty commented on Oct 21, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1777, merged into release/v0.2.38 as 83042c5.

    Closes #1725

    Fail-to-pass: not applicable: performance verification, task documentation, and changelog fragment PR

    2 file(s) changed.

    How it was verified

    Check runs at 25707cf:

    • Audit Defect PR Hardening: skipping
    • Prune PR DevContainer Images: pass
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Fail-to-Pass Check: pass
    • Rule Pack Tests: pass
    • Changed-Test Independence: pass
    • Fail-to-Pass Self-Check: pass
    • Tests & Coverage: pass
    • Analyze (python): pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1725-ci-time-budget.md:

    No Acceptance Criteria section.

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

    priority/p0-criticalscope/cisource/agenttype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions