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
Rename Songs→Rounds + new Music studio (Artists, Albums, Tracks, Ace-Step gen)
Context
The Songs page (/songs) is an a cappella composition/learning workbench (rounds, harmony parts,
recordings, score notation) backed by data/songs.json + /api/songs + server/services/songs.js. Its
real subject is musical rounds, so we're renaming it to Rounds (full-stack, per user decision).
Separately we want a new Music studio under the Create section for generating music with local OSS tools (Ace-Step first; room for Google Music / ElevenLabs / Suno later), organized into tracks/singles and albums, each with album art (AI-generated via the existing image-gen options or uploaded) and a designing artist persona managed like Authors.
Key discovery: PortOS already has most of the music backbone — server/services/pipeline/musicGen.js
(engine-agnostic ENGINES registry: musicgen + audioldm2, sidecar+venv gated, generateMusic()),
server/services/pipeline/musicLibrary.js (data/music/ shared library), venv provisioning in
scripts/setup-image-video.sh + server/lib/pythonSetup.js, and the imageGen/ provider-dispatcher
for album art. Authors (server/services/authors/{index,logic,db,file}.js) is the exact db-primary,
federated, soft-delete template to mirror for Artists/Albums/Tracks. So this is mostly composition of
existing patterns, not green-field.
Delivery: phased — 4 sequenced PRs off this branch, each independently reviewable/shippable.
Phase 1 — Songs → Rounds full-stack rename (PR 1)
Full-stack rename incl. data file + API. Songs are not federated today (absent from
schemaVersions.js, peerSync.js), so the rename has zero cross-install sync surface — no
schemaVersions bump needed (we keep Rounds local-only, matching Songs today).
Data migration — new scripts/migrations/0NN-rename-songs-to-rounds-data.js, modeled on
scripts/migrations/031-world-to-universe-data-rename.js (idempotent: skip if already migrated, warn if
both files exist):
data/songs.json→data/rounds.json- top-level key
songs[]→rounds[] - grep for cross-file refs (
songId, partner song ids, dashboard widget refs) and rewrite - add a
.test.jsbeside it (migrations carry tests here, e.g.074-*.test.js)
Server rename:
server/services/songs.js→rounds.js(STATE_PATH→data/rounds.json; rename exported identifierslistSongs→listRounds, etc., keep bounds constants)server/services/songsAI.js→roundsAI.jsserver/routes/songs.js→routes/rounds.js(mount/api/roundsinserver/index.js:547)server/lib/songCraftRef.js→roundCraftRef.js(consumed by guide)- nav manifest
server/lib/navManifest.js:34-35:nav.create.songs→nav.create.rounds,/songs→/rounds, labelSongs→Rounds, update aliases/keywords - rename
*.test.jssiblings; update migrations073-079,086imports (services/songs.js→rounds.js)
Client rename:
pages/Songs.jsx→Rounds.jsx,SongEditor.jsx→RoundEditor.jsx,SongsGuide.jsx→RoundsGuide.jsxservices/apiSongs.js→apiRounds.js(paths/songs→/rounds, fn names), updateservices/api.js:53App.jsx:52-54,295-297lazy imports + routes (/songs*→/rounds*)Layout.jsx:209sidebar link +:1134full-width prefix/songs/→/rounds/components/songs/dir +lib/song*.js+hooks/useSongTraining.js: keep internal names to limit churn, but rename the page-facing pieces and/songs/:idlinks inRoundStack.jsx,RoundEditor,RoundsGuide. (Component-internal "song" vocabulary may stay — user-facing label/route is the contract.)
Verify: cd server && npm test; cd client && npm test; boot (npm run dev), confirm /rounds
loads, create/edit/delete a round, /rounds/guide renders, ⌘K "rounds" navigates, and a fresh boot
runs the migration (rename a copy of data/songs.json back and watch it convert). Grep for stray
/songs / Songs references.
Phase 2 — Music page shell + Artist management (PR 2)
New Music page under Create + Artists (designing-artist personas), mirroring Authors 1:1.
Artists entity (db-primary, federated — mirror server/services/authors/):
server/services/artists/{logic,db,file,index}.js— copy authors, idartist-<uuid>; fields:name,bio,genre,musicalStyle(voice/production notes for gen prompts),physicalDescription+portraitStyle(for portrait render),portraitImageUrl(gen/upload/gallery). Reuselogic.jssanitize/build/patch/merge shapes verbatim.- Postgres
artiststable: add DDL toserver/scripts/init-db.sql(after authors768) and946) — sameensureSchema()inserver/lib/db.js(id/name/data JSONB/timestamps/deletedshape +idx_artists_live. server/routes/artists.js(mirrorroutes/authors.js); mount inserver/index.js.- Federation registration (mirror the author touch-points found in exploration):
schemaVersions.js(PORTOS_SCHEMA_VERSIONS.artists:1,RECORD_KIND_SCHEMA_CATEGORIES.artist),peerSync.js(PEER_SUBSCRIBABLE_KINDS,KIND_TO_CATEGORY, merge handler, asset manifest for portrait, syncability),syncWire.jssanitizer case, tombstone GC sweep. Auto-subscribe on create. client/src/services/apiArtists.js(mirrorapiAuthors.js, re-export fromapi.js).
Music page + Artist UI:
client/src/pages/Music.jsx— landing/studio: tabs or sections for Artists, Albums, Tracks (URL-param routed per convention, e.g./music/artists, not local tab state). Start with the Artists tab fully working; Albums/Tracks land in Phase 3.- Artist editor: master-detail copy of
pages/Authors.jsx(portrait viagenerateImage/uploadGalleryImage/GalleryImagePicker,useMediaJobProgress,buildHeadshotPrompt→buildPortraitPrompt). Reusecomponents/pipeline/AuthorPicker.jsx→ newArtistPicker.jsx. - Nav: add
App.jsxroutes,Layout.jsxCreate sidebar link (alphabetical: "Music" sits between "Mood Boards" and "Series Pipeline"), andNAV_COMMANDSentries innavManifest.js(nav.create.music,nav.create.music-artists, …).
Verify: server+client tests (add artists/*.test.js, routes/artists.test.js mirroring
authors); boot, create an Artist, generate + upload a portrait, ⌘K "music"/"artists" navigates,
navManifest.test.js + palette.test.js green.
Phase 3 — Albums + Tracks data model, album art, library + playback (PR 3)
Albums & Tracks (db-primary, federated — same authors template):
server/services/albums/— idalbum-<uuid>; fields:title,artistId(FK) +artist(denormalized name, like series→author),description,genre,releaseYear,coverImageUrl(gen/upload),trackIds[](ordered). DDL + ensureSchema + routes + federation (cover image as synced asset) +apiAlbums.js.server/services/tracks/— idtrack-<uuid>; fields:title,albumId?(null = single),artistId,lyrics,prompt,engine,modelId,durationSec,audioFilename(points intodata/music/viamusicLibrary.js),order. DDL + ensureSchema + routes + federation (audio file as synced asset, mirroring author headshot-filename asset path) +apiTracks.js.- Reuse
server/services/pipeline/musicLibrary.jsfor the actual audio files (data/music/); tracks store the library filename, not bytes.
Album art — reuse image-gen wholesale: /image-gen/generate (cover prompt from album
title+genre+artist style, e.g. 1024×1024) and /image-gen/upload + GalleryImagePicker, storing
coverImageUrl exactly like author headshots. No new image infra.
Album/Track UI (in Music.jsx): album grid + detail (cover, artist via ArtistPicker, ordered
track list, add/reorder/remove), track editor (title/lyrics/prompt/engine/duration + audio player).
Reuse formatTimecode/formatDurationMs from client/src/utils/formatters.js, useLockToggle,
existing audio <audio> playback pattern from AudioStage. Upload audio via the /api/uploads or
music-library upload path.
Verify: tests for albums/tracks services+routes; boot, create an album under an artist, generate + upload cover art, add tracks (upload an mp3/wav), reorder, play back in-page; confirm album/track records federate (asset manifest includes cover + audio).
Phase 4 — Ace-Step engine + real generation wired to Tracks (PR 4)
Add Ace-Step as a third ENGINES entry in server/services/pipeline/musicGen.js — the registry is
already engine-agnostic, so this is additive. Ace-Step is full-song (prompt + lyrics + duration),
richer than the background-music sidecars, so extend the sidecar contract with an optional --lyrics
flag (musicgen/audioldm2 ignore it).
- Python sidecar
scripts/generate_acestep.py— mirrorgenerate_musicgen.py/generate_audioldm2.pycontract:--model --text [--lyrics] --duration --output --runtime-dir, emitSTAGE:progress lines- final
RESULT:{json}(path, durationSec), write WAV to--output. Ace-Step supports Apple Silicon (MPS) per upstream (https://github.com/ace-step/ACE-Step-1.5).
- final
- Venv provisioning — add
INSTALL_ACESTEP=1block toscripts/setup-image-video.sh(cloneace-step/ACE-Step-1.5, create~/.portos/venv-acestep, pip install its requirements, model weights lazy-download on first run via HF, gated byhfTokenEnv()), and resolver constants inserver/lib/pythonSetup.js(ACESTEP_VENV_*,ACESTEP_RUNTIME_DIR,resolveAcestepPython). - Registry entry in
musicGen.js:ENGINES.acestep(models/duration window/scriptPath/resolver/ installEnvINSTALL_ACESTEP).generateMusic({ engine:'acestep', prompt, lyrics, durationSec })works through the existing gate (503 with install hint when venv missing — exactly like FLUX.2). ThreadlyricsthroughbuildSidecarArgs. - Standalone generation route — new
server/routes/music.jsPOST /api/music/generate(the pipeline path is audio-stage-internal; the Music studio needs its own). CallsgenerateMusic, lands the WAV inmusicLibrary, and on success creates/updates a Track with the engine/model/lyrics/prompt metadata +audioFilename. Long renders: reusemediaJobQueue(newkind:'music') for async + SSE progress, mirroring image-gen — or run inline with the existing AbortSignal cancel if acceptable. - UI in the Track editor: engine picker (musicgen/audioldm2/acestep), readiness gate via
isEngineReady/a/api/music/enginesstatus endpoint (show "RunINSTALL_ACESTEP=1 …" hint when not provisioned), prompt+lyrics+duration inputs, Generate button → SSE progress → attach audio to track.
Verify: unit-test buildSidecarArgs lyrics threading + engine registry (no Python needed, like
musicGen.test.js); on the M5 Max box (128GB) run INSTALL_ACESTEP=1 bash scripts/setup-image-video.sh,
generate a real short track from the Music page, confirm WAV lands in data/music/, plays back, and the
Track record persists with correct metadata. Confirm graceful 503 + install hint when venv absent.
Cross-cutting notes
- CLAUDE.md compliance: every new
apiX.js/lib module → barrelindex.js+README.mdrow (enforced byindex.test.js); all route inputs Zod-validated (POST + PUT/PATCH.partial()); new pages → both<Route>andNAV_COMMANDS; sidebar stays alphabetical; new entities followdocs/STORAGE.mddb-primary classification (Postgres, not newdata/*.json); schema parity when adding fields. - Tests: never run
*.db.test.jsagainst realportosDB — usenpm run test:db(→portos_test). Mirror authors'file.jsbackend so service tests run without Postgres. - Federation schemaVersions: Artists/Albums/Tracks each get their own per-category gate (
artists,albums,tracks) so a newer peer can't corrupt an older one; follow the authorsv1precedent comment block inschemaVersions.js. - Run
/simplifyafter each phase's substantive work; commit + open PR per phase (rebase-merge, no squash, no AI attribution per global instructions). - Defer/PLAN.md: future engines (Google Music/ElevenLabs/Suno as
externalHTTP providers mirroringimageGen/external.js) are explicitly out of scope here — capture as a PLAN.md item after Phase 4.