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): allow-list explicit taskTypes + round-trip-stable sandboxed fallback
Adam Eivya76366834274
diff --git a/server/services/taskLearning/store.js b/server/services/taskLearning/store.jsindex 4be0941ef8..f4642789bf 100644--- a/server/services/taskLearning/store.js+++ b/server/services/taskLearning/store.js@@ -160,6 +160,17 @@ const DESCRIPTION_CLASSIFIERS = [{ type: 'test-task', re: /\b(unit test|coverage|test suite|write tests?)\b/ }];+/**+ * Concrete `task.taskType` values (beyond user/internal, resolved upstream) that+ * map to a real learned domain. Allow-listed rather than accepting any string so+ * an unexpected/high-cardinality taskType can't spawn a swarm of non-sandboxed+ * singleton buckets that skew routing — anything not here falls through to the+ * description heuristics and, failing that, the sandboxed fallback.+ */+const KNOWN_UNSPECIALIZED_TASK_TYPES = new Set([+ 'scheduled', 'test', 'architect', 'layered-intelligence', 'all'+]);+/** Normalize a raw task-type token to a stable, low-cardinality slug. */function slugTaskType(raw) {return String(raw).trim().toLowerCase().replace(/[^a-z0-9:_-]+/g, '-').replace(/^-+|-+$/g, '');@@ -178,6 +189,11 @@ function slugTaskType(raw) {export function classifyUntypedTask(task) {if (!task || typeof task !== 'object') return EXTERNAL_UNTYPED_TASK_TYPE;+ // Round-trip safety: re-classifying an already-classified task by its own+ // recorded type must be stable and preserve the sandboxed bucket (the fallback+ // string's `/` would otherwise be slugged to a non-sandboxed `-task` below).+ if (isSandboxedTaskType(task?.taskType)) return task.taskType;+// 1) A self-improvement hint not paired with a taskApp (that pairing is// handled by the primary extractor upstream).const selfImprovementType = task?.metadata?.selfImprovementType;@@ -186,12 +202,14 @@ export function classifyUntypedTask(task) {}// 2) An explicit task.taskType the primary extractor didn't special-case- // (user/internal are resolved upstream). Preserve it as a concrete domain- // rather than collapsing distinct system domains into one bucket.+ // (user/internal are resolved upstream). Map an already-namespaced type+ // (`a:b`) or an allow-listed known domain to a concrete bucket; anything+ // else falls through so an unexpected value can't skew routing.const explicit = task?.taskType;if (typeof explicit === 'string' && explicit.trim() && explicit !== 'unknown') {const slug = slugTaskType(explicit);- if (slug) return slug.includes(':') ? slug : `${slug}-task`;+ if (slug.includes(':')) return slug;+ if (KNOWN_UNSPECIALIZED_TASK_TYPES.has(slug)) return `${slug}-task`;}// 3) Broader description keyword signatures (bracket-tag patterns already randiff --git a/server/services/taskLearning/store.test.js b/server/services/taskLearning/store.test.jsindex 7d9d95ce46..a1cfc87363 100644--- a/server/services/taskLearning/store.test.js+++ b/server/services/taskLearning/store.test.js@@ -83,7 +83,7 @@ describe('store.classifyUntypedTask (issue #2333)', () => {.toBe('self-improve:perf-tuning');});- it('preserves an explicit task.taskType the primary extractor did not special-case', () => {+ it('maps an allow-listed explicit task.taskType the primary extractor did not special-case', () => {// Previously these all collapsed to 'unknown'expect(classifyUntypedTask({ taskType: 'scheduled' })).toBe('scheduled-task');expect(classifyUntypedTask({ taskType: 'architect' })).toBe('architect-task');@@ -91,6 +91,20 @@ describe('store.classifyUntypedTask (issue #2333)', () => {expect(classifyUntypedTask({ taskType: 'self-improve:ui' })).toBe('self-improve:ui');});+ it('does not spawn a non-sandboxed bucket for an unexpected/high-cardinality taskType', () => {+ // Not allow-listed and not namespaced → falls through to the sandboxed fallback+ // rather than a routing-influencing `whatever-task` bucket.+ expect(classifyUntypedTask({ taskType: 'whatever-9f3a2b' })).toBe(EXTERNAL_UNTYPED_TASK_TYPE);+ });++ it('is round-trip stable: re-classifying the sandboxed fallback preserves the sandboxed bucket', () => {+ // Feeding external/untyped back through must NOT slug the `/` into a+ // non-sandboxed `external-untyped-task`.+ const rt = classifyUntypedTask({ taskType: EXTERNAL_UNTYPED_TASK_TYPE });+ expect(rt).toBe(EXTERNAL_UNTYPED_TASK_TYPE);+ expect(isSandboxedTaskType(rt)).toBe(true);+ });+it('classifies free-form descriptions by keyword when no type token is present', () => {expect(classifyUntypedTask({ description: 'Investigate the crash in the pipeline' })).toBe('auto-fix');expect(classifyUntypedTask({ description: 'Refactor and clean up the store module' })).toBe('self-improve:general');