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
address review (copilot): decouple vision model from voice text model (cfg.llm.visionModel); trim+cap forPeer query param + route test
Adam Eivy79ecffc35166
diff --git a/PLAN.md b/PLAN.mdindex 3b92b7a67b..a690a52043 100644--- a/PLAN.md+++ b/PLAN.md@@ -110,8 +110,7 @@ Surfaced during code review of the federated-media-collection-sync feature and c- [ ] [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.- [ ] [meatspace-workouts-read-path] **`getWorkouts()` is a write-only feature today.** Voice (`meatspace_log_workout`) and the palette can *write* workouts via `addWorkout` (`server/services/meatspaceHealth.js:194`), and `getWorkouts()` (line 189) is exported, but it has zero consumers — no route, no UI, no test reads workouts back. Wire a `GET /api/meatspace/workouts` route + a MeatSpace tab section so logged workouts are visible. Surfaced during v2.9.0 release review (claude, NIT). Deferred: feature-completion follow-up; the write side works and is tested.-- [ ] [datasync-route-forpeer-test] **Route-level `forPeer` + `videoHistory` coverage gap.** `server/routes/dataSync.js` threads the `forPeer` query param (incl. the `typeof === 'string'` array-drop guard) and the new `videoHistory` category to `getSnapshot`/`getChecksum`, but coverage exists only at the service layer (`dataSync.pipelineUniverse.test.js`). Add a route test asserting `?forPeer=x` reaches the snapshot/checksum calls and that a repeated `?forPeer=a&forPeer=b` (array) drops to `undefined`. Surfaced during v2.9.0 release review (claude, NIT). Deferred: test-coverage gap only, no correctness defect.-- [ ] [voice-vision-pinned-text-model] **`ui_describe_visually` reuses the voice text model for vision.** `describeScreenshot` (`server/services/voice/pipeline.js:602`) + `ui_describe_visually` (`tools.js:1356`) send the screenshot to `cfg.llm.model` when the user has pinned a non-`'auto'` voice model. If that pinned model is text-only, the chart description is empty/garbage (degrades gracefully to a clean error, no crash; the `'auto'` default is fine). Route vision through a dedicated vision-provider config, or validate vision-capability and message accordingly. Surfaced during v2.9.0 release review (claude, NIT). Deferred: only bites a non-default pinned-model config.+- [ ] [voice-vision-model-settings-ui] **Wire a `cfg.llm.visionModel` field into the Voice settings UI.** The v2.9.0 release review decoupled `ui_describe_visually`'s vision model from the voice text model — `describeScreenshot` (`server/services/voice/pipeline.js`) now reads an optional `cfg.llm.visionModel` and otherwise falls back to the provider's vision-capable `defaultModel` (so a pinned text-only voice model no longer breaks vision). But nothing in the Voice settings UI sets `visionModel` yet, so it can only be configured by hand-editing settings (the read path is forward-compatible, mirroring `cfg.location` for `weather_now`). Add a Voice-settings field + a Zod slice so a user can pin a specific vision model. Small.- [ ] [ltx2-utils-constants-qualified] **LTX2 negative-prompt patch imports a generic top-level module.** `scripts/generate_ltx2.py:92` tries `("utils", "constants")` to override `DEFAULT_NEGATIVE_PROMPT`; `utils` is a very generic top-level package name in a shared venv and could be shadowed (the `hasattr(...)` guard makes a wrong-module *write* improbable, so this is defense-in-depth only). If the real module is namespaced under the ltx package, prefer the fully-qualified import path. Surfaced during v2.9.0 release review (claude, NIT). Deferred: guarded; cosmetic robustness.## Future Ideasdiff --git a/server/routes/dataSync.js b/server/routes/dataSync.jsindex 1f422eb801..a60add2333 100644--- a/server/routes/dataSync.js+++ b/server/routes/dataSync.js@@ -48,11 +48,14 @@ router.post('/tombstones/sweep', asyncHandler(async (req, res) => {// for torn-down subs. Absent (older peers, non-peer callers) → full snapshot,// applied idempotently by the receiver. Express returns an array for repeated// query keys; the `typeof === 'string'` guard drops those so only a single-// scalar instanceId scopes the request.-const forPeerOf = (req) =>- typeof req.query.forPeer === 'string' && req.query.forPeer.length > 0- ? req.query.forPeer- : undefined;+// scalar instanceId scopes the request. Trim + length-cap the value (matching+// the defensive id handling in the peerSync routes) so stray whitespace or a+// malformed/oversized client value can't become a junk cache key.+const forPeerOf = (req) => {+ if (typeof req.query.forPeer !== 'string') return undefined;+ const trimmed = req.query.forPeer.trim().slice(0, 128);+ return trimmed.length > 0 ? trimmed : undefined;+};// GET /api/sync/:category/checksum — return checksum only (lightweight)router.get('/:category/checksum', asyncHandler(async (req, res) => {diff --git a/server/routes/dataSync.test.js b/server/routes/dataSync.test.jsindex f602a669e1..48c4f1bd2f 100644--- a/server/routes/dataSync.test.js+++ b/server/routes/dataSync.test.js@@ -19,6 +19,7 @@ vi.mock('../services/dataSync.js', () => ({}));import { sweepTombstones, getSweepStatus } from '../services/sharing/tombstoneGc.js';+import { getChecksum, getSnapshot } from '../services/dataSync.js';import dataSyncRoutes from './dataSync.js';const buildApp = () => {@@ -87,3 +88,29 @@ describe('POST /api/sync/tombstones/sweep', () => {expect(sweepTombstones).not.toHaveBeenCalled();});});++describe('GET /api/sync/:category/checksum — forPeer scoping', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ getChecksum.mockResolvedValue({ checksum: 'abc' });+ getSnapshot.mockResolvedValue({ data: {}, checksum: 'abc' });+ });++ it('threads a trimmed forPeer to getChecksum as forPeerId', async () => {+ const res = await request(buildApp()).get('/api/sync/universe/checksum?forPeer=%20peer-1%20');+ expect(res.status).toBe(200);+ expect(getChecksum).toHaveBeenCalledWith('universe', { forPeerId: 'peer-1' });+ });++ it('drops a blank/whitespace-only forPeer to undefined (full snapshot)', async () => {+ const res = await request(buildApp()).get('/api/sync/universe/checksum?forPeer=%20%20');+ expect(res.status).toBe(200);+ expect(getChecksum).toHaveBeenCalledWith('universe', { forPeerId: undefined });+ });++ it('drops a repeated forPeer (array) to undefined so only a scalar id scopes', async () => {+ const res = await request(buildApp()).get('/api/sync/universe/checksum?forPeer=a&forPeer=b');+ expect(res.status).toBe(200);+ expect(getChecksum).toHaveBeenCalledWith('universe', { forPeerId: undefined });+ });+});diff --git a/server/services/voice/pipeline.js b/server/services/voice/pipeline.jsindex 24ec5a8b90..f07bb51375 100644--- a/server/services/voice/pipeline.js+++ b/server/services/voice/pipeline.js@@ -129,10 +129,20 @@ const requestScreenshot = (emit, state, timeoutMs, signal) => new Promise((resol// endpoint and return the description text. Reuses visionTest's provider-aware// OpenAI-compatible /chat/completions call so we don't reimplement the request// shape. Lazy import keeps tools.js / the pipeline free of a hard vision dep.+//+// Vision model selection is DECOUPLED from the voice text model: reusing+// `cfg.llm.model` here meant that pinning a text-only voice model silently broke+// ui_describe_visually even when the provider had a working vision-capable+// default. Prefer an explicit `cfg.llm.visionModel` when set; otherwise pass+// undefined so describeImageDataUrl falls back to the provider's defaultModel+// (which is vision-capable for vision-capable providers).const describeScreenshot = async (dataUrl, prompt, cfg) => {const { describeImageDataUrl } = await import('../visionTest.js');const providerId = cfg?.llm?.provider || 'lmstudio';- const model = cfg?.llm?.model && cfg.llm.model !== 'auto' ? cfg.llm.model : undefined;+ const visionModel = cfg?.llm?.visionModel;+ const model = typeof visionModel === 'string' && visionModel && visionModel !== 'auto'+ ? visionModel+ : undefined;return describeImageDataUrl({ dataUrl, prompt, providerId, model });};