Skip to content

feat(cli): enforce the complexity cap with ruff C901 and an inline baseline that only shrinks (#586) - #1078

Merged
dan-petty merged 1 commit into
release/v0.2.25from
feat/complexity-cap-c901
Oct 3, 2026
Merged

dan-petty merged 1 commit into
release/v0.2.25from
feat/complexity-cap-c901

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Closes #586

Summary

The complexity cap of 10 is now enforced by Ruff C901 (standard McCabe, owner decision D1), run by devops ci, the pre-commit Ruff hook and GitHub CI's ruff check .. Before this PR nothing enforced it, although AGENTS.md said it was strictly enforced.

  • Config: pyproject.toml selects C901, RUF100 and PGH004 and sets max-complexity = 10.
  • Baseline: the 66 functions over the cap at 321ecda (65 in src, 1 in tests) carry # noqa: C901, added once with ruff check --select C901 --add-noqa. RUF100 removes a marker when its function drops under the cap. No function is decomposed here.
  • Ceiling: a test fails when the count of C901 markers exceeds DEFAULT_C901_SUPPRESSION_CEILING (66). The ceiling may only go down; its message says to decompose the function, not raise the ceiling.
  • Meta-test: one helper reports every way past the cap: a raised or missing max-complexity, C901/RUF100/PGH004 not selected by their own codes, top-level [tool.ruff] lint keys Ruff still honours (per-file-ignores, extend-ignore), include/extend/lint.exclude, per-file ignores covering the cap rules, file-level ruff/flake8 exemptions, Ruff's own # ruff: ignore|disable|file-ignore[C901] comments, nested Ruff configs, and .ignore/.gitignore entries that drop sources from the lint. 36 escape cases plus 2 controls; no test runs Ruff.
  • Hook: the structural-invariants hook checks nesting only; its complexity arithmetic and note are deleted, with test_complexity_is_reported_without_blocking and test_filesystem_get_tools_complexity. It now measures with an explicit stack, so a very long expression no longer raises RecursionError.
  • Docs: AGENTS.md:14, CONTRIBUTING.md:13, docs/SDLC.md:129 and docs/ROUTINE_TASKS.md:55 name the real enforcers.
  • Stale codes: the 9 noqa codes for unselected rules that RUF100 flags are removed; the # nosec comments stay.

Roadmap

docs/ROADMAP.md is generated since #739 and item PRs don't edit it (#933). The entry "Metric Provenance: radon's Cyclomatic Complexity Behind One Adapter" is superseded by D1: its PR 3 (nesting-only hook) is delivered here, and its PRs 1–2 (pin radon, an adapter, a provenance registry) are not wanted. "Structural Pre-Commit Hook Inversion"'s "Not delivered" note and #841's constraint that C901 is unselected are out of date after this PR; the next devops roadmap render picks them up.

Measured

  • The ceiling, the counting helper and ruff check --select C901 --ignore-noqa --statistics --exit-zero . all report 66.
  • git diff -U0 321ecda -- src tests | grep -c '^-.*# noqa' prints 9.
  • ruff check .: 1.27 s → 1.08 s without cache (median of 7).
  • The 47 new test items take 0.47 s together; the test step lost the 5 s hook subprocess test.
  • uv run devops ci --check --no-cache passes.

Merge order

If the release tip moves before merge, the baseline and ceiling are re-run on the new tip. #740 (in flight) brings its one new over-cap function under the cap itself, so it needs no marker.

@dan-petty
dan-petty merged commit dcafadf into release/v0.2.25 Oct 3, 2026
8 checks passed
@dan-petty
dan-petty deleted the feat/complexity-cap-c901 branch October 3, 2026 14:43
dan-petty added a commit that referenced this pull request Oct 3, 2026
* chore(release): open the v0.2.25 cycle (#918)

Bumps the version to 0.2.25 and opens [Unreleased] above [0.2.24]. A [0.2.25] header opened now would make release prepare rebuild only that section at the cut (#863).

ROADMAP: v0.2.24 is Completed and v0.2.25 the Active Release. Entries whose issues closed as completed are ticked, and the entries for v0.2.24's critical fixes move into its section. Every planned release section now holds an entry for each item in its milestone. Entries stranded in older sections move to their release, with the issue number added where the heading lacked one. Two new sections hold v0.2.27 and v0.2.28, and 17 items that had no entry get one. Issue-less rows stay for #739's migration report.

* refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface (#768) (#919)

Adds devops_cli.roadmap: a runtime-checkable RoadmapStore Protocol with frozen Release, Item, Candidate and Change models, a GitHub adapter over an injected gh runner and an in-memory adapter for tests. Reads page through every result, raise rather than return an empty or partial result, and are never cached. Items are only this repository's issues on the board. Each Item write checks the board's options and records the value it set in the Job record field. The milestone commands and the release milestone close move onto the store. edit sends only the fields it is given, so it no longer closes the milestone, and list exits 1 on a failed read. The client: Any milestone wrappers, the gh milestone helpers, both clients' milestone methods and the test-only REST board read are deleted without shims. Tests that patched run_gh for milestone paths now use the in-memory store.

Closes #768

* fix(k8s): restore k8s-monitoring metrics, add sre service dashboard and otel loki exporter (#922) (#923)

- Disable Node Exporter integration allowlist in k8s-monitoring to preserve host disk and network metrics.
- Include container cpu usage, memory working set, and network packet/drop counters in cAdvisor metrics tuning.
- Add Loki exporter to OpenTelemetry Collector and update network policies for logs ingestion and egress.
- Add dedicated SRE Service Dashboard with correlated Loki logs and provision stack dashboards via sidecar.

Closes #922

* feat(k8s): ingress traffic and cloudflare tunnel sre grafana dashboard (#924) (#925)

* feat(gh): project and release metrics analytics and grafana dashboard (#926) (#927)

* feat(pr): readiness requires a pr to close one issue and change its task file (#704) (#929)

* feat(roadmap): github is the roadmap's source, with migrate and render commands (#739) (#928)

* fix(review): branch and pr reviews compute their own symbol delta (#593) (#932)

* feat(ai): track local llm usage against hardware spend and recognize cluster gateways (#930) (#934)

- Expose ai.reference_model and ai.hardware_cost_usd in devops config show and document in config.example.yaml.
- Recognize cluster domain subdomains and gateway URLs as local in is_local() pricing logic.
- Emit devops_cli_ai_local_cost_equivalent_usd_total counter for uncached local requests.
- Add local cloud savings and hardware amortization payoff panels to Grafana AI spend dashboard.
- Update CI pipeline to execute docs_fix sequentially before concurrent test tasks to prevent tripwire races.
- Add unit and invariant tests for config, pricing, and telemetry instruments.

Closes #930

* fix(k8s): show node names in dcgm exporter dashboard and realign otel loki exporter (#935) (#936)

- Relabel __meta_kubernetes_pod_node_name to node and instance in dcgm-exporter ServiceMonitor.
- Update dcgm-exporter metrics fixtures and integration assertions.
- Realign OpenTelemetry Collector to use otlp_http/loki exporter for Loki 3.x OTLP ingest.
- Record completed task file docs/agent/tasks/task-935-dcgm-exporter-dashboard-node-names.md.

Closes #935

* fix(release): changelog fragments so concurrent pull requests never conflict on CHANGELOG.md or docs/ROADMAP.md (#933) (#937)

* feat(ai): model-in-the-loop prompt benchmarking (#413) (#939)

* feat(k8s): integrate grafana pyroscope to the monitoring stack (#943) (#944)

- Add grafana/pyroscope Helm chart to infra stack in src/devops_cli/commands/k8s/stack_lifecycle.py
- Configure chart values in k8s/monitoring/pyroscope-values.yaml for single-binary architecture, local-path storage, resource limits, and telemetry opt-out
- Add Pyroscope datasource to k8s/monitoring/grafana-values.yaml pointing to http://pyroscope.monitoring.svc.cluster.local:4040
- Update k8s/monitoring/networkpolicy.yaml and k8s/otel/networkpolicy.yaml to permit port 4040 profiling ingress and egress
- Add test_pyroscope_helm_release_and_grafana_datasource to tests/test_k8s.py and update tests/test_k8s_network_policies.py
- Document deliverable in docs/agent/tasks/task-943-integrate-grafana-pyroscope-monitoring-stack.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(cli): genai span attributes checked against the pinned semantic conventions (#588) (#941)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(review): subject-keyed review history with a leave-one-out baseline (#607) (#940)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(telemetry): add heatmap and ratio-based graphs to sre dashboards (#938) (#942)

- Add request duration distribution heatmaps (traefik_service_request_duration_seconds_bucket) to ingress-tunnel.json and sre-service.json
- Add ratio-based timeseries graphs for Cloudflare Tunnel error ratio %, HTTP status code ratios %, container resource saturation ratios % of limit, CFS CPU throttling ratio %, and network packet drop ratio %
- Add test_sre_dashboards_contain_heatmap_and_ratio_panels with consolidated structural tuple equality assertions to tests/test_grafana_dashboards.py
- Document deliverable in docs/agent/tasks/task-938-sre-dashboards-heatmap-and-ratio-graphs.md

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(review): per-model review quality baseline for the devops-review pool (#475) (#962)

* fix(security): delete DynamicWorkflow and CodeMode, whose sandboxes let model-written code reach os and start processes (#947) (#964)

* feat(ai): finish reasons and stream completeness for model replies (#599) (#966)

* fix(security): align security scanner timeout and filter non-code files from semgrep ast scan (#963) (#967)

* feat(telemetry): add properly labeled sum and average lines to service and cluster grafana graphs (#968) (#969)

* fix(ai): reviews ask an unserved embedding model once and never search with a hash fallback (#945) (#971)

* fix(cli): argo namespace, and workspace, devcontainer, port-forward, tls, drift-report and label state handling (#961) (#973)

* fix(security): reviews run nothing from, and take no conventions from, the tree under review (#946) (#976)

* feat(k8s): expose pyroscope ui endpoints, port-forwarding and grafana dashboards (#977) (#978)

* fix(security): dive invents no layers, the rbac audit reads the cluster, and checkov's fallback and the complexity scan catch what they missed (#957) (#979)

* fix(security): the mcp telemetry_profile tool runs no command, and delegated commands keep their end-of-options marker (#980) (#991)

* fix(telemetry): rag query latency reaches past 5 s, times each stage, counts qdrant retries and searches collections at once (#975) (#993)

* fix(telemetry): rag query latency reaches past 5 s, times each stage, counts qdrant retries and searches collections at once (#975)

* fix(telemetry): the qdrant request timeout is the qdrant.timeout setting, 300 s by default, and rag buckets reach 600 s (#975)

* feat(review): verdicts land on the finding shown, record who gave them, and machine-invalidated candidates can be overturned (#949) (#994)

* feat(review): review prompts state a threat model and an evidence bar, and send nothing the pipeline does not use (#951) (#1004)

* feat(review): the terminal summarizes low findings, dependencies and network references and points to the report (#987) (#1011)

* fix(security): bandit runs on reviews of more than 50 python files, and a failed analyzer's reason reaches the report (#1009) (#1012)

* fix(security): scanner failure reasons are masked before they are cut, in sarif, the cli and review.md (#915) (#1033)

* fix(review): criteria settle a verdict only on evidence about the cited code, the verifier sees only the claim, and every unverified finding says why (#846) (#1035)

* fix(review): the report ranks verified findings first, keeps only scanned advisories, and uses one category taxonomy and calibrated severity (#948) (#1037)

* fix(review): the review learns only from a person's verdicts, and every reader of the feedback dataset is honest (#950) (#1039)

* fix(review): the review learns only from a person's verdicts, and every reader of the feedback dataset is honest (#950)

* test(review): the prompt-eval help check pins COLUMNS, so it reads the same at CI's 80 columns (#950)

* test(review): the prompt-eval help check reads its phrase across a wrapped help table, as CI renders it at 80 columns (#950)

* fix(review): criteria commands run in the reviewed project's environment with a measured python timeout (#847) (#1040)

* fix(review): criteria commands run in the reviewed project's environment with a measured python timeout (#847)

* test(review): the live sandbox tests build the project environment they check, so they hold on any host (#847)

* feat(llm): add speed-tier service aliases, align 48gib slow routing weights and bump max loaded models (#1042)

* feat(llm): tune gpt-oss weight in devops-review and pinned model group (#1048)

* fix(review): the devsecops persona reports misconfiguration and error-handling defects again, scored against a fixed recall set (#1015) (#1054)

* fix(review): mitigation and confirmation verdicts point at evidence that exists, and a verdict whose reason refutes it is not applied (#845) (#1055)

* fix(k8s): the monitoring perimeter admits no world cidr, qdrant runs with its container security context, and single-ollama leftovers are gone (#953) (#1056)

* fix(review): passing criteria leave a finding for the verifier instead of verifying it, and running the cited test counts as evidence (#1043) (#1057)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(review): the scanned-clean check invalidates only claims about a dependency's own advisories (#1044) (#1058)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(k8s): every ollama tier keeps one model loaded and serves one request at a time, so its kv cache holds one context (#1061) (#1062)

* fix(security): a review takes no config, data, contracts, scanner config or probe suppressions from a tree it does not own (#972) (#1063)

* fix(k8s): ollama-48gib-slow keeps its embedding model and qwen3-coder loaded and leaves every interactive pool (#1064) (#1071)

* fix(cli): docker and sandbox output print remote text as written, never as rich markup (#955) (#1073)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(ai): toolset instructions and deferred-tool hooks get the run's context, sqlite memory persists, and stopping a command ends its process group (#958) (#1075)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(ai): polyglot outlines parse with tree-sitter, token estimates measure the outline, and ast queries check the size cap (#959) (#1076)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(docs): generated docs show non-secret defaults and off switches, telemetry variables are registered, and docs name only what exists (#956) (#1074)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(ai): client timeouts take effect, replies are read under the size limit, and remote models go where their settings say (#960) (#1077)

* fix(ai): client timeouts take effect, replies are read under the size limit, and remote models go where their settings say (#960)

* fix(ai): log a failed RAG lookup's cause through redact_text, which CodeQL does not read as a secret (#960)

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix(ai): the embedding benchmark takes no endpoint from an MCP client and counts failed embeddings as failures (#954) (#1072)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat(cli): enforce the complexity cap with ruff C901 and an inline baseline that only shrinks (#586) (#1078)

* feat(github): current release admission, cap, descoping and stall rules (`devops roadmap reprioritize`) (#740) (#1084)

* chore(config): the project's Claude Code settings are checked in, while local settings, scratch and worktrees stay ignored (#1087) (#1088)

* fix(security): a review's isolated Semgrep scan hands Semgrep only targets under its working directory, so it finishes instead of rediscovering each file across the checkout (#1079) (#1091)

* fix(monitoring): Loki deletes logs after 30 days on a volume that holds them, and Prometheus keeps 30 days under a size cap that does not bind first (#550) (#1092)

* feat(monitoring): homelab hosts send their journals to Loki and their health metrics to Prometheus (#1080) (#1093)

* fix(monitoring): alerts reach an Alertmanager, and homelab rules cover nodes, GPUs, storage and the stack without k3s false positives (#549) (#1094)

* docs(review): SELF_IMPROVEMENT, AGENTS.md and the knowledge base describe the review loop as it runs (#952) (#1095)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore(release): cut v0.2.25: changelog fragments collected into CHANGELOG.md and the roadmap rendered from GitHub (#1096)

* fix(release): release notes over GitHub's body limits fall back to entry titles with a link to CHANGELOG.md, so a long release still publishes (#1097) (#1098)

* chore(release): cut v0.2.25: collect the late #1097 changelog fragment into the 0.2.25 section (#1099)

* fix(security): Loki admits only the OpenTelemetry collector from otel, and persona exemplars always come from the review target's project (#1100) (#1101)

* chore(release): cut v0.2.25: collect the late #1100 changelog fragment into the 0.2.25 section (#1102)

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

1 participant