Workflows

Workflows orchestrate teams of agents through defined phases with automatic knowledge fusion. The WorkflowOrchestrator manages execution, state transitions, and result aggregation — all persisted in Cortex.

Workflow lifecycle

mermaid
stateDiagram-v2
    [*] --> Pending : startWorkflow()
    Pending --> Running : executeNextPhase()
    Running --> Running : next phase
    Running --> Merging : all phases done
    Merging --> Completed : results merged
    Running --> Failed : error or timeout

Built-in workflows

code-review

Single parallel phase with 4 specialized review agents:

AgentRoleFocus
security-reviewersecurityOWASP vulnerabilities, input validation
test-reviewertestsTest coverage, edge cases
type-reviewertypesType safety, interface consistency
simplification-reviewersimplificationCode clarity, dead code

Strategy: additive — all findings are combined.

feature-dev

Four sequential phases building on each other:

  1. Exploreexplorer agent maps the codebase structure
  2. Designarchitect agent creates the implementation plan
  3. Review — parallel security-reviewer + quality-reviewer (strategy: conflict-flag)
  4. Implementimplementer agent writes the code

security-review

Single parallel phase with 2 security agents:

  • static-scanner: OWASP Top 10, hardcoded credentials, insecure dependencies
  • semantic-scanner: data flow analysis, authorization boundaries, privilege escalation

Strategy: additive.

Custom workflows

Register custom workflow definitions at runtime:

typescript
import { registerWorkflow } from "./workflows/registry.js";

registerWorkflow({
  name: "my-workflow",
  description: "Custom review process",
  defaultStrategy: "additive",
  phases: [
    {
      name: "analyze",
      description: "Analyze the target",
      parallel: true,
      strategy: "additive",
      agents: [
        { agentId: "analyzer-1", role: "analyzer", task: "Analyze ${path}" },
        { agentId: "analyzer-2", role: "analyzer", task: "Analyze ${path}" },
      ],
    },
  ],
});

The ${path} placeholder in task descriptions is interpolated with the target path at runtime.

Git worktree integration

When worktree.enabled is true, each agent in a workflow phase gets an isolated git worktree via the GitWorktreeManager. This prevents agents from interfering with each other's file changes.

Worktrees are created under .mayros/worktrees/ with branches prefixed mayros/worktree/.

Configuration

json5
{
  teams: {
    maxTeamSize: 8,
    defaultStrategy: "additive",
    workflowTimeout: 600,
  },
  worktree: {
    enabled: false,
    basePath: ".mayros/worktrees",
  },
}