{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://unpkg.com/context-room@latest/schemas/codex-prompt-runtime-receipt-v2.schema.json",
  "title": "Codex prompt runtime receipt v2",
  "description": "Strict schema for prompt-overrides/runtime/<pid>.json.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "pid",
    "publicationGeneration",
    "processStartIdentity",
    "loadedAtUnixMs",
    "runtimeVersion",
    "manifestRevision",
    "manifestHash",
    "catalogFile",
    "catalogHash",
    "catalogRevision",
    "activeOverrides"
  ],
  "properties": {
    "schemaVersion": {
      "const": 2
    },
    "pid": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "publicationGeneration": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "processStartIdentity": {
      "type": "string",
      "pattern": "^darwin-proc-bsdinfo-v1:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}:[1-9][0-9]*:[0-9]{6}$"
    },
    "loadedAtUnixMs": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "runtimeVersion": {
      "type": "string"
    },
    "manifestRevision": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "manifestHash": {
      "anyOf": [
        {
          "$ref": "#/$defs/hash"
        },
        {
          "type": "null"
        }
      ]
    },
    "catalogFile": {
      "type": "string",
      "pattern": "^[1-9][0-9]*\\.[0-9a-f]{64}\\.catalog\\.json$"
    },
    "catalogHash": {
      "$ref": "#/$defs/hash"
    },
    "catalogRevision": {
      "$ref": "#/$defs/hash"
    },
    "activeOverrides": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/activeOverride"
      }
    }
  },
  "$defs": {
    "hash": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "activeOverride": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "targetId",
        "sourceTargetId",
        "effectiveHash"
      ],
      "properties": {
        "targetId": {
          "type": "string",
          "minLength": 1
        },
        "sourceTargetId": {
          "type": "string",
          "minLength": 1
        },
        "effectiveHash": {
          "$ref": "#/$defs/hash"
        }
      }
    }
  },
  "$comment": "publicationGeneration must exactly equal runtimeOwnerGenerations[String(pid)] in the relevant stable owner vector from codex-prompt-publication-state-v2. runtimeRegistryGenerations is validated structurally but is not a receipt-freshness key. Receipt bytes are immutable for one publicationGeneration; every publication, replacement, or tombstone requires a fresh owner generation. processStartIdentity must equal the lowercase kern.bootsessionuuid plus the exact Darwin proc_pidinfo(PROC_PIDTBSDINFO) start tuple before and after snapshot validation, and the complete represented PID-to-identity set must still match during final batch verification. Receipt bytes and publication generations are reread byte-exactly before aggregation. catalogFile must contain the same PID as pid and the raw SHA-256 hex from catalogHash. The immutable snapshot uses codex-prompt-catalog-v1.schema.json."
}
