{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "trinityaccord.record-chain-server-receipt.v1",
  "title": "Server Receipt",
  "description": "A server receipt returned after a successful record-chain submission. commit_sha is NOT in the receipt body — it is immutable once created. Use receipt_commit_sha at the response envelope level.",
  "type": "object",
  "required": [
    "server_receipt_id",
    "service",
    "gateway_version",
    "record_type",
    "submission_sha256",
    "original_submission_sha256",
    "stored_submission_sha256",
    "accepted_at",
    "raw_readback_redacted",
    "receipt_sha256"
  ],
  "properties": {
    "server_receipt_id": {
      "type": "string",
      "pattern": "^rcg-\\d{8}-[a-f0-9]{12}$",
      "description": "Unique receipt identifier in the format rcg-YYYYMMDD-<12hex>."
    },
    "service": {
      "type": "string",
      "const": "record-chain-intake-gateway"
    },
    "gateway_version": {
      "type": "string",
      "description": "Semver of the gateway that produced this receipt."
    },
    "record_type": {
      "type": "string",
      "description": "The resolved record type."
    },
    "submission_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$",
      "description": "SHA-256 of the canonical submission JSON."
    },
    "original_submission_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$",
      "description": "SHA-256 of the original (pre-redaction) canonical submission."
    },
    "stored_submission_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$",
      "description": "SHA-256 of the redacted (persisted) canonical submission."
    },
    "received_raw_body_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$",
      "description": "SHA-256 hex of the raw request body bytes."
    },
    "accepted_at": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 UTC timestamp when the submission was accepted."
    },
    "file_path": {
      "type": "string",
      "description": "Repository-relative path where the record was persisted."
    },
    "intake_submission_path": {
      "type": "string",
      "description": "Repo path of the intake submission file."
    },
    "pending_file_path": {
      "type": "string",
      "description": "Repo path of the pending file."
    },
    "receipt_path": {
      "type": "string",
      "description": "Repo path of the receipt file."
    },
    "raw_readback_redacted": {
      "type": "boolean",
      "const": true,
      "description": "Always true. Confirms raw oath readback was redacted before receipt creation."
    },
    "receipt_is_not_final_chain_record": {
      "type": "boolean",
      "const": true,
      "description": "Always true. Receipt is intake acknowledgement only."
    },
    "oath_verification": {
      "type": ["object", "null"],
      "description": "Summary of oath verification results (excludes raw readback text)."
    },
    "receipt_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$",
      "description": "SHA-256 of the receipt contents (self-referencing integrity hash)."
    }
  },
  "additionalProperties": false
}
