Repository navigation
docs(cpp): enforce Public Settings Pattern for global setters - #2715
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR establishes the "Public Settings Pattern" architectural rule: library-wide configuration mutators in the ChangesPublic Settings Pattern enforcement
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Linter
participant FastLED_h
participant Report
Developer->>Linter: run checker on src/fl/**/*.h
Linter->>Linter: scan for set_*/enable_*/disable_*/use_* functions
Linter->>Linter: apply carve-outs & suppressions
Linter->>FastLED_h: search for CFastLED wrapper methods
FastLED_h-->>Linter: wrapper found or not found
Linter->>Report: record violation with required wrapper name
Report-->>Developer: HIGH-severity: missing CFastLED wrapper
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes The PR spans multiple file categories (docs, agent rules, Python linter with core logic + helpers, comprehensive test suite, and C++ API wrappers) with mixed complexity. The linter implementation requires careful review of scope tracking, carve-out heuristics, and cross-file wrapper detection; the test suite is extensive but systematic. Documentation and rule updates are straightforward and consistent across files. Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.coderabbit.yaml:
- Around line 28-31: Remove the grandfathered symbol
fl::set_rgbw_colorimetric_profile from the allowlist entries: delete the list
item in .coderabbit.yaml and the mirrored occurrences in
agents/docs/cpp-standards.md, .claude/agents/architecture-reviewer-agent.md, and
.claude/commands/code_review.md so that only fl::set_input_gamut remains; this
aligns the policy with the newly backfilled CFastLED::setRgbwColorimetricProfile
implementation and ensures the enforcement no longer exempts the old name.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3b7e304b-3587-4304-8465-6238aac644f3
📒 Files selected for processing (6)
.claude/agents/architecture-reviewer-agent.md.claude/commands/code_review.md.coderabbit.yamlCLAUDE.mdagents/docs/cpp-standards.mdsrc/FastLED.h
…agma keep Pre-existing IWYU violation flagged by the Stop hook's lint run. The `IwyuPragmaBlockChecker` requires system headers like `freertos/*.h` to carry an explicit `// IWYU pragma: keep` (or be wrapped in `begin_keep`/`end_keep`) so IWYU doesn't propose dropping them. Untouched by PR #2715's main work, but landing on the same branch under the project's "fix all encountered errors immediately" policy. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…al setters Removes the grandfathered exceptions section from the Public Settings Pattern docs. Both names that were allowlisted in the initial commit of this PR were introduced after the policy itself was being defined, so neither was historically grandfathered: - `fl::set_rgbw_colorimetric_profile` is already wrapped on `CFastLED` (`CFastLED::setRgbwColorimetricProfile`) in this PR, so it no longer needs an exception. - `fl::set_input_gamut` (#2710) is introduced in PR #2711 without a `CFastLED` wrapper. The wrapper must be added before that PR merges. Updated files: - `.coderabbit.yaml` - `agents/docs/cpp-standards.md` - `.claude/agents/architecture-reviewer-agent.md` - `.claude/commands/code_review.md` Addresses CodeRabbit review on PR #2715. Co-Authored-By: Claude Opus 4.7 <[email protected]>
…layer 5) (#2716) * feat(lint): enforce Public Settings Pattern for fl:: global setters Adds `PublicSettingsPatternChecker` (ci/lint_cpp/public_settings_pattern_checker.py) — layer 5 of the six-layer Public Settings Pattern enforcement plan introduced in PR #2715 / docs commit d51a8f6. What it checks: Every public free function declared at `namespace fl` root scope in `src/fl/**/*.h` whose name matches `^(set|enable|disable|use)_[a-z]` MUST have a matching `CFastLED::setX()` / `enableX()` / `disableX()` wrapper in `src/FastLED.h` that delegates to it. Carve-outs (NOT flagged): - Sub-namespaces (fl::detail::, fl::isr::, fl::colorimetric_detail::, …) - Anonymous namespaces - Class/struct member functions (per-object setters) - Function-pointer installers (set_rgb_2_rgbw_function, set_rgb_2_rgbww_function) - Per-object mutators: non-const ptr/ref to user-defined type as first param - Lines suppressed with `// nolint` or `// ok public_settings` Grandfathered allowlist (pre-rule offenders, not flagged): set_rgbw_colorimetric_profile, set_input_gamut (from #2715 description), enable_rgbw_colorimetric_lut, disable_rgbw_colorimetric_lut (#2545), set_rgbww_colorimetric_profile (#2558). Implementation notes: - Uses a per-`{` scope stack (not a simple brace counter) so that enum bodies, inline function definitions, and nested namespaces are all tracked correctly without false namespace pops. - FastLED.h is loaded once at `__init__` time for cross-file wrapper lookup. - 63 unit tests; `bash lint --cpp` passes clean on the full codebase. - Registered in the `fl` scope in run_all_checkers.py. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * fix(lint): annotate first_param list type in public_settings checker Pyright (--strict) flagged `first_param` as `list[Unknown]` since it's initialized as a bare `[]`. The list only ever holds str characters from iterating `params_raw` (a str), so the annotation is `list[str]`. Drive-by while reviewing the agent-generated PR #2716. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
…attern `fl::set_input_gamut` (#2710) is a library-wide global setter. Under the Public Settings Pattern in agents/docs/cpp-standards.md, every public fl:: global setter must ship with a thin inline `CFastLED` wrapper that becomes the documented user-facing call site. The two-arg and three-arg overloads now have matching `CFastLED::setInputGamut` wrappers. Removes the implicit grandfathered exception this function was relying on in PR #2715 — that PR's follow-up commit explicitly dropped the allowlist, so this wrapper is now required before merge rather than deferred. Co-Authored-By: Claude Opus 4.7 <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ci/lint_cpp/test_public_settings_pattern_checker.py (1)
41-65: 💤 Low valueTest helper functions use default parameter values.
Per coding guidelines, Python function parameters must not have default values. These helpers use
path: str = _FL_PATHandfastled_h: str = "". While this violates the strict guideline, it significantly improves test readability and is acceptable for internal test helpers. As per coding guidelines: "All function parameters MUST have explicit type annotations and MUST NOT have default values".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ci/lint_cpp/test_public_settings_pattern_checker.py` around lines 41 - 65, The helper functions _make and _violations currently define default parameter values (path: str = _FL_PATH, fastled_h: str = ""), which violates the no-default-parameters rule; remove the defaults so signatures are _make(code: str, path: str, fastled_h: str) and _violations(code: str, path: str, fastled_h: str), then update all local test call sites to pass _FL_PATH and the fastled_h string explicitly (or appropriate values) when invoking _make and _violations to preserve existing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@ci/lint_cpp/test_public_settings_pattern_checker.py`:
- Around line 41-65: The helper functions _make and _violations currently define
default parameter values (path: str = _FL_PATH, fastled_h: str = ""), which
violates the no-default-parameters rule; remove the defaults so signatures are
_make(code: str, path: str, fastled_h: str) and _violations(code: str, path:
str, fastled_h: str), then update all local test call sites to pass _FL_PATH and
the fastled_h string explicitly (or appropriate values) when invoking _make and
_violations to preserve existing behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dadd1a1c-de0d-439f-89f2-cf44cd64adcc
📒 Files selected for processing (3)
ci/lint_cpp/public_settings_pattern_checker.pyci/lint_cpp/run_all_checkers.pyci/lint_cpp/test_public_settings_pattern_checker.py
#2711) * fix(rgbw): default source = native LED gamut + D65; named-gamut opt-in (#2710) Closes #2710. #2705 added the source-RGB → LED-XYZ transform with `kRgbwDefaultProfile` defaulting to Rec709/sRGB primaries + D65. That silently clipped saturated inputs to the sRGB sub-volume of the LED's native gamut — `RGB=(255,0,0)` on a typical SK6812 strip drove the LED red diode to ~70 % of its capability, leaving the rest unreachable through the public API. Flips the default to **native LED gamut + D65 white**: - `kRgbwDefaultProfile.input_xy_r/g/b` now mirror the profile's own LED `xy_r/g/b` (was sRGB), so saturated inputs hit the LED gamut at full saturation. - `input_xy_w` stays at D65 so neutral inputs land on a standard daylight white. - Same applies to `kRgbwwDefaultProfile` (RGBWW warm + cool paths). Adds a small opt-in API for users who explicitly want standard color-space input semantics: enum class InputGamut : u8 { Native, Rec709, Rec2020, DciP3D65, DciP3D60 }; void set_input_gamut(DiodeProfile* profile, InputGamut g) noexcept; void set_input_gamut(DiodeProfile* profile, InputGamut g, const float white_xy[2]) noexcept; Users with sRGB content (ambilight, video bridges) write one line at setup: `fl::set_input_gamut(&my_profile, fl::InputGamut::Rec709);`. The white-override overload covers niche cases like D50 photography workflow or D60 ACES theatrical mastering. Tests ===== - `default profile carries native-LED + D65 source space (#2710)` — asserts input_xy_* mirror xy_* and input_xy_w == D65. - `source matrix matches published sRGB->XYZ matrix (Rec709 opt-in)` — the existing sRGB matrix-derivation check now opts into Rec709 via set_input_gamut() before building M_src. - `set_input_gamut: Native copies LED primaries` — trashes input_xy_* then proves Native restores them from xy_*. - `set_input_gamut: named gamuts populate canonical primaries` — hits Rec709 / Rec2020 / DCI-P3 D65 / DCI-P3 D60 and asserts canonical primary + white-point values. - `set_input_gamut: white override honored` — covers the overload that takes a custom white (D50 in the test). - `set_input_gamut: null profile is a no-op` — defensive guard parity with `set_rgbw_colorimetric_profile(nullptr)`. Drive-by ======== Removes `compare_rgbw.py`, a one-off scratch comparison harness that slipped into master via #2709's squash-merge despite being deleted on the branch. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore(ci): apply ruff format drift bash lint reformatted three CI files during PR #2711 review work. No functional change — purely line-break/whitespace adjustments that ruff flagged as drift from the current format profile. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(rgbw): address CodeRabbit review on #2711 Three follow-ups from the CodeRabbit review: 1. **(major) Cache invalidation on in-place gamut mutation** — set_input_gamut() rewrites profile->input_xy_* in place, but the ColorimetricCacheHolder and LutStateHolder are keyed on (profile_ptr, cct). Without invalidation, the cache held stale M_src/LUT entries after a gamut switch on the currently active profile, producing deterministic wrong colors. Now the active per-process caches are evicted whenever set_input_gamut() mutates a profile that matches the cache key. No-op in the FASTLED_RGBW_COLORIMETRIC=0 build (no cache exists to invalidate). 2. **(contract) white_xy doc mismatch** — The header doc said the `white_xy` override "must point to a 2-float array" but the impl already accepted nullptr as "use the gamut's reference white" (equivalent to the 2-arg overload). Doc now matches behavior. Kept the raw-array signature instead of switching to fl::span<const float, 2> — the header sits low in the include graph and pulling fl/stl/span.h here would be a heavier change than the contract bug warrants; the 2-arg overload remains the recommended call site for the default-white path. 3. **(nitpick) RGBWW native-gamut guard** — Added an explicit test asserting kRgbwwDefaultProfile.warm_path / cool_path keep input_xy_* mirroring xy_* and input_xy_w pinned at D65. Symmetric to the existing assertion at rgbw_colorimetric.cpp:252-272; locks the native-LED-gamut contract on both warm and cool paths so future chromaticity retuning can't silently desync source from emitter. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(cpp): wrap fl::set_input_gamut on CFastLED per Public Settings Pattern `fl::set_input_gamut` (#2710) is a library-wide global setter. Under the Public Settings Pattern in agents/docs/cpp-standards.md, every public fl:: global setter must ship with a thin inline `CFastLED` wrapper that becomes the documented user-facing call site. The two-arg and three-arg overloads now have matching `CFastLED::setInputGamut` wrappers. Removes the implicit grandfathered exception this function was relying on in PR #2715 — that PR's follow-up commit explicitly dropped the allowlist, so this wrapper is now required before merge rather than deferred. Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…agma keep Same pre-existing IWYU violation as on PR #2715 — this branch was cut from master before that fix landed, so the linter flags it again. Same one-line fix: `// IWYU pragma: keep` on each freertos system header. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…2717) (#2718) * docs(cpp): add 8 code-gen rules from 2-week CodeRabbit survey Closes #2717. Adds 8 new rules to agents/docs/cpp-standards.md capturing the recurring themes CodeRabbit flagged across 94 PRs (2026-05-20 → 2026-06-03, 59 with CodeRabbit activity, ~95 substantive findings). All 8 are preventable at code-generation time with a written rule. Rules added (in order, append-only at end of file): 1. Singleton-Stored Configuration: Own by Value, Never by Borrowed Pointer — prevents use-after-scope when callers pass a stack temporary to a `set_X(const T*)` that stashes the pointer in process state. Pairs with the Public Settings Pattern (PR #2715 — where the setter lives; this rule — how it stores the value). 2. In-Place Profile Mutation Bumps a Version — cache-invalidation contract for `set_X(T* obj, ...)` patterns. Without a version bump and key, derived-value caches keyed on `(obj_ptr, ...)` return stale data when the same pointer is mutated across frames. 3. Contract Change Fanout — broadens the existing "API Unit Change" rule (§595-604) from `_ms` / `_us` suffixes to any bound, enum range, or struct shape change. PRs must touch producer + validator + tests + docs + debug-metrics in one diff. 4. `fl::span` for Callback Typedefs and Small Fixed-Size Arrays — extends the existing span rule with two shapes that kept slipping through: `fl::function<...(const u8*, size_t)>` typedefs and `const float xy[2]` fixed-size arrays. 5. ISR-Shared State: `fl::atomic` or Critical Section, Never Bare `volatile` — uses `fl::atomic<T>` (not `std::atomic`, per the project-wide "prefer fl:: over std::" rule) with explicit memory order, OR `portENTER_CRITICAL_ISR` guarded access. Plain `volatile` is not sufficient on dual-core MCUs. 6. Unsigned Narrowing Cast Must Clamp — sibling to the existing Signed Integer Overflow rule. `static_cast<u8>(x)` wraps silently when x > 255 — defined behavior, wrong behavior. The signed-UB rule explicitly does NOT cover this case. 7. Test Mirrors Must Call Production Symbols, Not Redeclare Them — local lambda re-implementations in test files silently pass when the production code regresses. Test must `#include` and call the production symbol. 8. ASCII-Only in Source Files — emoji and Unicode math glyphs (`⚠️ `, `×`, `−`, `ρ`, `∆`) in C++ comments and Python source confuse toolchains and obscure compile errors. Markdown (`*.md`) files exempt. Rule dropped from the original recommendation: mirror the KeyboardInterrupt pattern into `agents/docs/python-standards.md` — on inspection the rule is already present there at lines 17-46. The recurring violations come from agents reading other docs first; that is a discovery problem, not a documentation gap. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(iwyu): wrap freertos includes in lcd_spi clockless driver with pragma keep Same pre-existing IWYU violation as on PR #2715 — this branch was cut from master before that fix landed, so the linter flags it again. Same one-line fix: `// IWYU pragma: keep` on each freertos system header. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(cpp): address CodeRabbit nitpicks on PR #2718 Two "Quick win" nitpicks from CodeRabbit on the survey-rules PR: 1. **Rule 1 (Singleton-Stored Configuration)** — softens the "MUST take const T&" wording to allow `const T*` parameters when the pointer is used as a nullable-reset signal (nullptr → revert to default). The existing `set_rgbww_colorimetric_profile(const T*)` is the in-repo example of this idiom; it copies on non-null and resets on null, which is correct even though the parameter shape is `T*`. The HIGH-severity flag now fires only when BOTH parameter and storage are `const T*` (the actual use-after-scope shape). 2. **Rule 4 (`fl::span` for callback typedefs)** — adds a scoped exception for deferred legacy migrations. A `(ptr, size)` typedef may be retained temporarily when migrating all callers in one PR isn't tractable, provided the typedef site carries a comment pointing at the tracking issue and the exception is timeboxed. Cited example: `src/fl/stl/cstdio.h`. Without this carve-out the rule would push engineers toward unprincipled mixed APIs. Both rules remain "use value semantics / spans by default" — the exceptions are explicit, documented, and bounded. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Codifies the long-implicit rule that new library-wide configuration setters must be exposed on the `CFastLED` god instance (e.g. `FastLED.setX(...)`) rather than as bare `fl::set_x(...)` free functions. The free function may exist for ADL / testability, but the documented call site is the god instance. Motivated by PR #2711, which added `fl::set_input_gamut(...)` as a free function only — following the unwrapped precedent of `fl::set_rgbw_colorimetric_profile`. Neither has a `FastLED.setX()` entry point, so users don't discover them. Both are now grandfathered exceptions; new code must wrap. Changes: - `agents/docs/cpp-standards.md`: New "Public Settings Pattern" section with rules, exemplar (`setPowerModel` → `set_power_model`), and a grandfathered allowlist. - `CLAUDE.md`: One-liner pointer in the task table and Code Standards section so agents see the rule on entry. - `.coderabbit.yaml`: `path_instructions` for `src/fl/**/*.h`, `src/FastLED.h`, and `src/fl/gfx/**` telling CodeRabbit to flag bare new `fl::set_* / enable_* / disable_* / use_*` declarations without a matching `CFastLED` wrapper as HIGH severity, with the grandfathered allowlist honored. - `.claude/agents/architecture-reviewer-agent.md`: API Surface check step gains a "Public Settings Pattern enforcement" subsection. - `.claude/commands/code_review.md`: New rule block before "SIGNED INTEGER OVERFLOW", plus a counter in the violations summary. - `src/FastLED.h`: Backfills `CFastLED::setRgbwColorimetricProfile()` and `getRgbwColorimetricProfile()` — thin `inline` delegators to the existing `fl::` free functions. `setInputGamut` is intentionally left for PR #2711 to add alongside its own free function (it isn't on master yet). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…al setters Removes the grandfathered exceptions section from the Public Settings Pattern docs. Both names that were allowlisted in the initial commit of this PR were introduced after the policy itself was being defined, so neither was historically grandfathered: - `fl::set_rgbw_colorimetric_profile` is already wrapped on `CFastLED` (`CFastLED::setRgbwColorimetricProfile`) in this PR, so it no longer needs an exception. - `fl::set_input_gamut` (#2710) is introduced in PR #2711 without a `CFastLED` wrapper. The wrapper must be added before that PR merges. Updated files: - `.coderabbit.yaml` - `agents/docs/cpp-standards.md` - `.claude/agents/architecture-reviewer-agent.md` - `.claude/commands/code_review.md` Addresses CodeRabbit review on PR #2715. Co-Authored-By: Claude Opus 4.7 <[email protected]>
…layer 5) (#2716) * feat(lint): enforce Public Settings Pattern for fl:: global setters Adds `PublicSettingsPatternChecker` (ci/lint_cpp/public_settings_pattern_checker.py) — layer 5 of the six-layer Public Settings Pattern enforcement plan introduced in PR #2715 / docs commit d51a8f6. What it checks: Every public free function declared at `namespace fl` root scope in `src/fl/**/*.h` whose name matches `^(set|enable|disable|use)_[a-z]` MUST have a matching `CFastLED::setX()` / `enableX()` / `disableX()` wrapper in `src/FastLED.h` that delegates to it. Carve-outs (NOT flagged): - Sub-namespaces (fl::detail::, fl::isr::, fl::colorimetric_detail::, …) - Anonymous namespaces - Class/struct member functions (per-object setters) - Function-pointer installers (set_rgb_2_rgbw_function, set_rgb_2_rgbww_function) - Per-object mutators: non-const ptr/ref to user-defined type as first param - Lines suppressed with `// nolint` or `// ok public_settings` Grandfathered allowlist (pre-rule offenders, not flagged): set_rgbw_colorimetric_profile, set_input_gamut (from #2715 description), enable_rgbw_colorimetric_lut, disable_rgbw_colorimetric_lut (#2545), set_rgbww_colorimetric_profile (#2558). Implementation notes: - Uses a per-`{` scope stack (not a simple brace counter) so that enum bodies, inline function definitions, and nested namespaces are all tracked correctly without false namespace pops. - FastLED.h is loaded once at `__init__` time for cross-file wrapper lookup. - 63 unit tests; `bash lint --cpp` passes clean on the full codebase. - Registered in the `fl` scope in run_all_checkers.py. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * fix(lint): annotate first_param list type in public_settings checker Pyright (--strict) flagged `first_param` as `list[Unknown]` since it's initialized as a bare `[]`. The list only ever holds str characters from iterating `params_raw` (a str), so the annotation is `list[str]`. Drive-by while reviewing the agent-generated PR #2716. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Sonnet 4.6 <[email protected]>
07ea2c4 to
692a090
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@agents/docs/cpp-standards.md`:
- Around line 262-268: The policy text claiming "No grandfathered offenders"
conflicts with the current checker which honors GRANDFATHERED_NAMES and the PR
note that fl::set_input_gamut is temporarily grandfathered; update
agents/docs/cpp-standards.md (the paragraph around the "No grandfathered
offenders" rule) to reflect the actual enforcement state by either (A) removing
the absolute "no grandfathered" statement and documenting the temporary
grandfathering mechanism and its allowed names (referencing GRANDFATHERED_NAMES
and fl::set_input_gamut), or (B) if you intend to remove grandfathering, change
the checker ci/lint_cpp/public_settings_pattern_checker.py to eliminate the
GRANDFATHERED_NAMES path and then update the doc to state the strict
no-grandfather rule—make sure the doc text and the checker
(public_settings_pattern_checker.py and the specific GRANDFATHERED_NAMES symbol)
are consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 556ea304-2e35-4aca-9d3b-929327e05b9c
📒 Files selected for processing (9)
.claude/agents/architecture-reviewer-agent.md.claude/commands/code_review.md.coderabbit.yamlCLAUDE.mdagents/docs/cpp-standards.mdci/lint_cpp/public_settings_pattern_checker.pyci/lint_cpp/run_all_checkers.pyci/lint_cpp/test_public_settings_pattern_checker.pysrc/FastLED.h
✅ Files skipped from review due to trivial changes (1)
- CLAUDE.md
🚧 Files skipped from review as they are similar to previous changes (6)
- ci/lint_cpp/run_all_checkers.py
- .coderabbit.yaml
- .claude/agents/architecture-reviewer-agent.md
- src/FastLED.h
- ci/lint_cpp/public_settings_pattern_checker.py
- ci/lint_cpp/test_public_settings_pattern_checker.py
CodeRabbit (#2715 thread on agents/docs/cpp-standards.md:262) flagged that the "No grandfathered offenders" wording contradicted the actual enforcement state: public_settings_pattern_checker.py still carries a small GRANDFATHERED_NAMES allowlist for legacy bare setters that have not yet received CFastLED wrappers (set_input_gamut, enable_rgbw_colorimetric_lut, disable_rgbw_colorimetric_lut, set_rgbww_colorimetric_profile). Reconcile the policy text in cpp-standards.md, architecture-reviewer- agent.md, and code_review.md to describe the transitional allowlist explicitly: strict for *new* code, shrinking allowlist for legacy names, entries removed as wrappers land. The behavior of the rule is unchanged; only the documentation matches reality now. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Motivation
Triggered by PR #2711, which added
fl::set_input_gamut(...)as a bare free function — following the pre-existing pattern offl::set_rgbw_colorimetric_profile. Neither has aFastLED.setX()god-instance entry point, so users discover and document the wrong call site (thefl::free function), and the library's public surface drifts out of sync with the documented exemplar (FastLED.setPowerModel→fl::set_power_model,src/FastLED.h:1455).The codebase has the correct pattern (
setPowerModel), but it wasn't written down. AI agents and humans both followed the unwrapped neighbor instead. This PR writes the rule down and adds enforcement at four layers so the drift stops.Six-layer enforcement plan (this PR does layers 1–4)
agents/docs/cpp-standards.md→ "Public Settings Pattern"CLAUDE.mdtable + Code Standards section pointer.coderabbit.yamlpath_instructionsforsrc/fl/**/*.h,src/FastLED.h,src/fl/gfx/**architecture-reviewer-agentsystem prompt/code_reviewchecklist + summary counterCFastLED::setRgbwColorimetricProfile+ gettersetInputGamutcpp-linter-builder-agentwrites a syntactic checkWhat the rule says
Grandfathered (predate the rule — do not flag for these names alone):
fl::set_rgbw_colorimetric_profile— wrapped in this PRfl::set_input_gamut(bug(rgbw): default source = Rec709/sRGB silently truncates LED gamut — switch default to native LED primaries + D65 #2710) — to be wrapped when fix(rgbw): default source = native LED gamut + D65; named-gamut opt-in #2711 lands (or folded into fix(rgbw): default source = native LED gamut + D65; named-gamut opt-in #2711)Changes
agents/docs/cpp-standards.md— New "Public Settings Pattern" section with rules, thesetPowerModelexemplar, grandfathered allowlist, and a "doesn't apply to" carve-out for helpers / per-object config /fl::detail::.CLAUDE.md— Adds a row to the task table and a bullet under Code Standards so agents see the rule on entry..coderabbit.yaml— Addspath_instructionsblocks teaching CodeRabbit to flag bare newfl::set_*free functions insrc/fl/**/*.hthat lack aCFastLEDwrapper. Also coverssrc/FastLED.h(delegate-don't-embed) andsrc/fl/gfx/**(where the recent offender lives). Grandfathered names called out by name..claude/agents/architecture-reviewer-agent.md— Adds a "Public Settings Pattern enforcement" subsection under API Surface, with HIGH severity and the canned violation language..claude/commands/code_review.md— New rule block before "SIGNED INTEGER OVERFLOW", plus a "Public Settings Pattern violations" counter in the violations summary.src/FastLED.h— Adds#include "fl/gfx/rgbw.h"and a "RGBW Colorimetric Configuration" group onCFastLEDcontainingsetRgbwColorimetricProfile(const fl::DiodeProfile*)andgetRgbwColorimetricProfile(). Both are thininlinedelegators to the existing free functions infl::, matching thesetPowerModelexemplar exactly.Test plan
bash lintclean (all four pipelines).path_instructionsand applies them.FastLED.setInputGamut(...)and update fix(rgbw): default source = native LED gamut + D65; named-gamut opt-in #2711's body/examples to recommend the god-instance call.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores