{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://law.arxo.io/schema/run.schema.json",
  "title": "Arxo run record 0.1",
  "description": "Host contract: an explicitly stored execution attempt or agent pass. The exact bytes live in storage under their digest; result statuses are copied from the document with addresses. Five separate check indicators instead of one \"verified\" flag. Carries no semantics: the evaluation document is unchanged.",
  "$comment": "DECISION-0455; formerly law.run/0.1",
  "type": "object",
  "required": [
    "schema",
    "runId",
    "producer",
    "event",
    "route",
    "artifacts",
    "result",
    "capture",
    "checks",
    "links",
    "savedAt"
  ],
  "properties": {
    "schema": {
      "const": "law.run/0.1"
    },
    "runId": {
      "type": "string",
      "pattern": "^run:[0-9a-f]{32}$",
      "description": "Identity digest of the event: schema, producer, event, route, artifacts; savedAt is not part of it."
    },
    "producer": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    },
    "event": {
      "type": "string",
      "minLength": 1,
      "description": "Name of the save event; two calls with one result are two events."
    },
    "route": {
      "type": "object",
      "required": [
        "kind"
      ],
      "properties": {
        "kind": {
          "enum": [
            "ask",
            "evaluate-test",
            "agent",
            "mcp",
            "serve",
            "accuracy",
            "impact"
          ]
        }
      },
      "additionalProperties": true
    },
    "artifacts": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "required": [
          "digest",
          "size"
        ],
        "properties": {
          "digest": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$"
          },
          "size": {
            "type": "integer",
            "minimum": 0
          }
        },
        "additionalProperties": false
      }
    },
    "result": {
      "type": "object",
      "properties": {
        "resultHash": {
          "type": [
            "string",
            "null"
          ]
        },
        "results": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "address"
            ],
            "properties": {
              "address": {
                "type": "string"
              }
            },
            "additionalProperties": true
          }
        },
        "score": {
          "type": [
            "object",
            "null"
          ]
        }
      },
      "additionalProperties": false
    },
    "capture": {
      "type": "object",
      "required": [
        "state",
        "missing"
      ],
      "properties": {
        "state": {
          "enum": [
            "complete",
            "partial",
            "refused"
          ]
        },
        "missing": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "checks": {
      "type": "object",
      "required": [
        "bytes",
        "inputs",
        "replay",
        "proof",
        "producer"
      ],
      "properties": {
        "bytes": {
          "type": "object",
          "required": [
            "state",
            "note"
          ],
          "properties": {
            "state": {
              "enum": [
                "verified",
                "mismatch",
                "unavailable",
                "not_checked"
              ]
            },
            "note": {
              "type": "string"
            },
            "engine": {
              "type": "object"
            }
          },
          "additionalProperties": false
        },
        "inputs": {
          "type": "object",
          "required": [
            "state",
            "note"
          ],
          "properties": {
            "state": {
              "enum": [
                "verified",
                "mismatch",
                "unavailable",
                "not_checked"
              ]
            },
            "note": {
              "type": "string"
            },
            "engine": {
              "type": "object"
            }
          },
          "additionalProperties": false
        },
        "replay": {
          "type": "object",
          "required": [
            "state",
            "note"
          ],
          "properties": {
            "state": {
              "enum": [
                "verified",
                "mismatch",
                "unavailable",
                "not_checked"
              ]
            },
            "note": {
              "type": "string"
            },
            "engine": {
              "type": "object"
            }
          },
          "additionalProperties": false
        },
        "proof": {
          "type": "object",
          "required": [
            "state",
            "note"
          ],
          "properties": {
            "state": {
              "enum": [
                "verified",
                "mismatch",
                "unavailable",
                "not_checked"
              ]
            },
            "note": {
              "type": "string"
            },
            "engine": {
              "type": "object"
            }
          },
          "additionalProperties": false
        },
        "producer": {
          "type": "object",
          "required": [
            "state",
            "note"
          ],
          "properties": {
            "state": {
              "enum": [
                "verified",
                "mismatch",
                "unavailable",
                "not_checked"
              ]
            },
            "note": {
              "type": "string"
            },
            "engine": {
              "type": "object"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "links": {
      "type": "object",
      "additionalProperties": true
    },
    "note": {
      "type": "string"
    },
    "savedAt": {
      "type": "string"
    }
  },
  "additionalProperties": false
}
