{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://awoooi.wooo.work/schemas/ai_agent_runtime_readback_approval_package_v1.schema.json",
  "title": "AI Agent Runtime Readback Approval Package v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_refs",
    "prior_readback_readiness",
    "approval_package_truth",
    "approval_packet_templates",
    "canonical_readback_plans",
    "rollback_drill_lanes",
    "telegram_failure_receipt_gates",
    "operator_actions",
    "display_redaction_contract",
    "rollups"
  ],
  "properties": {
    "schema_version": {
      "const": "ai_agent_runtime_readback_approval_package_v1"
    },
    "generated_at": {
      "type": "string"
    },
    "program_status": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "overall_completion_percent",
        "current_priority",
        "current_task_id",
        "next_task_id",
        "read_only_mode",
        "runtime_authority",
        "status_note"
      ],
      "properties": {
        "overall_completion_percent": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "current_priority": {
          "const": "P2"
        },
        "current_task_id": {
          "const": "P2-109"
        },
        "next_task_id": {
          "const": "P2-110"
        },
        "read_only_mode": {
          "const": true
        },
        "runtime_authority": {
          "const": "runtime_readback_approval_package_only_no_live_write"
        },
        "status_note": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "source_refs": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "prior_readback_readiness": {
      "$ref": "#/$defs/prior_readback_readiness"
    },
    "approval_package_truth": {
      "$ref": "#/$defs/approval_package_truth"
    },
    "approval_packet_templates": {
      "type": "array",
      "minItems": 5,
      "items": {
        "$ref": "#/$defs/approval_packet"
      }
    },
    "canonical_readback_plans": {
      "type": "array",
      "minItems": 4,
      "items": {
        "$ref": "#/$defs/canonical_readback_plan"
      }
    },
    "rollback_drill_lanes": {
      "type": "array",
      "minItems": 4,
      "items": {
        "$ref": "#/$defs/rollback_drill_lane"
      }
    },
    "telegram_failure_receipt_gates": {
      "type": "array",
      "minItems": 4,
      "items": {
        "$ref": "#/$defs/telegram_failure_receipt_gate"
      }
    },
    "operator_actions": {
      "type": "array",
      "minItems": 5,
      "items": {
        "$ref": "#/$defs/operator_action"
      }
    },
    "display_redaction_contract": {
      "$ref": "#/$defs/display_redaction_contract"
    },
    "rollups": {
      "$ref": "#/$defs/rollups"
    }
  },
  "$defs": {
    "string_array": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "redacted_sha256": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "prior_readback_readiness": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "source_schema_version",
        "readback_at",
        "readback_digest_count",
        "promotion_review_count",
        "failure_lane_count",
        "reviewer_queue_preview_count",
        "operator_action_count",
        "approval_required_digest_count",
        "blocked_total_count",
        "approved_without_execution_meta_24h",
        "execution_failed_with_matched_24h",
        "owner_approval_received_count",
        "readback_digest_generated_count",
        "promotion_approved_count",
        "reviewer_queue_write_count",
        "result_capture_write_count",
        "score_write_count",
        "learning_write_count",
        "playbook_trust_write_count",
        "gateway_queue_write_count",
        "telegram_send_count",
        "production_write_count",
        "readiness_note"
      ],
      "properties": {
        "source_schema_version": {
          "const": "ai_agent_owner_approved_result_capture_readback_v1"
        },
        "readback_at": {
          "type": "string"
        },
        "readback_digest_count": {
          "const": 5
        },
        "promotion_review_count": {
          "const": 5
        },
        "failure_lane_count": {
          "const": 4
        },
        "reviewer_queue_preview_count": {
          "const": 4
        },
        "operator_action_count": {
          "const": 5
        },
        "approval_required_digest_count": {
          "const": 2
        },
        "blocked_total_count": {
          "const": 7
        },
        "approved_without_execution_meta_24h": {
          "type": "integer",
          "minimum": 0
        },
        "execution_failed_with_matched_24h": {
          "type": "integer",
          "minimum": 0
        },
        "owner_approval_received_count": {
          "const": 0
        },
        "readback_digest_generated_count": {
          "const": 0
        },
        "promotion_approved_count": {
          "const": 0
        },
        "reviewer_queue_write_count": {
          "const": 0
        },
        "result_capture_write_count": {
          "const": 0
        },
        "score_write_count": {
          "const": 0
        },
        "learning_write_count": {
          "const": 0
        },
        "playbook_trust_write_count": {
          "const": 0
        },
        "gateway_queue_write_count": {
          "const": 0
        },
        "telegram_send_count": {
          "const": 0
        },
        "production_write_count": {
          "const": 0
        },
        "readiness_note": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "approval_package_truth": {
      "type": "object",
      "required": [
        "p2_107_readback_loaded",
        "approval_package_ready",
        "canonical_readback_plan_ready",
        "rollback_drill_ready",
        "telegram_failure_receipt_gate_ready",
        "owner_review_required_before_runtime",
        "canonical_runtime_readback_enabled",
        "runtime_result_capture_write_enabled",
        "runtime_score_write_enabled",
        "runtime_learning_write_enabled",
        "playbook_trust_write_enabled",
        "reviewer_queue_write_enabled",
        "gateway_queue_write_enabled",
        "telegram_failure_receipt_send_enabled",
        "bot_api_call_enabled",
        "rollback_work_item_write_enabled",
        "production_write_enabled",
        "secret_read_enabled",
        "destructive_operation_enabled"
      ],
      "properties": {
        "p2_107_readback_loaded": {
          "const": true
        },
        "approval_package_ready": {
          "const": true
        },
        "canonical_readback_plan_ready": {
          "const": true
        },
        "rollback_drill_ready": {
          "const": true
        },
        "telegram_failure_receipt_gate_ready": {
          "const": true
        },
        "owner_review_required_before_runtime": {
          "const": true
        },
        "canonical_runtime_readback_enabled": {
          "const": false
        },
        "runtime_result_capture_write_enabled": {
          "const": false
        },
        "runtime_score_write_enabled": {
          "const": false
        },
        "runtime_learning_write_enabled": {
          "const": false
        },
        "playbook_trust_write_enabled": {
          "const": false
        },
        "reviewer_queue_write_enabled": {
          "const": false
        },
        "gateway_queue_write_enabled": {
          "const": false
        },
        "telegram_failure_receipt_send_enabled": {
          "const": false
        },
        "bot_api_call_enabled": {
          "const": false
        },
        "rollback_work_item_write_enabled": {
          "const": false
        },
        "production_write_enabled": {
          "const": false
        },
        "secret_read_enabled": {
          "const": false
        },
        "destructive_operation_enabled": {
          "const": false
        }
      },
      "additionalProperties": true
    },
    "approval_packet": {
      "type": "object",
      "required": [
        "packet_id",
        "display_name",
        "owner_agent",
        "status",
        "risk_tier",
        "required_approval_fields",
        "blocked_runtime_actions",
        "operator_guidance",
        "approval_required",
        "runtime_write_allowed",
        "evidence_hash"
      ],
      "properties": {
        "packet_id": {
          "type": "string"
        },
        "display_name": {
          "type": "string"
        },
        "owner_agent": {
          "enum": [
            "openclaw",
            "hermes",
            "nemotron"
          ]
        },
        "status": {
          "enum": [
            "ready_for_owner_review",
            "approval_required",
            "blocked_by_policy"
          ]
        },
        "risk_tier": {
          "enum": [
            "medium",
            "high",
            "critical"
          ]
        },
        "required_approval_fields": {
          "$ref": "#/$defs/string_array"
        },
        "blocked_runtime_actions": {
          "$ref": "#/$defs/string_array"
        },
        "operator_guidance": {
          "type": "string"
        },
        "approval_required": {
          "const": true
        },
        "runtime_write_allowed": {
          "const": false
        },
        "evidence_hash": {
          "$ref": "#/$defs/redacted_sha256"
        }
      },
      "additionalProperties": false
    },
    "canonical_readback_plan": {
      "type": "object",
      "required": [
        "plan_id",
        "display_name",
        "owner_agent",
        "status",
        "query_scope",
        "required_fields",
        "redaction_checks",
        "live_query_enabled",
        "runtime_write_allowed",
        "evidence_hash"
      ],
      "properties": {
        "plan_id": {
          "type": "string"
        },
        "display_name": {
          "type": "string"
        },
        "owner_agent": {
          "enum": [
            "openclaw",
            "hermes",
            "nemotron"
          ]
        },
        "status": {
          "enum": [
            "planned_no_runtime_read",
            "blocked_by_policy"
          ]
        },
        "query_scope": {
          "type": "string"
        },
        "required_fields": {
          "$ref": "#/$defs/string_array"
        },
        "redaction_checks": {
          "$ref": "#/$defs/string_array"
        },
        "live_query_enabled": {
          "const": false
        },
        "runtime_write_allowed": {
          "const": false
        },
        "evidence_hash": {
          "$ref": "#/$defs/redacted_sha256"
        }
      },
      "additionalProperties": false
    },
    "rollback_drill_lane": {
      "type": "object",
      "required": [
        "lane_id",
        "display_name",
        "owner_agent",
        "status",
        "rollback_owner",
        "required_steps",
        "failure_if_missing",
        "rollback_write_enabled",
        "creates_runtime_write"
      ],
      "properties": {
        "lane_id": {
          "type": "string"
        },
        "display_name": {
          "type": "string"
        },
        "owner_agent": {
          "enum": [
            "openclaw",
            "hermes",
            "nemotron"
          ]
        },
        "status": {
          "enum": [
            "planned_no_write",
            "blocked_by_policy"
          ]
        },
        "rollback_owner": {
          "type": "string"
        },
        "required_steps": {
          "$ref": "#/$defs/string_array"
        },
        "failure_if_missing": {
          "type": "string"
        },
        "rollback_write_enabled": {
          "const": false
        },
        "creates_runtime_write": {
          "const": false
        }
      },
      "additionalProperties": false
    },
    "telegram_failure_receipt_gate": {
      "type": "object",
      "required": [
        "gate_id",
        "display_name",
        "owner_agent",
        "status",
        "required_evidence",
        "failure_if_missing",
        "queue_write_enabled",
        "telegram_send_enabled",
        "bot_api_call_enabled",
        "evidence_hash"
      ],
      "properties": {
        "gate_id": {
          "type": "string"
        },
        "display_name": {
          "type": "string"
        },
        "owner_agent": {
          "enum": [
            "openclaw",
            "hermes",
            "nemotron"
          ]
        },
        "status": {
          "enum": [
            "ready_for_owner_review",
            "blocked_by_policy"
          ]
        },
        "required_evidence": {
          "$ref": "#/$defs/string_array"
        },
        "failure_if_missing": {
          "type": "string"
        },
        "queue_write_enabled": {
          "const": false
        },
        "telegram_send_enabled": {
          "const": false
        },
        "bot_api_call_enabled": {
          "const": false
        },
        "evidence_hash": {
          "$ref": "#/$defs/redacted_sha256"
        }
      },
      "additionalProperties": false
    },
    "operator_action": {
      "type": "object",
      "required": [
        "action_id",
        "action_type",
        "display_name",
        "owner_agent",
        "operator_instruction",
        "runtime_write_allowed"
      ],
      "properties": {
        "action_id": {
          "type": "string"
        },
        "action_type": {
          "enum": [
            "review_approval_package",
            "validate_canonical_plan",
            "review_rollback_drill",
            "review_failure_receipt_gate",
            "reject_or_promote"
          ]
        },
        "display_name": {
          "type": "string"
        },
        "owner_agent": {
          "enum": [
            "openclaw",
            "hermes",
            "nemotron"
          ]
        },
        "operator_instruction": {
          "type": "string"
        },
        "runtime_write_allowed": {
          "const": false
        }
      },
      "additionalProperties": false
    },
    "display_redaction_contract": {
      "type": "object",
      "required": [
        "redaction_required",
        "frontend_display_policy",
        "raw_prompt_display_allowed",
        "private_reasoning_display_allowed",
        "secret_value_display_allowed",
        "raw_telegram_payload_display_allowed",
        "work_window_transcript_display_allowed"
      ],
      "properties": {
        "redaction_required": {
          "const": true
        },
        "frontend_display_policy": {
          "type": "string"
        },
        "raw_prompt_display_allowed": {
          "const": false
        },
        "private_reasoning_display_allowed": {
          "const": false
        },
        "secret_value_display_allowed": {
          "const": false
        },
        "raw_telegram_payload_display_allowed": {
          "const": false
        },
        "work_window_transcript_display_allowed": {
          "const": false
        }
      },
      "additionalProperties": false
    },
    "rollups": {
      "type": "object",
      "required": [
        "approval_packet_count",
        "canonical_readback_plan_count",
        "rollback_drill_lane_count",
        "telegram_failure_receipt_gate_count",
        "operator_action_count",
        "approval_required_packet_count",
        "blocked_packet_count",
        "blocked_readback_plan_count",
        "blocked_rollback_lane_count",
        "blocked_telegram_gate_count",
        "owner_approval_received_count",
        "runtime_readback_execution_count",
        "result_capture_write_count",
        "score_write_count",
        "learning_write_count",
        "playbook_trust_write_count",
        "reviewer_queue_write_count",
        "gateway_queue_write_count",
        "telegram_failure_receipt_send_count",
        "bot_api_call_count",
        "rollback_work_item_write_count",
        "production_write_count",
        "secret_read_count",
        "destructive_operation_count"
      ],
      "properties": {
        "approval_packet_count": {
          "const": 5
        },
        "canonical_readback_plan_count": {
          "const": 4
        },
        "rollback_drill_lane_count": {
          "const": 4
        },
        "telegram_failure_receipt_gate_count": {
          "const": 4
        },
        "operator_action_count": {
          "const": 5
        },
        "approval_required_packet_count": {
          "type": "integer",
          "minimum": 0
        },
        "blocked_packet_count": {
          "type": "integer",
          "minimum": 0
        },
        "blocked_readback_plan_count": {
          "type": "integer",
          "minimum": 0
        },
        "blocked_rollback_lane_count": {
          "type": "integer",
          "minimum": 0
        },
        "blocked_telegram_gate_count": {
          "type": "integer",
          "minimum": 0
        },
        "approved_without_execution_meta_24h": {
          "type": "integer",
          "minimum": 0
        },
        "execution_failed_with_matched_24h": {
          "type": "integer",
          "minimum": 0
        },
        "owner_approval_received_count": {
          "const": 0
        },
        "runtime_readback_execution_count": {
          "const": 0
        },
        "result_capture_write_count": {
          "const": 0
        },
        "score_write_count": {
          "const": 0
        },
        "learning_write_count": {
          "const": 0
        },
        "playbook_trust_write_count": {
          "const": 0
        },
        "reviewer_queue_write_count": {
          "const": 0
        },
        "gateway_queue_write_count": {
          "const": 0
        },
        "telegram_failure_receipt_send_count": {
          "const": 0
        },
        "bot_api_call_count": {
          "const": 0
        },
        "rollback_work_item_write_count": {
          "const": 0
        },
        "production_write_count": {
          "const": 0
        },
        "secret_read_count": {
          "const": 0
        },
        "destructive_operation_count": {
          "const": 0
        }
      },
      "additionalProperties": false
    }
  }
}
