{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://finalprompt.example/schema/api-run-response-v1.3.json",
  "title": "Final Prompt model phase response \u2014 illustrative host contract v1.3",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "run_id",
    "phase",
    "policy_hash",
    "baseline_commit",
    "status",
    "summary",
    "evidence",
    "findings",
    "actions",
    "blockers",
    "next_action"
  ],
  "properties": {
    "schema_version": {
      "const": "1.3"
    },
    "run_id": {
      "type": "string",
      "minLength": 1
    },
    "phase": {
      "type": "string",
      "minLength": 1
    },
    "policy_hash": {
      "type": "string",
      "minLength": 1
    },
    "baseline_commit": {
      "type": "string",
      "minLength": 1
    },
    "status": {
      "enum": [
        "NOT_STARTED",
        "IN_PROGRESS",
        "PASS",
        "FAIL",
        "BLOCKED",
        "UNVERIFIED",
        "NOT_APPLICABLE",
        "ACCEPTED_RISK"
      ]
    },
    "summary": {
      "type": "string"
    },
    "evidence": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "artifact_ref",
          "kind",
          "environment",
          "observed_at",
          "commit"
        ],
        "properties": {
          "artifact_ref": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "enum": [
              "file_inspection",
              "command_output",
              "executed_test",
              "browser_observation",
              "runtime_receipt",
              "versioned_diff",
              "operator_attestation",
              "other"
            ]
          },
          "environment": {
            "type": "string",
            "minLength": 1
          },
          "observed_at": {
            "type": "string",
            "format": "date-time"
          },
          "commit": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "finding_id",
          "severity",
          "confidence",
          "description",
          "disposition"
        ],
        "properties": {
          "finding_id": {
            "type": "string",
            "minLength": 1
          },
          "severity": {
            "enum": [
              "P0",
              "P1",
              "P2",
              "P3"
            ]
          },
          "confidence": {
            "enum": [
              "CONFIRMED",
              "PROBABLE",
              "UNVERIFIED"
            ]
          },
          "description": {
            "type": "string"
          },
          "disposition": {
            "enum": [
              "OPEN",
              "VERIFIED_CLOSED",
              "CODE_ONLY",
              "DEFERRED",
              "BLOCKED",
              "NOT_APPLICABLE"
            ]
          }
        }
      }
    },
    "actions": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "action_id",
          "kind",
          "result"
        ],
        "properties": {
          "action_id": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "enum": [
              "INSPECT",
              "PLAN",
              "PROPOSE_PATCH",
              "EXECUTE",
              "VERIFY",
              "REQUEST_APPROVAL",
              "CHECKPOINT"
            ]
          },
          "result": {
            "enum": [
              "PROPOSED",
              "EXECUTED",
              "DENIED",
              "BLOCKED",
              "UNVERIFIED"
            ]
          },
          "artifact_ref": {
            "type": "string"
          }
        }
      }
    },
    "blockers": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "next_action": {
      "type": [
        "string",
        "null"
      ]
    },
    "coverage": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "unverified": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "cost_estimate_usd": {
      "type": [
        "number",
        "null"
      ],
      "minimum": 0
    },
    "approval_request_ids": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "PASS"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "properties": {
          "evidence": {
            "minItems": 1
          }
        }
      }
    }
  ]
}
