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([test-autosubscribe-fanout-getpeers-guard-remaining]): remove from PLAN.md and log to changelog

Adam Eivyf939034c2c3a
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 5c80439756..220308c83e 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -23,6 +23,7 @@
## Fixed
- Providers (`/ai`) and Prompts (`/prompts`) pages now render the same Settings sub-nav tabbed header as the other settings pages, so users can hop between Backup / Database / General / MortalLoom / Prompts / Providers / Sharing / Telegram / Voice without going back to the sidebar. Extracted a shared `SettingsTabsHeader` component used by `Settings.jsx`, `AIProviders.jsx`, and `PromptManager.jsx`.
-- **Test fixtures no longer leak into the real `data/universes/` via peer-sync fan-out.** `createUniverse` fires a non-awaited `autoSubscribeRecordToAllPeers`, which reads the live peer registry through `instances.js#getPeers` — a `dataPath` closure that resolves to the REAL `PATHS.data` once the post-return microtask escapes a test's `fileUtils` mock window. Three universe-creating suites (`universeBuilder.test.js`, `universeBuilderPromote.test.js`, `universeCanon.test.js`) created non-ephemeral fixtures without stubbing `getPeers`, so their "Moebius SciFi" universes were pushed across the federation and persisted into real `data/` by receiving instances (and re-leaked intermittently on every run). Each suite now mocks `getPeers → []`, matching the existing guard in `importer.test.js` / `promoteToPipeline.test.js`. Remaining series/issue-creating suites with the same latent gap are tracked in PLAN.md (`[test-autosubscribe-fanout-getpeers-guard-remaining]`).
+- **[test-autosubscribe-fanout-getpeers-guard-remaining] Apply the `getPeers → []` test stub to the remaining record-creating test files (and consider a shared guard).** Added `mockNoPeers()` to the shared test helper module and applied it across the remaining universe/series-creating suites, preserving the sharing tests' explicit identity stubs. Documented the convention in `CLAUDE.md` so new record-creating tests do not leak fixtures into live peer sync data.
+- **Test fixtures no longer leak into the real `data/universes/` via peer-sync fan-out.** `createUniverse` fires a non-awaited `autoSubscribeRecordToAllPeers`, which reads the live peer registry through `instances.js#getPeers` — a `dataPath` closure that resolves to the REAL `PATHS.data` once the post-return microtask escapes a test's `fileUtils` mock window. Three universe-creating suites (`universeBuilder.test.js`, `universeBuilderPromote.test.js`, `universeCanon.test.js`) created non-ephemeral fixtures without stubbing `getPeers`, so their "Moebius SciFi" universes were pushed across the federation and persisted into real `data/` by receiving instances (and re-leaked intermittently on every run). Each suite now mocks `getPeers → []`, matching the existing guard in `importer.test.js` / `promoteToPipeline.test.js`.
## Removed
diff --git a/PLAN.md b/PLAN.md
index d3baf0b4ef..12df3be82b 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -5,7 +5,6 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changel
## Next Up
- [ ] [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.
-- [ ] [test-autosubscribe-fanout-getpeers-guard-remaining] **Apply the `getPeers → []` test stub to the remaining record-creating test files (and consider a shared guard).** Root-caused 2026-05-23: `createUniverse` (universeBuilder.js:939) and `createSeries` (pipeline/series.js:223) fire a non-awaited `import('./sharing/peerSync.js').then(autoSubscribeRecordToAllPeers)`. `autoSubscribeRecordToAllPeers` reads the live peer registry via `getPeers()` (instances.js, `dataPath` closure to the REAL PATHS), so any test that creates a non-ephemeral universe/series and does NOT mock `getPeers` fans the fixture out to real peers (void/null/NaN), which persist it into real `data/`. Fixed in `universeBuilder.test.js`, `universeBuilderPromote.test.js`, `universeCanon.test.js` (this is how the "Moebius SciFi"/uuid-0000 leak happened). **Still unguarded** (create subscribable records, no `getPeers` mock — verified via `grep -L getPeers` against the createUniverse/createSeries/createIssue caller set): `pipeline/arcPlanner.test.js`, `pipeline/autoRunner.test.js`, `pipeline/coverUniverseFiler.test.js`, `pipeline/episodeVideo.test.js`, `pipeline/issues.test.js`, `pipeline/migrateSeriesCanon.test.js`, `pipeline/seasons.test.js`, `pipeline/series.test.js`, `pipeline/textStages.test.js`, `pipeline/volumeBeatsRunner.test.js`, `sharing/subscriptions.test.js`, `sharing/integration.test.js`, `universeBuilderAutoSort.test.js` (the last is safe-by-accident: its synthetic in-memory fileUtils mock lacks `dataPath`, which breaks the peerSync import chain — but that's fragile). These create *series*, so they'd pollute `data/pipeline-series/` not `data/universes/` (no residue found yet, but same race). The `sharing/*` ones likely set up real peers intentionally — handle carefully (don't blanket-stub). **Better fix to evaluate:** a shared `mockNoPeers()` helper in `server/lib/mockPathsDataRoot.js` (or a vitest `setupFiles` default stub that individual sharing tests can override) so every new record-creating test is protected by default instead of relying on each author remembering. Add the `getPeers→[]` convention to CLAUDE.md's test section.
- [ ] [prune-orphan-subscriptions-for-deleted-records] **Sweep orphaned peer subscriptions left by tombstone prune.** `pruneTombstonedUniverses` / `pruneTombstonedSeries` rm the record dir but leave its rows in `data/peer_subscriptions.json`. After the 2026-05-23 leaked-fixture cleanup (22 universes force-pruned), the matching subs are now orphaned — on `peer:online`, `retryPendingPushesForPeer` walks them, `loadOne` returns null, and the push no-ops (harmless but inflates the "retrying N pending pushes" count — saw 141). Add an orphan-subscription sweep (drop subs whose `recordKind/recordId` no longer resolves to an on-disk record) to the tombstone GC path, or call it from the prune helpers. Low urgency; cosmetic + minor wasted work per sync cycle. 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).