{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://awoooi.wooo.work/schemas/ai_agent_matched_playbook_learning_gap_v1.schema.json",
  "title": "AI Agent Matched PlayBook Learning Gap v1",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_refs",
    "production_readback",
    "recent_status_breakdown",
    "learning_gap_truth",
    "gap_lanes",
    "learning_gates",
    "writeback_candidates",
    "display_redaction_contract",
    "rollups"
  ],
  "properties": {
    "schema_version": { "const": "ai_agent_matched_playbook_learning_gap_v1" },
    "generated_at": { "type": "string" },
    "program_status": {
      "type": "object",
      "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": { "enum": ["P0", "P1", "P2", "P3"] },
        "current_task_id": { "const": "P2-104" },
        "next_task_id": { "const": "P2-105" },
        "read_only_mode": { "const": true },
        "runtime_authority": { "const": "matched_playbook_learning_gap_contract_only_no_live_trust_write" },
        "status_note": { "type": "string" }
      },
      "additionalProperties": false
    },
    "source_refs": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
    "production_readback": {
      "type": "object",
      "required": [
        "readback_at",
        "readback_mode",
        "project_id_scope",
        "rls_fail_closed_verified",
        "approval_total",
        "approval_matched_total",
        "approval_24h_total",
        "approval_24h_matched",
        "matched_rate_24h_percent",
        "playbook_total",
        "playbook_with_execution_stats",
        "playbook_updated_24h",
        "readback_note"
      ],
      "properties": {
        "readback_at": { "type": "string" },
        "readback_mode": { "const": "read_only_db_readback" },
        "project_id_scope": { "const": "awoooi" },
        "rls_fail_closed_verified": { "const": true },
        "approval_total": { "type": "integer", "minimum": 0 },
        "approval_matched_total": { "type": "integer", "minimum": 0 },
        "approval_24h_total": { "type": "integer", "minimum": 0 },
        "approval_24h_matched": { "type": "integer", "minimum": 0 },
        "matched_rate_24h_percent": { "type": "integer", "minimum": 0, "maximum": 100 },
        "playbook_total": { "type": "integer", "minimum": 0 },
        "playbook_with_execution_stats": { "type": "integer", "minimum": 0 },
        "playbook_updated_24h": { "type": "integer", "minimum": 0 },
        "readback_note": { "type": "string" }
      },
      "additionalProperties": false
    },
    "recent_status_breakdown": {
      "type": "array",
      "minItems": 3,
      "items": {
        "type": "object",
        "required": [
          "status",
          "total",
          "matched",
          "execution_kind_present",
          "repair_attempted_true",
          "repair_executed_true",
          "learning_candidate_count",
          "readback_note"
        ],
        "properties": {
          "status": { "enum": ["APPROVED", "PENDING", "EXECUTION_FAILED"] },
          "total": { "type": "integer", "minimum": 0 },
          "matched": { "type": "integer", "minimum": 0 },
          "execution_kind_present": { "type": "integer", "minimum": 0 },
          "repair_attempted_true": { "type": "integer", "minimum": 0 },
          "repair_executed_true": { "type": "integer", "minimum": 0 },
          "learning_candidate_count": { "type": "integer", "minimum": 0 },
          "readback_note": { "type": "string" }
        },
        "additionalProperties": false
      }
    },
    "learning_gap_truth": {
      "type": "object",
      "required": [
        "p2_103_task_result_audit_loaded",
        "production_db_readback_completed",
        "rls_fail_closed_verified",
        "matched_playbook_id_present_24h",
        "matched_playbook_id_gap_resolved",
        "execution_learning_gap_detected",
        "approved_without_execution_meta_detected",
        "playbook_trust_update_gap_detected",
        "runtime_learning_write_enabled",
        "playbook_trust_write_enabled",
        "approval_auto_execute_enabled",
        "gateway_queue_write_enabled",
        "telegram_send_enabled",
        "production_write_enabled",
        "secret_value_read_enabled",
        "destructive_operation_enabled",
        "work_window_transcript_display_allowed",
        "approval_24h_total",
        "approval_24h_matched",
        "approved_without_execution_meta_24h",
        "pending_with_matched_24h",
        "execution_failed_with_matched_24h",
        "playbook_updated_24h",
        "live_learning_write_count_24h",
        "playbook_trust_write_count_24h",
        "gateway_queue_write_count_24h",
        "telegram_send_count_24h",
        "production_write_count_24h",
        "secret_value_read_count_24h",
        "destructive_operation_count_24h",
        "truth_note"
      ],
      "properties": {
        "p2_103_task_result_audit_loaded": { "const": true },
        "production_db_readback_completed": { "const": true },
        "rls_fail_closed_verified": { "const": true },
        "matched_playbook_id_present_24h": { "const": true },
        "matched_playbook_id_gap_resolved": { "const": true },
        "execution_learning_gap_detected": { "const": true },
        "approved_without_execution_meta_detected": { "const": true },
        "playbook_trust_update_gap_detected": { "const": true },
        "runtime_learning_write_enabled": { "const": false },
        "playbook_trust_write_enabled": { "const": false },
        "approval_auto_execute_enabled": { "const": false },
        "km_write_enabled": { "const": false },
        "logbook_runtime_write_enabled": { "const": false },
        "audit_db_write_enabled": { "const": false },
        "timeline_write_enabled": { "const": false },
        "gateway_queue_write_enabled": { "const": false },
        "telegram_send_enabled": { "const": false },
        "production_write_enabled": { "const": false },
        "secret_value_read_enabled": { "const": false },
        "destructive_operation_enabled": { "const": false },
        "work_window_transcript_display_allowed": { "const": false },
        "approval_24h_total": { "type": "integer", "minimum": 0 },
        "approval_24h_matched": { "type": "integer", "minimum": 0 },
        "approved_without_execution_meta_24h": { "type": "integer", "minimum": 0 },
        "pending_with_matched_24h": { "type": "integer", "minimum": 0 },
        "execution_failed_with_matched_24h": { "type": "integer", "minimum": 0 },
        "playbook_updated_24h": { "type": "integer", "minimum": 0 },
        "live_learning_write_count_24h": { "const": 0 },
        "playbook_trust_write_count_24h": { "const": 0 },
        "gateway_queue_write_count_24h": { "const": 0 },
        "telegram_send_count_24h": { "const": 0 },
        "production_write_count_24h": { "const": 0 },
        "secret_value_read_count_24h": { "const": 0 },
        "destructive_operation_count_24h": { "const": 0 },
        "truth_note": { "type": "string" }
      },
      "additionalProperties": false
    },
    "gap_lanes": {
      "type": "array",
      "minItems": 5,
      "items": {
        "type": "object",
        "required": [
          "lane_id",
          "display_name",
          "owner_agent",
          "status",
          "risk_tier",
          "count_24h",
          "matched_count_24h",
          "live_write_enabled",
          "evidence",
          "next_gate",
          "evidence_hash"
        ],
        "properties": {
          "lane_id": { "type": "string" },
          "display_name": { "type": "string" },
          "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
          "status": { "enum": ["passed", "blocked", "owner_review_required", "ready"] },
          "risk_tier": { "enum": ["low", "medium", "high", "critical"] },
          "count_24h": { "type": "integer", "minimum": 0 },
          "matched_count_24h": { "type": "integer", "minimum": 0 },
          "live_write_enabled": { "const": false },
          "evidence": { "type": "string" },
          "next_gate": { "type": "string" },
          "evidence_hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }
        },
        "additionalProperties": false
      }
    },
    "learning_gates": {
      "type": "array",
      "minItems": 5,
      "items": {
        "type": "object",
        "required": [
          "gate_id",
          "display_name",
          "owner_agent",
          "status",
          "required_before",
          "failure_if_missing",
          "creates_runtime_write"
        ],
        "properties": {
          "gate_id": { "type": "string" },
          "display_name": { "type": "string" },
          "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
          "status": { "enum": ["ready", "needs_owner_review", "blocked_by_policy"] },
          "required_before": { "type": "string" },
          "failure_if_missing": { "type": "string" },
          "creates_runtime_write": { "const": false }
        },
        "additionalProperties": false
      }
    },
    "writeback_candidates": {
      "type": "array",
      "minItems": 4,
      "items": {
        "type": "object",
        "required": [
          "candidate_id",
          "display_name",
          "owner_agent",
          "target_system",
          "allowed_mode",
          "write_enabled",
          "runtime_writer_enabled",
          "required_fields",
          "blocker_summary",
          "evidence_hash"
        ],
        "properties": {
          "candidate_id": { "type": "string" },
          "display_name": { "type": "string" },
          "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
          "target_system": { "type": "string" },
          "allowed_mode": { "enum": ["committed_snapshot_only", "gated_owner_review", "manual_append_plan"] },
          "write_enabled": { "const": false },
          "runtime_writer_enabled": { "const": false },
          "required_fields": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
          "blocker_summary": { "type": "string" },
          "evidence_hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" }
        },
        "additionalProperties": false
      }
    },
    "display_redaction_contract": {
      "type": "object",
      "required": [
        "redaction_required",
        "raw_prompt_display_allowed",
        "private_reasoning_display_allowed",
        "secret_value_display_allowed",
        "raw_telegram_payload_display_allowed",
        "work_window_transcript_display_allowed",
        "allowed_display_fields",
        "blocked_display_fields"
      ],
      "properties": {
        "redaction_required": { "const": true },
        "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 },
        "allowed_display_fields": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
        "blocked_display_fields": { "type": "array", "items": { "type": "string" }, "minItems": 1 }
      },
      "additionalProperties": false
    },
    "rollups": {
      "type": "object",
      "required": [
        "gap_lane_count",
        "passed_lane_count",
        "blocked_lane_count",
        "owner_review_lane_count",
        "approval_24h_total",
        "approval_24h_matched",
        "matched_rate_24h_percent",
        "approved_without_execution_meta_24h",
        "pending_with_matched_24h",
        "execution_failed_with_matched_24h",
        "playbook_with_execution_stats_count",
        "playbook_updated_24h_count",
        "learning_gate_count",
        "writeback_candidate_count",
        "live_learning_write_count",
        "playbook_trust_write_count",
        "gateway_queue_write_count",
        "telegram_send_count",
        "production_write_count",
        "secret_value_read_count",
        "destructive_operation_count"
      ],
      "additionalProperties": { "type": "integer" }
    }
  },
  "additionalProperties": false
}
