{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agentdirective.org/schemas/decision-set-v1.schema.json",
  "title": "AgentDirective Decision Set v1",
  "description": "Versioned user decisions used to compile a canonical Agent Directive.",
  "type": "object",
  "additionalProperties": false,
  "required": ["decision_set_id", "decision_set_version", "methodology_version", "architecture_model_id", "selected_pack_ids", "decisions"],
  "properties": {
    "$schema": { "type": "string", "format": "uri-reference" },
    "decision_set_id": { "type": "string", "pattern": "^DS-[A-Z0-9]{6,32}$" },
    "decision_set_version": { "$ref": "#/$defs/semver" },
    "methodology_version": { "$ref": "#/$defs/semver" },
    "architecture_model_id": { "type": "string", "pattern": "^AM-[A-Z0-9]{6,32}$" },
    "selected_pack_ids": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/packId" } },
    "decisions": { "type": "array", "items": { "$ref": "#/$defs/decision" } }
  },
  "$defs": {
    "semver": { "type": "string", "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$" },
    "packId": { "type": "string", "pattern": "^[A-Z]{2,10}-[0-9]{3,6}$" },
    "requirementId": { "type": "string", "pattern": "^[A-Z]{2,10}-[0-9]{3,6}-R[0-9]{1,4}$" },
    "decision": {
      "type": "object",
      "additionalProperties": false,
      "required": ["decision_id", "pack_id", "question_id", "requirement_refs", "status", "source", "recorded_at"],
      "properties": {
        "decision_id": { "type": "string", "pattern": "^DEC-[A-Z0-9]{4,32}$" },
        "pack_id": { "$ref": "#/$defs/packId" },
        "question_id": { "type": "string", "pattern": "^[A-Z]{2,10}-[0-9]{3,6}-Q[0-9]{1,4}$" },
        "requirement_refs": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "$ref": "#/$defs/requirementId" } },
        "status": { "enum": ["confirmed", "recommended", "unresolved", "not_applicable", "explicitly_rejected"] },
        "value": {},
        "unit": { "type": ["string", "null"], "maxLength": 80 },
        "source": { "enum": ["user_stated", "user_corrected", "model_suggested", "system_unresolved"] },
        "rationale": { "type": "string", "maxLength": 3000 },
        "recorded_at": { "type": "string", "format": "date-time" }
      }
    }
  }
}
