feat(rigs): persist chain routers + add Garcia two-board split rig

Add ChainRouter persistence so routed multi-board rigs survive save/load —
previously captureState/loadRig only handled plain boards, so any A/B router
rig was silently lost on save (a latent gap this fixes for user rigs too).

- New ChainRouterState (Codable): each router's two linear branches as
  [PedalState] plus splitter branch levels and merger output levels.
- ShoeGazeState gains an additive `routers` field decoded with
  decodeIfPresent (nil for old rigs) — no format-version bump; routerless
  rigs stay byte-identical (nil, not []).
- captureState snapshots routers; rebuildAllBoards reconstructs each via
  makeChainRouter/addTo{A,B}/finalize and restores the blend.

FactoryRig gains a session-scoped builder variant (FactoryRigBuild enum) so
a rig can create its own boards/routers; makeEntries branches on it.

Ships the Garcia OBEL Clean/Effects Split: an effects/lead board (octave,
envelope filter, overdrive, phaser, delay, amp) vs a clean direct board,
selectable via the router — showcasing the multi-board capability.

Tests: full router capture -> JSON -> load round-trip with structure and
branch-level assertions plus a render check, backward-compat (no routers
key when routerless), and the Garcia rig via the factory load+render suite.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-09 13:19:42 -07:00
parent 75b99a547b
commit 7dccf596f4
8 changed files with 348 additions and 18 deletions
@@ -71,9 +71,12 @@ struct FactoryRigLibraryTests {
for (entry, rig): (RigEntry, FactoryRig) in zip(entries, rigs) {
#expect(entry.id == rig.id, "entry id must be the rig's stable id")
#expect(entry.name == rig.name)
#expect(entry.state.boards.count == 1, "\(rig.name) should build exactly one board")
let pedalCount: Int = entry.state.boards.first?.pedals.count ?? 0
#expect(pedalCount >= 3, "\(rig.name) should build a non-trivial chain")
// A rig builds either plain boards or a router (or both) — never nothing.
let routerStates: [ChainRouterState] = entry.state.routers ?? []
#expect(!entry.state.boards.isEmpty || !routerStates.isEmpty, "\(rig.name) built nothing")
let boardPedals: Int = entry.state.boards.reduce(0) { $0 + $1.pedals.count }
let routerPedals: Int = routerStates.reduce(0) { $0 + $1.boardA.count + $1.boardB.count }
#expect(boardPedals + routerPedals >= 3, "\(rig.name) should build a non-trivial chain")
}
// Stable ids: re-seeding yields identical ids (so a re-seed overwrites in place).