{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.example.com/prw/queue/resolution.replay.v1.json",
  "title": "ReplayJobV1",
  "description": "PROP · Internal resolver queue message (queue resolution.replay.v1, interface if_replay_job). The admin API (POST /v1/improvements/{id}/replays) produces one message per capture. Replays pin the adapter and profile versions and preserve the original observed_at. Delivery is at-least-once with no ordering guarantee. Consumers dedupe on job_id (replay_id:capture_id) and ack after commit. Dead-letter after 5 attempts (PROP). The message carries refs and sha256 only, never raw artifacts. tenant_id and catalog_id are stamped from the operator session and re-checked against the capture row. Size: at most 16 KB (PROP; verify against provider limit).",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "job_id",
    "replay_id",
    "improvement_id",
    "tenant_id",
    "catalog_id",
    "capture_id",
    "artifacts",
    "pins",
    "mode",
    "preserve_observed_at",
    "requested_by",
    "enqueued_at",
    "history_epoch"
  ],
  "properties": {
    "schema_version": {
      "const": "resolution.replay/1"
    },
    "job_id": {
      "type": "string",
      "pattern": "^rpl_[A-Za-z0-9_]+:cap_[A-Za-z0-9_]+$"
    },
    "replay_id": {
      "type": "string",
      "pattern": "^rpl_[A-Za-z0-9_]+$"
    },
    "improvement_id": {
      "type": "string",
      "pattern": "^imp_[A-Za-z0-9_]+$"
    },
    "tenant_id": {
      "type": "string",
      "pattern": "^ten_[a-z0-9_]+$"
    },
    "catalog_id": {
      "type": "string",
      "pattern": "^cat_[a-z0-9_]+$"
    },
    "capture_id": {
      "type": "string",
      "pattern": "^cap_[A-Za-z0-9_]+$"
    },
    "artifacts": {
      "type": "array",
      "minItems": 1,
      "maxItems": 20,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "artifact_id",
          "ref",
          "sha256",
          "media_type",
          "bytes"
        ],
        "properties": {
          "artifact_id": {
            "type": "string",
            "pattern": "^art_[A-Za-z0-9_]+$"
          },
          "ref": {
            "type": "string",
            "pattern": "^r2://evidence-private/"
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "media_type": {
            "type": "string"
          },
          "bytes": {
            "type": "integer",
            "minimum": 0
          }
        }
      }
    },
    "pins": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "adapter",
        "profile",
        "identity_generation",
        "definition_versions"
      ],
      "properties": {
        "adapter": {
          "type": "string",
          "pattern": "^pa_[a-z0-9_]+@[0-9]+\\.[0-9]+\\.[0-9]+$"
        },
        "profile": {
          "type": "string",
          "pattern": "^np_[a-z0-9_]+@[0-9]+$"
        },
        "identity_generation": {
          "type": "integer",
          "minimum": 1
        },
        "definition_versions": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 1
          }
        }
      }
    },
    "mode": {
      "enum": [
        "dry_run",
        "apply"
      ],
      "description": "Defaults to dry_run. apply needs a reviewer-approved improvement."
    },
    "preserve_observed_at": {
      "const": true
    },
    "requested_by": {
      "type": "string",
      "description": "Principal id of the operator (prn_*)."
    },
    "enqueued_at": {
      "type": "string",
      "format": "date-time"
    },
    "history_epoch": {
      "type": "string",
      "minLength": 1,
      "description": "External restore fence. Consumer rejects old/unknown epoch before processing; never relabel old deliveries."
    }
  },
  "examples": [
    {
      "schema_version": "resolution.replay/1",
      "job_id": "rpl_0003_1:cap_lum_0310",
      "replay_id": "rpl_0003_1",
      "improvement_id": "imp_0003",
      "tenant_id": "ten_primary",
      "catalog_id": "cat_primary",
      "capture_id": "cap_lum_0310",
      "artifacts": [
        {
          "artifact_id": "art_0310_html",
          "ref": "r2://evidence-private/ten_primary/a3b4c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f708192",
          "sha256": "a3b4c5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d5e6f708192",
          "media_type": "text/html",
          "bytes": 233904
        }
      ],
      "pins": {
        "adapter": "pa_lumen_specgrid@1.0.0",
        "profile": "np_storage@4",
        "identity_generation": 1,
        "definition_versions": {
          "storage:heatsink": 1
        }
      },
      "mode": "dry_run",
      "preserve_observed_at": true,
      "requested_by": "prn_operator_reviewer",
      "enqueued_at": "2026-10-11T10:00:00Z",
      "history_epoch": "history-demo-1"
    }
  ]
}
