{
  "type": "object",
  "additionalProperties": false,
  "required": [
    "ticket_id",
    "source",
    "source_ref_sha256",
    "content_sha256",
    "content_file",
    "source_updated_at",
    "ready_intent",
    "policy_version",
    "policy_digest",
    "gate_digest",
    "lifecycle_updated_at",
    "lease_expires_at",
    "resume_at",
    "resume_state",
    "park_reason",
    "resume_gate",
    "session_id",
    "last_error",
    "verification_plan_ref",
    "worktree",
    "executor_evidence",
    "verification_evidence",
    "grade_evidence",
    "prior_failure_evidence",
    "prior_reflection_evidence",
    "merge_disposition",
    "sync_outcomes"
  ],
  "properties": {
    "ticket_id": {
      "type": "string",
      "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"
    },
    "source": { "type": "string", "enum": ["github", "local"] },
    "source_ref_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "content_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "content_file": { "type": "string", "minLength": 70, "maxLength": 134 },
    "source_updated_at": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\\.[0-9]{1,3})?Z$"
    },
    "ready_intent": { "const": true },
    "policy_version": { "type": "integer", "minimum": 1 },
    "policy_digest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "gate_digest": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" },
    "lifecycle_updated_at": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"
    },
    "lease_expires_at": {
      "type": ["string", "null"],
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"
    },
    "resume_at": {
      "type": ["string", "null"],
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"
    },
    "resume_state": { "type": ["string", "null"], "enum": ["pending", "retryable", null] },
    "park_reason": { "type": ["string", "null"], "minLength": 1, "maxLength": 512 },
    "resume_gate": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["kind", "role_id", "engine", "session_id", "limited_session_version", "limited_observation_id", "limited_observed_at"],
      "properties": {
        "kind": { "type": "string", "enum": ["time", "quota"] },
        "role_id": { "type": ["string", "null"], "minLength": 3, "maxLength": 63 },
        "engine": { "type": ["string", "null"], "enum": ["claude", "codex", null] },
        "session_id": {
          "type": ["string", "null"],
          "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"
        },
        "limited_session_version": { "type": ["integer", "null"], "minimum": 0 },
        "limited_observation_id": {
          "type": ["string", "null"],
          "pattern": "^quota-[a-f0-9]{48}$"
        },
        "limited_observed_at": {
          "type": ["string", "null"],
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$"
        }
      }
    },
    "session_id": {
      "type": ["string", "null"],
      "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"
    },
    "last_error": { "type": ["string", "null"], "minLength": 1, "maxLength": 2048 },
    "verification_plan_ref": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["evidence_id", "sha256", "file_name"],
      "properties": {
        "evidence_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", "minLength": 6, "maxLength": 69 }
      }
    },
    "worktree": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["branch", "base_commit"],
      "properties": {
        "branch": { "type": "string", "minLength": 1, "maxLength": 255 },
        "base_commit": { "type": "string", "pattern": "^[a-f0-9]{40}(?:[a-f0-9]{24})?$" }
      }
    },
    "executor_evidence": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["evidence_id", "sha256", "file_name"],
      "properties": {
        "evidence_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", "minLength": 6, "maxLength": 69 }
      }
    },
    "verification_evidence": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["evidence_id", "sha256", "file_name"],
      "properties": {
        "evidence_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", "minLength": 6, "maxLength": 69 }
      }
    },
    "grade_evidence": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["evidence_id", "sha256", "file_name"],
      "properties": {
        "evidence_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", "minLength": 6, "maxLength": 69 }
      }
    },
    "prior_failure_evidence": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["evidence_id", "sha256", "file_name"],
      "properties": {
        "evidence_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", "minLength": 6, "maxLength": 69 }
      }
    },
    "prior_reflection_evidence": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["evidence_id", "sha256", "file_name"],
      "properties": {
        "evidence_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", "minLength": 6, "maxLength": 69 }
      }
    },
    "merge_disposition": { "const": "human_hold" },
    "sync_outcomes": {
      "type": "array",
      "minItems": 1,
      "maxItems": 64,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "nonce",
          "operation_sha256",
          "status",
          "content_sha256",
          "content_file",
          "record_version"
        ],
        "properties": {
          "nonce": {
            "type": "string",
            "pattern": "^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"
          },
          "operation_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "status": { "type": "string", "enum": ["created", "refreshed", "unchanged"] },
          "content_sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "content_file": { "type": "string", "minLength": 70, "maxLength": 134 },
          "record_version": { "type": "integer", "minimum": 0 }
        }
      }
    }
  }
}
