{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "dd-flow/flow-guidance@1",
  "title": "dd-flow CLI flow guidance block",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "current_stage",
    "allowed_next_stages",
    "recommended_next_action",
    "recommended_prompt",
    "required_predecessor_evidence",
    "guards",
    "blocked_if_missing"
  ],
  "properties": {
    "current_stage": {
      "type": "string",
      "minLength": 1
    },
    "lifecycle": {
      "type": "object",
      "additionalProperties": true,
      "required": ["flow", "stage", "status", "terminal", "raw_stage", "raw_status"],
      "properties": {
        "flow": { "type": "string", "minLength": 1 },
        "stage": { "type": "string", "minLength": 1 },
        "substage": { "type": ["string", "null"] },
        "status": { "type": "string", "minLength": 1 },
        "terminal": { "type": "boolean" },
        "legacy_stage": { "type": ["string", "null"] },
        "legacy_status": { "type": ["string", "null"] },
        "raw_stage": { "type": "string", "minLength": 1 },
        "raw_status": { "type": "string", "minLength": 1 },
        "queue_status": { "type": ["string", "null"] }
      }
    },
    "allowed_next_stages": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "recommended_next_action": {
      "type": "string",
      "minLength": 1
    },
    "recommended_prompt": {
      "type": "string",
      "minLength": 1
    },
    "required_predecessor_evidence": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "guards": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "status", "summary"],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "type": "string",
            "enum": ["pass", "fail", "unknown", "not_applicable", "degraded"]
          },
          "summary": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "blocked_if_missing": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    }
  }
}
