Skip to content

Dev-Orchestrator Routing Contract

The dev-orchestrator routes every normalized Development workstream to default-workflow, except that a small single-workstream task may go to quick-change when the classifier or -c workflow= selects it.

This document defines the routing contract. Rust-helper enforcement runs before workstream execution: model-produced recipe fields are advisory input only and cannot override the Development routing invariant.

Contents

Routing invariant

Any workstream whose normalized classification is Development must run default-workflow or quick-change. No other recipe is allowed.

For a single workstream, select-workflow chooses between the two and logs the choice and its reason.

For a parallel decomposition, build-workstreams-config sets each workstream's recipe. The model's recipe field never selects quick-change, because quick-change needs exactly one workstream (row 6 of the precedence table):

  • A Development workstream runs default-workflow, unless a valid -c workflow= override (quick-change or default-workflow) is set. The override applies only when the top-level task_type is Development, and quick-change is not applied when existing_branch or pr_number is set or the task text names its branch with a Branch: <ref> line. These are the same rules select-workflow applies and logs (W2, W3, W4), so the log line names the recipe the workstreams run.
  • A workstream with any other classification keeps the model's recipe, except that quick-change, which commits, pushes and opens a PR, becomes the classification's own recipe: investigation-workflow, qa-workflow or consensus-workflow, and default-workflow for Operations. The override never changes these workstreams.

How the single-workstream route chooses between the two is described in Quick-Change Recipe: Routing from smart-orchestrator.

The invariant applies per workstream. A top-level hybrid task can contain multiple workstreams with different classifications, and each workstream must be routed from its own normalized classification.

Prompts that start with [coord] are coordination messages between sessions. The workflow classification reminder gives them a short note instead of the routing prompt, unless the body is a work request that starts with a change verb, as in build #1740 or fix the parser for #12. A work request is throttled like the same text without the marker, and receives the note while the throttle holds. A report that starts with a verb used as a noun, such as fix landed on PR 12 or fix #12 merged, receives the note. The note still tells the agent to use dev-orchestrator when the message asks for a code change, so the invariant above holds for marked messages too. See Coordination Messages.

Classification authority

The routing implementation uses the most specific classification available.

Source Authority Routing effect
Per-workstream classification, task_type, or type Highest Used to normalize that workstream's recipe
Top-level task_type Fallback Used only when the workstream has no per-workstream classification
Model-provided recipe Advisory Preserved only when it does not violate deterministic routing

The normalized classification is authoritative for routing. The raw model text must be normalized before routing decisions are made, so common variants such as dev, development, or mixed-case Development resolve to the same classification.

The exact fallback rule is:

  1. Use the workstream's own classification, task_type, or type when present.
  2. Use the top-level task_type only when the workstream has none of those fields.
  3. Route an unclassified workstream under top-level Development to default-workflow.

This keeps hybrid decomposition safe: investigation, Q&A, operations, and consensus workstreams inside a broader development request must not inherit Development when they carry their own non-Development classification.

Recipe normalization

The deterministic normalization rule is:

Normalized workstream classification Input recipe Normalized recipe
Development missing default-workflow
Development "" or whitespace default-workflow
Development investigation-workflow default-workflow
Development default-workflow default-workflow
Development quick-change default-workflow
Development any other value default-workflow
Development, valid -c workflow= override, top-level task_type Development any value the override, except that quick-change becomes default-workflow when existing_branch or pr_number is set or the task names its branch
Non-Development, any override quick-change the classification's own recipe (investigation-workflow, qa-workflow, consensus-workflow, or default-workflow for Operations)
Non-Development, any override any other value Existing route is preserved

This table applies to parallel decompositions, the only case in which build-workstreams-config runs. A model-provided quick-change is not kept, because quick-change needs exactly one workstream; only a valid override selects it, which matches the workflow that select-workflow logs. Single-workstream runs use selected_workflow from select-workflow instead.

Non-Development classifications must not be rewritten by the Development invariant. Apart from the quick-change replacement above, their existing route selection remains in force:

Classification Existing routing behavior
Investigation Uses the investigation route selected by smart-orchestrator, normally investigation-workflow for recipe execution
Q&A Uses the direct analyzer-answer route for top-level Q&A; workstream recipes are preserved when a plan explicitly contains Q&A workstreams
Operations Uses the operations route selected by smart-orchestrator; workstream recipes are preserved when a plan explicitly contains operations workstreams. The current bundle does not define an ops-workflow recipe
Consensus Uses the consensus route selected by smart-orchestrator; workstream recipes are preserved when a plan explicitly contains consensus workstreams

Workstream JSON API

amplihack orch helper build-workstreams-config accepts the decomposition JSON emitted by smart-classify-route and writes a workstreams JSON file for amplihack orch run with deterministic Development routing applied.

Input shape

{
  "task_type": "Development",
  "goal": "Improve routing reliability",
  "success_criteria": [
    "Development workstreams always run default-workflow"
  ],
  "workstreams": [
    {
      "name": "routing-normalization",
      "classification": "Development",
      "description": "Fix deterministic routing normalization",
      "recipe": "investigation-workflow"
    }
  ]
}

Supported per-workstream classification keys:

Field Purpose
classification Preferred per-workstream classification field
task_type Backward-compatible classification field
type Backward-compatible classification field

The helper normalizes whichever per-workstream classification field is present. If more than one exists, the implementation treats the first supported field in its documented precedence order as the workstream classification.

Output shape

[
  {
    "issue": "TBD",
    "branch": "feat/orch-1-routing-normalization",
    "task": "Fix deterministic routing normalization",
    "description": "routing-normalization",
    "recipe": "default-workflow"
  }
]

The output uses the amplihack orch run workstreams schema. See orch run for the complete execution schema.

Configuration

There is no configuration flag that disables the Development routing invariant.

Setting Effect on routing
workflow=quick-change Forces quick-change for every Development workstream. Ignored, with a warning, for non-Development tasks, when existing_branch or pr_number is set, and when the task text names its branch (Branch: <ref>)
workflow=default-workflow Forces default-workflow for every Development workstream, even when the classifier recommends quick-change
workflow=<anything else> Ignored with [dev-orchestrator] WARNING: unknown workflow override '<value>' ignored
force_single_workstream=true Prevents parallel decomposition; a single Development workstream runs default-workflow or quick-change
strict_delivery other than empty or "false" Prevents parallel decomposition, as force_single_workstream=true does, because parallel workstreams do not carry it (Where the inputs apply)
base_branch Does not affect routing. smart-orchestrator, smart-classify-route and smart-execute-routing declare it (default empty), and smart-execute-routing passes it to each default-workflow call on a single workstream. quick-change clears it before cutting its quick/ branch, and parallel workstreams do not receive it (Where the inputs apply)
AMPLIHACK_MAX_DEPTH=0 Blocks parallel spawning and adapts to single-session execution; the adaptive path always runs default-workflow
AMPLIHACK_AGENT_BINARY Chooses the agent backend; does not affect workflow recipe selection
AMPLIHACK_HOME Locates recipe assets; does not affect the routing invariant

Prompt text in dev-orchestrator, smart-classify-route, smart-execute-routing, and the routing hook should state the same rule for model guidance:

Development classification routes to default-workflow, or to quick-change for a small change in a single workstream or when -c workflow=quick-change forces it; any recipe value the model gives a workstream is coerced to default-workflow.

That prompt text is supportive documentation for the model. The Rust helper is authoritative.

Examples

Development workstream with missing recipe

Input:

{
  "task_type": "Development",
  "workstreams": [
    {
      "name": "api-fix",
      "classification": "Development",
      "description": "Fix the user API timeout"
    }
  ]
}

Normalized output:

[
  {
    "issue": "TBD",
    "branch": "feat/orch-1-api-fix",
    "task": "Fix the user API timeout",
    "description": "api-fix",
    "recipe": "default-workflow"
  }
]

Development workstream with wrong recipe

Input:

{
  "task_type": "Development",
  "workstreams": [
    {
      "name": "test-regression",
      "classification": "Development",
      "description": "Add regression tests for routing",
      "recipe": "investigation-workflow"
    }
  ]
}

Normalized output:

[
  {
    "issue": "TBD",
    "branch": "feat/orch-1-test-regression",
    "task": "Add regression tests for routing",
    "description": "test-regression",
    "recipe": "default-workflow"
  }
]

Hybrid decomposition preserves non-Development routes

Input:

{
  "task_type": "Development",
  "workstreams": [
    {
      "name": "trace-current-routing",
      "classification": "Investigation",
      "description": "Trace current workstream route selection",
      "recipe": "investigation-workflow"
    },
    {
      "name": "fix-routing",
      "classification": "Development",
      "description": "Enforce Development routing in Rust",
      "recipe": "investigation-workflow"
    }
  ]
}

Normalized output:

[
  {
    "issue": "TBD",
    "branch": "feat/orch-1-trace-current-routing",
    "task": "Trace current workstream route selection",
    "description": "trace-current-routing",
    "recipe": "investigation-workflow"
  },
  {
    "issue": "TBD",
    "branch": "feat/orch-2-fix-routing",
    "task": "Enforce Development routing in Rust",
    "description": "fix-routing",
    "recipe": "default-workflow"
  }
]

The top-level task is Development, but the investigation workstream keeps its own route because its per-workstream classification is Investigation.

Unclassified workstream under top-level Development

Input:

{
  "task_type": "Development",
  "workstreams": [
    {
      "name": "unclassified-fix",
      "description": "Fix an unclassified development workstream",
      "recipe": "investigation-workflow"
    }
  ]
}

Normalized output:

[
  {
    "issue": "TBD",
    "branch": "feat/orch-1-unclassified-fix",
    "task": "Fix an unclassified development workstream",
    "description": "unclassified-fix",
    "recipe": "default-workflow"
  }
]

The workstream has no own classification, so the helper falls back to the top-level Development classification.

Security contract

Decomposition JSON is model-produced and treated as untrusted input.

The routing helper must:

  • trim recipe strings before checking whether they are empty
  • normalize classification before comparing it to Development
  • never let a raw recipe string select quick-change: a Development workstream gets default-workflow unless a valid override is set, and a non-Development quick-change becomes the classification's own recipe
  • accept a -c workflow= override only from the exact list quick-change, default-workflow
  • avoid building shell commands from model-provided recipe values
  • preserve non-Development behavior, apart from the quick-change replacement, without broad fallback logic that masks malformed plans