{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://realpg.net/reality/publication-candidate-schema-v0.json",
  "title": "Mirage Public Evidence publication candidate v0",
  "description": "Internal, read-only review value. A candidate is a complete public-safe case snapshot, never an event delta or a ledger object.",
  "readOnly": true,
  "type": "object",
  "additionalProperties": false,
  "required": ["candidateId", "caseId", "sourceResearchRevision", "previousAcceptedPublicRevisionId", "proposedStatus", "proposedClaims", "proposedSources", "proposedDecision", "strongestCounterClaimId", "reopenConditions", "freshness", "semanticEvents", "publicSafety", "provenance"],
  "properties": {
    "candidateId": {"type": "string", "minLength": 1},
    "caseId": {"type": "string", "minLength": 1},
    "sourceResearchRevision": {"type": "integer", "minimum": 1},
    "previousAcceptedPublicRevisionId": {"type": ["string", "null"]},
    "proposedStatus": {"type": "string", "minLength": 1},
    "proposedClaims": {"type": "array", "items": {"$ref": "#/$defs/claim"}},
    "proposedSources": {"type": "array", "items": {"$ref": "#/$defs/source"}},
    "proposedDecision": {"$ref": "#/$defs/decision"},
    "strongestCounterClaimId": {"type": ["string", "null"]},
    "reopenConditions": {"type": "array", "items": {"type": "string", "minLength": 1}},
    "freshness": {"$ref": "#/$defs/freshness"},
    "semanticEvents": {"type": "array", "uniqueItems": true, "items": {"enum": ["CASE_CREATED", "CLAIMS_CHANGED", "COUNTER_CHANGED", "DECISION_CHANGED", "OUTCOME_ADDED", "SOURCE_STATE_CHANGED", "FRESHNESS_CHANGED", "SUPERSEDED", "STALE", "RETRACTED"]}},
    "publicSafety": {"$ref": "#/$defs/publicSafety"},
    "provenance": {"$ref": "#/$defs/provenance"}
  },
  "$defs": {
    "claim": {"type": "object", "additionalProperties": false, "required": ["claimId", "epistemicClass", "text", "sourceRefs", "derivedFromClaimIds"], "properties": {"claimId": {"type": "string"}, "epistemicClass": {"enum": ["OBSERVATION", "INTERPRETATION", "COUNTER", "OUTCOME"]}, "text": {"type": "string"}, "sourceRefs": {"type": "array", "items": {"type": "string"}}, "derivedFromClaimIds": {"type": "array", "items": {"type": "string"}}}},
    "source": {"type": "object", "additionalProperties": false, "required": ["sourceId", "sourceObservationId", "url", "normalizedPublicUrl", "role", "retrievedAt", "verification"], "properties": {"sourceId": {"type": "string"}, "sourceObservationId": {"type": "string"}, "url": {"type": "string", "format": "uri"}, "normalizedPublicUrl": {"type": "string", "format": "uri"}, "publisher": {"type": "string"}, "role": {"type": "string"}, "retrievedAt": {"type": "string", "format": "date-time"}, "verification": {"type": "string"}}},
    "decision": {"type": "object", "additionalProperties": false, "required": ["executionClass", "reasonClass", "reasonText", "outcomeState"], "properties": {"executionClass": {"enum": ["RUN", "PARK", "HOLD", "DROP", "CLOSED"]}, "reasonClass": {"enum": ["ACTIVE_EXPERIMENT", "RELATIVE_PRIORITY", "EXTERNAL_PROXY", "INSUFFICIENT_EVIDENCE", "FALSIFIED", "DELEGATED", "OTHER"]}, "reasonText": {"type": "string", "maxLength": 2000}, "outcomeState": {"enum": ["NONE", "OUTCOME_PENDING", "OUTCOME_RECORDED"]}}},
    "freshness": {"type": "object", "additionalProperties": false, "required": ["state"], "properties": {"state": {"enum": ["CURRENT", "STALE"]}, "checkedAt": {"type": "string", "format": "date-time"}}},
    "publicSafety": {"type": "object", "additionalProperties": false, "required": ["publicSourceOnly", "noPrivateContextDependency", "noForbiddenFieldsOrValues"], "properties": {"publicSourceOnly": {"const": true}, "noPrivateContextDependency": {"const": true}, "noForbiddenFieldsOrValues": {"const": true}}},
    "provenance": {"type": "object", "additionalProperties": false, "required": ["compiler", "sourceResearchRevision"], "properties": {"compiler": {"type": "string"}, "sourceResearchRevision": {"type": "integer", "minimum": 1}, "aggregatedResearchRevisions": {"type": "array", "items": {"type": "integer", "minimum": 1}}}}
  }
}
