Repository navigation
Description
Friction
Because the policy is that a ceiling only falls and nothing may be suppressed, the complexity cap is guarded by a test suite that re-implements Ruff's configuration semantics: key allowlists, nested-config discovery, ignore files and suppression comment spellings. About 520 lines of tests and 66 lines of constants exist only to prove a ten-line configuration cannot be weakened, and a new Ruff setting is reported as a failure until a reviewed change admits it.
Evidence
tests/test_architectural_invariants.py: of the 990 lines from 1131 to 2120, 522 belong to the Ruff cap and the C901 ceiling (the table_COMPLEXITY_CAP_ESCAPESalone is 38 cases and 279 lines) and 396 to the ast-grep network gate.src/devops_cli/config/constants.py:4135-4200holds the key sets and patterns, used only by those tests (13 references inconstants.py, 33 in the test, none elsewhere insrc/).- The review proposed CODEOWNERS lines as the replacement control. The verification pass found it protects nothing here: the main ruleset has
require_code_owner_review: falseandrequired_approving_review_count: 0,.github/CODEOWNERSis* @dan-petty, and a sole owner could not approve their own pull request if it were switched on. This item therefore moves the control into the tool's flags. - A resolved-settings assertion alone is not enough: in a scratch trial a nested
ruff.tomlwithignore = ["C901"]silenced a 13-complexity function whileruff check --show-settingson the top-level file still listed C901 enabled.--config pyproject.tomlis reported to close that and--no-respect-gitignorecloses the ignore-file escape (verification pass; the item re-runs both). - Ruff has native counterparts for much of this and the pre-commit
ast-grep-scanhook already passes--error=unused-suppression --error=no-suppress-all.
Proposed remedy
- Run
ruff checkwith--config pyproject.tomlincommands/ci.py:661, in the pre-commit hook and in CI; add--no-respect-gitignorein CI only, where the checkout is clean (locally it would lint the gitignored scratch under.data/). - One test reads
ruff check --show-settingsand asserts C901 enabled atmax-complexity10, the item 3 nesting rule, and theTID251banned-API table; one test asserts no workflow, hook orci.pyrow passes--select,--ignore,--extend-*,--isolatedor another--config. - Keep the ast-grep half (396 lines, 18 cases): ast-grep has no settings dump, so it stays until a separate trial.
- Reword AGENTS.md line 14, CONTRIBUTING.md, docs/SDLC.md and docs/TESTING.md as pairs A15 (interim), O02, O10 and O31 give.
What it deletes
- 522 lines of tests (about 70 added) and about 66 lines of
constants.py.
Tests
- Negative controls in
tmp_pathrepositories: a nestedruff.tomlthat ignores C901, a.gitignoreentry for a source directory, a--selectadded to a hook. The first two fail the invocation test or the lint run; the third fails the invocation test. - File-level
# ruff: noqa: C901is not seen by the settings test and stays covered by thefile-level directivecounter (item 4).
Dependencies
- docs(agents): a convention yields to an open tool, and instructions with no check or with a contradiction are pruned
Acceptance criteria
- The 38 escape cases no longer exist and the tree still cannot silence C901 through configuration, nested files, ignore files or flags, shown by the negative controls.
uv run devops cipasses.
Size: M.
Proposed design
Problem statement
The current implementation of the complexity cap in Ruff relies on a complex set of tests and configuration constants to enforce that C901 complexity rules cannot be bypassed. This approach is brittle and requires maintaining numerous test cases and constants that only serve to prove the configuration is correctly enforced.
Acceptance criteria
- Criterion 1: The Ruff configuration enforces the C901 complexity cap without allowing any escape mechanisms through nested configurations, ignore files, or suppression comments.
Verification: Runruff checkwith--config pyproject.tomland--no-respect-gitignorein CI and verify that C901 complexity rules are enforced. - Criterion 2: The negative controls for nested configurations, ignore files, and command-line flags properly fail the invocation test or lint run.
Verification: Create temporary repositories with nestedruff.tomlfiles that ignore C901,.gitignoreentries for source directories, and hooks with added--selectflags, and verify they fail the tests. - Criterion 3: The
uv run devops cicommand passes successfully.
Verification: Executeuv run devops ciand confirm it completes without errors.
Key questions
- What are the key files that currently implement the complexity cap enforcement?: The key files are
tests/test_architectural_invariants.pywhich contains 522 lines of tests andsrc/devops_cli/config/constants.pywhich holds the key sets and patterns used only by those tests. [sources: tests/test_architectural_invariants.py:1131, src/devops_cli/config/constants.py:4135] - How does the current implementation protect against configuration escapes?: The current implementation uses a test suite that re-implements Ruff's configuration semantics, including key allowlists, nested-config discovery, ignore files and suppression comment spellings. [sources: tests/test_architectural_invariants.py]
- What changes are proposed to enforce the complexity cap using native Ruff flags?: The proposed change is to run
ruff checkwith--config pyproject.tomlin both pre-commit hooks and CI, and add--no-respect-gitignorein CI only. (proposed) - What is the purpose of the
--no-respect-gitignoreflag?: The--no-respect-gitignoreflag ensures that ignore files are not respected during linting, preventing escape mechanisms through .gitignore entries. [sources: tests/test_architectural_invariants.py:1450]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 22, 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 describes a refactor of CI configuration and test suite to simplify complexity cap enforcement using Ruff's native flags.This is a refactor that improves tooling and reduces code complexity, but does not address an urgent issue or bug.Improves developer experience and tooling consistency by removing redundant tests and configuration logic.The changes involve updating CI scripts and removing a moderate amount of test code, with no new functionality added.dan-petty commentedon Oct 22, 2026
Status set to Ready at ae8c2d9 (see proposed design in issue body).
refactor(ci): Ruff's own flags and resolved settings hold the complex…
dan-petty commentedon Oct 22, 2026
What changed
#1892, merged into
release/v0.2.39as aba8206.14 file(s) changed.
How it was verified
Check runs at 916a1b4:
Acceptance Criteria of
docs/agent/tasks/task-1870-ruff-owns-the-complexity-cap.md:tests/test_ruff_complexity_cap.pyshow this.src,testsor the docs. The exceptions aredocs/agent/tasks,docs/agent/archiveandCHANGELOG.md.uv run devops docs checkreports every file up to date.ruff check,ruff format --check,mypyoversrc,deptryand the targeted tests pass. The targeted tests includetests/test_architectural_invariants.py,tests/test_ruff_complexity_cap.py,tests/test_swallowed_failures_ratchet.py,tests/test_ci.py,tests/test_ci_dry_run.py,tests/test_workflow_contracts.pyand the tests ofAGENTS.mdclaims and task files.uv run devops cipasses on the delivering tree. This change ran the targeted tests and not the gate.feat(release): v0.2.39 (#1947)