[workflow]

[[workflow.states]]
id    = "new"
label = "New"

  [[workflow.states.transitions]]
  to      = "groomed"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "closed"
  trigger = "manual"
  outcome = "cancelled"

[[workflow.states]]
id           = "groomed"
label        = "Groomed"
actionable   = ["agent"]
dep_requires = "spec"

  [[workflow.states.transitions]]
  to              = "in_design"
  trigger         = "command:start"
  worker_profile  = "claude/spec-writer"
  context_section = "Problem"
  outcome         = "needs_input"

  [[workflow.states.transitions]]
  to      = "closed"
  trigger = "manual"
  outcome = "cancelled"

[[workflow.states]]
id         = "question"
label      = "Question"
actionable = ["supervisor"]

  [[workflow.states.transitions]]
  to      = "groomed"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "closed"
  trigger = "manual"
  outcome = "cancelled"

[[workflow.states]]
id             = "specd"
label          = "Specd"
actionable     = ["supervisor"]
satisfies_deps = "spec"
worker_end     = true

  [[workflow.states.transitions]]
  to      = "ready"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "ammend"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "closed"
  trigger = "manual"
  outcome = "cancelled"

[[workflow.states]]
id             = "ammend"
label          = "Ammend"
actionable     = ["agent"]
dep_requires   = "spec"
satisfies_deps = "spec"

  [[workflow.states.transitions]]
  to      = "specd"
  trigger = "manual"
  outcome = "success"

  [[workflow.states.transitions]]
  to      = "question"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to             = "in_design"
  trigger        = "command:start"
  worker_profile = "claude/spec-writer"
  outcome        = "needs_input"

  [[workflow.states.transitions]]
  to      = "closed"
  trigger = "manual"
  outcome = "cancelled"

[[workflow.states]]
id    = "in_design"
label = "In Design"

  [[workflow.states.transitions]]
  to      = "specd"
  trigger = "manual"
  worker_profile = "claude/spec-writer"
  outcome = "success"

  [[workflow.states.transitions]]
  to      = "question"
  trigger = "manual"
  worker_profile = "claude/spec-writer"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "ammend"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "closed"
  trigger = "manual"
  outcome = "cancelled"

[[workflow.states]]
id             = "ready"
label          = "Ready"
actionable     = ["agent"]
satisfies_deps = "spec"

  [[workflow.states.transitions]]
  to             = "in_progress"
  trigger        = "command:start"
  worker_profile = "claude/worker"
  outcome        = "needs_input"

  [[workflow.states.transitions]]
  to      = "ammend"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "specd"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "closed"
  trigger = "manual"
  outcome = "cancelled"

[[workflow.states]]
id             = "in_progress"
label          = "In Progress"
satisfies_deps = "spec"

  [[workflow.states.transitions]]
  to         = "implemented"
  trigger    = "manual"
  completion = "pr_or_epic_merge"
  on_failure = "merge_failed"
  outcome    = "success"

  [[workflow.states.transitions]]
  to      = "blocked"
  trigger = "manual"
  label   = "Agent is blocked — wrote questions in ### Open questions"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "ready"
  trigger = "manual"
  warning = "Reverting in_progress ticket to ready — any uncommitted work on the branch may be lost"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "ammend"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "closed"
  trigger = "manual"
  outcome = "cancelled"

[[workflow.states]]
id         = "blocked"
label      = "Blocked"
actionable = ["supervisor"]

  [[workflow.states.transitions]]
  to      = "ready"
  trigger = "manual"
  label   = "Supervisor answered questions — agent can resume"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "closed"
  trigger = "manual"
  outcome = "cancelled"

[[workflow.states]]
id             = "implemented"
label          = "Implemented"
actionable     = ["supervisor"]
satisfies_deps = true
worker_end     = true

  [[workflow.states.transitions]]
  to            = "ready"
  trigger       = "manual"
  focus_section = "Code review"
  outcome       = "needs_input"

  [[workflow.states.transitions]]
  to      = "ammend"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "in_progress"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "closed"
  trigger = "manual"
  outcome = "cancelled"

[[workflow.states]]
id         = "merge_failed"
label      = "Merge failed"
actionable = ["supervisor"]

  [[workflow.states.transitions]]
  to      = "implemented"
  trigger = "manual"
  outcome = "needs_input"

  [[workflow.states.transitions]]
  to      = "in_progress"
  trigger = "manual"
  outcome = "needs_input"

[[workflow.states]]
id             = "closed"
label          = "Closed"
terminal       = true
satisfies_deps = true

[workflow.prioritization]
priority_weight = 10.0
effort_weight   = -2.0
risk_weight     = -1.0
