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
feat(cos): record no-action decisions with reasons for full evaluation transparency
Adam Eivy481041f80d5d
diff --git a/.changelog/v0.16.x.md b/.changelog/v0.16.x.mdindex 76a3c1c633..31929d88bd 100644--- a/.changelog/v0.16.x.md+++ b/.changelog/v0.16.x.md@@ -4,7 +4,7 @@ Released: YYYY-MM-DD## Overview-Agent persistence and reliability improvements.+Agent persistence, reliability, and decision transparency improvements.## Fixes@@ -15,3 +15,12 @@ Agent persistence and reliability improvements.- **`getAgent()` falls back to disk** -- individual agent lookups now check the cache when not found in state- **`deleteAgent()` now cleans up disk files** -- previously only removed from state, leaving orphaned metadata directories; now removes the agent directory entirely- **`clearCompletedAgents()` now cleans up disk files** -- previously only cleared state, leaving metadata files that would reappear on next cache load; now removes all completed agent directories++## Improvements++### CoS now records every no-action decision with reasons+- **Capacity decisions logged** -- when max concurrent agents (global or per-project) prevents task spawning, the reason is recorded to the decision log with full context (which limit was hit, how many agents running)+- **Cooldown decisions logged** -- when a system task is skipped because its target app is still in cooldown, the decision log captures the app ID and cooldown window duration+- **Idle decisions logged** -- when CoS has nothing to spawn after a full evaluation, it records whether that's due to tasks awaiting approval, all tasks on cooldown, or genuinely no work available+- **New decision types** -- added `CAPACITY_FULL` and `IDLE` to the decision type vocabulary; started using the previously-defined but unused `COOLDOWN_ACTIVE` type+- **Dashboard surfacing** -- capacity and cooldown decisions now appear in the impactful decisions summary on the dashboard, making it easy to spot bottlenecks at a glancediff --git a/server/services/cos.js b/server/services/cos.jsindex 16ce127f31..f9898d81ad 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -588,6 +588,11 @@ export async function evaluateTasks() {if (availableSlots <= 0) {emitLog('warn', `Max concurrent agents reached (${runningAgents}/${state.config.maxConcurrentAgents})`);+ await recordDecision(+ DECISION_TYPES.CAPACITY_FULL,+ `All ${state.config.maxConcurrentAgents} agent slots occupied`,+ { running: runningAgents, max: state.config.maxConcurrentAgents }+ );cosEvents.emit('evaluation', { message: 'Max concurrent agents reached', running: runningAgents });return;}@@ -682,7 +687,13 @@ export async function evaluateTasks() {if (tasksToSpawn.length >= availableSlots) break;const userTask = { ...task, taskType: 'user' };if (!canSpawnTask(userTask)) {- emitLog('debug', `⏳ Queued user task ${task.id} - per-project limit reached for ${task.metadata?.app || '_self'}`);+ const project = task.metadata?.app || '_self';+ emitLog('debug', `⏳ Queued user task ${task.id} - per-project limit reached for ${project}`);+ await recordDecision(+ DECISION_TYPES.CAPACITY_FULL,+ `User task ${task.id} deferred — per-project limit (${perProjectLimit}) reached for ${project}`,+ { taskId: task.id, project, limit: perProjectLimit }+ );continue;}tasksToSpawn.push(userTask);@@ -701,13 +712,24 @@ export async function evaluateTasks() {const onCooldown = await isAppOnCooldown(appId, state.config.appReviewCooldownMs);if (onCooldown) {emitLog('debug', `Skipping system task ${task.id} - app ${appId} on cooldown`);+ await recordDecision(+ DECISION_TYPES.COOLDOWN_ACTIVE,+ `System task ${task.id} skipped — app ${appId} on cooldown (${Math.round(state.config.appReviewCooldownMs / 60000)}min window)`,+ { taskId: task.id, appId, cooldownMs: state.config.appReviewCooldownMs }+ );continue;}}const sysTask = { ...task, taskType: 'internal' };if (!canSpawnTask(sysTask)) {- emitLog('debug', `⏳ Queued system task ${task.id} - per-project limit reached for ${appId || '_self'}`);+ const sysProject = appId || '_self';+ emitLog('debug', `⏳ Queued system task ${task.id} - per-project limit reached for ${sysProject}`);+ await recordDecision(+ DECISION_TYPES.CAPACITY_FULL,+ `System task ${task.id} deferred — per-project limit (${perProjectLimit}) reached for ${sysProject}`,+ { taskId: task.id, project: sysProject, limit: perProjectLimit }+ );continue;}tasksToSpawn.push(sysTask);@@ -878,7 +900,18 @@ export async function evaluateTasks() {}if (tasksToSpawn.length === 0) {- emitLog('info', 'No tasks to process - idle');+ const awaitingCount = cosTaskData.awaitingApproval?.length || 0;+ const idleReason = awaitingCount > 0+ ? `${awaitingCount} task(s) awaiting approval, none auto-approved`+ : hasPendingUserTasks+ ? 'User tasks exist but all on cooldown or at capacity'+ : 'No user tasks, system tasks, or idle work available';+ emitLog('info', `No tasks to process - idle: ${idleReason}`);+ await recordDecision(+ DECISION_TYPES.IDLE,+ idleReason,+ { pendingUser: pendingUserCount, pendingSystem: pendingSystemCount, awaitingApproval: awaitingCount, runningAgents }+ );cosEvents.emit('evaluation', { message: 'No pending tasks to process' });}}diff --git a/server/services/decisionLog.js b/server/services/decisionLog.jsindex 5b887b6f40..da452af8ca 100644--- a/server/services/decisionLog.js+++ b/server/services/decisionLog.js@@ -27,11 +27,13 @@ export const DECISION_TYPES = {TASK_SKIPPED: 'task_skipped', // Task skipped due to poor success rateTASK_SWITCHED: 'task_switched', // Switched to alternative taskINTERVAL_ADJUSTED: 'interval_adjusted', // Interval changed by learning system- COOLDOWN_ACTIVE: 'cooldown_active', // Task still in cooldown+ COOLDOWN_ACTIVE: 'cooldown_active', // Task/app still in cooldown periodNOT_DUE: 'not_due', // Task not due based on scheduleQUEUE_FULL: 'queue_full', // Too many tasks in queue+ CAPACITY_FULL: 'capacity_full', // Max concurrent agents reached (global or per-project)TASK_SELECTED: 'task_selected', // Task was selected to run- REHABILITATION: 'rehabilitation' // Skipped task type retried+ REHABILITATION: 'rehabilitation', // Skipped task type retried+ IDLE: 'idle' // No work available after full evaluation};// Default data structure@@ -145,12 +147,14 @@ export async function getDecisionSummary() {byType[d.type] = (byType[d.type] || 0) + 1;}- // Get impactful decisions (skips, switches, adjustments)+ // Get impactful decisions (skips, switches, capacity issues, cooldowns)const impactfulTypes = [DECISION_TYPES.TASK_SKIPPED,DECISION_TYPES.TASK_SWITCHED,DECISION_TYPES.INTERVAL_ADJUSTED,- DECISION_TYPES.REHABILITATION+ DECISION_TYPES.REHABILITATION,+ DECISION_TYPES.CAPACITY_FULL,+ DECISION_TYPES.COOLDOWN_ACTIVE];const impactfulDecisions = recentDecisions