Repository navigation
Description
Problem or Motivation
Several agents work on this repository at the same time. Each agent runs devops ci in its own worktree. Nothing limits how many gates run on the host at once, and the pytest of each run starts -n logical workers (16 on this host). ADR 0014 records the effect: "Nothing limits how many runs share the host, and the pytest of each run uses every CPU. The load average reached 88."
Measured effect, from the 399 passing entries in the CI cache of this host:
| Check | Median | p90 | Maximum |
|---|---|---|---|
test |
243 s | 526 s | 1435 s |
security |
98 s | 450 s | 1688 s |
typecheck |
57 s | 239 s | 856 s |
Every other check has a p90 below 90 s. A full gate takes 2.5 minutes on a quiet host (#1752) and 7 to 15 minutes under the load of parallel agents. A timed test then fails (#2069, #2092), and the whole run starts again. The container also has a hard pids.max of 2048, so a burst of gates can fail to fork. AGENTS.md rule 5 says that a check which averages more than 5 minutes is a P0 bug.
Proposed Solution & Architectural Design
Add a host-wide admission limit for the gate. A gate that runs a CPU-heavy check waits for a free slot and then runs alone with the CPU. It does not run beside every other gate.
- A slot is one lock file in
<data dir>/ci-gate-slots/. Every worktree of the repository shares that directory (resolve_data_path). filelock.FileLock(timeout=0)takes a slot. The lock isfcntl.flock, so the operating system frees it when the holder exits or dies. A killed agent cannot leak a slot.- A gate tries each slot, then waits and tries again. While it waits, it prints which worktree and process hold the slots.
- A check is heavy when its p90 is above 200 s in the table above:
test,securityandtypecheck.CheckSpecgets aheavyflag. A run needs a slot only when it selects a heavy check. The pre-push hook (--only lint,format,actionlint,zizmor) takes no slot and never waits. devops ci testanddevops ci coveragetake a slot too, because they start the same workers.--dry-runand a cached verdict take no slot.- One setting,
ci.gate_slots, sets the number of slots. The default ismax(1, cpu_count // 8), which is 2 on a 16-CPU host.DEVOPS_CLI_CI_GATE_SLOTSsets it from the environment. - GitHub-hosted runners have 4 CPUs, so the default there is 1 slot and a single job never waits.
Target Subsystem
SDLC, Git & PR Governance
Existing Tool Considered
filelock(tox-dev, maintained) covers the lock. It is already inuv.lockas a dependency oftldextract, so the change adds no package. It has no counting semaphore, so a loop over N lock files supplies the count (about 15 lines).- GNU parallel
semis a counting semaphore, but it is a host package. CI and the devcontainer must not need a host install (the project rule for runners). systemd-runwith CPU quotas needs systemd, which the devcontainer does not run.- POSIX named semaphores (
posix_ipc) keep their count when a holder dies, which leaks slots. - A merge queue does not apply: ADR 0014 records that a user account owns the repository.
Feasibility
filelock4.2.4 callsfcntl.flock(fd, LOCK_EX | LOCK_NB)(filelock/_unix.py).- A scratch probe held a slot in a child process, refused a second acquire, killed the child with SIGKILL and then took the slot 1 ms later.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 27, 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 change affects infrastructure and CI systems, specifically how gates are managed in the CI environment.This issue impacts CI performance and stability under load, causing test failures and requiring retries.Improving CI performance and reducing test flakiness benefits all developers and users of the project.The implementation requires changes to how CI gates are scheduled and managed, involving file locking and configuration handling.Both items deal with CI checks but the candidate focuses on limiting parallel CPU-heavy runs while #2164 reorganizes how committed file checks are run.dan-petty commentedon Oct 27, 2026
Reopened. Pull request #2339 carried only the OpenSpec plan, and its
Closes #2336closed this issue before any code existed. The code follows in a new pull request.feat(ci): make devops ci wait for a gate slot before a CPU-heavy check (
feat(repos): add devops repos worktrees add that refuses a held issue (…
chore(main): release 0.7.0 (#2329)