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 (codex): fail closed on explicit-worktree failure; serialize voice completion announcements
Adam Eivyd520cc47eb09
diff --git a/PLAN.md b/PLAN.mdindex 8abd46cb97..869ab8228d 100644--- a/PLAN.md+++ b/PLAN.md@@ -9,7 +9,6 @@ _Batch-cleared 2026-05-25: 23 Next Up items shipped together via parallel sub-ag- [ ] [flux2-multi-reference-python-runner] **FLUX.2 multi-reference Python runner.** The UI + server contract for multi-reference editing shipped 2026-05-17 (slug `multi-reference-image-editing-for-flux-2-ui`); the Python runner (`scripts/flux2_macos.py`) currently ignores the `--reference-images`/`--reference-strengths` args that `local.js` now passes. Wire diffusers' multi-reference API in the runner and swap `server/lib/mediaModels.js#flux2-klein-9b` `tokenizerRepo` to `FLUX.2-klein-9B-kv` (gated repo — requires the user to accept the license on HF). Validate end-to-end with 2–4 uploaded refs. _(Deferred 2026-05-25 from the batch-clear: blocked on gated HF model + GPU validation; can't be verified autonomously.)_- [ ] [apple-health-integration-live-sync] **Apple Health integration for MeatSpace.** iOS live sync (HealthKit Shortcut → `POST /api/meatspace/apple-health` endpoint) plus a bulk historical import path for an exported `export.xml`. Wire into existing MeatSpace tabs so steps / sleep / heart rate / VO2 max / resting HR show alongside the alcohol / blood / body / epigenetic tracks already shipped. GOALS.md flags this as a documented Secondary Goal ("Apple Health integration planned") but no implementation tracking existed until this entry. When this lands, also fold an Apple-Health-imported signal into the Capabilities page "Genome & Health" row (`server/lib/capabilityMap.js#genomeRow` + the route's `genome` fetch) so a health-only setup no longer reports "Not set up" purely because no genome is uploaded (codex review of `[codex5-onboarding-capability-map]`, 2026-05-24). _(Deferred 2026-05-25 from the batch-clear: multi-file feature with an iOS Shortcut component that needs a device to verify.)_- [ ] [voice-code-agent-target-managed-app] **Voice code-agent delegation can't target a managed app yet.** The `dispatch_code_agent` voice tool (`server/services/voice/tools.js`) creates a CoS user task with no `app` set, so the agent always runs against the PortOS repo (the CoS default workspace). Add an optional spoken target ("…in BookLoom") → resolve to an app id and pass `app` through to `addTask` (cos.js already persists `metadata.app`, and `agentLifecycle.js#registerAgent` already reads it). Needs a phrase→app resolver (fuzzy match against managed app names) and a guard for "app not found." Deferred from the initial build (2026-05-26) to keep v1 scoped to the self-repo case.-- [ ] [voice-code-agent-completion-rate-limit-drop] **Two voice-dispatched tasks finishing within 30s: the second completion announcement is silently dropped.** `proactiveTriggers.js` rate-limits the `task-complete` source at 30s and `allowBySource` DROPS (doesn't queue) throttled lines, so if two distinct dispatched tasks reach a terminal status within the window the user is never told about the second. Coding tasks usually take minutes so it's rare, but a solicited completion shouldn't be dropped — consider a small per-(task-id) dedupe + a short queue for `task-complete` lines instead of a hard throttle, or drop the rate limit for this source (solicited completions are low-frequency and user-wanted). Surfaced by the xhigh code review (2026-05-26).- [ ] [voice-code-agent-status-query] **No mid-task voice status query for dispatched coding agents.** Once a task is dispatched via `dispatch_code_agent`, the user can only learn the outcome from the completion announcement — there's no "how's that coding task going?" tool. Add a `code_agent_status` voice tool that reads `data/cos/state.json` for running agents tagged `metadata.voiceDispatch` and reports phase/elapsed. Deferred from the initial build (2026-05-26); the completion announcement covers the common case.- [ ] [voice-code-agent-announce-pr-url] **Completion announcement can't speak the PR link.** `agent:completed` (cosAgents.js) fires BEFORE `cleanupAgentWorktree` creates the PR (agentLifecycle.js), so `formatAgentCompletionLine` (proactiveTriggers.js) only speaks success/failure + the task description, not the PR. To include "PR #512 is up," either (a) emit a later `agent:pr-opened` event from the cleanup path carrying `{ taskId, prUrl, voiceDispatch }` and announce on that instead, or (b) have the announcement defer until the agent record gains a `prUrl`. Deferred 2026-05-26 — a spoken GitHub URL is poor UX anyway and the user reviews the PR visually; the "done" announcement is enough for v1.- [ ] [mediacard-use-mediaimage-for-syncing-assets] **`MediaCard.jsx` grid thumbnails still use a raw `<img src={previewUrl}>`.** Same peer-sync placeholder/live-swap gap that `[peer-sync-medialightbox-use-mediaimage-for-syncing-assets]` fixed for the lightbox — `client/src/components/media/MediaCard.jsx` (~line 42) doesn't get the "Syncing" placeholder or the `peerSync:asset-arrived` atomic swap. Swap the raw `<img>` for `MediaImage`. Surfaced by that item's cross-check during the batch-clear (2026-05-25); was outside its stated scope.diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.jsindex e21a7aad10..d8b57c776d 100644--- a/server/services/agentLifecycle.js+++ b/server/services/agentLifecycle.js@@ -420,6 +420,29 @@ export async function spawnAgentForTask(task) {emitLog('success', `🌳 Agent ${agentId} will work in worktree: ${worktreeInfo.branchName} (base: ${worktreeInfo.baseBranch})`, {agentId, worktreePath: worktreeInfo.worktreePath, branchName: worktreeInfo.branchName, baseBranch: worktreeInfo.baseBranch});+ } else {+ // Isolation was EXPLICITLY requested (useWorktree/openPR) but the+ // worktree couldn't be created. Falling back to the shared workspace+ // would run the agent against the live checkout and — with openPR —+ // auto-commit to the current branch, exactly the isolation the+ // caller opted into. Fail closed: block the task rather than touch+ // the working tree behind the user's back. (The auto-detected+ // conflict branch below keeps its lenient shared-workspace fallback,+ // since there the worktree was only a recommendation, not a request.)+ const reason = `Worktree creation failed for task ${task.id}; refusing to run in the shared workspace because isolation was explicitly requested`;+ emitLog('warn', `🌳 ${reason}`, { taskId: task.id });+ await updateTask(task.id, {+ status: 'blocked',+ metadata: {+ ...task.metadata,+ blockedReason: 'Worktree creation failed — isolation was explicitly requested',+ blockedCategory: 'worktree-failed',+ blockedAt: new Date().toISOString(),+ },+ }, task.taskType || 'user').catch(() => {});+ cleanupOnError(reason);+ cosEvents.emit('agent:error', { taskId: task.id, error: reason });+ return null;}} else if (!jiraBranchName && !isFalsyMeta(task.metadata?.useWorktree)) {const { getAgents } = await import('./cos.js');diff --git a/server/services/voice/proactiveTriggers.js b/server/services/voice/proactiveTriggers.jsindex 815e2eff16..ee2f8a902b 100644--- a/server/services/voice/proactiveTriggers.js+++ b/server/services/voice/proactiveTriggers.js@@ -39,10 +39,12 @@ export const RATE_LIMIT_MS = {error: 90_000,'task:ready': 60_000,notification: 60_000,- // Completion of a voice-dispatched coding task. A 30s floor keeps two- // tasks finishing back-to-back from talking over each other while still- // letting the user hear about each within a normal review cadence.- 'task-complete': 30_000,+ // NOTE: there is intentionally NO 'task-complete' entry. Completions of+ // voice-dispatched tasks are solicited (the user asked for each one), so a+ // drop-based throttle would silently lose the second of two tasks finishing+ // close together. Instead the wiring serializes completion lines onto a+ // queue (see taskCompleteTail) so they are spoken one after another without+ // dropping or overlapping.};// Spoken lines should be short — synthesis is capped at MAX_PROACTIVE_TEXT_LEN@@ -180,9 +182,14 @@ export const wireProactiveTriggers = ({ io, speak = defaultSpeak, limits = RATE_// before the config read. A user-cancelled task lands as blocked with// blockedCategory 'user-terminated' — suppress it (the user stopped it on// purpose; "didn't finish cleanly" would be wrong). Solicited: bypasses- // proactive-enabled but not voice-disabled / quiet hours. dispatch() (not- // fire) so we can await the config read and still route the rejection- // through the same catch.+ // proactive-enabled but not voice-disabled / quiet hours.+ //+ // Completions are SERIALIZED onto this tail promise rather than going+ // through the per-source rate limit: each completion is solicited, so a+ // drop-based throttle would silently lose the second of two tasks that+ // finish close together. Chaining makes two near-simultaneous completions+ // speak one after the other (no drop, no overlapping audio).+ let taskCompleteTail = Promise.resolve();const onTaskUpdated = (evt) => {if (evt?.action !== 'updated') return;const task = evt.task;@@ -190,12 +197,12 @@ export const wireProactiveTriggers = ({ io, speak = defaultSpeak, limits = RATE_if (status !== 'completed' && status !== 'blocked') return;if (!isMetaTrue(task.metadata?.voiceDispatch)) return;if (status === 'blocked' && task.metadata?.blockedCategory === 'user-terminated') return;- (async () => {+ taskCompleteTail = taskCompleteTail.then(async () => {const cfg = await getVoiceConfig();if (cfg?.llm?.codeAgent?.announceOnComplete === false) return;const priority = status === 'completed' ? 'normal' : 'high';await dispatch('task-complete', formatTaskCompletionLine(task), priority, { solicited: true });- })().catch((err) =>+ }).catch((err) =>console.error(`🔕 voice: proactive task-complete trigger failed: ${err?.message || err}`),);};diff --git a/server/services/voice/proactiveTriggers.test.js b/server/services/voice/proactiveTriggers.test.jsindex 6406d95212..3c1591ad66 100644--- a/server/services/voice/proactiveTriggers.test.js+++ b/server/services/voice/proactiveTriggers.test.js@@ -246,11 +246,25 @@ describe('wireProactiveTriggers', () => {}});- it('default RATE_LIMIT_MS covers all wired sources', () => {+ it('rate-limits the throttled sources but NOT solicited task completions', () => {expect(RATE_LIMIT_MS).toHaveProperty('error');expect(RATE_LIMIT_MS).toHaveProperty('task:ready');expect(RATE_LIMIT_MS).toHaveProperty('notification');- expect(RATE_LIMIT_MS).toHaveProperty('task-complete');+ // Solicited completions are serialized (queued), not drop-throttled.+ expect(RATE_LIMIT_MS).not.toHaveProperty('task-complete');+ });++ it('announces BOTH of two back-to-back completions (no drop-based throttle)', async () => {+ unwire = wireProactiveTriggers({ io: {}, speak });+ const upd = (id) => ({ type: 'user', action: 'updated', task: { id, status: 'completed', description: `task ${id}`, metadata: { voiceDispatch: true } } });+ cosEvents.emit('tasks:changed', upd('a'));+ cosEvents.emit('tasks:changed', upd('b'));+ await flush();+ await flush();+ expect(speak).toHaveBeenCalledTimes(2);+ const spoken = speak.mock.calls.map((c) => c[0].text).join(' | ');+ expect(spoken).toMatch(/task a/);+ expect(spoken).toMatch(/task b/);});// Helper: a tasks:changed 'updated' event payload for a voice-dispatched task.