{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://yao.local/schemas/adaptation-proposal.schema.json",
  "title": "Yao Adaptation Proposal Report",
  "type": "object",
  "required": [
    "schema_version",
    "ok",
    "generated_at",
    "skill_dir",
    "pattern_count",
    "proposal_count",
    "apply_supported",
    "failure_count",
    "proposal_only",
    "approval_required",
    "writes_repository_files",
    "approval_draft_supported",
    "summary",
    "proposal_contract",
    "report_contract",
    "proposals",
    "artifacts"
  ],
  "properties": {
    "schema_version": {
      "const": "1.0"
    },
    "ok": {
      "type": "boolean"
    },
    "generated_at": {
      "type": "string"
    },
    "skill_dir": {
      "type": "string"
    },
    "pattern_count": {
      "type": "integer",
      "minimum": 0
    },
    "proposal_count": {
      "type": "integer",
      "minimum": 0
    },
    "apply_supported": {
      "type": "boolean"
    },
    "failure_count": {
      "type": "integer",
      "minimum": 0
    },
    "proposal_only": {
      "const": true
    },
    "approval_required": {
      "const": true
    },
    "writes_repository_files": {
      "const": false
    },
    "approval_draft_supported": {
      "const": true
    },
    "summary": {
      "type": "object",
      "required": ["pattern_count", "proposal_count", "apply_supported"],
      "properties": {
        "pattern_count": {
          "type": "integer",
          "minimum": 0
        },
        "proposal_count": {
          "type": "integer",
          "minimum": 0
        },
        "apply_supported": {
          "type": "boolean"
        }
      },
      "additionalProperties": true
    },
    "proposal_contract": {
      "type": "object",
      "required": [
        "proposal_only",
        "approval_required",
        "writes_repository_files",
        "allowlisted_targets_required",
        "target_file_sha256_required_for_apply",
        "approval_draft_supported",
        "rollback_required_for_apply",
        "apply_command_available"
      ],
      "properties": {
        "proposal_only": {
          "const": true
        },
        "approval_required": {
          "const": true
        },
        "writes_repository_files": {
          "const": false
        },
        "allowlisted_targets_required": {
          "const": true
        },
        "target_file_sha256_required_for_apply": {
          "const": true
        },
        "approval_draft_supported": {
          "const": true
        },
        "rollback_required_for_apply": {
          "const": true
        },
        "apply_command_available": {
          "type": "boolean"
        }
      },
      "additionalProperties": true
    },
    "report_contract": {
      "type": "object",
      "required": [
        "schema_version",
        "contract",
        "top_level_mirrors_summary",
        "top_level_mirrors_proposal_contract",
        "summary_fields",
        "proposal_contract_fields",
        "source_of_truth"
      ],
      "properties": {
        "schema_version": {
          "const": "1.0"
        },
        "contract": {
          "const": "adaptation-proposals"
        },
        "top_level_mirrors_summary": {
          "const": true
        },
        "top_level_mirrors_proposal_contract": {
          "const": true
        },
        "summary_fields": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "proposal_contract_fields": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "source_of_truth": {
          "type": "array",
          "items": {
            "enum": [
              "summary",
              "proposal_contract"
            ]
          }
        }
      },
      "additionalProperties": true
    },
    "proposals": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "proposal_id",
          "status",
          "requires_approval",
          "write_allowed_without_approval",
          "target_files",
          "verification_commands",
          "rollback_plan"
        ],
        "properties": {
          "proposal_id": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "const": "proposal-only"
          },
          "requires_approval": {
            "const": true
          },
          "write_allowed_without_approval": {
            "const": false
          },
          "risk_level": {
            "enum": ["low", "medium", "high"]
          },
          "target_files": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "verification_commands": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "rollback_plan": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": true
      }
    },
    "artifacts": {
      "type": "object"
    }
  },
  "additionalProperties": true
}
