Repository navigation
Core hardening from the external review (7/7) - #48
Merged
Merged
Conversation
…aw-source viz Fixes from an on-branch external review (UBSan-assisted): - render16 lerp16(): the delta × frac intermediate spans ±65535², overflowing int32 — signed-overflow UB that happened to produce correct values (and passed the extreme-value tests doing it). Intermediate widened to int64; descending-direction extremes added to test_render16. - Mode crossfade is now scoped to the CHANGED segment's window instead of blending the whole canvas: other segments render live during the 2 s fade rather than easing against a frozen frame. A second effect change mid-fade widens the window and re-freezes at the current visual state. New discriminating multi-segment test (fails against the whole-canvas blend). - Viz readback (GET /api/v2/pixels) now mirrors raw sources: sACN and the /api/pixels direct path bypass the 16-bit pipeline, so smooth_ held a stale ghost of the last native effect. When pipeline16_ is false the endpoint serves leds[] verbatim (raw bytes never passed gamma/correction — already screen-appropriate). Asserted in the direct-pixels test; API_V2.md updated. - Command::setEffect removed (enum case, union field, factory): it carried a borrowed const char* — a dangling-pointer trap with zero remaining producers; effect changes ride ApplyEffectSpec, which owns its id. - Dead 8-bit-era constants purged: LED_MIN_OUTPUT + LED_CORRECTION_FULL_AT survived only in comments describing a floor the 16-bit pipeline explicitly removed; comment blocks in constants.h/render16.h/controller.h rewritten to the current design. - show()-rate comments made honest about scaling: ~30 µs/pixel of blocking wire time means 'several hundred Hz' holds at ≲300 px but caps near 33 Hz at 1000 px — showHz_ reports the truth. - LED_STRIP_TYPE / LED_COLOR_MODE now #ifndef-guarded so board envs can retarget hardware via build_flags (-DLED_STRIP_TYPE=SM16703 ...) instead of editing global defaults. 82/82 native tests pass. Not addressed by design: queue-overflow drops the oldest command (existing policy), trail-effect canvas state during crossfades (pre-existing), render-RAM cost of the 16-bit buffers (accepted trade). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Sep 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes from an external review of the whole branch:
lerp16()undefined behavior: the int32 intermediate overflowed (UBSan-confirmed). Widened to int64. The old tests passed through the UB, so descending-direction extremes are added./api/pixels, the readback serves the raw bytes instead of a stale image of the last effect.Command::setEffectremoved: it carried a borrowedconst char*(a dangling-pointer trap) and had no producers.LED_MIN_OUTPUT,LED_CORRECTION_FULL_AT) and their comments are purged. The show-rate comments are now honest about how the rate scales with strip length.LED_STRIP_TYPE/LED_COLOR_MODEare#ifndef-guarded, so other strips can be targeted viabuild_flagswithout editing defaults.Review notes
Deliberately not changed: the queue drops the oldest command on overflow (existing policy), and the render RAM cost of the 16-bit buffers is accepted (~24 KB at 1000 LEDs).
Verification
Built and tested on this branch alone: 82/82 native tests pass (includes the new multi-segment crossfade test and the lerp16 extremes), the firmware builds for
seeed_xiao_esp32c3(65.3% of the app partition), and the web UI JS passesnode --check. This branch's tree is byte-identical to the originalclaude/next-goal-notes-merge-prep-6bb680: the whole stack is a pure repackaging.🤖 Generated with Claude Code
The stack (merge top to bottom):