Remove task-level approval system

Task-level approval (requiresApproval, mergeRequiresApproval,
pending_approval status) was redundant with executionMode
(yolo vs review_per_phase) and blocked the orchestrator's
phase completion flow. Tasks now complete directly;
phase-level review via executionMode is the right granularity.

Removed: schema columns (left in DB, removed from Drizzle),
TaskPendingApprovalEvent, approveTask/listPendingApprovals
procedures, findPendingApproval repository method, and all
frontend approval UI.
This commit is contained in:
Lukas May
2026-03-05 17:09:48 +01:00
parent 209629241d
commit 8804455c77
27 changed files with 48 additions and 237 deletions

View File

@@ -13,7 +13,6 @@ import type {
TaskCompletedEvent,
TaskBlockedEvent,
TaskDispatchedEvent,
TaskPendingApprovalEvent,
} from '../events/index.js';
import type { AgentManager, AgentResult, AgentInfo } from '../agent/types.js';
import type { TaskRepository } from '../db/repositories/task-repository.js';
@@ -172,7 +171,6 @@ export class DefaultDispatchManager implements DispatchManager {
/**
* Mark a task as complete.
* If the task requires approval, sets status to 'pending_approval' instead.
* Updates task status and removes from queue.
*
* @param taskId - ID of the task to complete
@@ -184,78 +182,15 @@ export class DefaultDispatchManager implements DispatchManager {
throw new Error(`Task not found: ${taskId}`);
}
// Determine if approval is required
const requiresApproval = await this.taskRequiresApproval(task);
// Store agent result summary on the task for propagation to dependent tasks
await this.storeAgentSummary(taskId, agentId);
if (requiresApproval) {
// Set to pending_approval instead of completed
await this.taskRepository.update(taskId, { status: 'pending_approval' });
// Remove from queue
this.taskQueue.delete(taskId);
log.info({ taskId, category: task.category }, 'task pending approval');
// Emit TaskPendingApprovalEvent
const event: TaskPendingApprovalEvent = {
type: 'task:pending_approval',
timestamp: new Date(),
payload: {
taskId,
agentId: agentId ?? '',
category: task.category,
name: task.name,
},
};
this.eventBus.emit(event);
} else {
// Complete directly
await this.taskRepository.update(taskId, { status: 'completed' });
// Remove from queue
this.taskQueue.delete(taskId);
log.info({ taskId }, 'task completed');
// Emit TaskCompletedEvent
const event: TaskCompletedEvent = {
type: 'task:completed',
timestamp: new Date(),
payload: {
taskId,
agentId: agentId ?? '',
success: true,
message: 'Task completed',
},
};
this.eventBus.emit(event);
}
// Also remove from blocked if it was there
this.blockedTasks.delete(taskId);
}
/**
* Approve a task that is pending approval.
* Sets status to 'completed' and emits completion event.
*/
async approveTask(taskId: string): Promise<void> {
const task = await this.taskRepository.findById(taskId);
if (!task) {
throw new Error(`Task not found: ${taskId}`);
}
if (task.status !== 'pending_approval') {
throw new Error(`Task ${taskId} is not pending approval (status: ${task.status})`);
}
// Complete the task
await this.taskRepository.update(taskId, { status: 'completed' });
log.info({ taskId }, 'task approved and completed');
// Remove from queue
this.taskQueue.delete(taskId);
log.info({ taskId }, 'task completed');
// Emit TaskCompletedEvent
const event: TaskCompletedEvent = {
@@ -263,12 +198,15 @@ export class DefaultDispatchManager implements DispatchManager {
timestamp: new Date(),
payload: {
taskId,
agentId: '',
agentId: agentId ?? '',
success: true,
message: 'Task approved',
message: 'Task completed',
},
};
this.eventBus.emit(event);
// Also remove from blocked if it was there
this.blockedTasks.delete(taskId);
}
/**
@@ -563,26 +501,4 @@ export class DefaultDispatchManager implements DispatchManager {
return { phases, tasks: implementationTasks, pages };
}
/**
* Determine if a task requires approval before being marked complete.
* Checks task-level override first, then falls back to initiative setting.
*/
private async taskRequiresApproval(task: Task): Promise<boolean> {
// Task-level override takes precedence
if (task.requiresApproval !== null) {
return task.requiresApproval;
}
// Fall back to initiative setting if we have initiative access
if (this.initiativeRepository && task.initiativeId) {
const initiative = await this.initiativeRepository.findById(task.initiativeId);
if (initiative) {
return initiative.mergeRequiresApproval;
}
}
// If task has a phaseId but no initiativeId, we could traverse up but for now default to false
// Default: no approval required
return false;
}
}