{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://awoooi.wooo.work/schemas/ai_agent_tool_adoption_approval_package_v1.schema.json",
  "title": "AI Agent Tool Adoption Approval Package v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_evidence",
    "agent_review_matrix",
    "adoption_lanes",
    "tool_candidates",
    "approval_packet_fields",
    "approval_boundaries",
    "rollups"
  ],
  "properties": {
    "schema_version": {
      "const": "ai_agent_tool_adoption_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": {
          "type": "string"
        },
        "current_task_id": {
          "type": "string"
        },
        "next_task_id": {
          "type": "string"
        },
        "read_only_mode": {
          "const": true
        },
        "runtime_authority": {
          "const": "approval_package_only_no_tool_install_or_ci_change"
        },
        "status_note": {
          "type": "string"
        }
      }
    },
    "source_evidence": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source_id",
          "tool_id",
          "name",
          "url",
          "retrieved_at",
          "evidence_type",
          "usage_boundary"
        ],
        "properties": {
          "source_id": {
            "type": "string"
          },
          "tool_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "retrieved_at": {
            "type": "string"
          },
          "evidence_type": {
            "type": "string"
          },
          "usage_boundary": {
            "type": "string"
          }
        }
      }
    },
    "agent_review_matrix": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "agent_id",
          "role",
          "allowed_now",
          "blocked_until_approval",
          "output"
        ],
        "properties": {
          "agent_id": {
            "type": "string"
          },
          "role": {
            "type": "string"
          },
          "allowed_now": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "blocked_until_approval": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "output": {
            "type": "string"
          }
        }
      }
    },
    "adoption_lanes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "lane_id",
          "display_name",
          "owner_agent",
          "tool_ids",
          "approval_gate",
          "planned_output",
          "blocked_now"
        ],
        "properties": {
          "lane_id": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "owner_agent": {
            "type": "string"
          },
          "tool_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "approval_gate": {
            "type": "string"
          },
          "planned_output": {
            "type": "string"
          },
          "blocked_now": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "tool_candidates": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "tool_id",
          "display_name",
          "category",
          "owner_agent",
          "adoption_status",
          "risk_tier",
          "cost_profile",
          "secret_requirement",
          "external_data_requirement",
          "ci_change_required",
          "official_source_refs",
          "intended_scope",
          "approval_requirements",
          "blocked_until_approval",
          "recommendation",
          "rollback_plan"
        ],
        "properties": {
          "tool_id": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "owner_agent": {
            "type": "string"
          },
          "adoption_status": {
            "enum": [
              "approval_required",
              "defer_until_gate",
              "rejected"
            ]
          },
          "risk_tier": {
            "enum": [
              "low",
              "medium",
              "high"
            ]
          },
          "cost_profile": {
            "type": "string"
          },
          "secret_requirement": {
            "type": "string"
          },
          "external_data_requirement": {
            "type": "string"
          },
          "ci_change_required": {
            "type": "boolean"
          },
          "official_source_refs": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            }
          },
          "intended_scope": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "approval_requirements": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            }
          },
          "blocked_until_approval": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "recommendation": {
            "type": "string"
          },
          "rollback_plan": {
            "type": "string"
          }
        }
      }
    },
    "approval_packet_fields": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "field_id",
          "required",
          "owner_agent",
          "description"
        ],
        "properties": {
          "field_id": {
            "type": "string"
          },
          "required": {
            "type": "boolean"
          },
          "owner_agent": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        }
      }
    },
    "approval_boundaries": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "tool_install_allowed",
        "ci_workflow_change_allowed",
        "external_registry_lookup_allowed",
        "vulnerability_database_download_allowed",
        "package_upgrade_allowed",
        "lockfile_write_allowed",
        "docker_build_allowed",
        "image_pull_allowed",
        "gitea_pr_creation_allowed",
        "auto_merge_allowed",
        "telegram_direct_send_allowed",
        "paid_service_enabled",
        "production_route_change_allowed",
        "secret_plaintext_allowed"
      ],
      "properties": {
        "tool_install_allowed": {
          "const": false
        },
        "ci_workflow_change_allowed": {
          "const": false
        },
        "external_registry_lookup_allowed": {
          "const": false
        },
        "vulnerability_database_download_allowed": {
          "const": false
        },
        "package_upgrade_allowed": {
          "const": false
        },
        "lockfile_write_allowed": {
          "const": false
        },
        "docker_build_allowed": {
          "const": false
        },
        "image_pull_allowed": {
          "const": false
        },
        "gitea_pr_creation_allowed": {
          "const": false
        },
        "auto_merge_allowed": {
          "const": false
        },
        "telegram_direct_send_allowed": {
          "const": false
        },
        "paid_service_enabled": {
          "const": false
        },
        "production_route_change_allowed": {
          "const": false
        },
        "secret_plaintext_allowed": {
          "const": false
        }
      }
    },
    "rollups": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "tool_count",
        "source_evidence_count",
        "adoption_lane_count",
        "approval_required_tool_ids",
        "ci_change_required_tool_ids",
        "secret_required_tool_ids",
        "external_data_required_tool_ids",
        "sbom_tool_ids",
        "vulnerability_scan_tool_ids",
        "update_pr_tool_ids",
        "tool_install_allowed_count",
        "ci_change_allowed_count",
        "auto_merge_allowed_count",
        "telegram_direct_send_count",
        "next_approval_task_ids"
      ],
      "properties": {
        "tool_count": {
          "type": "integer",
          "minimum": 0
        },
        "source_evidence_count": {
          "type": "integer",
          "minimum": 0
        },
        "adoption_lane_count": {
          "type": "integer",
          "minimum": 0
        },
        "approval_required_tool_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "ci_change_required_tool_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "secret_required_tool_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "external_data_required_tool_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "sbom_tool_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "vulnerability_scan_tool_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "update_pr_tool_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "tool_install_allowed_count": {
          "const": 0
        },
        "ci_change_allowed_count": {
          "const": 0
        },
        "auto_merge_allowed_count": {
          "const": 0
        },
        "telegram_direct_send_count": {
          "const": 0
        },
        "next_approval_task_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}
