{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tiffany.systems/api/schema/operation-result.schema.json",
  "title": "OperationResult",
  "description": "The deterministic outcome of evaluating an operation envelope. Machine-readable throughout: a stop reason is typed data, not a sentence in a log that something later has to parse.",
  "x-schema-version": "1.0.0",
  "type": "object",
  "additionalProperties": false,
  "required": ["operation_id", "outcome", "state", "checks", "stop_reasons", "audit"],
  "properties": {
    "operation_id": {"type": "string"},
    "outcome": {"type": "string", "enum": ["ACCEPTED", "STOPPED", "CONFLICT", "NO_OP_IDEMPOTENT"]},
    "state": {"type": "string", "enum": ["DRAFT", "PROPOSAL", "SHADOW_RESULT", "APPROVED_FOR_PUBLICATION", "PUBLISHED", "SUPERSEDED", "WITHDRAWN", "CONFLICT", "REJECTED"]},
    "checks": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["id", "title", "status"], "properties": {"id": {"type": "string"}, "title": {"type": "string"}, "status": {"type": "string", "enum": ["PASS", "FAIL", "NOT_APPLICABLE"]}, "detail": {"type": ["string", "null"]}}}},
    "stop_reasons": {"type": "array", "items": {"type": "object", "additionalProperties": false, "required": ["code", "detail"], "properties": {"code": {"type": "string"}, "detail": {"type": "string"}}}},
    "effect": {"type": ["string", "null"], "enum": ["NONE", "WOULD_CREATE_VERSION", "WOULD_SUPERSEDE", "WOULD_WITHDRAW", "WOULD_RELEASE", null], "description": "What the operation would do if executed live. In shadow mode the actual effect is always NONE."},
    "resulting_version": {"type": ["string", "null"]},
    "resulting_digest": {"type": ["string", "null"]},
    "rollback": {"type": ["object", "null"], "additionalProperties": false, "properties": {"available": {"type": "boolean"}, "target_version": {"type": ["string", "null"]}, "note": {"type": ["string", "null"]}}},
    "review_required": {"type": ["array", "null"], "items": {"type": "string"}},
    "scientific_status_note": {"type": "string", "description": "Present on every result. States that acceptance is operational and says nothing about scientific standing."},
    "audit": {"type": "object", "additionalProperties": false, "required": ["actor", "delegation_id", "policy_version", "evaluated_at", "input_digest"], "properties": {"audit_event_id": {"type": ["string", "null"]}, "actor": {"type": "string"}, "delegation_id": {"type": "string"}, "policy_version": {"type": "string"}, "evaluated_at": {"type": "string"}, "input_digest": {"type": "string"}, "output_digest": {"type": ["string", "null"]}, "reason": {"type": ["string", "null"]}}}
  }
}
