{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rohitkumarnaidu.github.io/Forgevena/schemas/release-retrospective.schema.json",
  "title": "Forgevena Release Retrospective Ledger",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "policyEffectiveFrom", "assessedAt", "owner", "expectedStableTags", "releases"],
  "properties": {
    "schemaVersion": { "const": 1 },
    "policyEffectiveFrom": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "assessedAt": { "type": "string", "format": "date-time" },
    "owner": { "type": "string", "minLength": 1 },
    "expectedStableTags": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "pattern": "^v[0-9]+\\.[0-9]+\\.[0-9]+$" } },
    "releases": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/release" } }
  },
  "$defs": {
    "release": {
      "type": "object",
      "additionalProperties": false,
      "required": ["tag", "commit", "outcome", "decision", "summary", "findings", "controls", "totals"],
      "properties": {
        "tag": { "type": "string", "pattern": "^v[0-9]+\\.[0-9]+\\.[0-9]+$" },
        "commit": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
        "outcome": { "enum": ["published", "failed-publication", "superseded"] },
        "decision": { "enum": ["current-certified", "historical-assurance", "failed-as-recorded", "not-certified"] },
        "summary": { "type": "string", "minLength": 1 },
        "findings": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "controls": { "type": "array", "minItems": 8, "maxItems": 8, "items": { "$ref": "#/$defs/control" } },
        "totals": { "$ref": "#/$defs/totals" }
      }
    },
    "control": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "weight", "mandatory", "status", "rationale", "evidence"],
      "properties": {
        "id": { "enum": ["source-integrity", "release-automation", "security-quality", "documentation", "migration-rollback", "distribution", "post-release-verification", "current-governance-evidence"] },
        "weight": { "type": "integer", "minimum": 1 },
        "mandatory": { "type": "boolean" },
        "status": { "enum": ["pass", "partial", "fail", "unknown", "not-applicable"] },
        "rationale": { "type": "string", "minLength": 1 },
        "evidence": { "type": "array", "items": { "type": "string", "minLength": 1 } }
      }
    },
    "totals": {
      "type": "object",
      "additionalProperties": false,
      "required": ["applicablePoints", "earnedPoints", "score", "mandatoryFailures"],
      "properties": {
        "applicablePoints": { "type": "number", "minimum": 0, "maximum": 100 },
        "earnedPoints": { "type": "number", "minimum": 0, "maximum": 100 },
        "score": { "type": "integer", "minimum": 0, "maximum": 100 },
        "mandatoryFailures": { "type": "array", "items": { "type": "string" } }
      }
    }
  }
}

