{
  "api_version": "1.0.0",
  "schema_version": "1.0.0",
  "required_property_count": 24,
  "schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://conroy1988.github.io/Achievements/api/promotion-plan-schema.json",
    "title": "GitHub Achievement Encyclopedia promotion plan",
    "type": "object",
    "additionalProperties": false,
    "required": [
      "id",
      "source_packet_id",
      "source_review_id",
      "source_review_path",
      "source_issue",
      "mission_id",
      "achievement_slug",
      "claim_id",
      "claim_type",
      "current_level",
      "proposed_level",
      "contradiction_id",
      "applied_rule_ids",
      "status",
      "blockers",
      "preconditions",
      "source_operations",
      "generated_outputs",
      "validation_commands",
      "release_gate_impact",
      "rollback",
      "maintainer_approval_required",
      "separate_pull_request_required",
      "automatic_application"
    ],
    "properties": {
      "id": {
        "type": "string",
        "pattern": "^PPL-[0-9]{4}-[0-9]{3}$"
      },
      "source_packet_id": {
        "type": "string",
        "pattern": "^MISSION-DRAFT-ISSUE-[0-9]+$"
      },
      "source_review_id": {
        "type": "string",
        "pattern": "^MRV-[0-9]{4}-[0-9]{3}$"
      },
      "source_review_path": {
        "type": "string",
        "pattern": "^reviews/mission/.+\\.json$"
      },
      "source_issue": {
        "type": "string",
        "format": "uri",
        "pattern": "^https://github\\.com/"
      },
      "mission_id": {
        "type": "string",
        "pattern": "^MSN-[0-9]{3}$"
      },
      "achievement_slug": {
        "type": "string",
        "minLength": 1
      },
      "claim_id": {
        "type": "string",
        "pattern": "^CLM-[0-9]{3}$"
      },
      "claim_type": {
        "type": "string",
        "enum": [
          "trigger",
          "tiers",
          "historical"
        ]
      },
      "current_level": {
        "type": "string",
        "enum": [
          "unknown",
          "community-reported",
          "observed",
          "confirmed",
          "official"
        ]
      },
      "proposed_level": {
        "type": "string",
        "enum": [
          "observed",
          "confirmed",
          "official"
        ]
      },
      "contradiction_id": {
        "type": [
          "string",
          "null"
        ],
        "pattern": "^CTR-[0-9]{3}$"
      },
      "applied_rule_ids": {
        "type": "array",
        "minItems": 1,
        "uniqueItems": true,
        "items": {
          "type": "string",
          "pattern": "^ADJ-R[0-9]{2}$"
        }
      },
      "status": {
        "type": "string",
        "enum": [
          "ready-for-maintainer-review",
          "blocked"
        ]
      },
      "blockers": {
        "type": "array",
        "uniqueItems": true,
        "items": {
          "type": "string",
          "minLength": 1
        }
      },
      "preconditions": {
        "type": "array",
        "minItems": 7,
        "items": {
          "type": "string",
          "minLength": 1
        }
      },
      "source_operations": {
        "type": "array",
        "minItems": 5,
        "items": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "path",
            "operation",
            "rationale"
          ],
          "properties": {
            "path": {
              "type": "string",
              "minLength": 1
            },
            "operation": {
              "type": "string",
              "enum": [
                "create-or-update",
                "update",
                "reassess",
                "record"
              ]
            },
            "rationale": {
              "type": "string",
              "minLength": 10
            }
          }
        }
      },
      "generated_outputs": {
        "type": "array",
        "minItems": 10,
        "uniqueItems": true,
        "items": {
          "type": "string",
          "minLength": 1
        }
      },
      "validation_commands": {
        "type": "array",
        "minItems": 6,
        "uniqueItems": true,
        "items": {
          "type": "string",
          "minLength": 1
        }
      },
      "release_gate_impact": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "coverage_score",
          "claims_below_confirmed",
          "official_or_confirmed_claims",
          "open_contradictions",
          "publication_status"
        ],
        "properties": {
          "coverage_score": {
            "type": "string",
            "const": "recalculate-after-canonical-change"
          },
          "claims_below_confirmed": {
            "type": "integer",
            "minimum": -1,
            "maximum": 0
          },
          "official_or_confirmed_claims": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1
          },
          "open_contradictions": {
            "type": "integer",
            "const": 0
          },
          "publication_status": {
            "type": "string",
            "const": "must-be-regenerated"
          }
        }
      },
      "rollback": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "strategy",
          "isolated_commit_required",
          "restore_paths",
          "preserve_review_record"
        ],
        "properties": {
          "strategy": {
            "type": "string",
            "const": "revert-isolated-canonical-promotion-commit"
          },
          "isolated_commit_required": {
            "type": "boolean",
            "const": true
          },
          "restore_paths": {
            "type": "array",
            "minItems": 6,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "preserve_review_record": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "maintainer_approval_required": {
        "type": "boolean",
        "const": true
      },
      "separate_pull_request_required": {
        "type": "boolean",
        "const": true
      },
      "automatic_application": {
        "type": "boolean",
        "const": false
      }
    }
  }
}
