{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/mmerterden/multi-agent-pipeline/pipeline/schemas/planning-output.schema.json",
  "version": "1.0.0",
  "title": "Multi-Agent Pipeline  -  Phase 2 planning output",
  "description": "Contract for Phase 2 task decomposition. Consumed by Phase 3 TDD cycles  -  each task becomes one red→green→refactor iteration.",
  "type": "object",
  "additionalProperties": false,
  "required": ["tasks", "approved"],
  "properties": {
    "approach": {
      "type": "string",
      "description": "One paragraph explaining the overall strategy  -  why this decomposition, what's deferred, what's in scope."
    },
    "tasks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title", "type", "files"],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^T[0-9]+$",
            "description": "Local task id, e.g. T1, T2."
          },
          "title": { "type": "string", "minLength": 4 },
          "type": {
            "type": "string",
            "enum": ["test", "code", "refactor", "docs", "chore"],
            "description": "test=new/updated test, code=production change, refactor=no-behavior-change cleanup, docs=documentation, chore=infra/config."
          },
          "files": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Files expected to change in this task. Phase 3 uses this to scope edits."
          },
          "dependsOn": {
            "type": "array",
            "items": { "type": "string", "pattern": "^T[0-9]+$" },
            "description": "Other task ids that must complete first. Phase 3 orchestrator respects ordering."
          },
          "acceptanceCriteria": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Bullet list of testable conditions that prove the task is done."
          }
        }
      }
    },
    "approved": {
      "type": "boolean",
      "description": "User approved the plan (true) or changes requested (false → loop with feedback)."
    },
    "userFeedback": {
      "type": ["string", "null"],
      "description": "If approved=false, the user's requested changes. Re-run Phase 2 with this feedback."
    }
  }
}
