v1.4.0 release: live-coding scratch editor, interpreted Graph DSL, ClosureSynthesizer + SampleLoop

This commit is contained in:
2026-07-20 10:02:49 -07:00
parent 560724d116
commit 38d2107f64
104 changed files with 14471 additions and 105 deletions
+23 -1
View File
@@ -2,7 +2,7 @@
Phases are ordered by dependency. Each phase should have tests before moving on.
Completed phases (1–34, 36–95, 96a, 97, 99, 101, 102a, 102b, 103, 104a, 104b, 104c, 104d, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 159, 160, 161, 162, 163, 170, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 196, 197, 198, 88b, MCE-A, MCE-B, 85.5, 86.75a, 86.75b, LyrebirdBufferUpdates, 77-review-cleanup, 71b, 49b, 46, iOS-1–iOS-4, Score Phases A–D, 204, 222, GC-1–GC-9B, GC-11, GC-12, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239) are archived in `docs/01-completed-working-order.md`.
Completed phases (1–34, 36–95, 96a, 97, 99, 101, 102a, 102b, 103, 104a, 104b, 104c, 104d, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 159, 160, 161, 162, 163, 170, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 196, 197, 198, 88b, MCE-A, MCE-B, 85.5, 86.75a, 86.75b, LyrebirdBufferUpdates, 77-review-cleanup, 71b, 49b, 46, iOS-1–iOS-4, Score Phases A–D, 204, 222, GC-1–GC-9B, GC-11, GC-12, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, LC-1, LC-2, LC-3, LC-4, LC-5, LC-6, LC-7) are archived in `docs/01-completed-working-order.md`.
## Phase Completion Checklist
@@ -241,11 +241,33 @@ Full details in `docs/01-completed-working-order.md`.
| 237 | Doc-example fallout — fixed `GettingStarted`'s flagship example (`doneAction`/`.freeEnclosing` never existed), made entry examples self-contained (coverage 382/1458; the original `try` rot now fails), harness `throws` wrapper + narrowest-first preambles, and pinned `DistributionKind`'s golden values (3 of 4 had drifted). | 5465 |
| 238 | Doc-rot gap pass — extended the DocC gate to `LyrebirdUI` (was entirely unguarded; 0 warnings), implemented the `member` preamble (396 → 426 fences), confirmed zero remaining dead API forms, and established that the residual 1032 fences are continuation fragments no preamble can fix. | 5477 |
| 239 | Doc checks in the review process — `check-doc-impact.sh` reports which docs a diff's public-API changes may have invalidated (validated against the commit that caused the original `engine.add` rot). Reports, never fails; suppresses refs the compile guard already covers; wired into `/lyrebird_review` step 2b. | 5477 |
| LC-1 | Re-eval readiness signal (`ReevalState`) — `LyrebirdScratchModel` publishes `.empty`/`.clean`/`.dirty`/`.compiling`/`.failed` + `canEvaluate`; view status badge; menu Run gated on `canEvaluate` via `NSMenuItemValidation`. Folded in: `discoverSPMModuleMaps` fixes snippet `import LyrebirdSynth` under bare `swift build`/`swift test` (was Xcode-only). LiveCompile sub-package 47/47. | 5497 (+47 sub-pkg) |
| LC-2 | Bare-graph play ergonomics — new public `ClosureSynthesizer` (`SynthesizerBase` from a closure, no `build()` override); `SnippetContext.play { }` forwarder; scratch placeholder leads with the one-liner. | 5502 (+48 sub-pkg) |
| LC-3 | Named slots / `Pdef`-style hot-swap — `LiveSession` name→synth slot map (persists across non-additive re-eval); `SnippetContext.play(slot:) { }` replaces one voice in place; `clearSlot`/`clearSlots`; Clear Synths full-reset. | 5502 (+54 sub-pkg) |
| LC-4 | On-beat swap (latency masking) — `SwapQuantize` (`.immediate`/`.nextBeat`/`.nextBar`); quantized slot swaps schedule add+remove on the next `LyrebirdClock` boundary (orphan-safe via per-slot add-time); `ReevalState.queued(untilBeat:)`. | 5502 (+63 sub-pkg) |
| LC-5 | Module-cache prewarm (time-to-first-sound) — measured: warm compile ~0.12s, cold `.pcm` build ~2–3s; `LiveCompiler.prewarm`/`LiveSession.prewarm()` warm swiftc's default cache off-main at `onAppear`; auto-annotate dropped (measured worthless); dedicated `-module-cache-path` reverted (dlopen cast-crash). | 5502 (+67 sub-pkg) |
| LC-6 | Scratch editor syntax highlighting — `ScratchSwiftTokenizer` (pure UTF-16 lexer) + `ScratchSyntaxHighlighter` paints token colors onto `NSTextStorage`; `isRichText`, re-highlight per edit. Completion (SourceKit-LSP) deferred. | 5502 (+80 sub-pkg) |
| LC-7 | Session reset valve + snippet-memory accounting — `LiveSession.resetAll()` (panic clear) + `loadedSnippetCount`; dlclose rejected as unsafe (dangling Swift conformance-cache pointers). User-facing memory UI revisit deferred to end of arc. | 5502 (+83 sub-pkg) |
---
## Upcoming Phases
### LiveCompile / Scratch Improvements (LC-1 … LC-8)
Two tracks. **Track A** (LC-1…LC-7) polishes the existing Swift-compile scratchpad — full Swift power, macOS-only, floors at a few-hundred-ms warm eval (Swift has no supported in-process JIT). **Track B** (LC-8) is a separate bet: an interpreted Generator-graph DSL for instant, no-dylib, no-leak evaluation. iOS reach is a *bonus* of Track B, deprioritized as a driver.
Cross-cutting note: the async off-main compile path is **already implemented** (`LyrebirdScratchModel.run` awaits `LiveSession.compileAndRunAsync`, gated by `isCompiling`). So the near-term work is readiness signalling + ergonomics, not un-freezing.
- **LC-1 — Re-eval readiness signal.** ✅ Complete (see `docs/01-completed-working-order.md`). `ReevalState` published by `LyrebirdScratchModel`, view badge, menu Run gating on `canEvaluate`; folded in the `discoverSPMModuleMaps` bare-SPM compile fix.
- **LC-2 — Bare-graph play ergonomics (time-to-first-sound).** ✅ Complete (see `docs/01-completed-working-order.md`). Public `ClosureSynthesizer` (core) + `SnippetContext.play { }` forwarder; placeholder leads with the one-liner.
- **LC-3 — Named slots + hot-swap (`Pdef` analogue).** ✅ Complete (see `docs/01-completed-working-order.md`). `context.play(slot:) { }` replaces one voice in place; per-name tracking in `LiveSession` (persists across non-additive re-eval); `clearSlot`/`clearSlots`.
- **LC-4 — On-beat swap (latency masking).** ✅ Complete (see `docs/01-completed-working-order.md`). `SwapQuantize` + `LiveSession.swapClock`/`swapQuantize`; quantized slot swaps schedule add+remove on the next `LyrebirdClock` boundary (orphan-safe); `ReevalState.queued(untilBeat:)`.
- **LC-5 — Module-cache prewarm.** ✅ Complete (see `docs/01-completed-working-order.md`). Measurement showed the cost is purely the cold `.pcm` build; `LiveSession.prewarm()` warms swiftc's default cache in the background at session start (first ⌘↩ ~0.12s vs ~2.2s). Auto-annotate lever dropped — measured to shave nothing at warm.
- **LC-6 — Editor UX.** ✅ Syntax highlighting complete (see `docs/01-completed-working-order.md`): `ScratchSwiftTokenizer` + `ScratchSyntaxHighlighter`, re-highlight per edit.
- **LC-6b — Code completion (SourceKit-LSP).** ✅ Complete (see `docs/01-completed-working-order.md`). `SourceKitLSPClient` drives the toolchain's `sourcekit-lsp` over stdio; `SnippetCompletionService` resolves snippet symbols via a wrapped-snippet workspace + generated `compile_commands.json`; the editor pops the standard completion window on `.` (Swift mode only). Manual-invoke shortcut is a possible follow-up.
- **LC-7 — Dylib leak mitigation.** ✅ Complete (see `docs/01-completed-working-order.md`). Reset valve (`LiveSession.resetAll()` + `loadedSnippetCount`; refcount-gated `dlclose` **rejected as unsafe** — dlopen registers Swift type metadata + conformance records into process-global caches that dlclose leaves dangling → crash even with zero live instances). **User-facing revisit done**: the editor mirrors `loadedSnippetCount` as a "snippets: N" count (orange past a 50-dylib threshold) and shows a warning banner nudging a restart or a switch to the leak-free Graph DSL mode; `snippetMemoryHint` is a unit-tested pure boundary.
- **LC-8 — Interpreted Generator-graph DSL (Track B).** ✅ Complete (see `docs/01-completed-working-order.md`). Cross-platform `LyrebirdGraphDSL` target + `DSLBuiltin`/registry code-genned from generator sources (`Tools/DSLRegistryGen`, `scripts/generate-dsl-registry.sh` + `--check`; **304 builtins** = 165 audio + 121 control + 18 buffer). Language: `DSLLexer`→`DSLParser`→AST→`DSLGraphBuilder`→`DSLInterpreter.evaluate` — instant, no swiftc, no dylib, no leak. Rate suffix is the exact Swift name (`OscSin.Control`) for paste-compatibility; buffer resources via a `DSLValue`/`DSLResourceResolver` contract. Editor (8d): status-bar mode toggle in the scratch view runs the buffer through `LiveSession.runGraphDSL` on the same track/slot machinery, DSL errors in the same gutter. (Bus/URL/closure/demand builtins intentionally out of DSL scope — host-level or Swift-path.)
## Deferred / Future