Skip to content

Refactor tests, scripts and the rules tool, then select every ruff rule (ALL) - #3934

Draft
anth-volk wants to merge 32 commits into
ruff-complexity-applicationfrom
ruff-complexity-tests-scripts
Draft

anth-volk wants to merge 32 commits into
ruff-complexity-applicationfrom
ruff-complexity-tests-scripts

Conversation

@anth-volk

@anth-volk anth-volk commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #3931

Summary

Phase 1 step 1.8, group 8b, part 3 of 3: tests, scripts and the rules tool, refactored within ruff's complexity limits, then select = ["ALL"]. Stacked on #3933. This completes step 1.8.

  • All 64 findings in scope are fixed, with no complexity suppressions.
  • Rules tool (scripts/rules/, still standard-library only and runnable on Python 3.11):
    • The command line, registry loading, enforcer descriptions, the Mermaid graph, validation and the workflow parser are split into helpers and lookup tables.
    • 35 new unittests pin its command line, schema, validation (all 41 ordered violations from a fixture registry) and rendered output.
    • Old and new versions gave byte-identical output across every real workflow, about 3,000 generated workflows and 500 generated registries.
  • Scripts: the collector verifier, baseline capture, Cloud Run load generator, household mirror command and local boot smoke test now take grouped values, and status codes are HTTPStatus members. Each command-line interface is unchanged: the same --help text, output and exit codes. New tests cover each script.
  • Tests:
    • Long tests split into assertion helpers.
    • Fixtures grouped into composite fixtures or case values.
    • Route tables replace long if chains in the v1 contract test.
    • No assertion was dropped, and collected test IDs are unchanged apart from the 71 added.
  • ALL:
    • pyproject.toml selects every rule, and ignores only the two that conflict with ruff format (COM812, ISC001) and one of each mutually exclusive docstring pair (D203, D213).
    • The registered per-file exemptions are unchanged: tests, generated Alembic revisions, and the rules tool's unittest tests for PT.
    • ALL found one new finding, a tuple-valued test enum without __slots__, which gets its own commit.
  • Registry and docs:
    • api.quality.ruff-lint now lists ALL, and its statement gives the four ignores and why.
    • The rules-registry skill doc says every rule applies and that a ruff upgrade PR fixes any new rule's violations.

Testing

  • The make test set at this branch's tip: 2,919 passed, which is the base's 2,433 plus 166, 249 and this PR's 71.
  • The rules tool's unittests (109) pass on Python 3.11 and on the venv's Python.
  • uvx ruff@0.15.12 check . (with ALL) and ruff format --check . are clean. Ruff reports no formatter conflicts.
  • make typecheck-v2 is clean.
  • mypy outside the gate:
    • The changed files that already existed show no new errors, and 9 fewer than the base.
    • The 23 new characterization test files from parts 1 and 2 have 152 mypy errors, mostly no-untyped-def. Tests are outside the mypy gate and exempt from annotation rules.
  • Every model schema and pre-existing adapter, the FastAPI OpenAPI, the /v2/openapi.json preview and the legacy spec are byte-identical to ruff-idioms-arguments, with and without OLD_SIMULATION_GATEWAY_URL set.
  • CI/CD: no workflow changed. The changed .github scripts read the same environment variables in the same order. The collector's COLLECTOR_ID_TOKEN and GOOGLE_OAUTH_ACCESS_TOKEN are exported by verify_observability_collector.sh from gcloud. OBSERVABILITY_PROJECT_ID and OBSERVABILITY_METRIC_LOCATION come from vars.* in deploy-observability-collector.yml. I haven't checked that those repository variables exist in GitHub's settings.
  • CI: above the bottom of its stack, so only CI complete runs until the PRs below merge.

🤖 Generated with Claude Code

@anth-volk
anth-volk added this pull request to stack #3917 October 14, 2026 18:47
@anth-volk anth-volk changed the title ruff complexity tests scripts Refactor tests, scripts and the rules tool, then select every ruff rule (ALL) Oct 14, 2026
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch 3 times, most recently from 17fa756 to 375bd46 Compare October 14, 2026 21:13
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch from 375bd46 to dac4ae8 Compare October 14, 2026 21:53
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch 3 times, most recently from 092a7b9 to 61abab1 Compare October 14, 2026 22:56
anth-volk and others added 17 commits October 15, 2026 04:05
…utput

Characterization tests before the complexity refactors: the command line's
output and exit status for every command, the ordered schema and validation
violations for malformed registries, enforcer descriptions, mermaid graphs,
CI test-collection checks and every field the workflow reader extracts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cross-field check splits into status conflicts and checker conflicts,
and the proof check counts the CI fields from PROOF_CI_FIELDS instead of
a literal 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reader handles one key line at a time: step tracking, one-line
values, run: block scalars and matrix entries each get a method.
parse_jobs hands the jobs body to a helper that splits it into jobs, and
the two-character quote check gets a named constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Characterization tests for the version bump inference, the changelog
fetch, the collector verifier's Google Cloud reads and delivery wait, the
baseline capture's request probes, the migration contract workflow
guard, the household event command's audit records and proxy port, the
v1 metadata difference shapes, the Cloud Run load generator and the
local boot smoke test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…scripts

HTTP statuses use http.HTTPStatus; the changelog fragment and Alembic
metadata difference lengths get named constants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alue

verify and _wait_for_delivery take a CloudReadback (project, metric
location and access token) and the delivery wait takes the
VerificationProbe, instead of six separate arguments. The command line
and the environment variables it reads are unchanged; a 404 is named
HTTPStatus.NOT_FOUND.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_client_loop takes the cell's settings, deadlines and record list as one
_LoadCellRun instead of seven arguments, and status classification names
its codes with http.HTTPStatus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e value

The command's arguments, output and environment variables are unchanged;
the highest TCP port gets a named constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Health checks compare against HTTPStatus.OK; the output, exit status and
process handling are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fake budget-window result becomes a keyword-only dataclass, and the
request bodies and expected response subsets move from if-chains into
tables keyed by path and method. Each lookup returns a fresh copy, as
the if-chains did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 15 commits October 15, 2026 04:05
create_mock_reform_impact drops three parameters no test ever passed,
create_mock_budget_window_batch_execution takes the batch's year-by-year
progress as one MockBatchProgress, and the cached-error test takes its
service, parameters and mocks through one composite fixture, set up in
the same order as before. The request-plumbing test's running-years poll
passes its progress as a MockBatchProgress too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each region is a keyword-only _Region whose source() returns the same
mutable SimpleNamespace the registry held before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The household-lock test's before_cursor_execute listener uses
SQLAlchemy's named=True form, so it no longer spells out six arguments
it ignores. The user-policy route tests' _association_read drops the
country, user and policy parameters no caller passed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each case is a _PersistenceFailure, and the test IDs are rebuilt to
match the ones pytest generated for the seven separate parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…motion checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rage checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The typed-failure worker becomes a small transport class whose app name
the test switches for the retry, the version routes, setup options,
stored impacts and economy requests become helpers, and the recorded
failure checks move into two assertion helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hases

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each downgrade target gets its own assertion helper and every return to
head shares one upgrade-check-assert helper; the migration commands, SQL
and assertions run in the same order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The helpers extracted from long tests and the new characterization
tests get annotations; JSON bodies and ORM rows the tests index stay
typed as Any, and the rules loader's downgrade reason is typed as str.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Selecting every ruff rule turns on SLOT001, which asks tuple subclasses to
define __slots__. The enum-normalization test's tuple-valued enum gets an
empty __slots__; its members, values and normalization are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every rule family now passes, so pyproject.toml selects ALL instead of the
per-group list. It ignores COM812 and ISC001, which conflict with ruff
format (ruff's documentation says to disable them with the formatter), and
D203 and D213, which are mutually exclusive with the kept D211 and D212.
The per-file ignores and namespace packages are unchanged.

The api.quality.ruff-lint rule's enforcer codes become ["ALL"], which the
rules tool's select check and hidden-rule discovery both accept as is, and
its statement names the four ignores and why. The rendered rules page and
the AGENTS.md rules block are regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk force-pushed the ruff-complexity-tests-scripts branch from 61abab1 to c88d8f4 Compare October 15, 2026 00:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor tests, scripts and the rules tool, then select every ruff rule (ALL)

1 participant