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
clamp sync since param, expand health check, add schema upgrade path
Adam Eivyecaca29a823d
diff --git a/server/lib/db.js b/server/lib/db.jsindex 839777abf0..a10aa33d9e 100644--- a/server/lib/db.js+++ b/server/lib/db.js@@ -72,10 +72,14 @@ export async function withTransaction(fn) {*/export async function checkHealth() {try {- const result = await pool.query(- "SELECT EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'memories') AS has_table"- );- return { connected: true, hasSchema: result.rows[0].has_table };+ const result = await pool.query(`+ SELECT+ EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'memories') AS has_memories,+ EXISTS(SELECT 1 FROM information_schema.tables WHERE table_name = 'memory_links') AS has_links,+ EXISTS(SELECT 1 FROM information_schema.columns WHERE table_name = 'memories' AND column_name = 'sync_sequence') AS has_sync+ `);+ const { has_memories, has_links, has_sync } = result.rows[0];+ return { connected: true, hasSchema: has_memories && has_links && has_sync };} catch (err) {return { connected: false, hasSchema: false, error: err.message };}diff --git a/server/routes/memory.js b/server/routes/memory.jsindex d1e51635b9..5a1738694c 100644--- a/server/routes/memory.js+++ b/server/routes/memory.js@@ -90,7 +90,7 @@ router.get('/sync', asyncHandler(async (req, res) => {if (name !== 'postgres') {throw new ServerError('Sync requires PostgreSQL backend', { status: 400 });}- const since = parseInt(req.query.since, 10) || 0;+ const since = Math.max(parseInt(req.query.since, 10) || 0, 0);const limit = Math.min(Math.max(parseInt(req.query.limit, 10) || 100, 1), 1000);const result = await memorySync.getChangesSince(since, limit);res.json(result);diff --git a/server/scripts/init-db.sql b/server/scripts/init-db.sqlindex fe267f4eab..4df4932818 100644--- a/server/scripts/init-db.sql+++ b/server/scripts/init-db.sql@@ -29,6 +29,12 @@ CREATE TABLE IF NOT EXISTS memories (sync_sequence BIGSERIAL);+-- Schema upgrades: add columns that may not exist on older installs+DO $$ BEGIN+ ALTER TABLE memories ADD COLUMN IF NOT EXISTS sync_sequence BIGSERIAL;+EXCEPTION WHEN others THEN NULL;+END $$;+-- HNSW index for fast vector similarity search (O(log n) instead of O(n))CREATE INDEX IF NOT EXISTS idx_memories_embeddingON memories USING hnsw (embedding vector_cosine_ops)