{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://awoooi.wooo.work/schemas/ai_agent_redis_dry_run_gate_v1.schema.json",
  "title": "AI Agent Redis Dry Run Gate v1",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_refs",
    "dry_run_truth",
    "consumer_group_dry_run_contract",
    "handoff_envelope_contract",
    "ack_dead_letter_replay_contract",
    "dry_run_steps",
    "handoff_lanes",
    "approval_boundaries",
    "display_redaction_contract",
    "rollups"
  ],
  "properties": {
    "schema_version": {"const": "ai_agent_redis_dry_run_gate_v1"},
    "generated_at": {"type": "string"},
    "program_status": {
      "type": "object",
      "required": [
        "overall_completion_percent",
        "current_task_id",
        "next_task_id",
        "read_only_mode",
        "runtime_authority"
      ],
      "properties": {
        "overall_completion_percent": {"type": "integer", "minimum": 0, "maximum": 100},
        "current_task_id": {"const": "P2-403C"},
        "next_task_id": {"type": "string"},
        "read_only_mode": {"const": true},
        "runtime_authority": {"const": "dry_run_contract_only_no_redis_runtime"}
      },
      "additionalProperties": true
    },
    "source_refs": {"type": "array", "items": {"type": "string"}, "minItems": 1},
    "dry_run_truth": {
      "type": "object",
      "required": [
        "redis_connection_allowed",
        "consumer_group_created",
        "xadd_allowed",
        "xreadgroup_allowed",
        "ack_allowed",
        "dead_letter_write_allowed",
        "replay_runtime_allowed",
        "telegram_send_allowed",
        "learning_writeback_allowed",
        "live_dry_run_event_count",
        "live_ack_count",
        "live_dead_letter_count",
        "live_replay_count"
      ],
      "properties": {
        "redis_connection_allowed": {"const": false},
        "consumer_group_created": {"const": false},
        "xadd_allowed": {"const": false},
        "xreadgroup_allowed": {"const": false},
        "ack_allowed": {"const": false},
        "dead_letter_write_allowed": {"const": false},
        "replay_runtime_allowed": {"const": false},
        "telegram_send_allowed": {"const": false},
        "learning_writeback_allowed": {"const": false},
        "live_dry_run_event_count": {"const": 0},
        "live_ack_count": {"const": 0},
        "live_dead_letter_count": {"const": 0},
        "live_replay_count": {"const": 0}
      },
      "additionalProperties": true
    },
    "consumer_group_dry_run_contract": {
      "type": "object",
      "required": [
        "candidate_group_name",
        "stream_namespace",
        "fixture_only",
        "redis_network_call_allowed",
        "required_fixture_fields"
      ],
      "properties": {
        "fixture_only": {"const": true},
        "redis_network_call_allowed": {"const": false},
        "required_fixture_fields": {"type": "array", "items": {"type": "string"}, "minItems": 1}
      },
      "additionalProperties": true
    },
    "handoff_envelope_contract": {
      "type": "object",
      "required": [
        "required_fields",
        "forbidden_fields",
        "redacted_evidence_required",
        "idempotency_key_required"
      ],
      "properties": {
        "required_fields": {"type": "array", "items": {"type": "string"}, "minItems": 1},
        "forbidden_fields": {"type": "array", "items": {"type": "string"}, "minItems": 1},
        "redacted_evidence_required": {"const": true},
        "idempotency_key_required": {"const": true}
      },
      "additionalProperties": true
    },
    "ack_dead_letter_replay_contract": {
      "type": "object",
      "required": [
        "ack_requires_verifier",
        "dead_letter_requires_reason",
        "replay_requires_idempotency",
        "runtime_replay_allowed"
      ],
      "properties": {
        "ack_requires_verifier": {"const": true},
        "dead_letter_requires_reason": {"const": true},
        "replay_requires_idempotency": {"const": true},
        "runtime_replay_allowed": {"const": false}
      },
      "additionalProperties": true
    },
    "dry_run_steps": {"type": "array", "items": {"$ref": "#/$defs/dry_run_step"}, "minItems": 1},
    "handoff_lanes": {"type": "array", "items": {"$ref": "#/$defs/handoff_lane"}, "minItems": 1},
    "approval_boundaries": {"type": "object", "additionalProperties": {"const": false}},
    "display_redaction_contract": {
      "type": "object",
      "required": [
        "redaction_required",
        "raw_payload_display_allowed",
        "private_reasoning_display_allowed",
        "secret_value_display_allowed",
        "forbidden_frontend_content"
      ],
      "properties": {
        "redaction_required": {"const": true},
        "raw_payload_display_allowed": {"const": false},
        "private_reasoning_display_allowed": {"const": false},
        "secret_value_display_allowed": {"const": false},
        "forbidden_frontend_content": {"type": "array", "items": {"type": "string"}, "minItems": 1}
      },
      "additionalProperties": true
    },
    "rollups": {"type": "object", "additionalProperties": true}
  },
  "$defs": {
    "dry_run_step": {
      "type": "object",
      "required": [
        "step_id",
        "display_name",
        "owner_agent",
        "status",
        "operator_signal",
        "blocked_runtime_action"
      ],
      "properties": {
        "step_id": {"type": "string"},
        "display_name": {"type": "string"},
        "owner_agent": {"type": "string"},
        "status": {"type": "string"},
        "operator_signal": {"type": "string"},
        "blocked_runtime_action": {"type": "string"}
      },
      "additionalProperties": true
    },
    "handoff_lane": {
      "type": "object",
      "required": [
        "lane_id",
        "display_name",
        "from_agent",
        "to_agent",
        "status",
        "required_evidence"
      ],
      "properties": {
        "lane_id": {"type": "string"},
        "display_name": {"type": "string"},
        "from_agent": {"type": "string"},
        "to_agent": {"type": "string"},
        "status": {"type": "string"},
        "required_evidence": {"type": "string"}
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
