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 (claude): keep in_progress { error } miss non-fatal so unpersisted mission/idle tasks still spawn
Adam Eivy0e29fa96d7fa
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 7a59d8a700..3b415bfdd5 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -40,7 +40,7 @@- **[issue-2643] De-flake the Wiki vault-default test under full-suite load.** `Wiki.test.jsx`'s "defaults to the first vault" (and the sibling "restores the selected vault") assertions checked `scanNotesVault` synchronously right after `await waitFor(...)` on the rendered vault id. That mock call is fired by a *separate* `useEffect` keyed on the selected vault, so the committed overview render can land before the passive effect flushes — reliably true in isolation, but on a CPU-saturated full client run the bare assertion raced ahead of the effect and failed (`expected vi.fn() to be called with arguments`). The two mock-call assertions now sit inside their own `waitFor`, awaiting the async side-effect instead of sampling it. Test-only change (no `test.retry` or timeout inflation) — no runtime behavior change.-- **[issue-2633] Direct `task:ready` emits now claim against the right task file.** The Creative Director bridge, the on-demand `dequeueNextTask`, and `spawnPriority0OnDemand` publish task records with no `taskType`, so an internal (`sys-*`/`cd-*`/`app-improve-*`) task's claim/in_progress `updateTask` fell back to `'user'`, targeted TASKS.md instead of COS-TASKS.md, missed the record, and returned a truthy `{ error }` object the `if (!updateResult)` check silently swallowed — leaving the task un-claimed while the agent spawned anyway. `runAgentSpawn` now normalizes `taskType` from the id via `isInternalTaskId` up front (mirroring the completion path), and the in_progress-claim check rejects the `{ error }` shape (not just `null`) and warn-logs the miss so it's no longer silent.+- **[issue-2633] Direct `task:ready` emits now claim against the right task file.** The Creative Director bridge, the on-demand `dequeueNextTask`, and `spawnPriority0OnDemand` publish task records with no `taskType`, so an internal (`sys-*`/`cd-*`/`app-improve-*`) task's claim/in_progress `updateTask` fell back to `'user'`, targeted TASKS.md instead of COS-TASKS.md, missed the record, and returned a truthy `{ error }` object the `if (!updateResult)` check silently swallowed — leaving the task un-claimed while the agent spawned anyway. `runAgentSpawn` now normalizes `taskType` from the id via `isInternalTaskId` up front (mirroring the completion path), so a correctly-routed internal task's claim lands in COS-TASKS.md. The in_progress-claim miss is now warn-logged so it's no longer silent — but it stays non-fatal: legitimately-unpersisted autonomous emits (Priority 3 mission and Priority 4 idle-review tasks carry `taskType:'internal'` but are never written to COS-TASKS.md) must still spawn as they did before, so only a `null` result (updateTask threw) aborts the spawn.- **[issue-2540] Stop full-JSONB table loads for pipeline issue id sweeps and bound the multi-account message inbox aggregate.** `listIssueIds` (the conflict-journal orphan-base-hash sweep + tombstone GC) went through `readState()` → `loadAll()`, pulling every issue's full `data` JSONB — up to ~12MB of stage `runHistory` each — into memory only to read the ids; it now sources the store's `SELECT id` projection, with the PG backend filtering tombstones via the mirrored `deleted` column (`listIds({ includeDeleted })`) so the whole-record load is skipped entirely for the default live sweep. Separately, `messageSync.getMessages`'s multi-account inbox spread every message from every account into one array and globally sorted it before slicing a page; it now bounds each account's contribution to the top `offset+limit` by date and merges those heads, so a paged inbox reads `accounts × (offset+limit)` messages into the merge instead of the full cross-account total (the exact `total` count is preserved).- **[issue-2538] Bound Spotify auth and privacy-broker fetches, and single-flight token refresh.** The Spotify token endpoint (`spotifyAuth.js`) and the BADBOOL / CA-registry broker fetchers (`privacyBrokers.js`) used bare `fetch` with no timeout, so a hung `accounts.spotify.com` could stall an OAuth callback or a history-sync refresh — and a broker source that never responded could hang a user-triggered refresh — indefinitely. All three now go through the shared `fetchWithTimeout` helper with a 15s cap. Separately, concurrent `getAccessToken()` callers that all found the token expired each POSTed their own refresh, and since Spotify rotates the grant the losers persisted a stale token (last-write-wins); refreshes now share one in-flight `refreshPromise` (single-flight), so the grant is rotated exactly once and the guard is released on settle so a failed refresh can retry.- **[issue-2552] Enlarge above-the-fold mobile touch targets to 44px.** The GoalDetailPanel close button (`p-1` + a 16px icon, ~24px) and the notification bell (40px min) were below the 44×44 touch-target minimum the shell's other chrome controls already meet. The close button now uses `min-h-[44px] min-w-[44px]` centered around its icon (matching the shared `Drawer` control sizing), and the bell's mobile hit area is bumped 40→44px (its `sm:` desktop shrink is unchanged). The notification panel also gains `max-w-[calc(100vw-2rem)]` so its `w-80` width can't overflow a narrow mobile sidebar, and the ⌘K result rows get a `min-h-[44px]` so each is comfortably tappable.diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.jsindex db441eab4a..67e031e29f 100644--- a/server/services/agentLifecycle.js+++ b/server/services/agentLifecycle.js@@ -502,14 +502,20 @@ async function runAgentSpawn(task) {console.error(`❌ Failed to mark task ${task.id} as in_progress: ${err.message}`);return null;});- // Catch BOTH failure shapes: a null from the `.catch` above (updateTask threw)- // and a truthy `{ error }` object from a silent miss — e.g. the task id isn't- // present in the file for `task.taskType` (issue #2633). A bare `if (!updateResult)`- // lets the error object through, so the spawn proceeds against an unclaimed task.- if (!updateResult || updateResult.error) {- if (updateResult?.error) {- emitLog('warn', `⚠️ in_progress claim for task ${task.id} returned an error (taskType=${task.taskType}): ${updateResult.error}`, { taskId: task.id, error: updateResult.error });- }+ // Surface a silent `{ error }` miss (issue #2633) — the task id wasn't present+ // in the file for `task.taskType`, so the claim didn't land. This is EXPECTED+ // for legitimately-unpersisted autonomous emits: Priority 3 mission tasks+ // (cos.js `spawnDequeuePriority3Missions`) and Priority 4 idle-review tasks+ // carry `taskType: 'internal'` but are never written to COS-TASKS.md, so their+ // in_progress `updateTask` returns `{ error: 'Task not found' }`. Warn-log it+ // for visibility, but do NOT block the spawn on it — the pre-#2633 behavior+ // spawned these anyway, and treating the error as fatal would silently kill+ // every mission / idle-review autonomous spawn. Only a `null` (updateTask+ // threw) is fatal.+ if (updateResult?.error) {+ emitLog('warn', `⚠️ in_progress claim for task ${task.id} returned an error (taskType=${task.taskType}): ${updateResult.error}`, { taskId: task.id, error: updateResult.error });+ }+ if (!updateResult) {await cleanupOnError('Failed to update task status');return null;}diff --git a/server/services/agentLifecycle.test.js b/server/services/agentLifecycle.test.jsindex 707961eb7a..b629549d0e 100644--- a/server/services/agentLifecycle.test.js+++ b/server/services/agentLifecycle.test.js@@ -487,14 +487,22 @@ describe('runAgentSpawn source — taskType normalization + claim-miss guard (is.toBeLessThan(firstUpdateIdx);});- it('the in_progress claim check catches a truthy { error } object, not just null', () => {- const guardIdx = RUN_SPAWN_BODY.indexOf('if (!updateResult || updateResult.error)');- expect(guardIdx, 'the claim result must be rejected when it carries an { error } (silent miss)').toBeGreaterThan(-1);+ it('only a null in_progress result is fatal — an { error } miss must NOT block the spawn', () => {+ // A truthy `{ error }` is EXPECTED for legitimately-unpersisted autonomous+ // emits (Priority 3 mission / Priority 4 idle-review tasks carry+ // taskType:'internal' but are never written to COS-TASKS.md). Blocking on it+ // would silently kill every mission/idle spawn — the pre-#2633 behavior+ // spawned them anyway, so the fatal guard must remain `!updateResult` only.+ const fatalIdx = RUN_SPAWN_BODY.indexOf('if (!updateResult) {');+ expect(fatalIdx, 'the fatal guard must be `!updateResult` alone — the { error } shape must not be fatal').toBeGreaterThan(-1);+ expect(RUN_SPAWN_BODY, 'the { error } shape must not be part of the fatal guard (it would block unpersisted mission/idle spawns)')+ .not.toContain('if (!updateResult || updateResult.error)');});it('warn-logs when the in_progress claim returns an { error } object so silent misses are visible', () => {- const guardIdx = RUN_SPAWN_BODY.indexOf('if (!updateResult || updateResult.error)');- const body = RUN_SPAWN_BODY.slice(guardIdx, guardIdx + 400);+ const warnIdx = RUN_SPAWN_BODY.indexOf('if (updateResult?.error) {');+ expect(warnIdx, 'a silent { error } miss must be surfaced via a warn log').toBeGreaterThan(-1);+ const body = RUN_SPAWN_BODY.slice(warnIdx, warnIdx + 400);expect(body).toMatch(/emitLog\('warn'/);expect(body).toContain('updateResult.error');});