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
fix: stop logging 'Task not found' for scheduled job tasks that are never persisted (#12875)
Adam Eivyaab0261329b2
diff --git a/server/lib/README.md b/server/lib/README.mdindex c2c915fa79..ec0d07d326 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -116,7 +116,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `persistentMindToolActivation.js` | Pure lease-state helpers for progressive Persistent Mind tool exposure: the `TOOL_ACTIVATION_FAMILIES` vocabulary, `tools.activate`/`tools.deactivate` input schemas, and default/normalize/age/activate/renew/deactivate over a `{family: turnsLeft}` lease map. Retention is a selection hint only — every consumer still re-checks the real capability grant.| `heavyJobClaim.js` | Cross-process, machine-wide accelerator claim: `claimHeavyLocalJob({ kind, id, timeoutMs? })` either acquires an ephemeral `data/` lock or reports its active holder; dead-PID claims are reclaimed, and a spawned child can take over the recorded PID across a server restart. || `agentValidation.js` | Social-bot agent schemas (personality, Moltbook/Moltworld accounts, automation schedules, agent tools + Moltworld payloads) and CoS Feature Agent definitions. |-| `autonomousJobTask.js` | `generatedJobTaskFields` — flattens a `generateTaskFromJob` result into the top-level keys the non-raw `cos.addTask` path maps onto metadata. One allowlist shared by the manual "Run now" endpoint and the quota-burn lane, so a key added to the generator cannot reach one and not the other. Pure. |+| `autonomousJobTask.js` | `generatedJobTaskFields` — (+ `isEphemeralJobTask` / `isExpectedUnpersistedMiss`: a scheduled fire never persists its task, so the spawn/finalize status writes miss by design and stay quiet) flattens a `generateTaskFromJob` result into the top-level keys the non-raw `cos.addTask` path maps onto metadata. One allowlist shared by the manual "Run now" endpoint and the quota-burn lane, so a key added to the generator cannot reach one and not the other. Pure. || `qualitySchedulePlan.js` | Lays a managed app's schedulable quality audits out across a week. `planQualitySchedule({taskTypes, fileIssuesByType, busy, options})` → one weekly cron per check plus ONE daily cron for the issue-claim drain that follows each check by `claimOffsetHours` (placed forward-only, so a drain never precedes the audit it works for); `orderQualityChecks` topologically sorts the selection by `AUDIT_SUGGESTED_AFTER`; `buildBusySlots(occupancies, options)` turns expanded crons into the occupied `"<day>:<hour>"` cells the placement avoids (which is how a 03:30 release job keeps audits out of its window); `resolveQualityScheduleOptions` is the ONE default/window/claim-type resolver the planner and its service caller share. Which repo shape each audit needs is catalog-owned (`auditCapabilityRequirement`), not declared here. Pure: no schedule read, no repo read, no clock. || `quotaBurnConfig.js` | Quota-burn plan shape: the provider families, the burn-job type alphabet + catalog the config page renders its form from, `QUOTA_BURN_BOUNDS` (the one bounds table the normalizer clamps to, the Zod schemas reject against, and the catalog descriptors publish as min/max), and total normalization (`normalizeQuotaBurnConfig`). Owns the dispatch-cap sentinel too (`QUOTA_BURN_UNLIMITED_DISPATCHES` / `isUnlimitedDispatchCap`) — -1 means the window is not counted, and is the default. Also owns the retired executor's task-description parser (`QUOTA_BURN_TASK_PREFIX` / `quotaBurnFamilyOfDescription`), kept for migration 225, and the `run once` vocabulary (`quotaBurnJobKey` / `jobIsSpent`, plus the two family predicates `familyIsConfigured` and `familyHasRunnableJobs`). Pure — no storage, no provider I/O. || `quotaBurnLegacyConversion.js` | The ONE rule turning a LEGACY quota-burn step (copied prompt + quota-only `jobType`) into a scheduled-task reference, shared by migration 359 and the live compat path so the two cannot drift. `planQuotaBurnStepConversion` decides between three outcomes — a recognized unmodified shipped preset onto its scheduled audit counterpart with issues-only pinned explicitly (`AUDIT_TASK_TYPE_BY_PRESET_ID`, inverted from `auditCatalog.js`), the two programmatic types onto their scheduled handlers, and anything customized or targetless onto a `buildQuotaBurnCustomJob` on-demand custom task addressed by the deterministic `quotaBurnCustomJobId` (which is what makes a repeated or resumed conversion create no duplicate). `legacyAgentTaskMetadata` reproduces the retired executor's dispatch posture; `applyQuotaBurnStepConversion` rewrites the step, preserving id, label, enabled and run-once state. Recognition is `matchStoredAuditPreset`, never a label or a partial match. |diff --git a/server/lib/autonomousJobTask.js b/server/lib/autonomousJobTask.jsindex ded8ed3860..3c9a948d1f 100644--- a/server/lib/autonomousJobTask.js+++ b/server/lib/autonomousJobTask.js@@ -58,3 +58,19 @@ export function generatedJobTaskFields(generated) {effort: meta.effort,};}++/**+ * A scheduled fire hands its generated task straight to `task:ready` without+ * writing it to the task store (id `<jobId>-<base36 ts>`), so the status writes+ * at spawn and finalization legitimately find no row. Manual/quota runs queue+ * through `addTask` and get a store-minted id, so a missing one IS a deletion.+ */+export function isEphemeralJobTask(task) {+ const jobId = task?.metadata?.jobId;+ return task?.metadata?.autonomousJob === true && !!jobId && typeof task.id === 'string' && task.id.startsWith(`${jobId}-`);+}++/** True when an `updateTask` error is the expected miss for an unpersisted scheduled job task. */+export function isExpectedUnpersistedMiss(task, error) {+ return error === 'Task not found' && isEphemeralJobTask(task);+}diff --git a/server/lib/autonomousJobTask.test.js b/server/lib/autonomousJobTask.test.jsnew file mode 100644index 0000000000..e0b0951307--- /dev/null+++ b/server/lib/autonomousJobTask.test.js@@ -0,0 +1,18 @@+import { describe, it, expect } from 'vitest';+import { isExpectedUnpersistedMiss } from './autonomousJobTask.js';++const scheduled = { id: 'job-refresh-x-lz9abc', metadata: { autonomousJob: true, jobId: 'job-refresh-x' } };++describe('isExpectedUnpersistedMiss', () => {+ it('treats a missing scheduler-fired job task as expected', () => {+ expect(isExpectedUnpersistedMiss(scheduled, 'Task not found')).toBe(true);+ });+ it('still surfaces a persisted (addTask-minted) job task that vanished', () => {+ const persisted = { id: 'task-123', metadata: { autonomousJob: true, jobId: 'job-refresh-x' } };+ expect(isExpectedUnpersistedMiss(persisted, 'Task not found')).toBe(false);+ });+ it('still surfaces other errors and non-job tasks', () => {+ expect(isExpectedUnpersistedMiss(scheduled, 'Other failure')).toBe(false);+ expect(isExpectedUnpersistedMiss({ id: 'app-improve-1', metadata: {} }, 'Task not found')).toBe(false);+ });+});diff --git a/server/services/agentFinalization.js b/server/services/agentFinalization.jsindex 753961dd39..8bc502b006 100644--- a/server/services/agentFinalization.js+++ b/server/services/agentFinalization.js@@ -32,6 +32,7 @@ import { cosEvents, emitLog } from './cosEvents.js';// reach here.import { getAgent, getAgentRecord, updateAgent, completeAgent } from './cosAgentLifecycle.js';import { updateTask } from './cos.js';+import { isExpectedUnpersistedMiss } from '../lib/autonomousJobTask.js';import { getActiveProvider } from './providers.js';import { markProviderUsageLimit, markProviderUnavailable } from './providerStatus.js';import { resolveProviderBench } from '../lib/providerCooldown.js';@@ -1907,7 +1908,7 @@ export async function finalizeAgent({if (taskUpdate.metadata) delete taskUpdate.metadata.privateSecurityScope;}const taskResult = await updateTask(task.id, taskUpdate, taskType);- if (taskResult?.error) {+ if (taskResult?.error && !isExpectedUnpersistedMiss(task, taskResult.error)) {const label = terminatedByUser ? 'blocked' : verdict.success ? 'completed' : 'failed';emitLog('warn', `⚠️ Failed to update ${label} task ${task.id}: ${taskResult.error} (taskType=${taskType})`, { taskId: task.id, agentId, error: taskResult.error });}diff --git a/server/services/agentSpawnDispatch.js b/server/services/agentSpawnDispatch.jsindex 6f2b4df148..ae713edd33 100644--- a/server/services/agentSpawnDispatch.js+++ b/server/services/agentSpawnDispatch.js@@ -2,6 +2,7 @@ import { withBackupAssetPublication } from '../lib/backupSnapshotBoundary.js';import { join } from 'path';import { existsSync } from 'fs';import { getConfig, updateTask } from './cos.js';+import { isExpectedUnpersistedMiss } from '../lib/autonomousJobTask.js';import { isPrivateSecurityTask } from '../lib/privateSecurityPolicy.js';import { PROVIDER_CONFIG_BLOCKED_CATEGORY } from '../lib/taskBlockCategories.js';import { ensureDir, PATHS, writeFileGuarded } from '../lib/fileUtils.js';@@ -267,7 +268,7 @@ async function runAgentDispatch(context, { spawnViaRunner } = {}) {console.error(`❌ Failed to mark task ${task.id} as in_progress: ${err.message}`);return null;});- if (updateResult?.error) {+ if (updateResult?.error && !isExpectedUnpersistedMiss(task, updateResult.error)) {emitLog('warn', `⚠️ in_progress claim for task ${task.id} returned an error (taskType=${task.taskType}): ${updateResult.error}`, { taskId: task.id, error: updateResult.error });}if (prep.cleanupReviewPinConsumed && (updateResult?.error || updateResult?.statusChanged)) {