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([mediacollections-deterministic-loadone-fastpath]): remove from PLAN.md and log to changelog

[._.]/ Adam Eivy331fbc09c790
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index db9d75bd2c..58c2f82a6c 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -27,6 +27,7 @@
- **[media-job-progress-persist-debounce-count-test]** Hardened the test suite so the media-job progress-save coalescing can't silently regress to a per-event disk write.
- **[unify-media-job-sse-hook-imagegen-videogen]** Image Gen and Video Gen now share one live-render progress subscriber, consolidating duplicated streaming code with no change to behavior.
- **[importer-progress-hook]** The Importer's live analyze-progress checklist now runs on a shared, tested progress hook instead of page-local socket wiring — no change to behavior.
+- **[mediacollections-deterministic-loadone-fastpath]** Universe/series media-collection lookups now resolve their linked bucket in one direct read instead of scanning every collection, trimming the work done on each cross-machine sync push (no user-facing change).
## Fixed
diff --git a/PLAN.md b/PLAN.md
index fcee1ba00e..f2e42282d5 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -25,7 +25,6 @@ Claimable, well-specified, no decision needed — `/claim`-able. Unordered.
- [ ] [conflict-journal-push-flush-coalesce] **Coalesce per-push base-hash flushes.** `pushRecordToPeer` (`server/services/sharing/peerSync.js` ~947) stamps a base hash and calls `flushBaseHashes()` per pushed universe/series, so a large push loop rewrites `sync_base_hashes.json` once per record. A `setTimeout`-based debounce was tried and reverted (the unref'd timer leaked into `peerSync.test.js`'s settle-waits and made the suite flaky). A safe coalescing approach (microtask/`queueMicrotask` batch within a single push burst, or a test-injectable scheduler) could land the optimization without the timer-leak flake. Low priority.
- [ ] [conflict-journal-base-hash-prune] **`sync_base_hashes.json` grows unbounded.** `server/lib/conflictJournal.js` seeds a base hash per synced universe/series and never prunes entries for deleted/tombstoned records. Tiny per-entry, but a long-lived install accumulates dead keys. Add a sweep (drop keys whose record no longer resolves) to the tombstone GC path.
- [ ] [makesplitmigration-shared-factory] **Extract a shared `makeSplitMigration` factory into `scripts/migrations/_lib.js`.** The monolithic→per-record split scaffolding (`fileExists` / `readJsonStrict` / `readJsonTolerant` / `writeJson` + the `withFileTypes` already-split scan + the gate1/gate2/recovery/split/stamp/backup body) is now copied verbatim across **four** migrations: `034-split-universe-builder`, `035-split-pipeline-issues`, `036-split-pipeline-series`, `059-split-media-collections`. They differ only in `{ typeDirName, legacyFilename, backupSuffix, typeSchemaVersion, typeLabel, recordsKey, idPattern, buildConfig }` (e.g. `config: { runs }` for universes vs `config: {}` for collections). `_lib.js` already houses cross-migration families (`makePromptReplaceMigration`, layout helpers) — add a split family there and collapse the four to ~15-line config blocks. Pre-existing duplication; 059 was the 4th copy. Own change + test surface, so deferred out of the migration PR.
-- [ ] [mediacollections-deterministic-loadone-fastpath] **`findCollectionByUniverseId` / `findCollectionBySeriesId` (and the `findOrCreate*` provisioners) `loadAll()` where a deterministic `loadOne(uc-/sc-<id>)` fast-path would usually hit.** `server/services/mediaCollections.js` — these scan every record by stamp to also catch legacy unconverged collections at random ids. peerSync calls the lookups per outbound push (`peerSync.js:608/1108/1175`), so a `loadOne(linkedCollectionId({...}))`-first / `loadAll`-fallback would cut the warm path to O(1). Modest under single-user load; kept as a faithful scan for now.
- [ ] [mediacollections-parallel-merge-prune] **Parallelize the multi-record loops in `mergeMediaCollectionsFromSync` and `pruneTombstonedCollections`.** Both iterate distinct record ids in a sequential `for await` over `queueRecordWrite` — different ids use different per-record queues, so a bounded `Promise.all` (use the shared bounded-concurrency mapper) would fan out the snapshot-apply batch (`dataSync.js` passes a full collections list) and the GC sweep. Most peer pushes carry a single record so the realized win is the snapshot/GC paths only; low priority.
- [ ] [commands-centralized-parser] **`commands.js` re-implements command parsing with a naive `split(/\s+/)` instead of the centralized quote-aware parser.** `server/services/commands.js:28` splits on whitespace (breaks quoted args) and only imports `ALLOWED_COMMANDS`/`DANGEROUS_SHELL_CHARS` from `commandSecurity.js` — not its `parseCommandArgs`/`validateCommand`. Route through `validateCommand` so allow-listing, dangerous-char checks, and quote-aware arg parsing are one verified step. Verified (gemini IMPROVEMENT).
- [ ] [worktree-remove-helper] **Extract the repeated "worktree remove --force → on-fail rm + prune" dance into one helper.** The pattern is now inlined in 4 spots in `server/services/worktreeManager.js`: `removeWorktree`, `reapMergedWorktrees`, `cleanupExternalRepoWorktrees`, and `removePersistentWorktree`. Extract `forceRemoveWorktreeDir(repo, worktreePath, label)` and route all four through it.