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
PLAN.md: data-versioning follow-ups are proactive structural work, not trigger-gated
Adam Eivy7692b2462cab
diff --git a/PLAN.md b/PLAN.mdindex 4c0572d17b..2cfb7ffef4 100644--- a/PLAN.md+++ b/PLAN.md@@ -4,6 +4,9 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changel## Next Up+- [ ] [data-versioning-split-pipeline-issues] **Split `data/pipeline-issues.json` → `data/pipeline-issues/{id}/index.json` via `collectionStore`.** Highest-value follow-up from the data-versioning POC (PR #458). File is ~1MB / 173 records and every panel/page edit rewrites the whole thing through `server/services/pipeline/issues.js`'s `issueWriteTail` single-file queue. Per-record split gives the comic pipeline real concurrent-write headroom — multiple `PATCH /api/pipeline/issues/:id` calls against different issues stop blocking each other. Migration `035-split-pipeline-issues-to-per-id.js` mirrors `034-split-universe-builder-to-per-uuid.js`: pre-flight scan, atomic per-record writes, monolithic file renamed to `pipeline-issues.json.bak-035`. Bump `PORTOS_SCHEMA_VERSIONS.pipelineIssues` (new key) in `server/lib/schemaVersions.js` and register the store in `server/index.js`'s `verifyCollectionVersions` boot call. Per-record `schemaVersion` (record shape) stays where it is. Audit consumers of `loadIssues()` / `saveIssues()`: every caller must move to `store.loadOne` / `store.saveOne` / `store.listIds` + parallel load. Cross-record state in `pipeline-issues.json` (if any beyond the array — check before migrating) moves into `data/pipeline-issues/index.json`'s `config` slot.+- [ ] [data-versioning-split-pipeline-series] **Split `data/pipeline-series.json` → `data/pipeline-series/{id}/index.json`.** Lower record count than issues (21 records) but same structural fix; do it in the same PR as `[data-versioning-split-pipeline-issues]` so the pipeline area lands at one consistent layout. Same migration shape (`036-split-pipeline-series-to-per-id.js`) — mostly a copy-paste of the issues migration with type swapped.+- [ ] [data-versioning-history-jsonl] **`data/history.json` → `data/history.jsonl` — proactive structural fix.** Data shape is append-only by definition; rewriting the whole array on every append is the wrong shape regardless of current size. Convert to line-delimited JSON so appends are O(1) instead of O(N) and `tail`-based reads / log rotation become trivial. Migration `037-history-json-to-jsonl.js`: read `data/history.json`, emit one line per entry, rename old file to `history.json.bak-037`. Add `appendJsonLine(path, obj)` + `readJsonLines(path, { from, limit })` helpers to `server/lib/fileUtils.js` (barrel + README) so `data/brain/digests.jsonl` and `data/brain/inbox_log.jsonl` (already JSONL but hand-rolled) can adopt the same primitives. Pair with a quick audit of other append-only-shaped monolithic files (`client-errors.json`?, `media-jobs.json`?) — convert any that match the shape in the same PR or a follow-up.- [ ] [ai-fallback-coalesce-concurrent-failures] **Coalesce concurrent AI provider failures so N simultaneous calls don't all re-read `providers.json` and re-mark the same provider.** Surfaced by /simplify efficiency review during the ai-fallback PR (2026-05-22). When a stuck provider has N simultaneous in-flight calls, each failure independently runs `pickFallbackProvider` → `getAllProviders()` → `loadProviders()` (which reads `providers.json` from disk every time — no in-memory cache) → `markUnavailable` (writing `provider-status.json`). Two fixes that compound: (a) add a tiny TTL cache (~1s) to `aiToolkit/providers.js#loadProviders` so the read cost is amortized; (b) coalesce per-provider failure handling in `promptRunner.js` with a `Map<providerId, Promise>` so subsequent failures for the same provider await the first's mark-and-pick result and skip the duplicate work. Together they cut N-way failure storms to one disk-write + one mark. Acceptance: under a simulated 10-concurrent-failure load, providers.json is read at most twice and provider-status.json is written once.- [ ] [propagate-runner-errorAnalysis-into-onRunFailed-context] **Propagate `metadata.errorAnalysis` into the `onRunFailed` event context** so `promptRunner.js#markProviderUnavailableFromError` doesn't re-run `analyzeError` on the same text the runner already analyzed. The runner writes `errorAnalysis` to `metadata` (`server/lib/aiToolkit/runner.js:245`, 343, 433) but `server/index.js:202` only forwards a subset to the error event, so the analysis pass is duplicated on every failure. Either add `errorAnalysis` to the event context AND to the rejected error thrown to promptRunner, or attach it to the metadata object that the rejection carries. Microsecond-class perf, but cleaner. Surfaced by /simplify efficiency review during the ai-fallback PR (2026-05-22).- [ ] [upcoming-tasks-widget-drop-catch-to-empty] **Drop the `.catch(() => [])` in `UpcomingTasksWidget.jsx:21`.** Pre-existing tech debt (not touched in v2.6.0): `useAutoRefetch(() => api.getCosUpcomingTasks(6).catch(() => []), 60000)` wipes the prior list on transient errors. The seven sibling callers (Brain, DigitalTwin, QuickSummary, ActionableInsightsBanner, ProcessesTab, SystemHealthPage, CyberCity) were fixed during the v2.6.0 release review by dropping the catch and passing `{ silent: true }` to the API helper instead. Apply the same pattern here: add an `options` parameter to `getCosUpcomingTasks` (in `client/src/services/apiAgents.js`, mirroring `getCosQuickSummary`), drop the catch, and pass `{ silent: true }` in the call site. Surfaced by reviewer-4 in the v2.6.0 release review (2026-05-21).@@ -110,9 +113,6 @@ Items here need a research / design pass, an explicit decision, or a preconditio- [ ] [shots-aware-scene-output-contract-partial-split] **Shots-aware scene-output-contract partial.** Split into `_partials/scene-fields-core.md` + `_partials/scene-fields-shots.md` when a third shots-using stage appears.- [ ] [ref-watch-phosphene-bump-ltx2-pin-v0148] **Bump `LTX2_PIN` from `f8f20c83` to v0.14.8 + adopt phosphene's frame_rate / class-rename / a2v / lora-fusion patches together.** From `reference-watch` review of phosphene (2026-05-22). Concrete upstream wins between PortOS's pin and current dgrauet HEAD: VAE auto-tiling that caps peak Metal memory on HD / long runs (#25), `_pending_loras` honored across every pipeline's `load()` override (#22, #23 — fixes silent character-LoRA-drops on Extend/HQ), `--lora` on `--low-ram` flow (#30), accurate transformer load-time markers for progress UI. Cost: in v0.14.x, `TextToVideoPipeline` / `ImageToVideoPipeline` / `ExtendPipeline` / `TwoStagePipeline` / `AudioToVideoPipeline` are all renamed (public surface becomes `TI2VidOneStagePipeline`, `RetakePipeline`, `TI2VidTwoStagesPipeline`, `A2VidPipelineTwoStage`, etc.). `generate_ltx2.py` would fail at import. Source commits: `2166d138` / `770ed0bd` (defensive imports v2), `94ae3430` (method-presence dispatch instead of class assumption), `aa235aa0` (`fps=` → `frame_rate=` shim), `681f429a` (a2v missing `frame_rate=` runtime patch), plus `[ref-watch-phosphene-lazy-eval-env-bootstrap]`. Scope: large (100–200 lines of careful Python touching every pipeline path, plus smoke test of every mode — text/image/fflf/extend/a2v — at the new pin). **Decision needed:** ship as one PR vs split per-mode; do this before or after the post-decode `os._exit(0)` lands.- [ ] [ref-watch-phosphene-sigkill-watchdog-videogen-local] **Panel-side SIGKILL watchdog (Node layer) in `videoGen/local.js`.** From `reference-watch` review of phosphene (commit `94bd6965`, 2026-05-22). Even with helper-side `os._exit(0)` adopted (see `[ref-watch-phosphene-mlx-post-decode-os-exit]`), defense-in-depth at the Node layer is cheap insurance: watch stdout for the upstream "[Decoding video + audio + muxing] done in X.Xs" line (or the final `{"video_path": ...}` JSON), then arm a 30–45s grace timer that SIGKILLs the child if it doesn't exit. PortOS already has SIGTERM→SIGKILL escalation in `cancel()` (`server/services/videoGen/local.js:71-79`); reuse that path. **Trigger:** only do this if real users hit the hang after the pin bump and `os._exit(0)` proves insufficient (it shouldn't, in PortOS's short-lived-helper model). Scope: small/medium.-- [ ] [data-versioning-split-pipeline-issues] **Split `data/pipeline-issues.json` → `data/pipeline-issues/{id}/index.json` via `collectionStore`.** Highest-value follow-up from the data-versioning POC (PR #458). File is ~1MB / 173 records and every panel/page edit rewrites the whole thing through `server/services/pipeline/issues.js`'s `issueWriteTail` single-file queue. Per-record split gives the comic pipeline real concurrent-write headroom — multiple `PATCH /api/pipeline/issues/:id` calls against different issues stop blocking each other. Migration `035-split-pipeline-issues-to-per-id.js` mirrors `034-split-universe-builder-to-per-uuid.js`: pre-flight scan, atomic per-record writes, monolithic file renamed to `pipeline-issues.json.bak-035`. Bump `PORTOS_SCHEMA_VERSIONS.pipelineIssues` (new key) in `server/lib/schemaVersions.js` and register the store in `server/index.js`'s `verifyCollectionVersions` boot call. Per-record `schemaVersion` (record shape) stays where it is. Audit consumers of `loadIssues()` / `saveIssues()`: every caller must move to `store.loadOne` / `store.saveOne` / `store.listIds` + parallel load. The cross-record state in `pipeline-issues.json` (if any beyond the array — check before migrating) moves into `data/pipeline-issues/index.json`'s `config` slot.-- [ ] [data-versioning-split-pipeline-series] **Split `data/pipeline-series.json` → `data/pipeline-series/{id}/index.json`.** Lower priority than issues — only 21 records, low churn — but worth doing for consistency once `pipeline-issues` is split. Same migration shape (`036-split-pipeline-series-to-per-id.js`). Mostly a copy-paste of the issues migration with type swapped. Do it in the same PR as issues so the pipeline area lands at one consistent layout.-- [ ] [data-versioning-history-jsonl-or-partition] **`data/history.json` — switch to JSONL or date-partitioning when it grows.** Today 158 entries, append-only — fine. The right shape when it crosses ~5k entries is either (a) `data/history.jsonl` line-delimited so appends don't rewrite the whole file, or (b) date-partitioned `data/history/YYYY-MM/index.json` so old months can be archived without touching the live file. Either path needs a backfill migration. Trigger: file size > 1MB OR append latency > 50ms.- [ ] [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 — outside the scope of the data-versioning PR but worth folding into the same convention. 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.- [ ] [data-versioning-cache-invalidation-on-split] **Cache invalidation hooks in `brainStorage.js` / `messageSync.js` / `meatspacePostDrillCache.js` — needed only when their backing collections split.** Per the access-pattern audit during the data-versioning POC, these caches don't touch universe data so they were safe to skip for PR #458. When a future PR splits Brain or Messages collections into per-record `collectionStore` layouts, audit each cache for "cache key ↔ split-record-id" consistency: per-id writes are visible to other readers without going through the cache, so any cache that fronts the now-split file needs an invalidation event hook (or a switch to read-through against `store.loadOne`).- [ ] [data-versioning-typeindex-config-convention] **Establish a convention for the `config` slot on `data/{type}/index.json`.** `createCollectionStore` left `index.json`'s `config` open and unused — the first real consumer (probably the pipeline-issues split's history/runs analog) should pick the shape and document it in `server/lib/README.md` + the `collectionStore.js` header. Candidate shape: `{ config: { runs?: [], featureFlags?: {}, lockPolicies?: {} } }` — but defer the decision to the first real need.