{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ariesnet.com/downloads/governed-definition/refuse-record.schema.json",
  "$comment": "Illustration for a fictional insurer. Hand-authored in the shape an Ariesnet engagement's boundary check records a refuse or warn decision; not produced by CoreModels and not a CoreModels export. sample-refuse-record.json validates against this file. https://ariesnet.com/resources/governed-definition-end-to-end",
  "title": "RefuseOrWarnRecord",
  "description": "One decision a boundary check recorded: what fired, why, against which contract version, and the answer it refused or warned on.",
  "type": "object",
  "required": [
    "decision",
    "checkId",
    "reason",
    "mappingApprovedBy",
    "mappingApprovedAt",
    "freezeRecord",
    "checkRanBy",
    "checkedAt",
    "contractVersion",
    "shape",
    "mappingFailed",
    "answerRefused",
    "workflowId",
    "inputHash"
  ],
  "properties": {
    "_note": {
      "type": "string",
      "description": "Provenance of the illustration. Not part of the record an engagement writes."
    },
    "decision": {
      "enum": ["refuse", "warn"],
      "description": "The audited output. Refuse is the default; warn is permitted only for the mappings the conformance contract allowlists."
    },
    "checkId": {
      "type": "string",
      "description": "The check that fired, by the id the conformance contract gives it."
    },
    "reason": {
      "type": "object",
      "description": "Why it fired, in a form a harness can assert on.",
      "required": ["code", "detail"],
      "properties": {
        "code": {
          "type": "string",
          "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
          "description": "Stable machine-readable code. Not a framework control id."
        },
        "detail": {
          "type": "string",
          "description": "One sentence naming the shape or mapping fact that failed."
        }
      }
    },
    "mappingApprovedBy": {
      "type": "string",
      "description": "Who approved the mapping in force, and who reviewed it."
    },
    "mappingApprovedAt": {
      "type": "string",
      "format": "date-time"
    },
    "freezeRecord": {
      "type": "object",
      "description": "The timestamped freeze tied to the contested mapping id.",
      "required": ["at", "mappingId"],
      "properties": {
        "at": {
          "type": "string",
          "format": "date-time"
        },
        "mappingId": {
          "type": "string"
        }
      }
    },
    "checkRanBy": {
      "type": "string",
      "description": "The account the check ran under."
    },
    "checkedAt": {
      "type": "string",
      "format": "date-time",
      "description": "UTC timestamp of the decision."
    },
    "contractVersion": {
      "type": "object",
      "description": "The contract version the decision is reproducible against.",
      "required": ["coreModelProject", "schemaVersion", "elementVersion"],
      "properties": {
        "coreModelProject": {
          "type": "string"
        },
        "schemaVersion": {
          "type": "string"
        },
        "elementVersion": {
          "type": "string"
        }
      }
    },
    "shape": {
      "type": "string",
      "description": "The ShEx shape the mapping was validated against."
    },
    "mappingFailed": {
      "type": "string",
      "description": "The mapping id that failed."
    },
    "answerRefused": {
      "type": "string",
      "description": "The answer text the check refused or warned on. This is the check's input, stored in full."
    },
    "workflowId": {
      "type": "string",
      "description": "The agent or workflow that asked."
    },
    "inputHash": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$",
      "description": "Identifies the agent request without storing what it carried."
    },
    "exportableBy": {
      "type": "string",
      "description": "Who can export the pack, and in what format."
    }
  }
}
