{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oms.local/schemas/regression-request.schema.json",
  "title": "OMS typed regression request",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "goal_id",
    "reason",
    "objective",
    "stopping_condition",
    "requested_at",
    "source_artifacts",
    "predicate",
    "disposition"
  ],
  "properties": {
    "schema_version": { "const": 1 },
    "goal_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
    "reason": {
      "enum": ["native-goal-mismatch", "stale-native-snapshot", "predicate-failed", "ultragoal-mismatch"]
    },
    "objective": { "type": "string", "minLength": 1, "maxLength": 32768 },
    "stopping_condition": { "type": "string", "minLength": 1, "maxLength": 32768 },
    "requested_at": { "type": "string", "minLength": 20, "maxLength": 24 },
    "source_artifacts": {
      "type": "array",
      "maxItems": 2,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["kind", "artifact_id", "sha256", "file_name"],
        "properties": {
          "kind": { "enum": ["native-goal-snapshot", "team-checkpoint"] },
          "artifact_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
          "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "file_name": { "type": "string", "maxLength": 96 }
        }
      }
    },
    "predicate": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["predicate_id", "expected_sha256", "actual_sha256"],
      "properties": {
        "predicate_id": { "type": "string", "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$" },
        "expected_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "actual_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
      }
    },
    "disposition": { "const": "queue-request-only" }
  }
}
