Files
fusion/packages/core/src/agent-role-policy.ts
Fusion 1f7958fc0f feat(FN-3935): align engineer role routing with explicit assignment and del
Centralized routing policy helpers in core and aligned both direct assignment and delegation to route engineer-role agents consistently, ensuring assigned tasks respect explicit engineer routing the same way delegated tasks do. Added comprehensive test coverage across core, CLI, dashboard, and engin

Fusion-Task-Id: FN-3935

Fusion-Task-Lineage: 069f4d54-f7a8-4bd3-a2c3-4de830de042f
2026-05-11 21:48:26 -07:00

49 lines
1.5 KiB
TypeScript

import type { Agent, Task } from "./types.js";
const IMPLEMENTATION_TASK_COLUMNS: ReadonlySet<Task["column"]> = new Set([
"triage",
"todo",
"in-progress",
"in-review",
]);
export function isImplementationTask(task: Pick<Task, "column">): boolean {
return IMPLEMENTATION_TASK_COLUMNS.has(task.column);
}
export function isExecutorRoleAgent(agent: Pick<Agent, "role">): boolean {
return agent.role === "executor";
}
export function isEngineerRoleAgent(agent: Pick<Agent, "role">): boolean {
return agent.role === "engineer";
}
export function canAgentTakeImplementationTaskForExplicitRouting(
agent: Pick<Agent, "role">,
task: Pick<Task, "column">,
): boolean {
return !isImplementationTask(task) || isExecutorRoleAgent(agent) || isEngineerRoleAgent(agent);
}
export function canAgentTakeImplementationTaskForBacklogPickup(
agent: Pick<Agent, "role">,
task: Pick<Task, "column">,
): boolean {
return !isImplementationTask(task) || isExecutorRoleAgent(agent);
}
export function canAgentTakeImplementationTask(
agent: Pick<Agent, "role">,
task: Pick<Task, "column">,
): boolean {
return canAgentTakeImplementationTaskForBacklogPickup(agent, task);
}
export function formatRoleMismatchReason(
agent: Pick<Agent, "id" | "role">,
task: Pick<Task, "id" | "column">,
): string {
return `Agent ${agent.id} has role "${agent.role}"; implementation task ${task.id} requires an "executor"-role agent by default, with durable "engineer" supported only for explicit routing. Pass override=true to bypass.`;
}