Skip to content

ci(crate-gate): enforce RUST-018 workspace lint inheritance - #1931

Merged
zackees merged 1 commit into
mainfrom
agent/lint-inheritance-guard
Nov 6, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/lint-inheritance-guard

Conversation

@zackees

@zackees zackees commented Nov 6, 2026

Copy link
Copy Markdown
Member

Why

#1639 (RUST-018) is done in content but unguarded in policy:

  • Cargo.toml pins [workspace.lints.clippy] cognitive_complexity = "warn" and too_many_lines = "warn";
  • all 21 [workspace] members declare [lints] workspace = true (verified: 20 crates/* + bench/fastled-examples).

Nothing in CI asserted either fact. Two silent failures were reachable:

  1. a member drops [lints] workspace = true — that crate stops being checked by both ratchets, and the debt report still reads zero;
  2. the workspace level is edited to "allow" — one word removes the ratchet from every crate.

What changed

ci/check_workspace_crates.py (the monocrate batch gate already run by crate-gate.yml) gains lint_inheritance_errors():

  • [workspace.lints.clippy] must still declare both ratchet lints at warn or stricter (allow/off fails, naming the lint and pointing at #[expect(..., reason = ...)] as the sanctioned suppression);
  • every member manifest must inherit, accepting both cargo spellings ([lints] workspace = true and dotted lints.workspace = true);
  • comments are stripped quote-aware, so # [lints] / # workspace = true cannot fake a pass, while a trailing # RUST-018 comment on a real line is tolerated.

--json now carries lint_inheritance. Tests go into ci/test_crate_guard_parity.py, the module ci/gate_script_tests.toml already maps to this gate — no registry or workflow change (the gate is already invoked, so no new untested gate, MAX_UNTESTED stays 0).

Evidence (real runs, this branch)

$ uv run --script ci/check_workspace_crates.py
OK: 21 approved workspace members, no new crates, all inherit the workspace lints.
RC=0

$ uv run --no-project python -m unittest ci.test_crate_guard_parity
Ran 14 tests in 0.127s
OK                       # 7 before, 7 added

$ uv run --no-project --with ruff==0.12.12 ruff check ci/check_workspace_crates.py ci/test_crate_guard_parity.py
All checks passed!

$ uv run --no-project python ci/check_python_complexity.py
All checks passed!

RED proven both directions against the real tree (then reverted):

  • delete [lints]\nworkspace = true from crates/fbuild-serial/Cargo.toml → ::error::Workspace member 'crates/fbuild-serial' does not inherit the workspace lints…, RC=1;
  • cognitive_complexity = "allow" in the root manifest → ::error::… sets cognitive_complexity = "allow", which switches the RUST-018 ratchet off…, RC=1.

Mutation proof on the tests: inherits_workspace_lints -> return True fails 3 tests; elif level in ESCAPING_LEVELS -> elif False fails exactly the downgrade test.

Scope

Part of #1639 (the RUST-018 inheritance/ratchet half). Python-side PY-004 (ruff C901/RUF100 over every tracked file) is already implemented and guarded by ci/check_python_complexity.py + its test; no change needed here. No new crate, no new workflow, no threshold raised. Unmerged by design — Zach merges.

`[workspace.lints.clippy]` already pins `cognitive_complexity` and
`too_many_lines` at `warn`, and all 21 workspace members declare
`[lints] workspace = true` (#1639, RUST-018). Nothing
asserted either fact: a member that dropped that one line would silently
opt out of both ratchets while the report still showed zero debt, and
downgrading the workspace level to `allow` removed the ratchet with no
diff to review beyond one word.

Extend the existing monocrate batch gate (`ci/check_workspace_crates.py`,
run by `crate-gate.yml`) with `lint_inheritance_errors()`:

- `[workspace.lints.clippy]` must still declare both ratchet lints and
  must not set either to `allow`/`off` (stricter levels are accepted);
- every `[workspace] members` manifest must inherit, accepting both
  cargo spellings (`[lints] workspace = true` and `lints.workspace = true`);
- comments are blanked quote-aware, so a commented-out `workspace = true`
  or a trailing `# pinned` comment cannot fake a pass.

Tests live in the module the registry already maps to this gate
(`ci/test_crate_guard_parity.py`), so no registry change is needed.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@zackees
zackees added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 06669ad Nov 6, 2026
29 checks passed
@zackees
zackees deleted the agent/lint-inheritance-guard branch November 6, 2026 11:57
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant