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(plan): drop the issue-write-race item resolved in v2.8.0 (series-tail serialization)
Adam Eivy5905c9bc99f0
diff --git a/PLAN.md b/PLAN.mdindex 7639e53017..79604fd74b 100644--- a/PLAN.md+++ b/PLAN.md@@ -2,14 +2,9 @@For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changelog/](./.changelog/) and `git log`.-## In Progress--- [x] [local-llm-backend-management] **Local LLM backend (Ollama / LM Studio) setup + model management + migrate.** (1) `scripts/setup-llm.js` prompts at setup time for Ollama vs LM Studio, installs the chosen one if missing, writes `LLM_BACKEND` to `.env`; (2) unified model management UI (list/search/install/delete) mirroring the LoRA/MediaModels pattern, with a curated cross-backend catalog (`server/lib/localLlmCatalog.js`); (3) migrate/switch between Ollama and LM Studio mirroring the Docker↔native Postgres `DatabaseTab`. Server: `server/services/ollamaManager.js`, `server/services/localLlm.js`, `server/routes/localLlm.js`. Client: `client/src/services/apiLocalLlm.js`, `client/src/components/settings/LocalLlmTab.jsx` (Settings tab `local-llm`).-## Next Up- [ ] [extract-shared-env-file-helper] **Extract a shared `.env` parse/set-key helper.** `parseEnvFile()` + single-key upsert logic is now duplicated three ways: `scripts/setup-db.js` (`setPgMode`), `scripts/setup-llm.js` (`parseEnvFile`/`setBackend`), and `server/services/localLlm.js` (`readEnv`/`writeBackend`). Deferred from the `[local-llm-backend-management]` simplify pass because the two setup scripts are intentionally dependency-light/standalone (run before/around `npm install`) and shouldn't import from `server/lib`. Cleanest fix: a tiny `scripts/lib/envFile.js` shared only between the setup scripts (parse + `upsertEnvKey(path, key, value)`); leave `localLlm.js`'s copy or have it import the same helper if the script→server boundary is acceptable. ~15 lines each.-- [ ] [migrate-taskitem-formatattachmentsize-to-formatbytes] **Migrate `TaskItem.jsx`'s local `formatAttachmentSize` to shared `formatBytes`.** `client/src/components/cos/tabs/TaskItem.jsx` still defines a local `formatAttachmentSize(bytes)` (B/KB/MB with `.toFixed(1)`) that duplicates `formatBytes` in `client/src/utils/formatters.js`. Surfaced by gemini review during the `[migrate-two-remaining-local-formatters]` claim 2026-05-24; deferred as out-of-scope for that item (which named only `formatDateTime` + `formatDurationMin`). Note the edge-case semantics differ: the local helper returns `''` for falsy/0 size (used inside an attachment `title` like `(1.5 KB)`), while `formatBytes(0)` returns `'0 B'` — preserve the empty-on-missing behavior with a guard (`att.size ? formatBytes(att.size) : ''`) so the title doesn't render `(0 B)` for sizeless attachments.- [ ] [optimize-voice-ui-index-text-payload-lazy-only-run] **Optimize `voice:ui:index` text payload.** Lazy: only run `extractVisibleText` when server requests via `voice:ui:read-request`. Keep current behavior as fallback.- [ ] [voice-agent-explicit-long-term-memory-routing-on] **Voice agent — explicit long-term memory routing.** On retrieval-shaped voice turns, inject top-N relevant memories into the system prompt via `brain_search`.@@ -128,7 +123,6 @@ Surfaced during code review of the federated-media-collection-sync feature and c- [ ] [media-sync-drawer-test-act-warning] **Test polish: `SyncDetailDrawer.test.jsx` act() warning.** The universe-kind "shows per-peer breakdown" test renders without awaiting the async record-name fetch, emitting a React `act()` warning (test still passes). Wrap the render/assertions in `waitFor`/`act`. Test-quality only.- [ ] [peer-sync-tombstone-cooldown-bypass] **Schema-block cooldown suppresses tombstone (delete) pushes for up to 5 min.** `pushRecordToPeer` (`server/services/sharing/peerSync.js` ~line 714) short-circuits on `sub.blockedBySchema && !options.bypassSchemaCooldown` BEFORE building the push payload, so a delete (tombstone) edit to a schema-blocked subscription is held off — even though the receiver-side gate (~line 1197) explicitly exempts tombstones (`record.deleted !== true`) so soft-deletes always converge. Delete still converges on the next `peer:online` (which passes `bypassSchemaCooldown: true`) or after the cooldown elapses, so this is eventual-consistency-correct but slow in the rare schema-mismatch + edit-triggered-delete window. Fix: resolve whether the pending push is a tombstone (load the record, or thread a `deleted` hint) before the cooldown gate and bypass the cooldown for tombstones, mirroring the receiver exemption. Surfaced during v2.8.0 release review (claude). Deferred: touches delicate push-gate ordering, no test coverage, low impact.- [ ] [aitoolkit-ollama-ready-hook-injection] **Vendored AI toolkit imports out to a PortOS service.** `server/lib/aiToolkit/runner.js:8` does `import { ensureProviderReady as ensureOllamaProviderReady } from '../../services/ollamaManager.js'` (added by the "Run Ollama as a startup service" work), used at ~line 313 in the API chat-completions path. This violates the documented self-containment rule ("Keep the directory self-contained — no imports out to other PortOS modules — so future upstream syncs don't fight local edits"). Fix: inject `ensureProviderReady` through the runner `config`/`hooks` (the factory already accepts `hooks = {}`) and wire it where PortOS constructs the toolkit, mirroring the `executeCliRun`/`stopRun` override pattern in `server/index.js`; the hook early-returns success for non-Ollama providers, so no behavior change. Surfaced during v2.8.0 release review (claude). Deferred: cross-file DI refactor of the toolkit boundary with no test coverage — maintainability/sync-hygiene only, no runtime impact today.-- [ ] [pipeline-issue-bulk-write-queue-serialization] **Series-wide issue writes bypass the per-id write queue, racing per-issue stage saves.** `saveIssuesNow` (`server/services/pipeline/issues.js:460`) writes each issue via `saveOneNow` (raw, no queue). The renumber paths (e.g. `updateIssue` ~line 768) hold `queueSeriesIssuesWrite(seriesId)` — a *series-level* mutex — while stage saves (~line 879) hold `queueRecordWrite(issueId)` — a *per-id* mutex. Different keys ⇒ they don't serialize: a renumber's bulk write of issue X can interleave with a concurrent stage blur-save of issue X (last write wins, losing one). This is the documented "async PATCH races on shared records" class (see CLAUDE.md `issueWriteTail`). The naive fix (wrap each `saveIssuesNow` write in `queueRecordWrite(id)`) is insufficient AND deadlock-prone: (a) the renumber reads ALL issues into `state` up front, so even a per-id-queued write carries a stale snapshot that clobbers a stage-save landing mid-operation; (b) `queueRecordWrite` is not re-entrant (`collectionStore.js:116`), so any caller already inside `queueRecordWrite(id)` for an affected id deadlocks. Correct fix needs a design choice — either make stage saves also acquire the series queue (one mutex per series), or have renumber re-read+re-apply each issue inside its own per-id queue — plus a regression test simulating the concurrent renumber-vs-stage-save. Surfaced during v2.8.0 release review (codex, P1). Deferred: core pipeline storage, needs design + test, deadlock risk on a rushed fix.- [ ] [ollama-linux-systemd-enable-not-start] **Linux "Run at Startup" only starts Ollama for the current boot.** The systemd controller in `getServiceController` (`server/services/ollamaManager.js:80-82`) uses `systemctl start`/`stop` and `getServiceStatus` (line 109-120) treats `is-active` as `runAtStartup`, so the UI claims the service will run at login even though it won't survive a reboot (macOS `brew services start` IS persistent, so the contract is platform-inconsistent). Fix: Linux start → `systemctl enable --now ollama`, stop → `systemctl disable --now ollama`, and split status into `is-enabled` (→ `runAtStartup`) vs `is-active` (→ `running`) as two queries. Surfaced during v2.8.0 release review (codex, P2). Deferred: Linux-only path, untestable on the macOS dev machine, zero existing test coverage, privileged systemctl semantics — land it where it can be exercised on a real systemd host.- [ ] [migration-037-history-streaming] **History JSON→JSONL migration loads the whole file into memory.** `scripts/migrations/037-history-json-to-jsonl.js` reads all of `history.json` (and any existing `.jsonl`) and stringifies the union — fine for typical history sizes, but a very large action-history file could spike heap at upgrade time. Convert to a streaming/append-only line-by-line rewrite if large histories become a problem. Surfaced during v2.8.0 release review (gemini, IMPROVEMENT). Deferred: one-shot migration, speculative for realistic sizes.- [ ] [localllm-env-atomic-write] **`.env` backend marker write is non-atomic.** `writeBackend` in `server/services/localLlm.js` (~line 94) uses `writeFileSync` to rewrite `.env`; a crash mid-write could corrupt it. `atomicWrite` (temp+rename, passes strings through unchanged) would make it crash-safe — but `writeBackend` is currently sync and the write is tiny/rare. Surfaced during v2.8.0 release review (gemini, IMPROVEMENT). Deferred: requires a sync→async ripple for a microsecond-wide crash window.