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): fingerprint-exact headlines and legacy investigation recognition
[._.]/ Adam Eivy275fe7f99f61
diff --git a/server/services/agentErrorAnalysis.js b/server/services/agentErrorAnalysis.jsindex a6122e55e7..44e5fd7e6a 100644--- a/server/services/agentErrorAnalysis.js+++ b/server/services/agentErrorAnalysis.js@@ -569,6 +569,22 @@ export function buildInvestigationFingerprint(originalTask, analysis) {return `${category}:${kind}:${app}`;}+// Stable headline every investigation task ever created starts with — the one+// signal that exists on BOTH new tasks and pre-#2615 tasks (and on tasks synced+// from not-yet-upgraded federated peers, which a local migration couldn't fix).+const INVESTIGATION_HEADLINE_PREFIX = '[Auto] Investigate agent failure';++/**+ * Is this task an investigation task? Prefers the durable metadata marker;+ * falls back to the legacy headline shape so investigations persisted before+ * the marker existed still never spawn meta-investigations.+ */+export function isInvestigationTask(task) {+ if (isTruthyMeta(task?.metadata?.isInvestigation)) return true;+ return typeof task?.description === 'string'+ && task.description.trimStart().startsWith(INVESTIGATION_HEADLINE_PREFIX);+}+// Find an existing investigation task (user or internal queue) still tracking// this fingerprint in a non-terminal status.async function findOpenInvestigation(fingerprint) {@@ -642,14 +658,14 @@ async function doCreateInvestigationTask(agentId, originalTask, errorAnalysis) {|| analysis.suggestedFix|| 'Review the agent output, decide whether to fix the underlying config/code and retry, or close the task.';- // The app rides in the headline (mirroring the `[Improvement: <app>]`- // convention) so addTask's first-line dedup — which sees no `metadata.app`- // on investigation tasks — can't collapse identical messages from DIFFERENT- // apps into one task. Same-app repeats are already caught by the fingerprint- // scan above; deliberately NOT passed as `app` to addTask, which would- // change workspace routing for the investigation agent.- const app = originalTask?.metadata?.app || null;- const description = `[Auto] Investigate agent failure${app ? ` [${app}]` : ''}: ${message}+ // The fingerprint rides in the headline so addTask's first-line dedup —+ // which sees no `metadata.app` on investigation tasks — tracks fingerprint+ // identity exactly: identical messages from different apps OR different+ // task kinds/categories can never falsely collapse into one task, and+ // same-fingerprint repeats are already caught by the scan above. The app+ // is deliberately NOT passed as `app` to addTask, which would change+ // workspace routing for the investigation agent.+ const description = `${INVESTIGATION_HEADLINE_PREFIX} [${fingerprint}]: ${message}## What happenedAgent \`${agentId}\` failed while working on task \`${originalTask.id}\` (${originalDesc}).@@ -706,9 +722,11 @@ export async function maybeCreateInvestigationTask(agentId, task, analysis) {return;}// Meta-cascade guard (#2615): a failed investigation task must never spawn an- // investigation of the investigation. isTruthyMeta covers the markdown- // round-trip, where boolean metadata comes back as the string 'true'.- if (isTruthyMeta(task?.metadata?.isInvestigation)) {+ // investigation of the investigation. isInvestigationTask prefers the durable+ // metadata marker (isTruthyMeta covers the markdown round-trip, where boolean+ // metadata comes back as the string 'true') and falls back to the legacy+ // headline shape for tasks persisted before the marker existed.+ if (isInvestigationTask(task)) {emitLog('info', `⏭️ Skipping meta-investigation for ${task.id}: failed task is itself an investigation`, { agentId, taskId: task.id, category: analysis?.category });return;}diff --git a/server/services/agentErrorAnalysis.test.js b/server/services/agentErrorAnalysis.test.jsindex a5534f00e4..72dfaf9dce 100644--- a/server/services/agentErrorAnalysis.test.js+++ b/server/services/agentErrorAnalysis.test.js@@ -257,6 +257,24 @@ describe('maybeCreateInvestigationTask', () => {await maybeCreateInvestigationTask('agent-1', { id: 'inv-2', description: 'x', metadata: { isInvestigation: 'true' } }, { category: 'unknown', message: 'boom' });expect(addTask).not.toHaveBeenCalled();});++ it('recognizes pre-#2615 investigation tasks by their legacy headline (no metadata marker)', async () => {+ await maybeCreateInvestigationTask('agent-1', {+ id: 'inv-legacy',+ description: '[Auto] Investigate agent failure: some old failure message\n\n## What happened\n...',+ metadata: {}+ }, { category: 'unknown', message: 'boom' });+ expect(addTask).not.toHaveBeenCalled();+ });++ it('does not mistake an ordinary task mentioning investigations for an investigation', async () => {+ await maybeCreateInvestigationTask('agent-1', {+ id: 'task-ordinary',+ description: 'Improve the [Auto] Investigate agent failure flow',+ metadata: {}+ }, { category: 'unknown', message: 'boom' });+ expect(addTask).toHaveBeenCalledTimes(1);+ });});describe('buildInvestigationFingerprint', () => {@@ -357,16 +375,17 @@ describe('createInvestigationTask guards (#2615)', () => {expect(addTask).toHaveBeenCalledTimes(INVESTIGATION_CIRCUIT_MAX_CREATIONS + 1);});- it('embeds the failed task\'s app in the headline so first-line dedup cannot collapse different apps', async () => {+ it('embeds the fingerprint in the headline so first-line dedup tracks fingerprint identity exactly', async () => {await createInvestigationTask('agent-1', { ...failedTask, metadata: { app: 'ExampleApp' } }, analysis);expect(addTask.mock.calls[0][0].description.split('\n')[0])- .toBe('[Auto] Investigate agent failure [ExampleApp]: Agent exited during startup');- // No app → unchanged headline shape.+ .toBe('[Auto] Investigate agent failure [startup-failure:user:ExampleApp]: Agent exited during startup');+ // Different kind, same message → different first line, so addTask's+ // description dedup can never falsely collapse two distinct causes.addTask.mockClear();mockEmptyStore();- await createInvestigationTask('agent-2', failedTask, analysis);+ await createInvestigationTask('agent-2', { ...failedTask, metadata: { analysisType: 'app-improve' } }, analysis);expect(addTask.mock.calls[0][0].description.split('\n')[0])- .toBe('[Auto] Investigate agent failure: Agent exited during startup');+ .toBe('[Auto] Investigate agent failure [startup-failure:app-improve:none]: Agent exited during startup');});it('serializes concurrent same-fingerprint creates so only one task lands (TOCTOU)', async () => {