Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

docs([issue-2790]): log issue #2790 to changelog

[._.]/ Adam Eivyd2790c3edb67
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 4236922deb..df5378fda1 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -60,6 +60,8 @@
- **[issue-2493] Extracted a shared lookahead-transport factory for the three synth players.** The two lead-sheet score players (`createScorePlayer`/`createMultiScorePlayer`) and the MIDI preview player (`createMidiPlayer`) carried three near-verbatim copies of the same lookahead-scheduler state machine — the suspended-context resume with its `playToken` teardown-race guard, `stopNodes`/`clearTick` teardown, the `onended`-pruning node tracking, and the `pause`/`stop`/`finish`/`seek`/unclamped-`position` sequences — so a fix to the token-guard race or teardown semantics needed three application sites across two files. That machinery now lives once in `createLookaheadTransport` (`client/src/lib/lookaheadTransport.js`), which owns the clock and node lifecycle; each player supplies only its scheduling + playhead callbacks (`scheduleWindow`, `prepare`, `seekCursors`, `onStop`/`onEnded`/`onTeardown`) and stays a thin scheduler over it. The shared `SYNTH_TIMING` lookahead constants moved there too (single source, no circular import). Behavior is unchanged — all existing `scorePlayback`/`midiPlayback`/`metronome` suites stay green — and the two score/race test files were retrofitted onto the shared `fakeAudioContext.js` helper (extended with a suspended-resume mode) to drop their hand-rolled Web Audio fakes. (`client/src/lib/lookaheadTransport.js`, `client/src/lib/scorePlayback.js`, `client/src/lib/midiPlayback.js`, `client/src/test/fakeAudioContext.js`)
+- **[issue-2790] Collapsed the residual per-voice scheduler duplication between the two score players.** Follow-up to #2493: after the shared `createLookaheadTransport` extraction, `createScorePlayer` and `createMultiScorePlayer` (`client/src/lib/scorePlayback.js`) were thin schedulers over the transport but still carried duplicate scheduler-tick and cursor-positioning bodies — the multi player's per-voice window was the solo player's window wrapped in a `for (const voice of voices)` loop, and both positioned their resume cursors with the same `findIndex(e => e.startSec + e.durSec > offset)` walk. That shared walk now lives in three small helpers (`makeVoiceCursor` / `positionVoiceCursor` / `advanceVoiceWindow`) both players call, so each player only wires up its own distinct pieces: the tone destination (context output vs. per-play master bus), the `onNote` signature (`index` vs. `partId, index`), and — the multi player only — the per-voice end-notify that clears a short voice's playhead when it finishes. Behavior is unchanged and all `scorePlayback`/`midiPlayback` suites stay green. (`client/src/lib/scorePlayback.js`)
+
- **[issue-1893] Decided and documented `atomicWrite`'s symlink semantics.** Settled the design question deferred from the #1837 review: when `atomicWrite`'s target is a symlink, the temp+rename deliberately REPLACES the link with a regular file rather than following it to the backing file — the standard atomic-write contract (git, dpkg, rsync, `os.replace` all replace the link), and following it would reintroduce the non-atomic in-place truncate the helper exists to eliminate. The decision (and the reasoning behind not following or rejecting) is now recorded in the helper's JSDoc, and a test pins the replace-not-follow behavior so it can't silently regress. No runtime behavior changed — PortOS ships no symlinked data files — this closes the open question rather than altering the writer. (`server/lib/fileUtils.js`, `server/lib/fileUtils.test.js`)
- **[issue-725] Brain entity stores split to per-record `collectionStore` layout.** Every Brain store (people, projects, ideas, admin, memories, links, buckets, journals, inbox, songs) moved off its monolithic `data/brain/<type>.json` file — where every create/update/delete rewrote the whole file and every read parsed all records behind a 2s cache and one global write mutex — onto the per-record `collectionStore` shape (`data/brain/<type>/<id>/index.json`), read through to disk with per-id write queues so writes to different records no longer serialize. This is proactive scale headroom: PortOS is distributed and a user's federated peers accumulate Brain data on their own schedule, so stores are prepared for size before any one install hits the whole-file-rewrite cliff. Federation is untouched — Brain federates strictly per-record through the storage API seams, so the on-disk container shape is orthogonal to the wire format (no schema-version bump, no wire-category change), and in-place tombstones are preserved through the split so no last-writer-wins delete marker is lost. Migration 200 splits existing installs (legacy files renamed to `.bak-200`, never deleted; idempotent and recovery-safe), and the shared split skeleton (`makeSplitMigration`) gained a `map` mode for the object-keyed `{ records: { <id>: rec } }` shape alongside the existing array mode. Every exported `brainStorage` function keeps its signature and behavior, so all runtime consumers and the whole reconcile/anti-entropy path are unchanged. (`server/services/brainStorage.js`, `scripts/migrations/200-split-brain-stores-to-per-record.js`, `scripts/migrations/_lib.js`)