{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aiwg.io/schemas/decision/DecisionReview.schema.json",
  "title": "DecisionReview",
  "type": "object",
  "additionalProperties": false,
  "required": ["apiVersion", "kind", "schema", "revision", "reviewId", "tenantId", "projectId", "requesterId", "sourceReceipt", "evidencePins", "policyPins", "reasonCodes", "riskTier", "presentation", "proposals", "decisions", "events", "status", "createdAtEpochMs", "updatedAtEpochMs", "expiresAtEpochMs", "quorum", "continuation"],
  "properties": {
    "apiVersion": { "const": "decision.aiwg.io/v1alpha1" }, "kind": { "const": "DecisionReview" }, "schema": { "const": "decision-review/v1" },
    "revision": { "type": "integer", "minimum": 1 }, "reviewId": { "type": "string", "minLength": 1 }, "tenantId": { "type": "string", "minLength": 1 }, "projectId": { "type": "string", "minLength": 1 }, "requesterId": { "type": "string", "minLength": 1 },
    "sourceReceipt": { "$ref": "#/$defs/sourceReceipt" }, "evidencePins": { "type": "array", "items": { "$ref": "#/$defs/pin" } }, "policyPins": { "type": "array", "items": { "$ref": "#/$defs/pin" } },
    "reasonCodes": { "type": "array", "items": { "type": "string" }, "uniqueItems": true }, "riskTier": { "type": "string", "minLength": 1 }, "presentation": { "type": "object" },
    "proposals": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/proposal" } }, "decisions": { "type": "array", "items": { "$ref": "#/$defs/decision" } }, "events": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/event" } },
    "status": { "enum": ["pending", "claimed", "approved", "rejected", "expired", "escalated", "canceled", "resuming", "completed", "execution-failed", "tombstoned"] },
    "createdAtEpochMs": { "type": "integer", "minimum": 0 }, "updatedAtEpochMs": { "type": "integer", "minimum": 0 }, "expiresAtEpochMs": { "type": "integer", "minimum": 0 }, "retentionUntilEpochMs": { "type": "integer", "minimum": 0 }, "escalationAtEpochMs": { "type": "integer", "minimum": 0 }, "quorum": { "type": "integer", "minimum": 1, "maximum": 16 },
    "continuation": { "type": "object", "additionalProperties": false, "required": ["id", "tokenDigest"], "properties": { "id": { "type": "string", "minLength": 1 }, "tokenDigest": { "$ref": "#/$defs/digest" } } }, "effectReceipt": { "$ref": "#/$defs/effect" }, "executionError": { "type": "string" },
    "lifecycle": { "type": "object", "additionalProperties": false, "required": ["legalHold"], "properties": { "legalHold": { "type": "boolean" }, "tombstonedAtEpochMs": { "type": "integer", "minimum": 0 }, "tombstoneReason": { "type": "string" } } }
  },
  "$defs": {
    "evaluation": {
      "type": "object",
      "additionalProperties": false,
      "description": "Observed evaluator provenance and evidence. Agreement does not establish independent errors or proof.",
      "properties": {
        "evaluatorModel": {
          "type": "string",
          "minLength": 1,
          "maxLength": 8192,
          "pattern": "\\S"
        },
        "evaluatorVendor": {
          "type": "string",
          "minLength": 1,
          "maxLength": 8192,
          "pattern": "\\S"
        },
        "evaluatorFamily": {
          "type": "string",
          "minLength": 1,
          "maxLength": 8192,
          "pattern": "\\S",
          "description": "Observed model family; unknown remains unknown. CLI names are not model families."
        },
        "acceptanceCriteriaRef": {
          "type": "string",
          "minLength": 1,
          "maxLength": 8192,
          "pattern": "\\S"
        },
        "reReviewOf": {
          "type": "string",
          "minLength": 1,
          "maxLength": 8192,
          "pattern": "\\S",
          "description": "Reference to the previous review/decision, recorded on a re-review after material fixes."
        },
        "disagreements": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "claimRef",
              "generatorPosition",
              "evaluatorPosition"
            ],
            "properties": {
              "claimRef": {
                "type": "string",
                "minLength": 1,
                "maxLength": 8192,
                "pattern": "\\S"
              },
              "generatorPosition": {
                "type": "string",
                "minLength": 1,
                "maxLength": 8192,
                "pattern": "\\S"
              },
              "evaluatorPosition": {
                "type": "string",
                "minLength": 1,
                "maxLength": 8192,
                "pattern": "\\S"
              },
              "resolutionRef": {
                "type": "string",
                "minLength": 1,
                "maxLength": 8192,
                "pattern": "\\S"
              }
            }
          }
        }
      }
    },
    "digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "actor": { "type": "object", "additionalProperties": false, "required": ["id", "roles", "authorityContext"], "properties": { "id": { "type": "string", "minLength": 1 }, "roles": { "type": "array", "items": { "type": "string" } }, "authorityContext": { "type": "string" } } },
    "pin": { "type": "object", "additionalProperties": false, "required": ["id", "version", "digest"], "properties": { "id": { "type": "string" }, "version": { "type": "string" }, "digest": { "$ref": "#/$defs/digest" } } },
    "sourceReceipt": { "type": "object", "additionalProperties": false, "required": ["id", "digest"], "properties": { "id": { "type": "string" }, "digest": { "$ref": "#/$defs/digest" } } },
    "proposal": { "type": "object", "additionalProperties": false, "required": ["version", "action", "actionDigest", "createdAtEpochMs", "editor", "rationale"], "properties": { "version": { "type": "integer", "minimum": 1 }, "action": {}, "actionDigest": { "$ref": "#/$defs/digest" }, "createdAtEpochMs": { "type": "integer" }, "editor": { "$ref": "#/$defs/actor" }, "rationale": { "type": "string" } } },
    "decision": { "type": "object", "additionalProperties": false, "required": ["reviewer", "proposalVersion", "decision", "rationale", "atEpochMs"], "properties": { "reviewer": { "$ref": "#/$defs/actor" }, "proposalVersion": { "type": "integer" }, "decision": { "enum": ["approve", "reject"] }, "rationale": { "type": "string" }, "atEpochMs": { "type": "integer" }, "evaluation": { "$ref": "#/$defs/evaluation" } } },
    "event": { "type": "object", "additionalProperties": false, "required": ["sequence", "type", "atEpochMs", "actor", "proposalVersion", "rationale"], "properties": { "sequence": { "type": "integer" }, "type": { "enum": ["created", "claimed", "approved", "rejected", "edited", "expired", "escalated", "canceled", "resumed", "execution-completed", "execution-failed", "legal-hold-placed", "legal-hold-released", "tombstoned", "authorization-denied", "sensitive-view-accessed"] }, "atEpochMs": { "type": "integer" }, "actor": { "$ref": "#/$defs/actor" }, "proposalVersion": { "type": "integer" }, "rationale": { "type": "string" }, "operatorDecisionEventId": { "type": "string", "minLength": 1 }, "data": { "type": "object" } } },
    "effect": { "type": "object", "additionalProperties": false, "required": ["effectId", "continuationId", "proposalVersion", "completedAtEpochMs", "result"], "properties": { "effectId": { "type": "string" }, "continuationId": { "type": "string" }, "proposalVersion": { "type": "integer" }, "completedAtEpochMs": { "type": "integer" }, "result": {} } }
  }
}
