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: capture data-versioning follow-ups from POC plan
Adam Eivy7cc52e5c7448
diff --git a/PLAN.md b/PLAN.mdindex de10d9cfc8..4c0572d17b 100644--- a/PLAN.md+++ b/PLAN.md@@ -110,6 +110,12 @@ 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.- [ ] [cos-task-id-uniqueness-validation] **CoS task-ID uniqueness — validate at parse, not silently in `reorderTasks`.** Surfaced by gemini review (2026-05-23) on the data-versioning PR (out of scope at the time, captured here). 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.** Surfaced by gemini review (2026-05-23). `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.** Surfaced by gemini review (2026-05-23) at `server/services/cosAgents.js:216`. CLAUDE.md already documents the streaming-producers convention (batched variant + ~250ms debounce + drain on completion); the runner path uses it. Verify every producer that calls `appendAgentOutput` directly is human-pace, not a hot loop (PTY streams, AI tool-call streams). If any hot producer is still calling the per-line variant, migrate it to `appendAgentOutputLines`. Likely a no-op audit; capture it as a check so the convention doesn't silently drift.