{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/mmerterden/multi-agent-pipeline/pipeline/schemas/scope-check.schema.json",
  "version": "1.0.0",
  "title": "Multi-Agent Pipeline  -  Phase 3 scope self-check",
  "description": "Written by Phase 3 Step 3.7 to $WORKTREE/.pipeline/scope-check.json before the Phase 4 handoff: one stated reason per file in the diff, the changes deliberately not made, and the code-simplifier rationales. scope-check-gate.mjs compares files[] with the real diff; Phase 4 injects the record as <scope-self-check>; Phase 6 builds the PR Changes bullets and the follow-up list from it.",
  "type": "object",
  "additionalProperties": false,
  "required": ["version", "taskId", "files"],
  "properties": {
    "version": { "type": "string", "const": "1.0.0" },
    "taskId": { "type": "string", "minLength": 1 },
    "files": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["path", "reason"],
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "description": "Repo-relative path as it appears in git diff --name-only."
          },
          "reason": {
            "type": "string",
            "minLength": 4,
            "description": "Why this task needs this exact file. Names the requirement, never 'while I was here'."
          }
        }
      }
    },
    "notDone": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["what", "why"],
        "properties": {
          "what": { "type": "string", "minLength": 4 },
          "why": { "type": "string", "enum": ["out-of-scope", "follow-up", "rejected-abstraction"] }
        }
      }
    },
    "simplifier": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "applied": { "type": "integer", "minimum": 0 },
        "skipped": { "type": "integer", "minimum": 0 },
        "rationales": { "type": "array", "items": { "type": "string" } }
      }
    }
  }
}
