{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.driftframe.org/site-reading-governance/v2.0/coordination-horizon.schema.json",
  "title": "Coordination Horizon",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "horizon_id",
    "title",
    "objective",
    "as_of",
    "current_item_ids",
    "work_items",
    "reentry_capsule",
    "retained_effects",
    "consequential_questions",
    "metadata"
  ],
  "properties": {
    "horizon_id": {
      "$ref": "common.schema.json#/$defs/identifier"
    },
    "title": {
      "type": "string",
      "minLength": 5,
      "maxLength": 180
    },
    "objective": {
      "type": "string",
      "minLength": 20,
      "maxLength": 1200
    },
    "as_of": {
      "type": "string",
      "format": "date-time"
    },
    "current_item_ids": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "$ref": "common.schema.json#/$defs/identifier"
      }
    },
    "work_items": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "item_id",
          "horizon_label",
          "sequence",
          "state",
          "desired_state",
          "entry_evidence",
          "completion_evidence",
          "owner_role",
          "dependency_ids"
        ],
        "properties": {
          "item_id": {
            "$ref": "common.schema.json#/$defs/identifier"
          },
          "horizon_label": {
            "type": "string",
            "minLength": 2,
            "maxLength": 120
          },
          "sequence": {
            "type": "integer",
            "minimum": 1
          },
          "state": {
            "type": "string",
            "enum": [
              "active",
              "ready",
              "waiting",
              "settling",
              "complete"
            ]
          },
          "desired_state": {
            "type": "string",
            "minLength": 10,
            "maxLength": 700
          },
          "entry_evidence": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 5,
              "maxLength": 500
            }
          },
          "completion_evidence": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 5,
              "maxLength": 500
            }
          },
          "owner_role": {
            "type": "string",
            "minLength": 2,
            "maxLength": 120
          },
          "dependency_ids": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "$ref": "common.schema.json#/$defs/identifier"
            }
          }
        }
      }
    },
    "reentry_capsule": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "current_state",
        "recent_decisions",
        "next_safe_action",
        "verification"
      ],
      "properties": {
        "current_state": {
          "type": "string",
          "minLength": 10,
          "maxLength": 800
        },
        "recent_decisions": {
          "type": "array",
          "items": {
            "$ref": "common.schema.json#/$defs/identifier"
          }
        },
        "next_safe_action": {
          "type": "string",
          "minLength": 10,
          "maxLength": 700
        },
        "verification": {
          "type": "string",
          "minLength": 10,
          "maxLength": 700
        }
      }
    },
    "retained_effects": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 10,
        "maxLength": 700
      }
    },
    "consequential_questions": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 10,
        "maxLength": 700
      }
    },
    "metadata": {
      "$ref": "common.schema.json#/$defs/recordMetadata"
    }
  }
}
