{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sarada.io/contract-graph/schema/engineering-v1.schema.json",
  "title": "Contract Graph engineering guidelines catalog",
  "description": "Non-binding E engineering guidelines. Each entry is id, rule, and reason; a preference may also carry cost. This catalog is advisory; cg verify does not enforce it.",
  "type": "object",
  "additionalProperties": false,
  "required": ["$schema", "engineeringVersion", "categories", "principles"],
  "properties": {
    "$schema": {
      "const": "https://sarada.io/contract-graph/schema/engineering-v1.schema.json"
    },
    "engineeringVersion": { "const": "1.0" },
    "categories": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": { "type": "string", "minLength": 1 }
    },
    "principles": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/principle" }
    }
  },
  "$defs": {
    "principle": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "title", "category", "entries"],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^E[0-9]{2}$"
        },
        "title": { "type": "string", "minLength": 1 },
        "category": { "type": "string", "minLength": 1 },
        "entries": {
          "type": "array",
          "minItems": 1,
          "items": { "$ref": "#/$defs/entry" }
        }
      }
    },
    "entry": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "rule", "reason"],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^E[0-9]{2}-[0-9]{2}$"
        },
        "rule": { "type": "string", "minLength": 1 },
        "reason": { "type": "string", "minLength": 1 },
        "cost": { "type": "string", "minLength": 1 }
      }
    }
  }
}
