{
  "type": "object",
  "properties": {
    "profile": {
      "const": "build_pilot_report_v1"
    },
    "pilot_id": {
      "type": "string",
      "minLength": 1
    },
    "package_id": {
      "type": "string",
      "minLength": 1
    },
    "package_manifest_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "contract_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "runtime_contract_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "pilot_plan_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "producer_id": {
      "type": "string",
      "minLength": 1
    },
    "builder_id": {
      "type": "string",
      "minLength": 1
    },
    "started_at": {
      "type": "string",
      "format": "date-time"
    },
    "status": {
      "enum": [
        "not_started",
        "in_progress",
        "needs_revision",
        "ready_for_assessment"
      ]
    },
    "issues": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "classification": {
            "enum": [
              "standard_defect",
              "product_spec_defect",
              "implementation_defect",
              "environment_constraint",
              "bounded_decision"
            ]
          },
          "severity": {
            "enum": [
              "critical",
              "major",
              "minor",
              "info"
            ]
          },
          "status": {
            "enum": [
              "open",
              "resolved"
            ]
          },
          "requirement_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "summary": {
            "type": "string",
            "minLength": 1
          },
          "question_or_deviation": {
            "type": "string",
            "minLength": 1
          },
          "resolution": {
            "type": [
              "string",
              "null"
            ]
          },
          "decision_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "evidence": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string",
                  "minLength": 1
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "path",
                "sha256"
              ],
              "additionalProperties": false
            },
            "minItems": 0
          }
        },
        "required": [
          "id",
          "classification",
          "severity",
          "status",
          "requirement_ids",
          "summary",
          "question_or_deviation",
          "resolution",
          "decision_id",
          "evidence"
        ],
        "additionalProperties": false
      },
      "minItems": 0
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 0
    },
    "runtime_bindings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "brain_id": {
            "type": "string"
          },
          "model": {
            "type": "string",
            "minLength": 1
          },
          "version": {
            "type": "string",
            "minLength": 1
          },
          "adapter": {
            "type": "string",
            "minLength": 1
          },
          "mode": {
            "enum": [
              "authorised_model",
              "deterministic_simulator"
            ]
          },
          "evidence": {
            "type": "object",
            "properties": {
              "path": {
                "type": "string",
                "minLength": 1
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "path",
              "sha256"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "brain_id",
          "model",
          "version",
          "adapter",
          "mode",
          "evidence"
        ],
        "additionalProperties": false
      }
    },
    "review": {
      "type": "object",
      "properties": {
        "reviewer_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "decision": {
          "enum": [
            "pending",
            "accepted",
            "rejected"
          ]
        },
        "reviewed_content_sha256": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "path": {
                "type": "string",
                "minLength": 1
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "path",
              "sha256"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "reviewer_id",
        "decision",
        "reviewed_content_sha256",
        "evidence"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "profile",
    "pilot_id",
    "package_id",
    "package_manifest_sha256",
    "contract_sha256",
    "runtime_contract_sha256",
    "pilot_plan_sha256",
    "producer_id",
    "builder_id",
    "started_at",
    "status",
    "issues",
    "notes",
    "runtime_bindings",
    "review"
  ],
  "additionalProperties": false,
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
