{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://awoooi.wooo.work/schemas/ai_agent_communication_learning_contract_v1.schema.json",
  "title": "AI Agent Communication Learning Contract v1",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "communication_plane",
    "agent_lanes",
    "mcp_stack",
    "rag_memory_stack",
    "learning_loops",
    "intelligence_services",
    "rollout_tasks",
    "approval_boundaries",
    "rollups"
  ],
  "properties": {
    "schema_version": {
      "const": "ai_agent_communication_learning_contract_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"
      ],
      "properties": {
        "overall_completion_percent": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "current_priority": {
          "type": "string"
        },
        "current_task_id": {
          "type": "string"
        },
        "next_task_id": {
          "type": "string"
        },
        "read_only_mode": {
          "const": true
        },
        "runtime_authority": {
          "const": "contract_only_no_runtime_worker"
        }
      },
      "additionalProperties": true
    },
    "communication_plane": {
      "type": "object",
      "required": [
        "message_bus",
        "stream_key_pattern",
        "session_table",
        "event_tables",
        "turn_types",
        "frontend_redaction"
      ],
      "properties": {
        "message_bus": {
          "const": "Redis Streams"
        },
        "stream_key_pattern": {
          "type": "string"
        },
        "session_table": {
          "type": "string"
        },
        "event_tables": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "turn_types": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 5
        },
        "frontend_redaction": {
          "type": "object",
          "required": [
            "operator_conversation_display_allowed",
            "agent_private_reasoning_display_allowed"
          ],
          "properties": {
            "operator_conversation_display_allowed": {
              "const": false
            },
            "agent_private_reasoning_display_allowed": {
              "const": false
            }
          },
          "additionalProperties": true
        }
      },
      "additionalProperties": true
    },
    "agent_lanes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/agent_lane"
      },
      "minItems": 3
    },
    "mcp_stack": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/capability"
      },
      "minItems": 1
    },
    "rag_memory_stack": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/capability"
      },
      "minItems": 3
    },
    "learning_loops": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/capability"
      },
      "minItems": 1
    },
    "intelligence_services": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/capability"
      },
      "minItems": 1
    },
    "rollout_tasks": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/rollout_task"
      },
      "minItems": 1
    },
    "approval_boundaries": {
      "type": "object",
      "required": [
        "runtime_worker_allowed",
        "db_migration_allowed",
        "telegram_direct_send_allowed",
        "paid_external_service_allowed",
        "secret_plaintext_allowed",
        "autonomous_host_mutation_allowed",
        "production_route_change_allowed",
        "sdk_installation_allowed"
      ],
      "properties": {
        "runtime_worker_allowed": {
          "const": false
        },
        "db_migration_allowed": {
          "const": false
        },
        "telegram_direct_send_allowed": {
          "const": false
        },
        "paid_external_service_allowed": {
          "const": false
        },
        "secret_plaintext_allowed": {
          "const": false
        },
        "autonomous_host_mutation_allowed": {
          "const": false
        },
        "production_route_change_allowed": {
          "const": false
        },
        "sdk_installation_allowed": {
          "const": false
        }
      },
      "additionalProperties": true
    },
    "rollups": {
      "type": "object",
      "required": [
        "agent_lane_count",
        "mcp_stack_count",
        "rag_layer_count",
        "learning_loop_count",
        "intelligence_service_count",
        "rollout_task_count",
        "blocked_task_ids",
        "optional_service_ids"
      ],
      "properties": {
        "agent_lane_count": {
          "type": "integer",
          "minimum": 0
        },
        "mcp_stack_count": {
          "type": "integer",
          "minimum": 0
        },
        "rag_layer_count": {
          "type": "integer",
          "minimum": 0
        },
        "learning_loop_count": {
          "type": "integer",
          "minimum": 0
        },
        "intelligence_service_count": {
          "type": "integer",
          "minimum": 0
        },
        "rollout_task_count": {
          "type": "integer",
          "minimum": 0
        },
        "blocked_task_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "optional_service_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    }
  },
  "$defs": {
    "agent_lane": {
      "type": "object",
      "required": [
        "agent_id",
        "display_name",
        "primary_role",
        "initiates",
        "responds_to",
        "writes_to",
        "blocked_actions"
      ],
      "properties": {
        "agent_id": {
          "type": "string"
        },
        "display_name": {
          "type": "string"
        },
        "primary_role": {
          "type": "string"
        },
        "initiates": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "responds_to": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "writes_to": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "blocked_actions": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        }
      },
      "additionalProperties": true
    },
    "capability": {
      "type": "object",
      "required": [
        "id",
        "display_name",
        "primary_owner",
        "purpose",
        "storage_or_service",
        "status",
        "approval_gate"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "display_name": {
          "type": "string"
        },
        "primary_owner": {
          "type": "string"
        },
        "purpose": {
          "type": "string"
        },
        "storage_or_service": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "approval_gate": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "rollout_task": {
      "type": "object",
      "required": [
        "task_id",
        "priority",
        "status",
        "completion_percent",
        "owner_agent",
        "summary",
        "next_gate"
      ],
      "properties": {
        "task_id": {
          "type": "string"
        },
        "priority": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "completion_percent": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "owner_agent": {
          "type": "string"
        },
        "summary": {
          "type": "string"
        },
        "next_gate": {
          "type": "string"
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
