Skip to content

Core hardening from the external review (7/7) - #48

Merged
bring42 merged 1 commit into
mainfrom
claude/pr7-core-hardening
Sep 12, 2026
Merged

bring42 merged 1 commit into
mainfrom
claude/pr7-core-hardening

Conversation

@bring42

@bring42 bring42 commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

Stacked PR — part 7 of 7. Merge in order (1 → 7) using a merge commit, not squash: the per-commit messages are the documentation, and squashing would also break the PRs stacked on top. Split from claude/next-goal-notes-merge-prep-6bb680; the top of the stack is byte-identical to that branch.

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.
  • The mode crossfade is scoped to the changed segment. Other segments keep rendering live instead of blending against a frozen frame for 2 s. A new multi-segment test fails against the old behavior.
  • The viz shows raw sources correctly: under sACN or /api/pixels, the readback serves the raw bytes instead of a stale image of the last effect.
  • Command::setEffect removed: it carried a borrowed const char* (a dangling-pointer trap) and had no producers.
  • Dead 8-bit-era constants (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_MODE are #ifndef-guarded, so other strips can be targeted via build_flags without 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 passes node --check. This branch's tree is byte-identical to the original claude/next-goal-notes-merge-prep-6bb680: the whole stack is a pure repackaging.

🤖 Generated with Claude Code


The stack (merge top to bottom):

  1. Premium render substrate + 13 premium modes (1/7) #42 — Premium render substrate + 13 premium modes (1/7)
  2. Web UI: data/ as the single source of truth (2/7) #43 — Web UI: data/ as the single source of truth (2/7)
  3. Live viz: the channel visualizer mirrors the real strip (3/7) #44 — Live viz: the channel visualizer mirrors the real strip (3/7)
  4. WiFi observability: stop failing silently (4/7) #45 — WiFi observability: stop failing silently (4/7)
  5. 4 MB partition table: 1.75 MB A/B app slots (5/7) #46 — 4 MB partition table: 1.75 MB A/B app slots (5/7)
  6. AI prompt pipeline: key save, live model, honest outcomes (6/7) #47 — AI prompt pipeline: key save, live model, honest outcomes (6/7)
  7. Core hardening from the external review (7/7) #48 — Core hardening from the external review (7/7)

…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>
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.

2 participants