{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dakebu.github.io/Auto-Bandit-RL-Proof-In-Sleep/community/contribution.schema.json",
  "title": "BanditRLlib community lemma packet",
  "description": "A versioned handoff from sourced mathematics into the ABRL review and BanditRLlib integration pipeline.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "id",
    "title",
    "domain",
    "status",
    "mathematics",
    "lean",
    "provenance",
    "contributor",
    "verification",
    "license",
    "unresolved_proof_obligations"
  ],
  "properties": {
    "schema_version": { "const": "1.1" },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
      "minLength": 3,
      "maxLength": 96
    },
    "title": { "type": "string", "minLength": 1, "maxLength": 500 },
    "domain": { "type": "string", "minLength": 1, "maxLength": 160 },
    "status": {
      "enum": ["proposed", "in-review", "lean-checked", "integrated"]
    },
    "mathematics": {
      "type": "object",
      "additionalProperties": false,
      "required": ["plain", "latex"],
      "properties": {
        "plain": { "type": "string", "minLength": 1 },
        "latex": { "type": "string", "minLength": 1 }
      }
    },
    "lean": {
      "type": "object",
      "additionalProperties": false,
      "required": ["imports", "code", "proposed_name", "dependencies", "banditrl_reused", "mathlib_candidates", "lml_candidates"],
      "properties": {
        "imports": {
          "type": "array",
          "items": { "type": "string", "pattern": "^[A-Za-z0-9_.]+$" },
          "uniqueItems": true
        },
        "code": { "type": "string" },
        "proposed_name": { "type": "string", "maxLength": 500 },
        "dependencies": {
          "type": "array",
          "items": { "type": "string", "maxLength": 500 },
          "uniqueItems": true
        },
        "banditrl_reused": {
          "type": "array",
          "items": { "type": "string", "maxLength": 500 },
          "uniqueItems": true
        },
        "mathlib_candidates": {
          "type": "array",
          "items": { "type": "string", "maxLength": 500 },
          "uniqueItems": true
        },
        "lml_candidates": {
          "type": "array",
          "items": { "type": "string", "maxLength": 500 },
          "uniqueItems": true
        }
      }
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "required": ["source", "locator", "notes"],
      "properties": {
        "source": { "type": "string", "maxLength": 2000 },
        "locator": { "type": "string", "maxLength": 1000 },
        "notes": { "type": "string", "maxLength": 5000 }
      }
    },
    "contributor": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "credit", "contact"],
      "properties": {
        "name": { "type": "string", "maxLength": 300 },
        "credit": { "type": "string", "maxLength": 500 },
        "contact": { "type": "string", "maxLength": 500 }
      }
    },
    "verification": {
      "type": "object",
      "additionalProperties": false,
      "required": ["compiler", "accepted", "diagnostics", "translation_status", "semantic_review_status", "proof_status", "library_status"],
      "properties": {
        "compiler": { "type": "string", "maxLength": 500 },
        "accepted": { "type": "boolean" },
        "diagnostics": { "type": "string", "maxLength": 20000 },
        "translation_status": { "enum": ["candidate", "reviewed"] },
        "semantic_review_status": { "enum": ["not-reviewed", "reviewed"] },
        "proof_status": { "enum": ["unproved", "candidate-compiles", "compiled"] },
        "library_status": { "enum": ["external", "proposed", "integrated"] }
      }
    },
    "license": {
      "type": "object",
      "additionalProperties": false,
      "required": ["spdx", "agreed"],
      "properties": {
        "spdx": { "const": "MIT" },
        "agreed": { "type": "boolean" }
      }
    },
    "created_at": { "type": "string", "format": "date-time" },
    "unresolved_proof_obligations": {
      "type": "array",
      "items": { "type": "string" },
      "uniqueItems": true
    },
    "draft_missing_fields": {
      "type": "array",
      "items": { "type": "string" },
      "uniqueItems": true
    }
  }
}
