# DESIGN.md — MEI Score Editor ## Vision A local-first editor for MEI scores that treats notation the way a text editor treats text: a semantic document you navigate with a caret, select in ranges, and manipulate with copy/paste and keyboard commands. It is explicitly **not** an engraver — Verovio does all notation rendering — and explicitly not a "restricted SVG editor" in the MuseScore sense, where the visual layout is the thing you manipulate. The editor serves three workflows, in priority order: 1. **Arranging** — mixing material measure-by-measure across staves and across files: select measures 5–8 of the sax staff in file A, paste them into the piano right hand of file B, transpose, adjust. 2. **Transcription correction (AMT)** — cleaning up MEI files produced by audio-to-MIDI pipelines (e.g. sound2midi exports), with the raw transcription visible as ghost piano-roll layers behind the score for reference. 3. **OMR correction and annotation** — fixing MEI produced by optical music recognition, with the source scan image displayed per measure via MEI facsimile zones, and navigation driven by model confidence scores. The unifying idea: the MEI document is the single source of truth; everything on screen is a projection of it; every edit is a reversible command against it. ## Non-goals The project does not implement music layout (spacing, beaming, collision avoidance, page breaks) — that is Verovio's job, always. It does not aim for full MEI coverage on day one; it targets Common Western Music Notation as produced by Verovio-compatible tools, and unknown MEI elements are preserved verbatim on round-trip rather than understood. It is not a playback/DAW tool; playback is a utility (audition what you edited), not a product pillar. It is not a web service — it is a local desktop application, though the core must remain runnable in a browser context since everything is web technology. ## Architecture overview The system has four layers with strict one-way knowledge: the UI knows the view model, the view model knows the document, the document knows nothing above it. **Document core.** An in-memory tree parsed from MEI, holding the semantic structure the editor understands (score structure, scoreDef/staffDef context, measures, staves, layers, events: notes, rests, chords, tuplets, plus control events like slurs, ties, dynamics, dirs) and opaque preserved subtrees for everything else. Every element keeps its `xml:id` (generated on import if missing) — ids are the universal currency of the whole system. The core exposes queries (effective clef/key/meter at any measure/staff, duration sums per layer, element lookup by id) and mutations exclusively through the command layer. The core is pure logic with no I/O and no DOM dependency, so it can later be extracted as a standalone library (batch pipelines, headless CLI, or a Rust/WASM rewrite behind the same interface). **Command layer.** Every mutation is a command object with `apply()` and `revert()` against the document, e.g. `InsertNote`, `DeleteRange`, `PasteFragment`, `TransposeSelection`, `SplitMeasure`, `ChangeKeySig`. Commands report the set of *dirtied regions* (measure × staff-context) they touched, which drives rendering invalidation. Undo/redo is a stack of command groups (a paste that also retimes neighbors is one undo step). Clipboard content is a serialized MEI fragment plus metadata (source staff context, duration total), so copy/paste works across editor instances and even into a text editor as readable MEI. **Render layer (Verovio, two modes).** *Edit view — tiled.* Each measure-window (one measure, or a small horizontal window of measures per system row) is rendered by Verovio as an independent SVG tile from a synthesized slice: the effective `scoreDef`/`staffDef` context at that point plus the measure content. Tiles are cached with the key `(hash of measure content, hash of effective staff context)`. An edit re-renders only the tiles whose key changed; a key-signature or clef change naturally invalidates all downstream tiles because their context hash changes — no special-case logic. The editor performs its own flow layout of tiles into rows (like line-wrapping glyphs), giving O(1) edit latency and trivial virtualization for very large scores. Known cosmetic costs, accepted by design: spacing is locally rather than globally justified, and cross-tile slurs/ties render as broken continuations (the same visual convention as system breaks, occurring more often). *Page view — full Verovio layout.* For proofreading and export fidelity, the same document is rendered through Verovio's normal paged layout (optionally windowed via Verovio's `select()` by measure range for large scores). Selection and caret state carry over between views because both are expressed in ids and model coordinates, never pixels. **Interaction layer.** Rendering is read-only; all interaction happens on an overlay above the tiles. Verovio preserves `xml:id` on output SVG elements, so hit-testing is: pointer event → nearest ancestor with an id → document element. The overlay draws the caret, selection highlights, ghost layers, and facsimile strips; it holds all event handlers. The SVG itself is never mutated except for class toggles on highlighted ids. In Phase 9 that draw hook became the `overlays` extension point (slice 10a): a plugin's layer over each tile, handed the tile measured — its box, a box per engraved event, each staff's lines with the context in force — in the tile's own pixels, draw-only above the SVG and below the caret, still never on the SVG; time comes from the timemap, which names the same measure ids. Since 1.2.0 the point also reserves room ABOVE the tiles — a band whose height a plugin asks for per tile at the tile's width, the host taking each row's tallest — which is where the facsimile's scans stand. **Conversion layer (added 0.0.2).** Import and export of non-MEI formats ride Verovio's own converters, in a worker separate from the render pool: the Humdrum-enabled build is ~4.6 MB heavier, so it loads lazily on the first conversion and the editing path never pays for it. Imports (MusicXML plain and zipped, ABC, Plaine & Easie, Humdrum) convert to MEI *once, on open*, arriving as new unsaved documents so a plain save can never overwrite the source with MEI — the single-format principle holds: after the door, everything is the MEI document. Exports are projections (written-score MIDI, SVG pages, Humdrum, PAE), plus one the editor computes itself: playback MIDI, the player's exact interpretation (expanded form, merged ties, articulation gates) serialized from the same timemap-derived data the player consumes. A format table in one module is the single source of truth, and a pinning test runs the real bundled toolkit over a sample of every entry, so the table can never promise what Verovio cannot do. Phase 9 did it in two halves: slice 8a lifted detection, the open dialog's accept list and both registration halves onto the host's `formats` registry, and slice 8b moved the converters, the Humdrum-enabled build and the table itself into `packages/plugins/formats`. The table is still the single source of truth — it lives in the plugin's manifest now, because the host must know which extensions are claimed before the plugin's code exists, and its pinning test moved with it. Detection stays the host's (a plugin declares extensions and root elements, never a sniffer), the open and save paths stay the host's, and SVG stays the host's export because it is engraving from the render pool rather than a conversion. The worker is the plugin's own: a converter is handed a file and returns MEI, and how it gets there is nobody else's business — so the 13.45 MB Humdrum asset is reached only from the plugin's chunk, and a session that never leaves MEI never downloads it. **Host and plugins (Phase 9, shipped as 1.0.0 on 2026-09-18).** The layers gained one: core → command → **host** → plugins. The host is `App.tsx` cut down to what every score needs — tiles, caret, selection, command execution, the tabs and the file paths, the UI areas — plus the *host services*: rendering, interaction geometry, MIDI, audio, the workspace, notices, settings and storage, each with a browser backend and a shell backend and each read-only or message-only to a plugin. Everything else is a plugin: it declares what it contributes in a manifest, its code is fetched on the first activation event it declared and not before, and turning it off deactivates it at once and disposes everything it registered. The measurement the phase was run for holds: from the folder view on, whole features were added with `App.tsx` flat — 2,991 lines before the folder view, 3,017 after the pitch reference, the 26 lines being the mount of the overlays layer inside each tile — and the host's diff for a new plugin is the two lines in `plugins.ts` that list it. **The contract is `@battuta/api` 1.0.0, and it is data.** A manifest names the plugin, the api range it needs (`engines.battuta`), the capabilities it uses (`midi`, `audio`, `workspace`), its activation events (`onStartup`, `onCommand:`, `onLane:`, `onFormat:`, `onView:`, `onPointer:coarse`, `onSettings:`; `onDocument:` and `onPlay` reserved, unfired for want of a consumer) and its contributions: commands, keybindings, slot items, lanes, exports, imports. At activation a plugin receives a context and nothing else: the document and the open documents, the editor state (caret, selections, view, entry mode) and the keymap as stores with `get` and `subscribe`; a query facade that answers plain JSON (pitch events of a block, the block of a selection, a syllable, a harmony text, the event at the caret, the timemap, the notation facts, the MEI text); `execute(message)`, the ONE mutation path — a serializable message the host maps to the real core command, so a plugin cannot mutate in a way the host has not published and undo integrity and byte-identical revert hold for plugin edits by construction; `registerCommand`, `notice`, `confirm`; a settings and a storage namespace; and the points below. Core owns the document's data types (caret, block, pitch, syllable, harmony kind, staff context) and the api re-exports exactly those, type-only, so they are declared once and nothing else of core reaches a plugin. The surface is pinned: `api-report.d.ts` prints every public shape, re-exports inlined, and the test refuses a change to it at the same version — a slice adds only what its brief lists, and a change the user approved gets a version bump. Nothing of the editor is importable by a plugin, and plugins import `@battuta/api`, `react` and their own files (Tone.js and the Verovio converter build are the two allowed exceptions); a failing test, not a convention, keeps it so. **The extension points, and the rule of their birth.** *Slots* — the two header rows, the status bar, the battuta menu — take an item at runtime or one DECLARED in the manifest, which the host renders before a byte of the plugin exists: an entry point cannot come from the code it loads (the on-screen keyboard's 🎹, the folder view's 📁, the pitch reference's 🎙, a lane's status-bar entry, an export's menu row are all declared; a runtime item with the same id takes the face over while the plugin runs, so a button can dim with its panel). Host controls in the bar are anchored and contributions grow into the free space beside them, so a plugin item appearing or leaving never moves a host control; the host's control look is one class. *Panels* — a bottom area and a side area; the side pushes the score right, the bottom pads it, neither covers it. *Lanes* — a text lane at the caret is a host-owned buffer, key protocol, floating editor and status-bar select; a plugin contributes only a `LaneSpec` (what it attaches to, how the caret advances, which keys commit, what "complete" means, how to read and how to commit as one message), so the host knows nothing about the text of any lane. *Overlays* — a layer over every measure tile in edit view, handed the tile measured (its box, a box per engraved event with a note's box its head, each staff's lines with the clef, key and meter in force) in the tile's own pixels, draw-only, above the SVG and below the caret; time is the timemap's, which names the same measure ids. *Formats* — a plugin declares the extensions its converter claims and the root elements that tell a MusicXML `.xml` from an MEI one, the host owns detection and the open dialog, and a converter is handed a file and returns MEI; an export is declared so the menu lists it before its code loads and the host saves what the producer returns. *Actions by id* — the key dispatcher is a table, a key selects an id, and `ctx.actions.run(id)` enters the same table under the same conditions, so an input surface can do nothing the host has not named and never forges an event. The rule that made each point: an extension point is added only when a feature being extracted needs it, built against that feature as its named consumer, and closed from outside by a plugin holding only `ctx` — a rehearsal that holds the session by closure proves the registry and not the contract (the formats export learned this the hard way). A point that has never had a consumer is presumed wrong: the side panel area had been mounted since slice 1 and sat under the header for five slices, because nothing had ever been put in it. **Where the lines fell.** Between core and a plugin: core owns the *element* — where a `` hangs, how a syllable is read, how a pitch is written undoably — and the plugin owns the *vocabulary* — what a chord symbol is, what may be typed, what a retrograde is; a command writes what it is given and the plugin's `complete` is what refuses, so turning the plugin off unloads its grammar with it. Between the host and a plugin, for sound: the host owns the app's one AudioContext (the unlock a gesture grants, the shared context, a clock conversion), the MIDI ports (inputs deduped and hot-plugged, virtual inputs, outputs behind one ordered sink whose panic releases everything), the timemap as a read-only render service and the notation facts; what the facts mean in sound — ties merged, articulations as release gates — and the instrument that plays it are a plugin's, because there can be several performers and the host should have no opinion. For files: the workspace service hands out the folders the user picked, scoped by the shell — it lists, reads and watches, and since api 1.1.0 (after the release) it writes only by renaming in place, which the host follows with any open tab, and by creating folders and files create-only, never overwriting — and its watcher also feeds the editor's own external-change guard. A platform capability with two backends is always a host service, never a plugin; a plugin owns no document state — what it persists about a score goes in MEI or a declared sidecar, everything else in its storage namespace — which is what makes "all plugins off" safe and byte-identical. **The hard rules have failing tests.** `plugin-boundaries`: the import allowlist, no `@battuta/core`, `@battuta/editor` or `react-dom`, no `window` / `document` / `navigator` / web storage global, no Verovio engraving call, a tiny manifest module, a README and a BUILDING present. `host-boundaries`: no synthesized input anywhere, and the set of host modules is an allowlist a slice may extend only with the brief that permits it. The bundle budget: the initial chunk has a ceiling, every plugin is a lazy `plugin-` chunk that the entry must not reach, and anything the host and a plugin share is named in `manualChunks`. The api report. The union keymap snapshot, byte-identical across every extraction. Each plugin's suite runs against a real host in memory with a fake session, and a browser e2e per plugin drives the real UI; the shell smoke runs on an in-memory data store so a test never touches the user's session. **Deferrals, kept possible.** No extension-host process, no marketplace, no third-party loading: the api is message-passing-friendly — stores, plain JSON, a message for every write — so all three remain a decision rather than a rewrite, the stance this document takes on Rust. A key for a new feature is earned when a user asks for one. A plugin ships two documents, `README.md` (how to use it) and `BUILDING.md` (how it was built, eight fixed headings, the dead ends the most valuable), the second written for whoever — person or agent — builds the next one; the conventions live in `packages/plugins/README.md`. **What shipped, and what it proved.** Eight plugins: the reflection cycle (the first extraction: no api addition), the on-screen keyboard (buttons are action ids, never forged keys), the lyrics and harmony lanes (the lanes point closed from outside, the grammar line drawn), playback (the performer and its instrument out of the host, the budget real), the format converters (a 13 MB asset fetched only when a conversion needs it, after one honest failure), the folder view (a whole feature with the host untouched) and the pitch reference (signal processing as a plugin: a recording decoded by the host's context, YIN, alignment to the score's own tempo, the trace on the tiles through the overlays point, two transports from one playhead that follows the caret). Next on the same points, planned against api surface only: the piano-roll reference layer and OMR correction as the second and third overlay consumers, and measure-by-measure alignment for the pitch reference. The slice-by-slice record — every decision, every dead end, every gap and who closed it — is CHANGELOG.md's 1.0.0 section. **What the editor does not take on trust (Phase 12, 2026-11-20).** A review of 1.3.0 found the editor's own promises broken where no gate looked, and the phase that closed them left five standing rules, each held by tests. *A redo is the edit it was.* `apply()` runs again on every redo, so a command that creates elements keeps the ids it minted the first time (`MintedIds`, internal to core) and gives the same ones, in the same order, to what it rebuilds — a later command, which addresses what the first made by id, then still finds it; a command object is one edit (a rule of use: no test holds it yet), a command identifies everything it creates itself, a revert puts an element's attributes back whole (their order is part of byte-identity), and a command that cannot complete takes back what it wrote before it throws. *A save does not lose work.* The shell writes beside the file and renames over it; a tab knows its file's time on disk and the stored session carries it, so the external-change guard holds across a restart — a restored tab with nothing unsaved takes its file's new content unasked, one with unsaved changes asks once, at restore; the session comes back document by document; a save marks the tab clean for the state it wrote. *The page is not trusted with paths.* The page draws what a score contains, so a command that trusts the page trusts every score: on the desktop the shell keeps its own record of what the USER pointed at — a file opened or saved through a native dialog or handed over at launch, a folder picked, with everything inside it — and its file commands answer for nothing else; only a dialog, a launch argument or a pick adds to it, a refusal sends the save to the save-as dialog, and nothing ever asks (a folder of hundreds of scores reads and saves as before). On the tablets the system's sandbox and pickers are that scope. *The engraving is filtered.* Verovio's SVG is put on the page as markup and can carry markup a score brought with it, so every engraving passes an allow-list once, where the render pool receives it — shapes and text, references only inside the drawing — and every shell has a content security policy behind it: its own scripts and WebAssembly, nothing written into the page, nothing off the machine. *The loader keeps what it reads.* Whitespace is text where it separates words (under `xml:space="preserve"`, in or below an element with text of its own, or with no line break) and indentation elsewhere, never in the music's own structure, whose children the commands address by position; a prefixed MEI file is read with plain names and saved with MEI as the default namespace; what XML cannot carry is not written. The gates: the corpus is in the repository and the properties run in CI on it — every command kind applied, reverted and redone to the byte; the saved file is compared with its SOURCE by a parser that is not the core's; three browser checks and the shell's Rust tests are in the push workflow; the shell's smoke and the tablets' probe say whether the policy is in force. The slice-by-slice record is CHANGELOG.md's. ## The editing model **Caret.** Caret position is model state, not pixel state: `(measure, staff, layer, event index | gap position)`. Left/Right move through events in the layer (crossing measure boundaries transparently); Up/Down in navigation mode move between staves/layers, and in pitch mode transpose the event under the caret by step; dedicated keys handle octave jumps, duration changes, accidentals. The caret is drawn by projecting model position onto the bounding box of the corresponding SVG element in its tile. **Selection.** Two selection kinds, both stored as model ranges plus a resolved id-set: *Event selection* — an ordered set of events within one layer (click, shift-click, shift-arrows). Used for transposition, duration edits, articulation edits. *Block selection* — a rectangle in the (measure-range × staff-range) grid, the primary tool for arranging. A block resolves to per-staff MEI fragments. This is the "cell range" model: measures are rows of a table, staves are columns, and arranging is spreadsheet-like block manipulation. **Copy/paste and rhythmic integrity.** MEI layers must sum to the measure's notated duration, so paste is duration-aware by construction. Pasting a block over an equal-shaped block replaces layer contents one-to-one. Pasting into a mismatched target follows explicit, user-visible policies: *replace-measures* (target measures' layer content is replaced wholesale; the default for arranging), *splice-at-caret* (insert events and push/truncate the remainder to fit, filling gaps with rests), or *overlay-as-new-layer* (add a second `` in the target staff). Every paste result is validated by the core's duration checker before the command commits; a paste that cannot be made valid under the chosen policy fails loudly rather than producing corrupt MEI. **Cross-file arranging.** Multiple documents open in tabs or split view; the clipboard is shared; block-paste across documents goes through a compatibility pass (meter mismatch → warn and offer replace-measures with retiming disabled; key mismatch → offer written-pitch paste or transposed paste). This is the workflow the project exists for, so it is exercised from Phase 3 onward, not bolted on at the end. **The on-screen keyboard (added 0.0.2).** Touch devices get the whole editor through a screen panel, and the design constraint is that it must never become a second input system to maintain: the panel is a *projection of the keymap*. Rebindable actions generate their buttons from the live keymap (a rebind or a new action appears on its own); buttons synthesize the KeyboardEvents the one window keydown handler already understands, so the editing logic has no touch-specific paths. Sticky ctrl/alt/shift latches carry real-keyboard semantics — a latched shift transforms `e.key` exactly as each layout's physical shift would — and actions that live a modifier away from another key have no button at all: the latch is the button, and keys relabel live to show what they will do. The piano enters pitches through the same path as Web MIDI (explicit pitch and octave, multi-touch chords, caret advance on release). Coverage tests hold the panel against the keymap in both layouts, so an unreachable action fails CI. Slice 4b (2026-09-14) made it a plugin, and in doing so replaced the synthesized-event mechanism: a button is an ACTION ID (`ctx.actions.run`), never a forged key, so the panel reaches exactly the finite list of actions the host names and nothing else — ctrl + a letter button can no longer arrive at ctrl+s. It projects the *union* keymap — core bindings plus every active plugin's, reactively, so a binding contributed later gets its button — the piano half registers with the host's MIDI service as a virtual input, entering through the same door as a hardware controller, and the 🎹 is a manifest-declared slot item the host renders before the plugin's code loads. The consequence the slice surfaced — a binding CONTRIBUTED by another plugin was in the union keymap but not in the host's action table, so the panel could caption what it could not run — was settled by making `run(id)` mean *this action*: an id no core rule has goes to the plugins' commands through the registry, past the same gates its key would meet, so what a projection can reach and what a key can reach are the same set. Three api additions came out of the same stop and are the host's answers to what a UI plugin needs: `ctx.activatedBy` (activation runs before the command that caused it, so a toggle must know which woke it), `onSettings:` (come back at startup for a user who left you in use, without `onStartup` costing everyone your code), and a runtime slot item that overrides a declared one's face (a static entry point becomes a stateful button once the plugin is active). Decided the same day, in-house: `run(id)` means *this action* — a plugin's command is runnable by id exactly when its key would have been, through the registry after the same gates; the list of ids is a store, so a surface follows a plugin turning on or off; a plugin reads why it was woken (`activatedBy`) and can ask to return at startup when its own setting says so (`onSettings:`), and a live slot item may take over its declared entry point's face while the plugin is active. **Document tempo (added 0.0.2).** The score's tempo is document state like the title — `@midi.bpm` on the scoreDef, set by an undoable command. Everything downstream is projection: Verovio's timemap bakes it into playback, the player's speed select is a multiplier on top, and page view engraves a synthesized `♩ = bpm` marking injected copy-on-write at serialization time, so the document tree itself is only ever read by the render path. ## Reference layers (ghost pitches behind the score) For transcription work, the editor displays non-notation pitch data time-aligned behind the notation: the raw MIDI stems from a sound2midi export, or another instrument's line for context while transcribing a new part. Mechanism: Verovio's timemap (`renderToTimemap` / per-tile equivalent) gives score-time → x-coordinate mapping inside each tile. A reference layer is a set of `(onset, offset, pitch, velocity, track)` events (imported from MIDI or JSON); per tile, events overlapping the tile's time span are drawn on the overlay canvas as translucent piano-roll bars, with pitch mapped to staff-line space using the tile's effective clef (so a G4 bar sits on the G4 staff position — the ghost layer and the notation share a vertical pitch axis, which is what makes visual comparison instant). Layers are per-track toggleable with the same solo/mute/color affordances as the sound2midi player. Alignment between reference time and score time is by beat position by default, with an optional per-section offset/tempo map for material that was transcribed freely. Phase 9 built the `overlays` point for this (slice 10a) and shipped a different first consumer: the pitch reference plugin (slice 10b, `packages/plugins/pitch-reference`) — a recording of a performance, its pitch detected with YIN and traced over the measures against the written pitch, aligned to the score's own tempo by an offset and a rate. The piano-roll layer above follows on the same point, with "zero edits outside the API package" as the phase's exit criterion either way; a panel carries the controls. ## OMR support (facsimile) MEI's ``/`` mechanism links elements to pixel regions of source images via `@facs`. When a document carries zones (or a sidecar JSON from the OMR pipeline provides them), the edit view shows the source image strip for each measure directly above its tile — scan on top, rendering below, correction in between. A confidence sidecar (per-element scores from the OMR/AMT model) drives triage: elements below threshold get a heat tint on the overlay, and a "next flagged" key binding jumps the caret through them in reading order. The editor can also write annotations back (`` or attribute-level flags) so corrections feed training data for the upstream models. After Phase 9 this is the second overlay plugin, planned against API surface only. Its first step shipped in 1.2.0 (2026-10-11) as `packages/plugins/pdf-reference`: a score's PDF and the OMR pipeline's per-page annotation files (a box per element, keyed by MEI id, in the pixels of the page at 254 dpi), each measure's scan in a BAND above its tile — the overlays point grew room above the tiles for it, the host reserving each row's tallest — and the caret's system in a panel strip; measures are matched by id when the score carries the annotated ids and in reading order otherwise. Zones in the MEI, the confidence heat tint and "next flagged" are the steps after it. ## Technology decisions **Language: TypeScript for the application, with the document core behind a strict interface.** The rendering target (SVG), the interaction surface (DOM/canvas overlay), Verovio's first-class bindings, and the author's existing codebase (React + Pixi + Verovio in midi-stroke) are all web-native; TS is the shortest path to a working editor. The document core and command engine are written with no DOM or framework imports and a narrow, serializable API, which keeps the door open to reimplementing that core in Rust/WASM later if profiling or reuse in AI pipelines justifies it. Rust is a deliberate *deferral*, not a rejection. **Shell: Tauri.** Local-first file access, small binaries, native menus/dialogs, and the frontend remains a plain web app that also runs in a browser for development and demos — since 0.0.2 the browser build is deployed alongside the docs (battuta.vibetuned.com/editor), so "runs in a browser" is a shipped artifact, not just a dev convenience. The shell also carries the safety net where file identity exists: an external-change guard compares disk mtimes at save time, while session restore (the open tabs persisted after every edit, restored on the next start) and dirty-tab close confirmation live in web storage and work in both builds. Distribution is release-automated: the macOS universal build is signed and notarized in CI, and publishing a release fans out to a Homebrew tap, a GPG-signed apt repository served from the docs site, and a winget version bump — one "publish" click, every channel. **Rendering: verovio (WASM npm package) + SVG tiles in the DOM + a canvas/Pixi overlay** for ghost layers, selection, and caret (reusing rendering experience from midi-stroke). Plain DOM SVG for tiles keeps id-based hit-testing trivial; the overlay is canvas because ghost layers can be thousands of bars. **Playback: Verovio timemap → Tone.js**, reusing midi-stroke's audio approach. Playback of the current selection or measure window is the primary use (audition an edit), not full-score performance. As shipped, one timemap drives both the audio and the notation highlight (they cannot drift), the sound is a sampled piano embedded in the bundle (local-first — no CDN), and the document shapes the performance: repeats/voltas/jumps through a synthesized expansion, tie chains as single held notes, articulations and slurs as release gates. Phase 9 made that split real: slice 7a lifted what a player needs and cannot make itself — the app's one AudioContext, the timemap and the notation facts as read-only queries, the highlight as a view service — and slice 7b moved the rest into `packages/plugins/playback`, which wakes when you open page view. The host owns the context, never an instrument: Tone.js, the sampled piano, the scheduler and every performance decision (which ties merge, what a staccato does to a release, how the two sinks are arranged) are the plugin's, so a second player can disagree with this one without touching the editor. The player's three settings moved with it, the playback-MIDI export is a `contributes.exports` entry the menu lists before the plugin loads, and the plugin writes nothing to the document — turn it off and page view has no transport row, the menu no export entry, and the 2 MB piano and 332 kB of Tone.js are never fetched at all (the initial chunk fell to 361 kB). **MEI handling: DOM/XML parse into the core's own tree** (fast native `DOMParser` in the renderer; `fast-xml-parser` or similar in headless contexts), serialization that round-trips unknown content byte-stably where possible. MEI version target: whatever current Verovio consumes (MEI 5.x), validated in CI against sample corpora from the OMR/AMT pipelines and from mei-friend's examples. ## Performance budget Editing latency (keystroke → updated tile on screen) target under 50 ms for typical measures, under 100 ms worst case; achieved by tile-scoped Verovio renders, cache reuse, and rendering dirtied tiles off the interaction path. Opening a 500-measure, 20-staff score should show the first screen in under 1 s (render only visible tiles; hydrate the rest lazily). Undo/redo is model-only plus tile swap, so effectively instant. The full-page proofreading view is allowed to be slow-ish for huge scores; it uses Verovio `select()` windowing when needed. ## Risks and mitigations The main technical risk is tile-context correctness: a measure rendered in isolation must receive the exact effective `scoreDef`/`staffDef` (clef, key, meter, transposition, staff lines, ongoing octave displacement) or it renders wrong pitches convincingly. Mitigation: the context resolver lives in the core with exhaustive tests, and the cache key includes the context hash so stale context cannot be displayed. Second risk: control events spanning tiles (slurs, hairpins, pedal) need consistent splitting; mitigation is to normalize them into per-tile segments at slice-synthesis time, with the page view as the ground truth for how they should ultimately look. Third risk: MEI round-trip fidelity for files from diverse tools; mitigation is preserve-unknown-verbatim plus a growing corpus test suite. The scope risk — drifting into engraving — is handled by policy: any rendering complaint is either fixed by changing the MEI/Verovio options or explicitly accepted; the project never draws notation.