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): record every task blocked on a deduped investigation
[._.]/ Adam Eivyc5e85545c160
diff --git a/server/services/agentErrorAnalysis.js b/server/services/agentErrorAnalysis.jsindex 44e5fd7e6a..c7a1988024 100644--- a/server/services/agentErrorAnalysis.js+++ b/server/services/agentErrorAnalysis.js@@ -631,6 +631,13 @@ async function doCreateInvestigationTask(agentId, originalTask, errorAnalysis) {emitLog('info', `⏭️ Skipping duplicate investigation for ${fingerprint}: ${existing.id} is still ${existing.status}`, {agentId, taskId: originalTask.id, fingerprint, existingTaskId: existing.id, existingStatus: existing.status});+ // Union this failure's task id into the surviving investigation, so the+ // record names EVERY task blocked on this cause — resolving it should+ // unblock all of them, not just the first one mentioned in the body.+ const affected = Array.isArray(existing.metadata?.affectedTasks) ? existing.metadata.affectedTasks : [];+ if (originalTask.id && !affected.includes(originalTask.id)) {+ await updateTask(existing.id, { metadata: { affectedTasks: [...affected, originalTask.id] } }, 'internal');+ }return existing;}@@ -685,7 +692,8 @@ Approving and applying the fix lets the original task \`${originalTask.id}\` becontext: `Auto-generated from agent ${agentId} failure`,approvalRequired: true, // Require human approval before auto-fixingisInvestigation: true, // Meta-cascade guard marker (#2615)- investigationFingerprint: fingerprint+ investigationFingerprint: fingerprint,+ affectedTasks: [originalTask.id] // later same-fingerprint failures union in}, 'internal');// Count only genuine creations against the circuit — addTask's owndiff --git a/server/services/agentErrorAnalysis.test.js b/server/services/agentErrorAnalysis.test.jsindex 72dfaf9dce..319cfbfb4b 100644--- a/server/services/agentErrorAnalysis.test.js+++ b/server/services/agentErrorAnalysis.test.js@@ -17,7 +17,7 @@ import {INVESTIGATION_CIRCUIT_MAX_CREATIONS,__resetInvestigationCircuit} from './agentErrorAnalysis.js';-import { addTask, getAllTasks } from './cos.js';+import { addTask, updateTask, getAllTasks } from './cos.js';import { MAX_TOTAL_SPAWNS } from '../lib/validation.js';// Default store shape for suites that exercise the create path: no existing@@ -299,20 +299,44 @@ describe('createInvestigationTask guards (#2615)', () => {beforeEach(() => {addTask.mockReset();addTask.mockResolvedValue({ id: 'investigation-1' });+ updateTask.mockReset();+ updateTask.mockResolvedValue({});mockEmptyStore();__resetInvestigationCircuit();});- it('stamps the fingerprint and isInvestigation marker onto the created task', async () => {+ it('stamps the fingerprint, isInvestigation marker, and affectedTasks onto the created task', async () => {await createInvestigationTask('agent-1', failedTask, analysis);expect(addTask).toHaveBeenCalledWith(expect.objectContaining({priority: 'HIGH',approvalRequired: true,isInvestigation: true,- investigationFingerprint: 'startup-failure:user:none'+ investigationFingerprint: 'startup-failure:user:none',+ affectedTasks: ['task-1']}), 'internal');});+ it('unions a later same-fingerprint failure into the surviving investigation\'s affectedTasks', async () => {+ const existing = {+ id: 'inv-open', status: 'pending',+ metadata: { investigationFingerprint: 'startup-failure:user:none', affectedTasks: ['task-1'] }+ };+ getAllTasks.mockResolvedValue({ user: { tasks: [] }, cos: { tasks: [existing] } });+ await createInvestigationTask('agent-2', { ...failedTask, id: 'task-2' }, analysis);+ expect(addTask).not.toHaveBeenCalled();+ expect(updateTask).toHaveBeenCalledWith('inv-open', { metadata: { affectedTasks: ['task-1', 'task-2'] } }, 'internal');+ });++ it('does not re-write affectedTasks when the failed task is already recorded', async () => {+ const existing = {+ id: 'inv-open', status: 'pending',+ metadata: { investigationFingerprint: 'startup-failure:user:none', affectedTasks: ['task-1'] }+ };+ getAllTasks.mockResolvedValue({ user: { tasks: [] }, cos: { tasks: [existing] } });+ await createInvestigationTask('agent-2', failedTask, analysis); // task-1 again+ expect(updateTask).not.toHaveBeenCalled();+ });+it.each(['pending', 'in_progress', 'challenged', 'blocked'])('skips creation while a same-fingerprint investigation is %s',async (status) => {diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.jsindex 29f798bebc..8b61355ec0 100644--- a/server/services/cosTaskStore.js+++ b/server/services/cosTaskStore.js@@ -243,9 +243,11 @@ export async function addTask(taskData, taskType = 'user', { raw = false, ignoreif (taskData.voiceDispatch === true) metadata.voiceDispatch = true;if (taskData.isRecovery === true) metadata.isRecovery = true;// Investigation-task guards (#2615): the durable fingerprint dedupes repeat- // failures of the same cause; the marker blocks investigations-of-investigations.+ // failures of the same cause; the marker blocks investigations-of-investigations;+ // affectedTasks names every task blocked on the cause (later dedup hits union in).if (taskData.isInvestigation === true) metadata.isInvestigation = true;if (taskData.investigationFingerprint) metadata.investigationFingerprint = taskData.investigationFingerprint;+ if (Array.isArray(taskData.affectedTasks) && taskData.affectedTasks.length > 0) metadata.affectedTasks = taskData.affectedTasks;if (taskData.createJiraTicket) metadata.createJiraTicket = true;// Boolean flags: persist both true and false so users can explicitly override defaults.// The string round-trip ('false' from TASKS.md) is handled by isTruthyMeta/isFalsyMeta.diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.jsindex 725c73a05a..3153c30aea 100644--- a/server/services/cosTaskStore.test.js+++ b/server/services/cosTaskStore.test.js@@ -204,17 +204,21 @@ describe('cosTaskStore.addTask', () => {description: '[Auto] Investigate agent failure: agent exited during startup',approvalRequired: true,isInvestigation: true,- investigationFingerprint: 'startup-failure:user:none'+ investigationFingerprint: 'startup-failure:user:none',+ affectedTasks: ['task-abc']}, 'internal');expect(created.metadata.isInvestigation).toBe(true);expect(created.metadata.investigationFingerprint).toBe('startup-failure:user:none');+ expect(created.metadata.affectedTasks).toEqual(['task-abc']);// Survives the markdown serialize → parse round-trip: the colon-bearing- // fingerprint stays intact (parser splits on the FIRST colon only) and the- // boolean marker comes back as the string 'true' (isTruthyMeta territory).+ // fingerprint stays intact (parser splits on the FIRST colon only), the+ // boolean marker comes back as the string 'true' (isTruthyMeta territory),+ // and the affectedTasks array round-trips via the JSON sentinel.const { tasks } = await getCosTasks();const reloaded = tasks.find(t => t.id === created.id);expect(reloaded.metadata.investigationFingerprint).toBe('startup-failure:user:none');expect(reloaded.metadata.isInvestigation === true || reloaded.metadata.isInvestigation === 'true').toBe(true);+ expect(reloaded.metadata.affectedTasks).toEqual(['task-abc']);});it('omits investigation guard metadata when not supplied', async () => {