{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/wheresmycoleslaw/capability/blob/main/capability-receipt.schema.json",
  "title": "Capability Execution Receipt",
  "type": "object",
  "additionalProperties": true,
  "required": ["receiptId", "planId", "capability", "status", "startedAt", "endedAt", "durationMs", "effects", "inputHash"],
  "properties": {
    "receiptId": { "type": "string", "minLength": 1 },
    "planId": { "type": "string", "minLength": 1 },
    "capability": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "version"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "version": { "type": "string", "minLength": 1 }
      }
    },
    "status": { "enum": ["succeeded", "failed", "rolled_back", "rollback_failed"] },
    "startedAt": { "type": "string", "format": "date-time" },
    "endedAt": { "type": "string", "format": "date-time" },
    "durationMs": { "type": "number", "minimum": 0 },
    "effects": { "type": "array", "items": { "type": "string" } },
    "inputHash": { "type": "string", "minLength": 1 },
    "outputHash": { "type": "string" },
    "input": {},
    "output": {},
    "verification": { "type": "object" },
    "error": { "type": "object" },
    "rollbackResult": {},
    "metadata": { "type": "object" },
    "provenance": { "type": "object" }
  }
}
