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
feat: add local IdeaLoom list API (#5336)
[._.]/ Adam Eivy5690484bc1de
diff --git a/docs/API.md b/docs/API.mdindex a9da69605d..b5041bc26a 100644--- a/docs/API.md+++ b/docs/API.md@@ -344,6 +344,9 @@ Context tools remain read-only. Semantic reads and writes are independent, defau| GET | `/brain/ideas/:id` | Get idea || PUT | `/brain/ideas/:id` | Update idea || DELETE | `/brain/ideas/:id` | Delete idea |+| GET/PUT | `/brain/ideas/idealoom/settings` | Get or update local IdeaLoom integration settings (disabled by default) |+| GET/POST | `/brain/ideas/idealoom/lists` | List or create machine-local IdeaLoom lists |+| GET/PUT/DELETE | `/brain/ideas/idealoom/lists/:id` | Read, update, or delete a machine-local IdeaLoom list || GET | `/brain/admin` | List admin tasks || POST | `/brain/admin` | Create admin task || GET | `/brain/admin/:id` | Get admin task |diff --git a/docs/STORAGE.md b/docs/STORAGE.mdindex 3238edf617..e5690ca17b 100644--- a/docs/STORAGE.md+++ b/docs/STORAGE.md@@ -61,6 +61,7 @@ PostgreSQL is a **required** install/runtime dependency (see [Backup & Restore](- Sprite animation-track definitions — `data/sprites/animation-tracks.json` (#3152). A small hand-editable authoring config: which animation types exist beyond the compiled-in `walk` (label, directionality, frame/fps bounds, prompt template, and the on-disk `setKind` strings). `file-primary` rather than `db-primary` because it is **machine-local and inseparable from the on-disk sprite tree it describes** — a row names the `setKind` an approved set under `data/sprites/{id}/` already carries, so the two travel together or neither means anything — and because it has no cross-record queries, no relationships beyond `kinds` strings, and no sync cursor. Read synchronously and cached per process (`server/services/sprites/animationTrackStore.js`): `server/lib/validation.js` builds sprite Zod ranges from it at module load, so it must resolve without `await`. Seeded from `data.reference/sprites/animation-tracks.json` (migration 211), which is also the fallback read when no user copy exists yet. Backed up in full by the rsync snapshot.- Quota-burn plan — `data/cos/quota-burn.json` (#3390). The install's burn plan: master switch, poll interval, and per-provider-family windows + ordered job list. `file-primary` and **intentionally machine-local — never federated**: quota belongs to a particular machine and provider account, so a synced plan would have each peer spending against the other's window budget, and the plan's `agent-prompt` jobs name managed apps that only exist on this machine. No sync cursor, no tombstone. Its four companions are `ephemeral-file` — regenerable telemetry, all safe to delete: `data/cos/quota-burn-dispatches.json` (per-window dispatch counts, self-pruning at 30 days), `data/cos/quota-burn-runs.json` (capped run log), `data/cos/quota-burn-inflight.json` (entries a burn job has enqueued but whose renders have not completed, self-pruning at 6 hours — deleting it only risks re-queueing a render already in flight), and `data/cos/quota-burn-denials.json` (per-family blocks from an observed provider refusal, cleared by the next successful burn or a 5-hour TTL — deleting it only risks one dispatch into a still-exhausted window). Backed up with the rest of `data/cos/`; a restored plan simply re-applies on this machine. See [Quota Burn](./QUOTA-BURN.md).- YouTube brain ingests — `data/brain/youtube/{videoId}.md` (transcript), `{videoId}.mp3` (optional audio), plus `data/brain/youtube/index.json` (the ingest index) and `data/brain/youtube-ingest-settings.json`. The transcript IS an external file: it is mirrored into the user's Obsidian vault, edited there, and syncs through iCloud — the same boundary that keeps the Daily Log file-backed. The index is **intentionally machine-local — never federated**: every field in it is a local filesystem path, an Obsidian vault id, or a local video-history id, so a peer's copy would be meaningless and would poison brain reconcile exactly the way the daily log's `journal-obsidian-locations.json` sidecar would. The durable, federated record of "I consumed and kept this" is the brain `links` entry (`db-primary` via the brain store) plus a `media.watch` row in `human_activity_events`. No sync cursor, no tombstone. Adapter: `server/services/youtubeIngest.js`.+- IdeaLoom lists — `data/brain/idealoom-lists/{uuid}/index.json` with a schema-stamped collection index holding the disabled-by-default local integration settings. Lists retain their ordered idea strings, prompt/title/category/status/help, timestamps, and importer-owned local sync metadata. **Intentionally machine-local — never federated, reconciled, or memory-bridged**: a vault id, note path, and content hash are meaningful only on the install that configured them. Native Brain `ideas` remain a separate federated collection. Adapter: `server/services/idealoomLists.js`.- Local-model assessments — `data/local-llm/assessments.json` (#4539). Measured evidence for one installed local model per (backend, model): the fit verdict (`fits`/`does-not-fit`/`incompatible`/`unknown`), per-context throughput/TTFT samples, resident footprint, and the coarse hardware environment the measurement was taken in. `file-primary` — a flat, capped, single-JSON projection with no cross-record queries and no relationships; the newest measurement replaces the old one per model rather than accumulating history. **Intentionally machine-local — never federated**: an assessment is a claim about THIS box, so a peer inheriting a 128 GB machine's its verdict for its 8 GB laptop would be actively wrong. No sync cursor, no tombstone, no `PORTOS_SCHEMA_VERSIONS` entry. Backed up (a run costs the user minutes of local compute), and the environment record deliberately carries no hostname/username/path. Adapter: `server/services/localModelAssessmentStore.js` (durable store + environment capture; no path to a provider, so read-only consumers like the catalog fit badge can import it); the run lives in `server/services/localModelAssessments.js` and the scoring in `server/lib/localModelAssessment.js`. Each record's environment is re-compared against the live machine on read, so a reading taken before a RAM upgrade or backend update is flagged stale rather than silently trusted.- LoRA training datasets — `data/lora-datasets/{id}/index.json` + `images/*.png` (collectionStore). The record is inseparable from the image bytes it organizes, has no cross-record queries beyond a small characterId scan, and is **machine-local** like `data/loras/` itself (training artifacts tied to this machine's GPU output — never federates, no sync cursor/tombstone). Backed up in full: uploads and hand-edited captions are not re-creatable. Training RUN records are `db-primary` (`lora_training_runs`); run artifacts (checkpoints/samples) live under `data/training-runs/{runId}/` with checkpoints/cache excluded from backup.diff --git a/server/lib/brainValidation.js b/server/lib/brainValidation.jsindex d9c5b61bdd..962f675af1 100644--- a/server/lib/brainValidation.js+++ b/server/lib/brainValidation.js@@ -276,6 +276,28 @@ export const ideaInputSchema = z.object({tags: z.array(z.string().max(50)).optional()});+// IdeaLoom lists are intentionally distinct from native Brain ideas. They are+// machine-local list documents, so neither their shape nor their sync metadata+// belongs to the federated Brain entity schemas above.+export const ideaLoomListStatusEnum = z.enum(['draft', 'completed']);++export const ideaLoomListInputSchema = z.object({+ prompt: z.string().min(1).max(10000),+ title: z.string().min(1).max(200),+ category: z.string().min(1).max(100),+ status: ideaLoomListStatusEnum.optional().default('draft'),+ help: z.string().max(5000).optional(),+ ideas: z.array(z.string().trim().min(1).max(2000)).max(500)+}).strict();++// Settings deliberately contain only integration switches and a vault id.+// Paths and note hashes stay on local list records and never cross this API.+export const ideaLoomSettingsInputSchema = z.object({+ enabled: z.boolean().optional(),+ obsidianVaultId: z.string().uuid().nullable().optional(),+ autoSync: z.boolean().optional()+}).strict();+// Create/Update Admin input schemaexport const adminInputSchema = z.object({title: z.string().min(1).max(200),diff --git a/server/routes/brain.js b/server/routes/brain.jsindex 48f3e450a9..5229684031 100644--- a/server/routes/brain.js+++ b/server/routes/brain.js@@ -17,10 +17,13 @@ import syncRoutes from './brainSync.js';import dailyLogRoutes from './brainDailyLog.js';import songbookRoutes from './brainSongbook.js';import youtubeRoutes from './brainYoutube.js';+import ideaLoomRoutes from './brainIdeaLoom.js';const router = Router();router.use(captureRoutes);+// Static IdeaLoom routes must mount before brainCrud's `/ideas/:id` route.+router.use(ideaLoomRoutes);router.use(crudRoutes);router.use(digestRoutes);router.use(settingsRoutes);diff --git a/server/routes/brain.test.js b/server/routes/brain.test.jsindex 22462b4169..b002faa4a3 100644--- a/server/routes/brain.test.js+++ b/server/routes/brain.test.js@@ -78,6 +78,16 @@ vi.mock('../services/brain.js', () => ({deleteBucketAndUnlinkChildren: vi.fn()}));+vi.mock('../services/idealoomLists.js', () => ({+ getSettings: vi.fn(),+ updateSettings: vi.fn(),+ listLists: vi.fn(),+ getList: vi.fn(),+ createList: vi.fn(),+ updateList: vi.fn(),+ deleteList: vi.fn()+}));+// Mock the brain graph servicevi.mock('../services/brainGraph.js', () => ({getBrainGraphSearchIndex: vi.fn(),@@ -134,6 +144,7 @@ vi.mock('../services/brainJournal.js', () => ({// Import mocked modulesimport * as brainService from '../services/brain.js';+import * as ideaLoomLists from '../services/idealoomLists.js';import { getBrainGraphSearchIndex, getBrainGraphOverview, getBrainGraphNeighborhood } from '../services/brainGraph.js';import { syncAllBrainData, getEmbeddingCoverage } from '../services/brainMemoryBridge.js';import { getChangesSince } from '../services/brainSyncLog.js';@@ -151,6 +162,32 @@ describe('Brain Routes', () => {vi.clearAllMocks();});+ describe('IdeaLoom local lists', () => {+ const listInput = {+ prompt: 'Find practical improvements', title: 'Practical improvements',+ category: 'product', ideas: ['Improve empty states']+ };++ it('uses the static settings route before the native idea id route', async () => {+ ideaLoomLists.getSettings.mockResolvedValue({ enabled: false, obsidianVaultId: null, autoSync: false });+ const response = await request(app).get('/api/brain/ideas/idealoom/settings');+ expect(response.status).toBe(200);+ expect(response.body.enabled).toBe(false);+ expect(brainService.getIdeaById).not.toHaveBeenCalled();+ });++ it('validates local list CRUD input and preserves native Brain ideas', async () => {+ ideaLoomLists.createList.mockResolvedValue({ id: 'c17c0284-b7de-4db6-a09c-7f735f0fd501', ...listInput, status: 'draft' });+ const created = await request(app).post('/api/brain/ideas/idealoom/lists').send(listInput);+ expect(created.status).toBe(201);+ expect(ideaLoomLists.createList).toHaveBeenCalledWith({ ...listInput, status: 'draft' });+ expect(brainService.createIdea).not.toHaveBeenCalled();++ const rejected = await request(app).post('/api/brain/ideas/idealoom/lists').send({ ...listInput, ideas: [''] });+ expect(rejected.status).toBe(400);+ });+ });+// ===========================================================================// CAPTURE & INBOX// ===========================================================================diff --git a/server/routes/brainIdeaLoom.js b/server/routes/brainIdeaLoom.jsnew file mode 100644index 0000000000..8dc78ff316--- /dev/null+++ b/server/routes/brainIdeaLoom.js@@ -0,0 +1,50 @@+/** Machine-local IdeaLoom list and settings routes. */++import { Router } from 'express';+import { asyncHandler, ServerError } from '../lib/errorHandler.js';+import { validateRequest } from '../lib/validation.js';+import { partialWithoutDefaults } from '../lib/zodCompat.js';+import { ideaLoomListInputSchema, ideaLoomSettingsInputSchema } from '../lib/brainValidation.js';+import * as ideaLoomLists from '../services/idealoomLists.js';++const router = Router();++router.get('/ideas/idealoom/settings', asyncHandler(async (_req, res) => {+ res.json(await ideaLoomLists.getSettings());+}));++router.put('/ideas/idealoom/settings', asyncHandler(async (req, res) => {+ const updates = validateRequest(partialWithoutDefaults(ideaLoomSettingsInputSchema), req.body);+ res.json(await ideaLoomLists.updateSettings(updates));+}));++router.get('/ideas/idealoom/lists', asyncHandler(async (_req, res) => {+ res.json(await ideaLoomLists.listLists());+}));++router.post('/ideas/idealoom/lists', asyncHandler(async (req, res) => {+ const data = validateRequest(ideaLoomListInputSchema, req.body);+ res.status(201).json(await ideaLoomLists.createList(data));+}));++router.get('/ideas/idealoom/lists/:id', asyncHandler(async (req, res) => {+ const list = await ideaLoomLists.getList(req.params.id);+ if (!list) throw new ServerError('IdeaLoom list not found', { status: 404, code: 'NOT_FOUND' });+ res.json(list);+}));++router.put('/ideas/idealoom/lists/:id', asyncHandler(async (req, res) => {+ const updates = validateRequest(partialWithoutDefaults(ideaLoomListInputSchema), req.body);+ const list = await ideaLoomLists.updateList(req.params.id, updates);+ if (!list) throw new ServerError('IdeaLoom list not found', { status: 404, code: 'NOT_FOUND' });+ res.json(list);+}));++router.delete('/ideas/idealoom/lists/:id', asyncHandler(async (req, res) => {+ if (!await ideaLoomLists.deleteList(req.params.id)) {+ throw new ServerError('IdeaLoom list not found', { status: 404, code: 'NOT_FOUND' });+ }+ res.status(204).send();+}));++export default router;diff --git a/server/services/idealoomLists.js b/server/services/idealoomLists.jsnew file mode 100644index 0000000000..7605b01769--- /dev/null+++ b/server/services/idealoomLists.js@@ -0,0 +1,96 @@+/**+ * Machine-local IdeaLoom list storage.+ *+ * This intentionally does not use brainStorage: native Brain entity types are+ * federated and memory-bridgeable, while IdeaLoom list records and vault sync+ * metadata must remain on the machine that owns the configured vault.+ */++import { join } from 'path';+import { v4 as uuidv4 } from '../lib/uuid.js';+import { atomicWrite, ensureDir, PATHS } from '../lib/fileUtils.js';+import { createCollectionStore } from '../lib/collectionStore.js';++export const IDEALOOM_LIST_SCHEMA_VERSION = 1;+const DEFAULT_SETTINGS = Object.freeze({ enabled: false, obsidianVaultId: null, autoSync: false });++const store = createCollectionStore({+ dir: join(PATHS.brain, 'idealoom-lists'),+ type: 'idealoom-lists',+ schemaVersion: IDEALOOM_LIST_SCHEMA_VERSION,+ defaultTypeIndexConfig: { settings: DEFAULT_SETTINGS },+ idPattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,+});++export const ideaLoomListStore = () => store;++const timestamp = () => new Date().toISOString();+const withDefaults = (settings) => ({ ...DEFAULT_SETTINGS, ...(settings || {}) });++export async function getSettings() {+ const index = await store.loadTypeIndex();+ return withDefaults(index.config.settings);+}++export async function updateSettings(updates) {+ return store.queueTypeIndexWrite(async () => {+ const index = await store.loadTypeIndex();+ const settings = { ...withDefaults(index.config.settings), ...updates };+ await ensureDir(store.dir);+ await atomicWrite(store.typeIndexPath(), {+ ...index,+ config: { ...index.config, settings },+ updatedAt: timestamp(),+ });+ return settings;+ });+}++export async function listLists() {+ const ids = await store.listIds();+ const lists = await Promise.all(ids.map((id) => store.loadOne(id)));+ return lists.filter(Boolean).map((list) => ({ ...list })).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));+}++export async function getList(id) {+ const list = await store.loadOne(id);+ return list ? { ...list } : null;+}++export async function createList(data) {+ const id = uuidv4();+ const now = timestamp();+ const list = { id, schemaVersion: IDEALOOM_LIST_SCHEMA_VERSION, ...data, createdAt: now, updatedAt: now };+ // Stamp the collection index even when a user only creates local lists and+ // never changes integration settings. This keeps the layout-version contract+ // visible to the boot-time collection verifier from the first write.+ await store.saveTypeIndex();+ await store.saveOne(id, list);+ return list;+}++export async function updateList(id, updates) {+ if (!store.isValidId(id)) return null;+ return store.queueRecordWrite(id, async () => {+ const current = await store.loadOne(id);+ if (!current) return null;+ const list = {+ ...current,+ ...updates,+ // Local sync metadata is importer-owned and cannot be overwritten by a+ // normal list edit. Later import/sync slices update it explicitly.+ sync: current.sync,+ id: current.id,+ schemaVersion: IDEALOOM_LIST_SCHEMA_VERSION,+ createdAt: current.createdAt,+ updatedAt: timestamp(),+ };+ await store.saveOneNow(id, list);+ return list;+ });+}++export async function deleteList(id) {+ if (!store.isValidId(id)) return false;+ return store.deleteOne(id);+}diff --git a/server/services/idealoomLists.test.js b/server/services/idealoomLists.test.jsnew file mode 100644index 0000000000..9d1e6b771b--- /dev/null+++ b/server/services/idealoomLists.test.js@@ -0,0 +1,47 @@+import { describe, it, expect, afterAll, vi } from 'vitest';+import { mkdtempSync, rmSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';+import { makePathsProxy } from '../lib/mockPathsDataRoot.js';++var tempRoot; // eslint-disable-line no-var+function getTempRoot() {+ if (!tempRoot) tempRoot = mkdtempSync(join(tmpdir(), 'idealoom-lists-test-'));+ return tempRoot;+}++vi.mock('../lib/fileUtils.js', async () => {+ const actual = await vi.importActual('../lib/fileUtils.js');+ return makePathsProxy(actual, { dataRoot: () => getTempRoot() });+});++import * as lists from './idealoomLists.js';++afterAll(() => { if (tempRoot) rmSync(tempRoot, { recursive: true, force: true }); });++const draft = {+ prompt: 'Find small practical improvements',+ title: 'Practical improvements',+ category: 'product',+ status: 'draft',+ ideas: ['Improve the empty state', 'Add a clear keyboard shortcut']+};++describe('IdeaLoom local lists', () => {+ it('stores ordered list records separately with local-only defaults', async () => {+ expect(await lists.getSettings()).toEqual({ enabled: false, obsidianVaultId: null, autoSync: false });++ const created = await lists.createList(draft);+ expect(created.id).toMatch(/^[0-9a-f-]{36}$/i);+ expect(created.schemaVersion).toBe(1);+ expect(created.ideas).toEqual(draft.ideas);++ const updated = await lists.updateList(created.id, { ideas: [...draft.ideas, 'Keep items ordered'] });+ expect(updated.ideas).toEqual([...draft.ideas, 'Keep items ordered']);+ expect((await lists.listLists()).map(({ id }) => id)).toContain(created.id);+ });++ it('updates integration settings without requiring a vault', async () => {+ expect(await lists.updateSettings({ autoSync: true })).toEqual({ enabled: false, obsidianVaultId: null, autoSync: true });+ });+});