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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
docs([data-versioning-centralize-cosagents-settings]): remove from PLAN.md and log to changelog
[._.]/ Adam Eivyce76370e4d2d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 74d1a05a7e..ece7e7dd60 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -29,6 +29,7 @@- **[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).+- **[data-versioning-centralize-cosagents-settings] Saving settings is now crash-safe and serialized.** `settings.json` is written through the shared atomic temp-file/rename writer and overlapping saves run one at a time, so a mid-write crash can no longer truncate the file and two near-simultaneous settings changes can no longer clobber each other (no user-facing change).## Fixeddiff --git a/PLAN.md b/PLAN.mdindex efa3e20f5f..c1df198063 100644--- a/PLAN.md+++ b/PLAN.md@@ -8,7 +8,6 @@ Claimable, well-specified, no decision needed — `/claim`-able. Unordered.- [ ] [setup-browser-canary-headless] **Managed-browser headed/headless default.** `data.reference/browser-config.json` ships `"headless": true`, but `browser/server.js`'s header comment says "Default headed" and opting into Canary at setup currently runs it invisibly. **Decision (resolved 2026-05-30): default HEADED.** The whole purpose of the custom-Chrome-binary feature is a *visible, differentiated* browser, so headless-by-default defeats it. Flip the seed to `"headless": false` AND set `config.headless = false` in `scripts/setup-browser.js#applyCanaryToConfig` (this also closes item (c) of `[chrome-canary-followups]`). Ship a one-time migration that flips the seed value only where the installed config still matches the old shipped hash; leave user-customized values alone.- [ ] [setup-data-import-drift-tables-from-migrations] **`setup-data.js` should import drift tables from each migration file.** `SHIPPED_PROMPT_OLD_MD5` + `SHIPPED_PROMPT_NEW_MD5` in `scripts/setup-data.js:139-196` manually mirror the `ACCEPTED_OLD_MD5` + `NEW_SHIPPED_MD5` exports each migration file already maintains. The mirror is hand-edited every time a migration ships and is the most likely place to drift. After `[backport-pre-023-migrations-to-_lib]` lands, every prompt-replace migration will export those constants — `setup-data.js` can build the tables by sweeping/glob-importing the migration files and removing the mirror entirely. Single source of truth, no hand sync.-- [ ] [data-versioning-centralize-cosagents-settings] **Centralize `cosAgents.js` + `settings.js` on `atomicWrite` + `createFileWriteQueue`.** Both currently bypass the shared helpers and roll their own read/write paths. Audit each call site, migrate to the established pattern, run the existing tests. Low-risk mechanical refactor; do it once a CoS PR happens to be open.- [ ] [cos-task-id-uniqueness-validation] **CoS task-ID uniqueness — validate at parse, not silently in `reorderTasks`.** Two related risks: (1) `server/lib/taskParser.js` `parseTasksMarkdown` doesn't detect duplicate task IDs — corrupted markdown propagates downstream; either throw on duplicate or warn + dedupe with a suffix. (2) `server/services/cos.js` `reorderTasks` (~line 2781) builds a `new Map(tasks.map(t => [t.id, t]))` which silently collapses duplicates — only the last wins, losing the others on the reorder write-back. Fix order: harden the parser so reorder can rely on uniqueness, then keep the Map-build as-is or assert uniqueness defensively.- [ ] [cos-runner-client-non-json-response-handling] **`cosRunnerClient.js` fetch wrappers — handle non-JSON runner responses.** `spawnAgentViaRunner` and siblings (~`server/services/cosRunnerClient.js:139`) `await response.json()` unconditionally; if the runner returns a 500 HTML error page (e.g. PM2 crash mid-restart) the client crashes with `Unexpected token <` instead of surfacing the runner's actual error. Wrap each parse in `try { JSON.parse(text) } catch { { error: text } }` and propagate the synthesized error so the caller sees a useful message.- [ ] [cos-agent-output-write-amplification] **`appendAgentOutput` write-amplification — already batched via `appendAgentOutputLines`, audit non-runner producers.** CLAUDE.md documents the streaming-producers convention (batched variant + ~250ms debounce + drain on completion); the runner path uses it. Verify every producer that calls `appendAgentOutput` directly (`server/services/cosAgents.js:216`) is human-pace, not a hot loop. If any hot producer is still calling the per-line variant, migrate it. Likely a no-op audit; capture it so the convention doesn't silently drift.@@ -26,6 +25,8 @@ Claimable, well-specified, no decision needed — `/claim`-able. Unordered.- [ ] [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-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).+- [ ] [settings-getsave-callers-stale-base] **Migrate `getSettings()→saveSettings({...spread})` callers off the external-read pattern.** `settings.js` now serializes `saveSettings`/`updateSettings` on a per-file write queue, but four callers (`server/routes/imageGen.js:724,736`, `server/routes/loras.js:62,76`) still read via `getSettings()` *outside* the queue, mutate, then `saveSettings(...)` — so a concurrent `updateSettings` landing between their read and queued write is clobbered by their stale base. The clean fix is a deep-merge-aware queued updater they can call (a plain `updateSettings` swap would change semantics: loras uses `deepMerge`, but `updateSettings` shallow-merges, which would drop sibling `civitai.*` keys; imageGen:736 deletes a sub-key by spreading rest). Low value in a single-user install (concurrent settings writes are rare) — surfaced by codex review during the settings atomicWrite migration; deferred for scope + merge-semantics risk.+- [ ] [json-state-serialization-one-mechanism] **Two serialization mechanisms guard single-JSON-file writes — pick one.** `server/services/cosState.js` serializes `state.json` writes with the `withStateLock` async mutex (`createMutex`), while `settings.js` (and the issues/series/mediaCollections splits) serialize with `createFileWriteQueue` (single-tail promise chain). Both solve the same "don't let two read-merge-write cycles interleave on one file" problem. Standardize on `createFileWriteQueue` (the documented convention in CLAUDE.md and `fileWriteQueue.js`) and retire the mutex path: route `cosState.saveState`/`loadState`-mutating callers through a per-file queue, then drop `withStateLock`. Low value (both are correct today), and `withStateLock` is imported by several CoS modules so the migration needs care — surfaced by /simplify altitude during the settings atomicWrite migration.- [ ] [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.- [ ] [plan-task-prefer-merge] **Switch the `/claim` (`plan-task`) Phase-6 merge order to prefer `--merge` over `--squash`.** The live `plan-task` prompt in `server/services/taskSchedule.js` (~line 562) still tries `gh pr merge --auto || --squash || --merge || --rebase`, so `/claim` squash-merges by default — inconsistent with the `--merge`-first default now used by the review-loop / `/do:pr` agent prompts. Deferred because: (a) `plan-task` is a **version-migrated** prompt, so the change needs a `PROMPT_VERSIONS['plan-task']` bump (7→8) **and** the v7 default preserved in `PREVIOUS_DEFAULT_PROMPTS['plan-task']` (~190-line byte-exact copy); (b) `/claim` self-cleans its worktree/branch regardless of merge method; and (c) `reapMergedWorktrees` detects squash merges anyway. Low benefit, non-trivial migration cost — do it as a focused follow-up when touching `plan-task` prompt versioning next.- [ ] [shared-optional-provider-picker] **Add an optional/"Default" mode to the shared provider/model picker and migrate the inline copies.** Three pages now hand-roll the same inline two-`<select>` "Default sentinel + provider + model" picker because the shared `ProviderModelSelector.jsx` + `useProviderModels.js` force a selection. UniverseBuilder.jsx (~2968) and Importer.jsx (~437, plus its `getProviders`+enabled-filter effect ~93 and `llmModels` memo) duplicate the logic in `FeatureProviderPicker.jsx`/`useProviderModels`. Add an `emptyOption`/`allowDefault` prop to `ProviderModelSelector` and an `allowDefault`/`includeEmpty` flag to `useProviderModels` that skips the auto-select, then refactor both. Note the importer's default label must stay accurate to its *per-stage* resolution. Cleanup only; no behavior change.