Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bf67e68
chore: untangler phase 0 triage and baseline
mattromano Nov 7, 2026
79a5743
docs: untangler phase 1 audit (33 issues, Top 5 pending sign-off)
mattromano Nov 7, 2026
d579401
docs: untangler I-001 scoped to fast tests in the existing CI check
mattromano Nov 7, 2026
4ed8da5
chore: untangler Top 5 signed off, enter phase 2
mattromano Nov 9, 2026
d332dc5
test: untangler phase 2 safety nets for the Top 5
mattromano Nov 9, 2026
0543bcf
test: clone harness tolerates CRLF checkouts of build-common.sh
mattromano Nov 9, 2026
f155640
refactor(tests): move the six engine-loading tests into tests/engine
mattromano Nov 9, 2026
1d2d250
ci: run the fast test lane in the existing check job
mattromano Nov 9, 2026
5ebc3e3
chore: untangler I-001 done
mattromano Nov 9, 2026
34c14bc
refactor(main): move desktop config read/write into desktop-config.ts
mattromano Nov 9, 2026
ec74899
fix(main): keep a .corrupt copy instead of overwriting an unreadable …
mattromano Nov 9, 2026
f2ca43f
chore: untangler I-002 done
mattromano Nov 9, 2026
d6625c5
fix(build): fail the build when a bundled plugin is missing
mattromano Nov 9, 2026
23b79c1
chore: untangler I-006 done
mattromano Nov 9, 2026
caab1da
refactor(audio): fold seven exact-copy guarded addon calls into callA…
mattromano Nov 9, 2026
29240d9
chore: untangler I-004 done
mattromano Nov 9, 2026
36ffd5a
refactor(renderer): one tone-switch implementation for both IIFEs; se…
mattromano Nov 9, 2026
8446918
chore: untangler I-003 done pending listening check
mattromano Nov 9, 2026
7fc6d21
chore: untangler I-003 checked in the packaged app
mattromano Nov 9, 2026
0819293
chore: untangler phase 4 guard rails
mattromano Nov 9, 2026
2c5d1f4
chore: untangler phase 4 state
mattromano Nov 9, 2026
51289a8
chore: keep the pre-commit hook script LF on Windows checkouts
mattromano Nov 9, 2026
4755b17
docs: untangler handover
mattromano Nov 9, 2026
60218a7
fix(renderer): keep the chain on song load in MIDI program-change mode
mattromano Nov 9, 2026
55ae3af
docs: untangler deferred MIDI chain wipe fixed
mattromano Nov 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Shell scripts run under sh/bash must keep LF line endings on Windows checkouts.
scripts/hooks/pre-commit text eol=lf
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
- name: TypeScript type check
run: npm run typecheck

# Fast lane only (source-reading tests, ~2 s). The engine-loading tests in
# tests/engine/ need a built native addon and are run locally on demand.
- name: Fast tests
run: npm run test:fast

- name: npm audit
run: npm audit --audit-level=high
continue-on-error: true
74 changes: 74 additions & 0 deletions .untangler/HANDOVER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Untangler handover: feedBack desktop

Branch `refactor/untangle-2026-11-07`, from tag `pre-refactor-baseline` to
`refactor-complete-2026-11-09`. Nothing is pushed or merged. The branch sits on top of the
unpushed latency work (`e610887`, fix/heard-clocks), so it carries those commits too.

## What was audited

The whole repo: Electron main, the `screen.js` renderer plugin, the native engine, the VST
host, build scripts and CI. 33 issues are in `REFACTOR_AUDIT.md` and `.untangler/audit.json`.
You signed off a Top 5.

## What was fixed (Top 5)

| Issue | Change | Commits |
|-------|--------|---------|
| I-001 Test lanes | Engine-loading tests moved to `tests/engine/`. `npm test` = fast lane; `npm run test:engine` on demand. One ~2 s "Fast tests" step in the existing CI check job; no new jobs, nothing in build/release. | `f155640`, `1d2d250` |
| I-002 Desktop config | Read/write moved unchanged into `desktop-config.ts`. An unreadable `slopsmith-desktop.json` is now kept as `.corrupt` instead of being silently replaced. | `34c14bc`, `ec74899` |
| I-006 Missing plugins | A failed plugin clone fails the build (`ALLOW_MISSING_PLUGINS=1` to opt out). The desktop-plugin copy no longer hides errors. All 38 plugin repos checked reachable. | `d6625c5` |
| I-004 Guarded addon calls | `callAddon()` replaces the 7 handlers that were exact copies. The audit's "~40" overcounted; the rest differ in ways that matter. | `caab1da` |
| I-003 Tone switching | One bypass-switch step and one MIDI-switcher factory shared by both IIFEs. IIFE 2 switchers gain the preset-name map. IIFE 2's song preload runs under the same chain lock as tone-mapping applies. | `36ffd5a` |

### How it was verified

- **Safety-net tests first.** Each Top 5 item got its own test, written before the change:
- an `audio:*` handler snapshot (111 handlers, 3 addon states)
- a desktop-config behaviour test
- a bash harness that runs the real clone function
- tone-switch parity across every install site
- a test-file inventory

Each one was broken on purpose to prove it catches regressions.
- **173 fast tests** and the typecheck pass after every change.
- **I-003 in the packaged app**, driven over CDP:
- Tone changes: switch correctly.
- Tone lock: holds.
- Quick song switches: 25/25 in manual mode and 25/25 with Tone Automation.
- MIDI program changes: correct.
- Not checked by ear: how it sounds, and whether a VST actually changes patch on MIDI.

## Guard rails now in place

- `ARCHITECTURE.md`: module layout and 8 rules.
- `tests/boundaries.test.js`: enforces the rules in the CI fast lane.
- `scripts/hooks/pre-commit`: about 2 s, boundary rules plus safety nets. **Install once with
`npm run hooks:install`** (the automated install was blocked).
- `CLAUDE.md`: "Codebase Conventions" for future AI-assisted work.
- `CONTRIBUTING.md`: setup and test commands.

## Overrides

Phase 4, recorded in `.untangler/overrides.log`:

- **ESLint config:** replaced by `tests/boundaries.test.js`, so no new dependencies or CI
time.
- **Pre-commit install:** pending your `npm run hooks:install`.

## Deferred

The full list is in `.untangler/deferred.md` and `audit.json`. The next three by priority:

1. ~~MIDI PC mode wipes the chain on song load~~: **fixed after handover in `60218a7`**. A valid MIDI PC config now keeps the chain on song start; checked in the packaged app.
2. **One song load rebuilds the chain up to 3 times.** The rebuilds are the IIFE 2 preload
plus the IIFE 1 reapplies at 600 and 1500 ms. They're serialised now, but the work is
redundant and closes open VST editor windows each time.
3. **I-005: no lockfile.** CI uses `npm install`, so builds aren't reproducible. Commit a
`package-lock.json` and switch to `npm ci`. I-007, the `restartPython` race, is next
after that.

## Recommended cadence

About 30 minutes a week on `deferred.md`, one item per small commit. Keep
`npm run test:fast` and the pre-commit guard green. When a pattern starts repeating, add a
rule to `ARCHITECTURE.md` and `tests/boundaries.test.js` together.
52 changes: 52 additions & 0 deletions .untangler/RUNNING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# How to run this app

feedBack desktop (Rock Band edition): Electron main process (TypeScript), a vanilla-JS
renderer, a native C++/JUCE audio engine loaded as a Node addon, a sandboxed VST host, and
the bundled feedBack core (Python server + web UI) under `resources/slopsmith`.

Windows only for this engagement.

## Setup

- Node deps: `npm install` (runs `electron-builder install-app-deps`).
- Native engine: `npm run build:audio` (CMake + MSVC, see WINDOWS_BUILD_REQUIREMENTS.md).
Output: `build/Release/slopsmith_audio.node`. Already built on this machine; reuse it.
- Bundled core + plugins: `scripts/bundle-slopsmith.sh` with `SLOPSMITH_DIR` pointing at a
clone of `mattromano/feedBack@custom` (see `clone_slopsmith` in `scripts/build-common.sh`).
- `resources/python` and `resources/bin` are already bundled on this machine; reuse them.

## Run (the way the user tests: local packaged build, NOT `npm start`)

```bash
npm run build:ts && npx electron-builder --win --dir
release/win-unpacked/feedback.exe
```

Verified: `release/win-unpacked/feedback.exe` exists and ran this session (ASIO4ALL @256).

After any local build, restore `amps/`, `pedals/`, `racks/` into
`release/win-unpacked/resources/slopsmith/plugins/rig_builder/vst/` from
`%LOCALAPPDATA%\Temp\slopsmith\plugins\rig_builder\vst` (song tones store absolute paths
there). Close the dev/local copy before running the installed app: they share settings and
port 18000.

`npm start` / `npm run dev` also work (dev mode) but the user reported wrong guitar settings
in dev mode; prefer the packaged build for any check the user will hear.

## Test

Only targeted, source-reading tests on this machine. NEVER the full `npm test`.

Safe set (27 files, 162 tests incl. the Phase 2 safety nets, all passing, ~1.5 s):

```bash
node --test $(ls tests/*.test.js | grep -v -E "chain-mutation-storm|contract-check|live-pitch|ml-note-detection|multi-source|napi-arg-fuzz|config-bootstrap|config-reset")
```

Do NOT run locally (they load the native engine, grab ASIO devices and lag the PC):
chain-mutation-storm, contract-check, live-pitch, ml-note-detection, multi-source,
napi-arg-fuzz. The user's notes also exclude config-bootstrap and config-reset (they turn
out to use temp dirs only, but keep them out per the user's rule). Leave those to CI.

C++ unit suites (`tests/engine_units`, `tests/onset_lag`, `tests/chordscorer`, ...) build
with CMake; run individual test executables only, Debug builds, with a timeout.
29 changes: 29 additions & 0 deletions .untangler/STATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Codebase Untangler - State

**Started**: 2026-11-07T20:48:45.568531+00:00
**Current phase**: 5 (Handover)
**Branch**: refactor/untangle-2026-11-07
**Stack**: electron, typescript, vanilla-js-renderer, cpp-juce-node-addon, vst-sandbox, python-bundled-core

## Phase progress

- [x] Phase 0: Triage (done)
- [x] Phase 1: Audit (done)
- [x] Phase 2: Safety Net (done)
- [x] Phase 3: Refactor (done)
- [x] Phase 4: Hardening (done)
- [~] Phase 5: Handover (in_progress)

## Baseline

- Total LOC: 53008
- File count: 408
- Tests: 155 (155 passing, 0 failing)

## Overrides used

- 2026-11-09T16:14:35.080914+00:00 Phase 4: Lint config present - User override 2026-11-09: boundary rules enforced by tests/boundaries.test.js in the CI fast lane instead of ESLint (no new deps / CI runtime)
- 2026-11-09T16:14:35.160636+00:00 Phase 4: Pre-commit hooks configured - User override 2026-11-09: hook script committed (scripts/hooks/pre-commit); installing into .git/hooks was blocked by the permission check - user to run npm run hooks:install

---
*Auto-generated from state.json.*
Loading
Loading