Skip to content

fix(color): refuse a declared source space that cannot be built (#4156 R6) - #4258

Merged
zackees merged 1 commit into
masterfrom
fix/4156-r6-declared-source-space
Sep 10, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/4156-r6-declared-source-space

Conversation

@zackees

@zackees zackees commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

build_rgb_colorimetric_cache computed:

has_source_space = (input_xy_w[1] > 1e-6f) && build_source_matrix(...)

which folds two different answers into one. "No source space declared" and "a source space was declared and is unusable" both left has_source_space false — and false means #2705's legacy mode: the caller's RGB triple is the device drive triple.

So a profile with degenerate custom primaries — collinear, or a zero y — did not fail. It silently switched interpretation, and the sketch rendered a different colour from primaries it believed were in effect, with nothing said.

#4156 R6 names exactly this:

Its cache builder can also treat source-matrix failure as absence of a source space, which must not silently become managed-path behavior. […] Near-singular transforms need deterministic rejection or a separately bounded path, not arbitrary clamping that destroys the accuracy promise.

The fix

The two states are now distinct and the builder returns false for the second.

Three tests pin all three outcomes, because collapsing this in either direction is a silent behaviour change:

profile outcome
declared and unusable (collinear primaries) refused
not declared at all (input_xy_w[1] == 0) still fine — a supported mode, not a degenerate profile
declared and usable still builds — the rejection must not degrade into "refuse every declared space"

Safe to tighten the contract

No caller in src/ uses this yet — the Q16 path goes through buildRgbSolveMatrixQ16 — and the existing tests assert true for profiles that stay true.

Mutation testing

mutation fails
restore the silent fold the rejection case
reject every declared source space the usable case

Verification

  • bash test --cpp — 299/299 unit, 84/84 examples
  • bash lint — clean, exit 0

Refs #4156

🤖 Generated with Claude Code

https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of RGB color profiles with invalid declared source spaces.
    • Profiles without a declared source white continue to work as expected.
    • Valid source-space definitions continue to build successfully.
  • Tests

    • Added coverage for valid, invalid, and undeclared RGB source-space scenarios.

…R6)

`build_rgb_colorimetric_cache` computed

    has_source_space = (input_xy_w[1] > 1e-6f) && build_source_matrix(...)

which folds two different answers into one. "No source space declared" and "a
source space was declared and is unusable" both left `has_source_space` false,
and false means #2705's legacy mode: the caller's RGB triple *is* the device
drive triple.

So a profile with degenerate custom primaries -- collinear, or a zero `y` --
did not fail. It silently switched interpretation, and the sketch rendered a
different colour from primaries it believed were in effect, with nothing said.
#4156 R6 names this: a near-singular transform needs deterministic
rejection, not an arbitrary fallback that destroys the accuracy promise.

The two states are now distinct, and the builder returns false for the second.
Three tests pin all three outcomes, because collapsing this in either
direction is a silent behaviour change:

* declared and unusable -> refused;
* not declared at all -> still fine, since that is a supported mode rather
  than a degenerate profile, and the check must not swallow it;
* declared and usable -> still builds, so the rejection cannot degrade into
  "refuse every declared source space".

Safe to tighten the contract: no caller in `src/` uses this yet -- the Q16
path goes through `buildRgbSolveMatrixQ16` -- and the existing tests assert
true for profiles that stay true.

Mutation-tested both ways: restoring the fold fails the rejection case, and
rejecting every declared space fails the usable case.

Refs #4156

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7c2ec622-7f7a-42d0-8550-957d0740b0ce

📥 Commits

Reviewing files that changed from the base of the PR and between cf88276 and 53d2b44.

📒 Files selected for processing (2)
  • src/fl/gfx/colorimetric_response.h
  • tests/fl/gfx/colorimetric_response.cpp

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

build_rgb_colorimetric_cache now rejects unusable declared source spaces. Profiles without a declared source white remain valid drive-coordinate profiles. Tests cover invalid, absent, and valid source-space cases.

Changes

RGB source-space validation

Layer / File(s) Summary
Source-space declaration handling
src/fl/gfx/colorimetric_response.h
The cache records whether a source space is declared. It returns false when the declared source space cannot be built. The function documentation describes this distinction.
Source-space behavior tests
tests/fl/gfx/colorimetric_response.cpp
Tests cover rejection of collinear declared primaries, support for profiles without a source white, and successful construction of valid declared source spaces.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 53d2b

Declared but unusable RGB source spaces now fail cache construction instead of falling back to drive coordinates, while profiles with no declared source space and valid declared spaces retain their intended behavior. No current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: rejecting a declared source space when it cannot be built. The issue reference does not obscure the meaning.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/4156-r6-declared-source-space

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

Comment @coderabbitai help to get the list of available commands.

@zackees
zackees merged commit 77c050a into master Sep 10, 2026
27 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Sep 10, 2026
@zackees
zackees deleted the fix/4156-r6-declared-source-space branch November 5, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant