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
narrow the task intake's imports and drop tests the store boundary already proves
[._.]/ Adam Eivy505099c737d5
diff --git a/server/lib/importScoping.test.js b/server/lib/importScoping.test.jsindex 1dc659fcb2..cf2d0b3c3d 100644--- a/server/lib/importScoping.test.js+++ b/server/lib/importScoping.test.js@@ -67,6 +67,8 @@ const NARROWED = ['needs inferTuiCommand, which providerVendors.js declares'],['services/voice/tools/pipeline.js', 'services/pipeline/issues.js','needs NAVIGABLE_STAGE_IDS, which issuesShared.js declares'],+ ['services/cosTaskIntake.js', 'lib/validation.js',+ 'needs SWARM_COUNT_* and the reviewer normalizers, which cosValidation.js / reviewerConfig.js declare'],];describe('narrowed imports stay narrow (#6009)', () => {diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.jsindex 6383c85f2a..fadb33fab3 100644--- a/server/services/cosTaskGenerator.js+++ b/server/services/cosTaskGenerator.js@@ -38,7 +38,8 @@ import { remainingActionBudget } from '../lib/domainBudgets.js';import { getDomainBudgetStatus } from './domainUsage.js';import { pendingCosActionReservations } from './cosAdmissionReservations.js';import { cosEvents, emitLog } from './cosEvents.js';-import { addTask, updateTask, reviveBlockedTask, getAllTasks, getCosTasks, firstLine, PRIORITY_VALUES } from './cosTaskStore.js';+import { addTask, updateTask, reviveBlockedTask, getAllTasks, getCosTasks, firstLine } from './cosTaskStore.js';+import { PRIORITY_VALUES } from '../lib/taskParser.js';import { recordDecision, DECISION_TYPES } from './decisionLog.js';import { isAppOnCooldown, markAppReviewCooldown, bindAppReviewAgent, markIdleReviewStarted, getNextAppForReview, loadAppActivity, isAppActivityOnCooldown } from './appActivity.js';import { getActiveApps, getAppTaskTypeOverrides } from './apps.js';diff --git a/server/services/cosTaskIntake.js b/server/services/cosTaskIntake.jsindex c167d1b538..b2b88555ac 100644--- a/server/services/cosTaskIntake.js+++ b/server/services/cosTaskIntake.js@@ -22,7 +22,8 @@*/import { hasKnownPrefix, PRIORITY_VALUES } from '../lib/taskParser.js';-import { KEYED_REVIEWER_PINS, REVIEW_STOP_MODES, SWARM_COUNT_MAX, SWARM_COUNT_MIN, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers } from '../lib/validation.js';+import { SWARM_COUNT_MAX, SWARM_COUNT_MIN } from '../lib/cosValidation.js';+import { KEYED_REVIEWER_PINS, REVIEW_STOP_MODES, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers } from '../lib/reviewerConfig.js';import { isPlainObject } from '../lib/objects.js';import { PR_COMPLETIONS, PR_COMPLETION_VALUES } from '../lib/prDisposition.js';import { quotaBurnProvenance, quotaBurnTaskMetadata } from '../lib/quotaBurnOrigin.js';@@ -50,7 +51,7 @@ export function buildTaskMetadata(taskData, taskType, { now = Date.now() } = {})if (taskData.context) metadata.context = taskData.context;// The full agent-facing payload, when the producer names it explicitly// (#4153). Producers that still pass a multi-line `context` are classified- // by `splitTaskPromptFields` below, so both call shapes converge.+ // by `splitTaskPromptFields` in `cosTaskStore.js#addTask`, so both call shapes converge.if (typeof taskData.prompt === 'string') metadata.prompt = taskData.prompt;if (taskData.model) metadata.model = taskData.model;if (taskData.provider) metadata.provider = taskData.provider;@@ -241,7 +242,7 @@ export function buildTaskMetadata(taskData, taskType, { now = Date.now() } = {})// window will refuse first, which burn step asked, and which on-demand// request (if any) it was generated for. The built-in lane stamps these onto// the generated task's metadata via `lib/quotaBurnOrigin.js` and reaches disk- // through the RAW path above; a custom-job burn reaches disk through this+ // through the RAW path in `cosTaskStore.js#addTask`; a custom-job burn reaches disk through this// non-raw path instead. Both spread the SAME block so the two lanes cannot// carry different provenance for the same feature — mapping the keys one at// a time here is how `quotaBurnStepId` came to reach disk without everdiff --git a/server/services/cosTaskIntake.test.js b/server/services/cosTaskIntake.test.jsindex a169c17705..91ea51e7cf 100644--- a/server/services/cosTaskIntake.test.js+++ b/server/services/cosTaskIntake.test.js@@ -1,24 +1,18 @@/**- * Schema ↔ intake parity for the non-raw `addTask` path.- *- * `createCosTaskSchema` (lib/cosValidation.js) and `buildTaskMetadata`- * (cosTaskIntake.js) are two halves of one contract: the schema admits a- * request field, the intake carries it onto `metadata`. They drifted three- * times while the mapping was buried inside the store (`optionalReviewers`- * validated but never persisted; `discardWorktree` / `noCodeOutput` reachable- * only through the raw path). Every schema field must now be classified here:- * either it maps (and a sample proves it), or it is named as a non-metadata- * field with the reason. Adding a schema field without doing either fails.+ * Parity guard between `createCosTaskSchema` (lib/cosValidation.js) and+ * `buildTaskMetadata` — see the module header in cosTaskIntake.js for why.+ * Every schema field is either mapped (a schema-valid sample must change the+ * metadata) or named as non-metadata with the reason; anything else fails.*/import { describe, it, expect } from 'vitest';import { createCosTaskSchema } from '../lib/cosValidation.js';import { REVIEW_STOP_MODES } from '../lib/reviewerConfig.js';import { PR_COMPLETIONS } from '../lib/prDisposition.js';-import { buildTaskMetadata, buildQueuedTask } from './cosTaskIntake.js';+import { buildTaskMetadata } from './cosTaskIntake.js';const NOW = Date.UTC(2026, 0, 2, 3, 4, 5);-const base = (taskType = 'user') => buildTaskMetadata({ description: 'x' }, taskType, { now: NOW });+const base = () => buildTaskMetadata({ description: 'x' }, 'user', { now: NOW });// Request fields consumed by the route or the store itself, never carried// into `metadata`. Naming them is the verdict; the parity test below refuses@@ -78,7 +72,6 @@ describe('createCosTaskSchema ↔ buildTaskMetadata parity', () => {it('classifies every schema field exactly once', () => {const schemaFields = Object.keys(createCosTaskSchema.shape).sort();const classified = [...Object.keys(NON_METADATA_FIELDS), ...Object.keys(METADATA_SAMPLES)].sort();- expect(new Set(classified).size).toBe(classified.length);expect(classified).toEqual(schemaFields);});@@ -95,27 +88,3 @@ describe('createCosTaskSchema ↔ buildTaskMetadata parity', () => {expect(buildTaskMetadata({ description: 'x', notARequestField: true }, 'user', { now: NOW })).toEqual(base());});});--describe('buildQueuedTask', () => {- it('builds the pending record with a prefixed id and the LWW stamp', () => {- const task = buildQueuedTask({ id: 'abc', description: 'Do it', priority: 'high' }, 'user', { now: NOW });- expect(task).toMatchObject({- id: 'task-abc', status: 'pending', priority: 'HIGH', priorityValue: 3,- description: 'Do it', approvalRequired: false, autoApproved: false, section: 'pending',- });- expect(task.metadata.updatedAt).toBe(new Date(NOW).toISOString());- });-- it('collapses plan-only into the read-only, no-delivery posture', () => {- const { metadata } = buildQueuedTask(- { description: 'Plan it', planOnly: true, useWorktree: true, openPR: true, reviewers: ['codex'] },- 'user', { now: NOW }- );- expect(metadata).toMatchObject({- planOnly: true, slashdoCommand: 'plan-task', slashdoArgs: '--yes', readOnly: true,- noCodeOutput: true, useWorktree: false, openPR: false, reviewLoop: false,- });- expect(metadata).not.toHaveProperty('reviewers');- expect(metadata).not.toHaveProperty('prCompletion');- });-});diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.jsindex e8e4937527..d6d3dff817 100644--- a/server/services/cosTaskStore.js+++ b/server/services/cosTaskStore.js@@ -40,9 +40,6 @@ import { runLocalCodeReview, getCodeReviewDefaults } from './codeReview.js';// must normalize on the first line to match multi-line inputs.export const firstLine = (s) => (s || '').split('\n').map(l => l.trim()).find(l => l) || '';-// Re-exported at the address callers already use; taskParser.js declares it.-export { PRIORITY_VALUES };-const CLAIM_KEY_SET = new Set(CLAIM_METADATA_KEYS);@@ -260,9 +257,6 @@ export async function getTaskById(taskId) {* interval. `suppressDequeue` is reserved for an explicit dispatcher that will* force-spawn the returned task itself; the change event still reaches socket* consumers, but the normal scheduler must not race that dispatch.- *- * The non-raw request → task record mapping lives in `cosTaskIntake.js`- * (`buildQueuedTask`), whose test keeps it in parity with `createCosTaskSchema`.*/export async function addTask(taskData, taskType = 'user', { raw = false, ignoreTaskId = null, now = Date.now(), suppressDequeue = false } = {}) {return withStateLock(async () => {@@ -321,12 +315,7 @@ export async function addTask(taskData, taskType = 'user', { raw = false, ignore}// When raw=true, use the pre-built task object directly (for on-demand/generated tasks)- let newTask;- if (raw) {- newTask = taskData;- } else {- newTask = buildQueuedTask(taskData, taskType, { now });- }+ let newTask = raw ? taskData : buildQueuedTask(taskData, taskType, { now });// Route a multi-line context payload to `metadata.prompt` (#4153). Applied to// BOTH branches — the raw path is how the generator, the reference-watchdiff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.jsindex 64eb1dec51..73e8497a35 100644--- a/server/services/cosTaskStore.test.js+++ b/server/services/cosTaskStore.test.js@@ -93,7 +93,6 @@ vi.mock('./layeredIntelligenceOutcomes.js', () => ({import {firstLine,- PRIORITY_VALUES,getUserTasks,getCosTasks,getAllTasks,@@ -116,6 +115,7 @@ import {DEFAULT_FAILURE_TASK_MAX_AGE_MS,__resetTaskCache} from './cosTaskStore.js';+import { PRIORITY_VALUES } from '../lib/taskParser.js';import { AGENT_PAUSED_CATEGORY, PAUSE_METADATA_KEYS, registerPauseReleaseAdapter, __resetPauseReleaseAdapter } from '../lib/taskPauseHold.js';import { MAX_TOTAL_SPAWNS } from '../lib/cosValidation.js';