{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "dd-flow/stage-report@2",
  "title": "Generated stage report",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_id", "run_id", "stage", "generated_at", "verdict", "summary", "semantic", "mechanical", "artifacts", "validation"],
  "properties": {
    "schema_id": {"const": "dd-flow/stage-report@2"},
    "run_id": {"type": "string", "minLength": 1},
    "stage": {"type": "string", "minLength": 1},
    "generated_at": {"type": "string", "format": "date-time"},
    "verdict": {"enum": ["done", "waiting_for_user", "blocked", "failed", "degraded"]},
    "summary": {"type": "string", "minLength": 1},
    "semantic": {"type": "object", "required": ["result", "acceptance", "changed_files", "checks", "evidence", "next_action"], "additionalProperties": true, "properties": {"result": {"type": "string"}, "acceptance": {"type": "array"}, "changed_files": {"type": "array"}, "checks": {"type": "array"}, "evidence": {"type": "array"}, "next_action": {"type": "string"}}},
    "mechanical": {"type": "object", "required": ["started_at", "finished_at", "wall_clock_ms", "git"], "additionalProperties": true, "properties": {"started_at": {"type": "string", "format": "date-time"}, "finished_at": {"type": "string", "format": "date-time"}, "wall_clock_ms": {"type": ["integer", "null"], "minimum": 0}, "git": {"type": "object"}}},
    "artifacts": {"type": "object", "required": ["json", "markdown", "html"], "additionalProperties": false, "properties": {"json": {"type": "string"}, "markdown": {"type": "string"}, "html": {"type": "string"}}},
    "validation": {"type": "object", "required": ["status"], "additionalProperties": true, "properties": {"permission_scope": {"type": "string"}, "memory_bank_scope": {"type": "string"}, "status": {"type": "string"}}},
    "breadcrumbs": {"type": "array", "items": {"type": "object"}}
  }
}
