{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://awoooi.wooo.work/schemas/ai_agent_learning_writeback_approval_package_v1.schema.json",
  "title": "AI Agent Learning Writeback Approval Package",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "learning_truth",
    "writeback_package",
    "review_gates",
    "learning_lanes",
    "rollback_contract",
    "approval_boundaries",
    "display_redaction_contract",
    "rollups"
  ],
  "properties": {
    "schema_version": {
      "const": "ai_agent_learning_writeback_approval_package_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" },
        "current_priority": { "type": "string" },
        "current_task_id": { "const": "P2-403D" },
        "next_task_id": { "const": "P2-403E" },
        "read_only_mode": { "const": true },
        "runtime_authority": { "const": "approval_package_only_no_learning_writeback" },
        "status_note": { "type": "string" }
      },
      "additionalProperties": false
    },
    "learning_truth": {
      "type": "object",
      "properties": {
        "km_write_allowed": { "const": false },
        "playbook_trust_write_allowed": { "const": false },
        "timeline_learning_write_allowed": { "const": false },
        "agent_replay_score_write_allowed": { "const": false },
        "telegram_send_allowed": { "const": false },
        "runtime_worker_allowed": { "const": false },
        "live_learning_write_count": { "const": 0 },
        "live_playbook_trust_update_count": { "const": 0 },
        "live_km_update_count": { "const": 0 },
        "truth_note": { "type": "string" }
      },
      "additionalProperties": false
    },
    "writeback_package": {
      "type": "object",
      "required": [
        "required_fields",
        "forbidden_fields",
        "owner_review_required",
        "rollback_required"
      ],
      "properties": {
        "required_fields": { "type": "array", "items": { "type": "string" } },
        "forbidden_fields": { "type": "array", "items": { "type": "string" } },
        "owner_review_required": { "const": true },
        "rollback_required": { "const": true },
        "operator_meaning": { "type": "string" }
      },
      "additionalProperties": false
    },
    "review_gates": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["gate_id", "display_name", "owner_agent", "status", "required_evidence", "blocked_write_action"],
        "properties": {
          "gate_id": { "type": "string" },
          "display_name": { "type": "string" },
          "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
          "status": { "type": "string" },
          "required_evidence": { "type": "string" },
          "blocked_write_action": { "type": "string" }
        },
        "additionalProperties": false
      }
    },
    "learning_lanes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["lane_id", "display_name", "target_surface", "status", "owner_agent", "review_owner", "required_review"],
        "properties": {
          "lane_id": { "type": "string" },
          "display_name": { "type": "string" },
          "target_surface": { "type": "string" },
          "status": { "type": "string" },
          "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
          "review_owner": { "type": "string" },
          "required_review": { "type": "string" }
        },
        "additionalProperties": false
      }
    },
    "rollback_contract": {
      "type": "object",
      "required": ["rollback_required", "rollback_steps"],
      "properties": {
        "rollback_required": { "const": true },
        "rollback_steps": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    },
    "approval_boundaries": {
      "type": "object",
      "additionalProperties": { "const": false }
    },
    "display_redaction_contract": {
      "type": "object",
      "properties": {
        "redaction_required": { "const": true },
        "raw_payload_display_allowed": { "const": false },
        "private_reasoning_display_allowed": { "const": false },
        "secret_value_display_allowed": { "const": false },
        "allowed_frontend_content": { "type": "array", "items": { "type": "string" } },
        "forbidden_frontend_content": { "type": "array", "items": { "type": "string" } },
        "frontend_display_policy": { "type": "string" }
      },
      "additionalProperties": false
    },
    "rollups": {
      "type": "object",
      "required": [
        "review_gate_count",
        "learning_lane_count",
        "approval_required_gate_ids",
        "blocked_write_action_count",
        "required_field_count",
        "forbidden_field_count",
        "live_write_count_total"
      ],
      "properties": {
        "review_gate_count": { "type": "integer" },
        "learning_lane_count": { "type": "integer" },
        "approval_required_gate_ids": { "type": "array", "items": { "type": "string" } },
        "blocked_write_action_count": { "type": "integer" },
        "required_field_count": { "type": "integer" },
        "forbidden_field_count": { "type": "integer" },
        "live_write_count_total": { "const": 0 }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
