Technical document

Curbing CI Time Bloat in AI-Driven Development: Designing and Implementing Parallel Pipelines with Test File Internal Splitting and the '5-Minute Rule'

As test suites grow to become quality bulwarks for AI agent-generated code, prolonged CI times directly cripple development speed. We analyze the limitations of conventional file-unit sharding from empirical data and explain the design and operational decisions to maintain fast verification loops through internal splitting of spec files and the principle of 'immediate splitting if a single test exceeds 5 minutes'.
AI Development30 minPublication Date October 9, 2026Update date October 9, 2026
Thumbnail for Curbing CI Time Bloat in AI-Driven Development: Designing and Implementing Parallel Pipelines with Test File Internal Splitting and the '5-Minute Rule'

Summary

Key points of this document

  • 1. Background: Test Automation in the Age of AI Agents and the CI Execution Time Trade-off
  • 2. Bottleneck Identified from Empirical Data: Limitations of File-Unit Sharding
  • 3. Implementation Policy: Granular Division within SPEC and Strict Adherence to the '5-Minute Rule'

1. Background: Test Automation in the Age of AI Agents and the CI Execution Time Trade-off

In software development, the use of AI agents for autonomous coding and parallel implementation is rapidly becoming integrated into daily development workflows. In development environments where agents generate large amounts of code in cycles of minutes to tens of minutes, autonomously performing refactoring and feature extensions, the greatest bulwark for ensuring quality is 'multi-layered quality gates through automated testing'.

Beyond unit tests, continuously executing multi-layered verification pipelines in CI (Continuous Integration)—including E2E (End-to-End) tests that operate actual browsers, accessibility audits based on Web Content Accessibility Guidelines (WCAG), mutation testing to evaluate the detection capability of tests themselves, and formal verification to mathematically validate invariant conditions of critical logic—becomes a prerequisite for maintaining code quality and robustness.

However, the more we pursue the comprehensiveness and reliability of test suites, the more unavoidable it becomes:'The natural bloat of CI execution time'—this challenge.

When CI execution time prolongs to 10, 20, or 30 minutes, the development process suffers the following fatal negative impacts:

  1. Delay in AI Agent's Autonomous Correction Loop: The frequency of the feedback loop, where agents implement, CI detects errors, and agents autonomously correct and re-verify the code, drastically decreases.
  2. Stagnation of Human Review and Merge Speed: The waiting time from creating a Pull Request (PR) to confirming CI passage increases, leading to decreased developer concentration and context switching.
  3. Increased Conflicts Between Parallel Branches: In Trunk-based Development, when CI time extends,main the interval for merging into the main branch widens, causing merge conflicts and rebase overhead between parallel tasks to skyrocket.

Tests that were expanded to protect quality end up critically crippling development velocity itself—to prevent this counterproductive outcome, it is necessary to incorporate a clear boundary (Bounded Constraint) from the design stage: 'CI time is not something that can be extended indefinitely, but rather an engineering constraint that must be strictly controlled'.


2. Bottleneck Identified from Empirical Data: Limitations of File-Unit Sharding

A standard method for reducing CI execution time is 'Matrix Sharding / Parallel Splitting', which involves launching multiple CI runners to distribute and execute tests. For example, in GitHub Actions, you might set shard: 1/4, 2/4, 3/4, 4/4 to evenly distribute the test suite.

Many major test frameworks such as Playwright, Vitest, and Jest come with built-in sharding mechanisms that automatically distribute target test files (spec files) to each worker node based on hash values or file lists.

Challenges Highlighted by Empirical Survey

We conducted detailed profiling of test execution times in a large-scale web application with a CI pipeline of several hundred jobs. As a result, we encountered a phenomenon where the total CI duration remained around 20 minutes, even when increasing the number of CI workers from 4 to 8 parallel instances.

Upon measuring the breakdown times of each job, it was found that the bottleneck was not the degree of parallelism itself, but rather,**'The execution time of a single test file (spec file) itself exceeding 10-15 minutes'**was found to be the cause.

Specifically, these are the types of test cases:

  • WCAG Accessibility Audit Traversing All Screens and Components: A single massive spec file (empirically 12-15 minutes) that sequentially opens major screens and various modal/dialog state changes within the system, exhaustively verifying DOM structure, contrast ratios, and ARIA attributes.
  • Comprehensive Routing and Authorization Verification: A spec file (empirically 9-10 minutes) that continuously executes hundreds of patterns of screen transitions and role-based access controls within the same file.
  • Integrated E2E Tests Encompassing Complex Scenarios: Tests that sequentially verify multi-step business workflows within a single scenario file.

Longest Job First (Longest Job Bottleneck) Problem

If a test framework only performs splitting 'by file unit', no matter how many CI workers are added,**'The worker assigned the heaviest single file' becomes the critical path (longest execution path).**becomes.

Even if other workers finish their assigned files in 2-3 minutes and become idle, the entire CI pipeline will continue to wait for the completion of the single worker handling a massive spec file that takes 15 minutes.

【Traditional File-Unit Sharding (4 Workers)】
Worker 1: [spec_a.ts (2 min)] [spec_b.ts (2 min)] ───────> Completed (4 min) [Waiting...]
Worker 2: [spec_c.ts (3 min)] ─────────────────────────> Completed (3 min) [Waiting...]
Worker 3: [spec_d.ts (2 min)] [spec_e.ts (1 min)] ───────> Completed (3 min) [Waiting...]
Worker 4: [massive_wcag_audit.spec.ts (16 min)] ────────────────────────────> Completed (16 min)
Total CI Time: 16 min (Worker 4 is the bottleneck)

The conclusion drawn from this empirical data was clear.**'Simply redistributing entire spec files, no matter how many workers are added, will not shorten CI time'**This is what it means.


3. Implementation Policy: Granular Division within SPEC and Strict Adherence to the '5-Minute Rule'

Solution: Simply divide the contents of SPEC and execute them in parallel.

The approach to this bottleneck is extremely simple and fundamental.

“Without being constrained by the physical boundaries of files, finely divide the contents of SPEC files (scenario groups, verification points) and execute each as an independent test unit in parallel.”

Specifically, the test blocks or describe suites are logically subdivided into multiple independent files based on responsibility, target URL, and component category.

For example, for an accessibility audit test that used to traverse all screens in a single file, files are divided by target screen groups as follows:

  • wcag-audit-base-layouts.spec.ts(Top page, common navigation, settings screen)
  • wcag-audit-modals-dialogs.spec.ts(Various confirmation modals, alert dialogs, drawers)
  • wcag-audit-data-tables.spec.ts(List screen, filter operations, pagination)
  • wcag-audit-forms-inputs.spec.ts(Input forms, validation display states)

By dividing the internals in this way, the time required per file can be standardized to around 2-3 minutes. As a result, the CI runner's sharding mechanism can distribute the load evenly to each worker, achieving ideal load balancing where all workers complete almost simultaneously.

【Parallel Execution After Internal SPEC Splitting (4 Workers)】
Worker 1: [wcag_chunk_1.spec.ts (3 min)] [spec_a.ts (1 min)] ──> Completed (4 min)
Worker 2: [wcag_chunk_2.spec.ts (3 min)] [spec_b.ts (1 min)] ──> Completed (4 min)
Worker 3: [wcag_chunk_3.spec.ts (3 min)] [spec_c.ts (1 min)] ──> Completed (4 min)
Worker 4: [wcag_chunk_4.spec.ts (3 min)] [spec_d.ts (1 min)] ──> Completed (4 min)
Total CI Time: 4 min (All workers running equally)

Architectural Principle: Thorough Enforcement of the Rule 'If it runs for 5 minutes or more from the start, divide it'

To prevent this division method from ending as a temporary, individual solution, it is extremely effective to formalize and thoroughly enforce the following rule as an architectural principle for the entire development team.

[CI 5-Minute Rule]

No test job or verification unit shall be allowed to run for more than 5 minutes individually.

When creating new tests, or if execution time exceeds 5 minutes due to feature expansion, immediately divide internal scenarios and reconfigure them into parallel-executable units as a mandatory requirement for development completion.

Why set a '5-minute' budget?

  • Maintaining Cognitive Ergonomic Concentration: If the time from a developer pushing code to getting results is within 5 minutes, they can wait and respond immediately without switching to another context. If it exceeds 5 minutes, they will switch to other tasks, and the cost of resuming reviews and fixes will skyrocket.
  • Immediacy of AI Agent Autonomous Loops: When agents perform autonomous debugging, receiving CI result feedback within 5 minutes allows for rapid iteration of the correction cycle while maintaining token efficiency and context freshness.
  • Maintaining Trunk-Based CD Safeguards: Even when E2E tests are used as a blocking gate before deployment to staging (STG), the entire pipeline completes in a short time, ensuring safety without slowing down the release pace.

4. Design Decisions and Trade-offs

We will organize the trade-offs and design decisions that should be considered when aiming to speed up CI.

1. Reasons for Not Adopting 'Test Thinning'

As easy ways to shorten CI time, options exist such as 'reducing test execution frequency,' 'moving specific tests to nightly batches or weekly runs,' or 'using sampling execution.'

However, this approach should not be adopted in AI-driven development environments. Code changes by AI agents are extensive and rapid, so the moment tests are thinned out, regression detection (functional degradation) is delayed, and the risk of defects leaking into production environments or integration branches drastically increases.

The principle should be to 'reduce time through scale-out (parallelization/internal division) rather than by reducing test coverage or the strength of quality gates.'

2. Managing Fixed Overhead Associated with Parallel Division

When test files are subdivided and the number of parallel jobs increases, 'fixed overheads' such as container startup, dependency package expansion, and browser binary download and initialization occur redundantly in each worker.

To minimize this overhead, the following infrastructure and build designs are applied as a set.

  • Leveraging CI Caching and Pre-built Images: Use custom Docker images that pre-include OS-dependent packages and browser binaries (Chromium / WebKit, etc.) to eliminate runtime installation time.
  • Maintaining Appropriate Chunk Sizes: Excessive subdivision (micro-testing) that finishes in a few seconds results in a disproportionately large fixed overhead, wasting CI resources. Design divisions with a target granularity where each test chunk's execution time falls within 'approximately 2 to 4 minutes'.

3. Test Statelessness and Execution Order Independence

When dividing test files and executing them in parallel, the most important thing to watch out for isthe occurrence of flaky tests due to 'shared state between tests'..

Even if implicit dependencies, such as 'later tests referencing data created by earlier tests,' were established when executed within a single file, there are cases where tests fail due to conflicts or order inconsistencies the moment they are split into separate files or workers.

  • Complete Statelessness: Each test scenario autonomously sets up its required prerequisite data (e.g., test users, organizations, resources) and either cleans it up at the end of the test or assigns a unique ID (UUID/timestamp) to completely isolate namespaces.
  • Database Isolation: In integration tests involving a backend, assign an independent database schema or SQLite in-memory environment to each worker to prevent concurrent write conflicts.

4. Application to Long-Running Tests Other Than E2E (Mutation Testing, Formal Verification)

The concept of internal SPEC division can be applied not only to E2E tests but also to other long-running tests in exactly the same way.

  • Mutation Testing: Tests that measure the detection capability of tests by introducing mutations into the code tend to be computationally intensive and can take over an hour for a single job. By dividing the mutation set by target package or directory and executing them as independent parallel jobs, it's possible to complete them within 5 minutes without lowering the mutation score threshold.
  • Formal Verification: When model checking takes a long time due to state explosion, targets are divided by the unit of the model or invariant to be verified, and a DAG (Directed Acyclic Graph) is constructed to prevent multiple executions of the same target.

5. Automation of Verification Perspectives and Operations

To maintain the high speed of CI pipelines, it's not enough to just split once; continuous monitoring and guardrails are necessary.

1. CI Execution Time Metrics Collection and Visualization

Regularly retrieve telemetry data from GitHub Actions Workflow Run API and build tools to visualize the execution time trends of each job and step.

  • Track not only the median but also p95 (95th percentile) and maximum execution times.
  • Early detection of test files with increasing execution times or jobs experiencing retries.

2. Automated Detection of 5-Minute Overruns and Refactoring Mechanism

Introduce a mechanism that issues a warning or error if a single job exceeds 5 minutes during test code review and CI automated judgment.

By embedding prompts/guardrails into AI agents themselves, such as 'if a test exceeding 5 minutes is created, automatically split and parallelize the scenario,' we can prevent CI time degradation due to code bloat.


6. Summary: Design Decisions Readers Should Take Back to Their Teams

In the era of AI-driven development, the bottleneck in development speed is no longer 'the speed of writing code,' but rather,**'the speed at which CI confirms and proves that the written code is safe.'**it has shifted to.

The key points of the initiatives explained in this article are highly intuitive and reproducible.

  1. Do not rely on file-level sharding: If a single spec file is taking a long time, simply increasing the number of workers will not resolve the bottleneck.
  2. Split and parallelize the contents of SPEC: Subdivide test scenarios and verification perspectives internally, and standardize them into chunk sizes (2-4 minutes) that all workers can process equally.
  3. Thoroughly enforce the '5-minute rule' as a boundary constraint: Eliminate the compromise of thinning out tests, and establish an operational rule to immediately split tests if they exceed 5 minutes from the start, making it a guardrail for both the team and AI agents.

A fast CI pipeline not only provides developers with a sense of security but also serves as the most crucial infrastructure for autonomous AI agents to perform at their best. As a first step towards designing a pipeline that balances test coverage and feedback speed, please review your company's test suite execution time profile.

Technical documents

We will continue to increase technical documentation.

We will continue to organize our thoughts on AI, cloud, business app development, requirements definition, and operational design into documents.

Go to technical documentation list