mirror of
https://github.com/got-feedBack/feedBack.git
synced 2026-09-12 20:28:32 +00:00
Move all ~770-line T-section functions (chordWireHighDensity, chordTemplateLabel,
chordTemplateMarkedArpeggio, chordHandShapeArpeggioHint, mergeHandShapeSynthChords,
mergeChordShape, inferArpeggioFromNotePattern, chordShapeCoveredByStandaloneNotes,
hsStart, hsEnd, handShapeChartSpanSec, fillArpeggioGhostInferFlags,
arpeggioChordIdForNoteWithInferCache, arpHsBoundsForNote, fillLaneRailHandShapeFlags,
fillArpeggioRailShapeBoundsCaches, arpeggioLaneOuterRailLaneSlice,
arpeggioLaneOuterRailAtChartTime, arpeggioLaneDividerFrameAccentMul,
arpeggioLaneDividerXYScaleMatchFrameRim) into a createArp({}) factory.
DI surface: 19 params — 18 plain const shorthand + 1 live getter (getNStr).
lowerBoundT imported directly from ./geometry.js (not DI'd).
NEXT_ON_STRING_T_EPS was found during ALL_CAPS grep after initial survey and
added as param 19.
Structural fix: _resetStringDependentCaches() remains in screen.js; exports
resetChordShapeCache() so screen.js can reset _chordShapeCache without reaching
into arp.js internals. DI rewire: arpeggioLaneDividerXYScaleMatchFrameRim uses
getNStr() instead of bare nStr (the live let var).
Test coverage (tests/js/highway_3d_arp.test.js — 19 tests):
- Module shape, 21-export return object, lowerBoundT direct import
- DI param surface (NEXT_ON_STRING_T_EPS, getNStr getter)
- Screen.js wiring: import, T-section body gone, destructure callsite
- Wiring-correspondence guard (PINNED_RENAMES = {}, naming-class invariant)
- Amendment 2: resetChordShapeCache identity kill (gut reset → r3 === r1 → RED)
- Amendment 3: WeakMap re-keying guard (same-ref hit, new-ref recompute)
- Behavioral kills: mergeChordShape, mergeHandShapeSynthChords, chordWireHighDensity,
chordTemplateLabel, arpeggioLaneDividerXYScaleMatchFrameRim DI check
Also updates highway_3d_arp_deferral.test.js to look in src/arp.js for
chordShapeCoveredByStandaloneNotes (moved out of screen.js by this cut).
plugin.json: 3.47.0 → 3.48.0
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014uZ169yfoFYArXz962g7KW
54 lines
2.7 KiB
JavaScript
54 lines
2.7 KiB
JavaScript
// Pins the arpeggio chord-gem deferral gating in plugins/highway_3d/screen.js
|
|
// (feedBack#262). Without these guards, an over-eager `deferChordGems` makes
|
|
// arpeggio frames empty when standalone notes don't actually cover the shape,
|
|
// and an under-eager one duplicates gems on top of the standalone passage.
|
|
//
|
|
// Source-level only — same strategy as the other tests/js/ files.
|
|
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const SCREEN_JS = path.join(__dirname, '..', '..', 'plugins', 'highway_3d', 'screen.js');
|
|
// h3d-carve-12: chordShapeCoveredByStandaloneNotes moved to src/arp.js
|
|
const ARP_JS = path.join(__dirname, '..', '..', 'plugins', 'highway_3d', 'src', 'arp.js');
|
|
|
|
test('chordShapeCoveredByStandaloneNotes helper exists with the expected signature', () => {
|
|
const src = fs.readFileSync(ARP_JS, 'utf8');
|
|
assert.match(
|
|
src,
|
|
/function\s+chordShapeCoveredByStandaloneNotes\s*\(\s*ch\s*,\s*shape\s*,\s*notesArr\s*,\s*timeWin\s*\)/,
|
|
'helper that scans the note stream for shape coverage must be in src/arp.js (moved from screen.js by h3d-carve-12)',
|
|
);
|
|
});
|
|
|
|
test('deferChordGems gates both synth and explicit+covered branches on note-stream coverage', () => {
|
|
// Either branch firing without coverage produces the empty-lavender-frame
|
|
// regression PR #262 fixed. Pin both predicates so a refactor that drops
|
|
// one gate fails the test.
|
|
const src = fs.readFileSync(SCREEN_JS, 'utf8');
|
|
assert.match(
|
|
src,
|
|
/const\s+deferChordGems\s*=\s*\(\s*ch\.h3dSynth\s*&&\s*noteStreamCoversArpShape\(\)\s*\)\s*\|\|\s*inferredArpPattern\s*\|\|\s*\(\s*hsHintFrame\.explicit\s*&&\s*hsHintFrame\.covered\s*&&\s*noteStreamCoversArpShape\(\)\s*\)/,
|
|
'deferChordGems must guard the h3dSynth and explicit+covered branches with the coverage check',
|
|
);
|
|
});
|
|
|
|
test('noteStreamCoversArpShape is computed lazily (called, not eagerly bound)', () => {
|
|
// Eager allocation regressed perf on dense charts (Copilot review on PR
|
|
// #262). The shape must be a callable so short-circuit evaluation skips
|
|
// the note-stream scan when neither gating branch needs it.
|
|
const src = fs.readFileSync(SCREEN_JS, 'utf8');
|
|
assert.match(
|
|
src,
|
|
/const\s+noteStreamCoversArpShape\s*=\s*(?:\(\s*\)\s*=>|function(?:\s+\w+)?\s*\(\s*\))/,
|
|
'noteStreamCoversArpShape must be an arrow/function so the scan is lazy',
|
|
);
|
|
assert.doesNotMatch(
|
|
src,
|
|
/const\s+noteStreamCoversArpShape\s*=\s*chordShapeCoveredByStandaloneNotes\(/,
|
|
'noteStreamCoversArpShape must not eagerly invoke the coverage helper',
|
|
);
|
|
});
|