Skip to content

fix(bend): keep scalar bn and bnv curve consistent on Peak edits (Codex follow-up) - #15

Merged
byrongamatos merged 1 commit into
mainfrom
fix/bend-bn-bnv-desync
Jun 20, 2026
Merged

byrongamatos merged 1 commit into
mainfrom
fix/bend-bn-bnv-desync

Conversation

@byrongamatos

Copy link
Copy Markdown
Collaborator

Follow-up to #13. A post-merge Codex review found that the scalar bend peak (bn) and the per-note bend curve (bnv) could drift apart after an edit — and renderers/graders treat bnv as authoritative, so a stale bn is a real inconsistency.

Fix

  • New pure helper rescaleBendCurveToPeak (in the @pure:bend-shape block, so it's node-tested by extraction): rescales a curve's shape to a target peak. Returns null when the curve is empty, all-zero, or the target is below bnv's 0.1 precision (rounds wholly to 0) — i.e. whenever the curve can't faithfully carry the peak.
  • Bend modal Peak input → rescales the curve to the new peak, or clears it (Peak 0 / unscalable) so the OK reconcile keeps the typed Peak instead of deriving bn=0 from a leftover zero curve.
  • Bend modal OK → still derives bn from the curve peak (curve wins when one is present).
  • Inspector editorInspectorSetTech('bend') → rescales the curve and snaps bn to the curve's actual rounded peak, so a non-0.1 input (e.g. 0.25) can't leave bn and the curve disagreeing.

Inspector edits intentionally skip undo (documented PR3b convention, screen.js:3783), so the bend path stays a direct mutation like its siblings rather than a SetBendShapeCmd.

Review

Codex-reviewed across 3 rounds (caught the non-0.1 mismatch and the sub-0.1 all-zero-curve edge along the way): clean, no findings.

Tests

+5 node cases for rescaleBendCurveToPeak (rescale up/down, 0.1 rounding, unscalable→null, the 0.04null / 0.050.1 precision boundary). 14/14 bend-shape tests pass; node --check clean.

Part of got-feedBack/feedBack#334.

🤖 Generated with Claude Code

Post-merge Codex review of editor#13 found the scalar peak (bn) and the per-note
bend curve (bnv) could drift apart, since renderers/graders treat bnv as
authoritative:

- New pure helper rescaleBendCurveToPeak (in the @pure:bend-shape block) rescales
  a curve's shape to a target peak, returning null when the curve is empty,
  all-zero, or the target is below bnv's 0.1 precision (rounds wholly to 0) — i.e.
  whenever it can't faithfully carry the peak.
- Bend modal Peak input now rescales the curve to the new peak, or clears it
  (Peak 0, or unscalable) so the OK reconcile keeps the typed Peak instead of
  deriving bn=0 from a leftover zero curve.
- Bend modal OK still derives bn from the curve peak (curve wins when present).
- Inspector editorInspectorSetTech('bend') rescales the curve and snaps bn to the
  curve's actual rounded peak, so a non-0.1 input (e.g. 0.25) can't leave bn and
  the curve disagreeing.

Inspector edits intentionally skip undo (documented PR3b convention), so the bend
path stays a direct mutation like its siblings rather than a SetBendShapeCmd.

Codex-reviewed across 3 rounds: clean. +5 node tests for rescaleBendCurveToPeak
(rescale up/down, 0.1 rounding, unscalable->null, 0.04->null / 0.05->0.1 boundary).
14/14 bend-shape tests pass.

Part of got-feedBack/feedBack#334.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byrongamatos
byrongamatos merged commit 3125d03 into main Jun 20, 2026
@byrongamatos
byrongamatos deleted the fix/bend-bn-bnv-desync branch June 20, 2026 22:46
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.

1 participant