Skip to content

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

fix: unify extractTaskType to canonical implementation (#10403)

Adam Eivy408b2ed982a8
diff --git a/server/services/cos.js b/server/services/cos.js
index dde66b645c..0ed3178bf7 100644
--- a/server/services/cos.js
+++ b/server/services/cos.js
@@ -77,7 +77,6 @@ export {
getPendingAgentFeedbackCount,
getPendingAgentFeedbackPage,
initializeAgentFeedback,
- extractTaskType,
} from './cosAgentFeedback.js';
export { archiveStaleAgents, clearCompletedAgents } from './cosAgentArchive.js';
diff --git a/server/services/cosAgentFeedback.js b/server/services/cosAgentFeedback.js
index ce19115327..a4535b7628 100644
--- a/server/services/cosAgentFeedback.js
+++ b/server/services/cosAgentFeedback.js
@@ -1,7 +1,7 @@
/**
* CoS Agent Feedback Module
*
- * Per-agent feedback capture + aggregation and the task-type classifier.
+ * Per-agent feedback capture + aggregation.
* Extracted from the former monolithic cosAgents.js (issue #2530).
*
* The `cosAgents.js` barrel that used to re-export this module is retired
@@ -36,6 +36,7 @@ import {
removePendingAgentFeedbackRef,
upsertPendingAgentFeedbackRef,
} from './cosAgentFeedbackStore.js';
+import { extractTaskType } from './taskLearning/store.js';
const ARCHIVE_READ_BATCH_SIZE = 50;
const hasValidFeedback = hasValidAgentFeedback;
@@ -354,7 +355,11 @@ export async function submitAgentFeedback(agentId, feedback) {
taskId: response.agent?.taskId ?? null,
rating: feedbackData.rating,
comment: feedbackData.comment,
- taskType: extractTaskType(response.agent?.metadata?.taskDescription),
+ taskType: extractTaskType({
+ description: response.agent?.metadata?.taskDescription,
+ metadata: response.agent?.metadata,
+ taskType: response.agent?.metadata?.taskType,
+ }),
},
source: { service: 'cosAgentFeedback', fn: 'submitAgentFeedback' },
happenedAt: feedbackData.submittedAt,
@@ -384,7 +389,11 @@ export async function getFeedbackStats() {
// Group by task type
const byTaskType = {};
withFeedback.forEach(a => {
- const taskType = extractTaskType(a.metadata?.taskDescription);
+ const taskType = extractTaskType({
+ description: a.metadata?.taskDescription,
+ metadata: a.metadata,
+ taskType: a.metadata?.taskType,
+ });
if (!byTaskType[taskType]) {
byTaskType[taskType] = { positive: 0, negative: 0, neutral: 0, total: 0 };
}
@@ -437,23 +446,3 @@ export function initializeAgentFeedback() {
});
}
-// Helper to extract task type from description (mirrors client-side logic)
-export function extractTaskType(description) {
- if (!description) return 'general';
- const d = description.toLowerCase();
- if (d.includes('fix') || d.includes('bug') || d.includes('error') || d.includes('issue')) return 'bug-fix';
- if (d.includes('refactor') || d.includes('clean up') || d.includes('improve') || d.includes('optimize')) return 'refactor';
- if (d.includes('test')) return 'testing';
- if (d.includes('document') || d.includes('readme') || d.includes('docs')) return 'documentation';
- if (d.includes('review') || d.includes('audit')) return 'code-review';
- if (d.includes('mobile') || d.includes('responsive')) return 'mobile-responsive';
- if (d.includes('security') || d.includes('vulnerability')) return 'security';
- if (d.includes('performance') || d.includes('speed')) return 'performance';
- if (d.includes('ui') || d.includes('ux') || d.includes('design') || d.includes('style')) return 'ui-ux';
- if (d.includes('api') || d.includes('endpoint') || d.includes('route')) return 'api';
- if (d.includes('database') || d.includes('migration')) return 'database';
- if (d.includes('deploy') || d.includes('ci') || d.includes('cd')) return 'devops';
- if (d.includes('investigate') || d.includes('debug')) return 'investigation';
- if (d.includes('self-improvement') || d.includes('feature idea')) return 'self-improvement';
- return 'feature';
-}
diff --git a/server/services/cosAgentFeedback.test.js b/server/services/cosAgentFeedback.test.js
index 80a40e3835..b0ecc99308 100644
--- a/server/services/cosAgentFeedback.test.js
+++ b/server/services/cosAgentFeedback.test.js
@@ -254,9 +254,8 @@ describe('getPendingAgentFeedbackCount', () => {
neutral: 1,
satisfactionRate: 33,
byTaskType: {
- 'bug-fix': { positive: 0, negative: 1, neutral: 0, total: 1 },
- testing: { positive: 1, negative: 0, neutral: 0, total: 1 },
- documentation: { positive: 0, negative: 0, neutral: 1, total: 1 }
+ 'auto-fix': { positive: 0, negative: 1, neutral: 0, total: 1 },
+ 'external/untyped': { positive: 1, negative: 0, neutral: 1, total: 2 }
},
recentWithComments: [{
agentId: 'agent-archived',
@@ -267,6 +266,70 @@ describe('getPendingAgentFeedbackCount', () => {
}]
});
});
+
+ it('classifies claim-issue and self-improvement agents with parity between feedback and learning (#10403)', async () => {
+ // Issue: feedback stats used a divergent extractTaskType taxonomy. Verify
+ // that feedback classification now matches the canonical learning one by
+ // testing claim-issue (user task / issue description) and self-improvement
+ // agents get the same bucket in both paths.
+ const { extractTaskType: learningExtractTaskType } = await import('./taskLearning/store.js');
+
+ // Claim-issue agent: mimics a /do:next claim task with issue metadata
+ const claimAgent = {
+ id: 'agent-claim-issue',
+ taskId: 'github-issue-999',
+ status: 'completed',
+ completedAt: '2026-08-02T10:00:00.000Z',
+ metadata: {
+ taskType: 'user',
+ taskDescription: 'Investigate and fix parsing regression',
+ },
+ feedback: { rating: 'positive', submittedAt: '2026-08-02T11:00:00.000Z' }
+ };
+
+ // Self-improvement agent: metadata includes analysisType
+ const selfImprovementAgent = {
+ id: 'agent-self-improve',
+ status: 'completed',
+ completedAt: '2026-08-02T12:00:00.000Z',
+ metadata: {
+ taskType: 'internal',
+ analysisType: 'code-review',
+ taskDescription: 'Review recent PRs for quality',
+ },
+ feedback: { rating: 'positive', submittedAt: '2026-08-02T13:00:00.000Z' }
+ };
+
+ mockCosState.state.agents = {
+ [claimAgent.id]: claimAgent,
+ [selfImprovementAgent.id]: selfImprovementAgent,
+ };
+
+ // Get feedback classification
+ const feedbackStats = await getFeedbackStats();
+
+ // Get learning classification (what taskLearning/store.js would use)
+ const claimLearningType = learningExtractTaskType({
+ description: claimAgent.metadata.taskDescription,
+ metadata: claimAgent.metadata,
+ taskType: claimAgent.metadata.taskType,
+ });
+ const selfImproveLearningType = learningExtractTaskType({
+ description: selfImprovementAgent.metadata.taskDescription,
+ metadata: selfImprovementAgent.metadata,
+ taskType: selfImprovementAgent.metadata.taskType,
+ });
+
+ // Verify feedback and learning classifications match
+ expect(Object.keys(feedbackStats.byTaskType)).toContain(claimLearningType);
+ expect(Object.keys(feedbackStats.byTaskType)).toContain(selfImproveLearningType);
+ expect(feedbackStats.byTaskType[claimLearningType]).toEqual({
+ positive: 1, negative: 0, neutral: 0, total: 1
+ });
+ expect(feedbackStats.byTaskType[selfImproveLearningType]).toEqual({
+ positive: 1, negative: 0, neutral: 0, total: 1
+ });
+ });
});
// ── Operator-action ledger (#5594) ──────────────────────────────────────────
@@ -310,8 +373,9 @@ describe('submitAgentFeedback records the rating (#5594)', () => {
taskId: 'task-42',
rating: 'negative',
comment: 'Missed the root cause',
- // extractTaskType maps the description to a bucket the learning view uses.
- taskType: 'bug-fix',
+ // extractTaskType uses the canonical classifier from taskLearning/store.js,
+ // which prioritizes taskType field and metadata patterns over description.
+ taskType: 'user-task',
});
expect(event.dedupeKey).toBe(`cos.agent.feedback:agent-1:${event.happenedAt}`);
});