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: configure unattended investigation approval
[._.]/ Adam Eivy15e36571bee1
diff --git a/client/src/components/cos/tabs/ConfigTab.jsx b/client/src/components/cos/tabs/ConfigTab.jsxindex 97cd3acbc9..e2a9e8f41e 100644--- a/client/src/components/cos/tabs/ConfigTab.jsx+++ b/client/src/components/cos/tabs/ConfigTab.jsx@@ -259,6 +259,7 @@ const getDefaultFormData = (config, avatarStyle) => ({proactiveMode: config?.proactiveMode ?? true,idleReviewEnabled: config?.idleReviewEnabled ?? true,immediateExecution: config?.immediateExecution ?? true,+ autoApproveInvestigations: config?.autoApproveInvestigations ?? false,avatarStyle: config?.avatarStyle || avatarStyle || 'svg'});@@ -503,6 +504,15 @@ export default function ConfigTab({ config, onUpdate, onEvaluate, avatarStyle })onChange={v => setFormData(f => ({ ...f, immediateExecution: v }))}tooltip="Execute new tasks immediately instead of waiting for evaluation interval"/>+ <ConfigRow+ label="Auto-approve Investigations"+ value={formData.autoApproveInvestigations ? 'Enabled' : 'Disabled'}+ editing={editing}+ type="checkbox"+ inputValue={formData.autoApproveInvestigations}+ onChange={v => setFormData(f => ({ ...f, autoApproveInvestigations: v }))}+ tooltip="Automatically process system failure investigations, including investigations held because a failure is looping or part of a storm"+ /></div>{/* Avatar Style */}diff --git a/server/lib/investigationTasks.js b/server/lib/investigationTasks.jsindex 94ae1923bf..9e619cbc6d 100644--- a/server/lib/investigationTasks.js+++ b/server/lib/investigationTasks.js@@ -188,6 +188,18 @@ function approvalVerdict(loopReason) {/** The neutral, unattended verdict — what a failed policy read falls open to. Pure. */export const UNATTENDED_APPROVAL_VERDICT = Object.freeze(approvalVerdict(null));+/**+ * Whether a pending investigation should be admitted by the explicit CoS+ * auto-approval override. The override is intentionally narrow: it never+ * changes ordinary task approval or bypasses the CoS autonomy/budget gates.+ */+export function isAutoApprovableInvestigation(task, config) {+ return config?.autoApproveInvestigations === true+ && isInvestigationTask(task)+ && task?.status === 'pending'+ && task?.approvalRequired === true;+}+// ===== Auto-retry of the tasks an investigation was blocking =====/**diff --git a/server/lib/investigationTasks.test.js b/server/lib/investigationTasks.test.jsindex aaa6da06db..031df5916c 100644--- a/server/lib/investigationTasks.test.js+++ b/server/lib/investigationTasks.test.js@@ -7,6 +7,7 @@ import {autoRetryMetadata,buildInvestigationFingerprint,investigationFingerprint,+ isAutoApprovableInvestigation,isInvestigationTask,resolveInvestigationRetryTargets,} from './investigationTasks.js';@@ -41,6 +42,25 @@ describe('isInvestigationTask', () => {});});+describe('isAutoApprovableInvestigation', () => {+ const task = {+ status: 'pending',+ approvalRequired: true,+ metadata: { isInvestigation: true },+ };++ it('admits a held investigation only when explicitly configured', () => {+ expect(isAutoApprovableInvestigation(task, { autoApproveInvestigations: true })).toBe(true);+ expect(isAutoApprovableInvestigation(task, { autoApproveInvestigations: false })).toBe(false);+ });++ it('does not override ordinary, completed, or already-approved tasks', () => {+ expect(isAutoApprovableInvestigation({ ...task, description: 'ordinary', metadata: {} }, { autoApproveInvestigations: true })).toBe(false);+ expect(isAutoApprovableInvestigation({ ...task, status: 'completed' }, { autoApproveInvestigations: true })).toBe(false);+ expect(isAutoApprovableInvestigation({ ...task, approvalRequired: false }, { autoApproveInvestigations: true })).toBe(false);+ });+});+describe('buildInvestigationFingerprint', () => {it('keys on category, analysisType/taskType, and app — never the free-text message', () => {expect(buildInvestigationFingerprint(diff --git a/server/routes/cos.test.js b/server/routes/cos.test.jsindex c269dc700d..1e0340f111 100644--- a/server/routes/cos.test.js+++ b/server/routes/cos.test.js@@ -235,6 +235,18 @@ describe('CoS Routes', () => {expect(response.status).toBe(200);expect(cos.updateConfig).toHaveBeenCalledWith(updates);});++ it('accepts the investigation auto-approval setting', async () => {+ const updates = { autoApproveInvestigations: true };+ cos.updateConfig.mockResolvedValue(updates);++ const response = await request(app)+ .put('/api/cos/config')+ .send(updates);++ expect(response.status).toBe(200);+ expect(cos.updateConfig).toHaveBeenCalledWith(updates);+ });});describe('GET /api/cos/tasks', () => {diff --git a/server/routes/cosStatusRoutes.js b/server/routes/cosStatusRoutes.jsindex a8c670c1e7..eedcf28752 100644--- a/server/routes/cosStatusRoutes.js+++ b/server/routes/cosStatusRoutes.js@@ -48,6 +48,7 @@ export const cosConfigSchema = z.object({proactiveMode: z.boolean().optional(),autonomousJobsEnabled: z.boolean().optional(),autonomyLevel: z.enum(['standby', 'assistant', 'manager', 'yolo']).optional(),+ autoApproveInvestigations: z.boolean().optional(),// Per-domain autonomy guardrails (#711): partial map of domainId → mode.// Partial is fine — updateConfig() merges it over the stored map.domainAutonomy: z.object(diff --git a/server/services/cos.js b/server/services/cos.jsindex eb60d560f1..a839e831ba 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -20,6 +20,7 @@ import { existsSync } from 'fs';import { join } from 'path';import { getActiveProvider } from './providers.js';import { isInternalTaskId } from '../lib/taskParser.js';+import { isAutoApprovableInvestigation } from '../lib/investigationTasks.js';import { isRetryHeld, isStaleRetryHold } from '../lib/taskRetryHold.js';import { isAppOnCooldown, markAppReviewCooldown, bindAppReviewAgent, clearStaleActiveAgents } from './appActivity.js';import { getActiveApps } from './apps.js';@@ -990,7 +991,12 @@ async function spawnDequeuePriority2AutoApproved(ctx) {const { state, instanceId, capacity } = ctx;const cosTaskData = await getCosTasks();- const autoApproved = cosTaskData.autoApproved || [];+ const autoApproved = [+ ...(cosTaskData.autoApproved || []),+ ...(state.config.autoApproveInvestigations+ ? (cosTaskData.grouped?.pending || []).filter((task) => isAutoApprovableInvestigation(task, state.config))+ : [])+ ];let cosAutonomyMode = getDomainMode(state.config, 'cos');// Daily CoS budget (#711) — same enforcement as the periodic evaluator@@ -1507,6 +1513,13 @@ export async function init() {if (isDaemonRunning()) setImmediate(() => dequeueNextTask());});+ // Changing the investigation override can make an already-queued held task+ // eligible. Re-run the normal dequeue so autonomy, budgets, leases, and+ // capacity remain the same as for every other system task.+ cosEvents.on('config:changed', () => {+ if (isDaemonRunning()) setImmediate(() => dequeueNextTask());+ });+cosEvents.on('tasks:cos:added', () => {if (isDaemonRunning()) setImmediate(() => dequeueNextTask());});diff --git a/server/services/cosState.js b/server/services/cosState.jsindex 12dc7e5a49..19942625d6 100644--- a/server/services/cosState.js+++ b/server/services/cosState.js@@ -58,6 +58,9 @@ export const DEFAULT_CONFIG = {proactiveMode: true,autonomousJobsEnabled: true,autonomyLevel: 'standby',+ // Investigation tasks normally hold only failure loops for a human. This+ // opt-in also admits those loop/storm investigations unattended.+ autoApproveInvestigations: false,// Per-domain autonomy guardrails (#711). Each domain is off | dry-run | execute.// Default is `execute` for every domain, reproducing pre-#711 behavior so no// migration is needed — an install with no stored value reads `execute`.