{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://awoooi.wooo.work/schemas/ai_agent_gitea_pr_draft_lane_v1.schema.json",
  "title": "AI Agent Gitea PR Draft Lane v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_refs",
    "lane_intent",
    "branch_strategy",
    "grouping_rules",
    "lane_steps",
    "required_checks",
    "owner_response_requirements",
    "rollback_requirements",
    "draft_templates",
    "agent_roles",
    "display_redaction_contract",
    "operation_boundaries",
    "approval_boundaries",
    "rollups"
  ],
  "properties": {
    "schema_version": {
      "const": "ai_agent_gitea_pr_draft_lane_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": "draft_lane_only_no_pr_creation_or_branch_push"
        },
        "status_note": {
          "type": "string"
        }
      }
    },
    "source_refs": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "lane_intent": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "purpose",
        "non_goals",
        "human_approval_gate"
      ],
      "properties": {
        "purpose": {
          "type": "string"
        },
        "non_goals": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "human_approval_gate": {
          "type": "string"
        }
      }
    },
    "branch_strategy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "draft_branch_prefix",
        "branch_name_pattern",
        "branch_push_allowed",
        "pr_creation_allowed",
        "automerge",
        "required_prefix_after_approval"
      ],
      "properties": {
        "draft_branch_prefix": {
          "type": "string"
        },
        "branch_name_pattern": {
          "type": "string"
        },
        "branch_push_allowed": {
          "const": false
        },
        "pr_creation_allowed": {
          "const": false
        },
        "automerge": {
          "const": false
        },
        "required_prefix_after_approval": {
          "type": "string"
        }
      }
    },
    "grouping_rules": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "group_id",
          "display_name",
          "owner_agent",
          "risk_tier",
          "max_batch_size",
          "draft_only",
          "automerge",
          "requires_openclaw_review",
          "rollback_required",
          "required_check_ids",
          "allowed_change_kinds",
          "blocked_change_kinds"
        ],
        "properties": {
          "group_id": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "owner_agent": {
            "type": "string"
          },
          "risk_tier": {
            "type": "string"
          },
          "max_batch_size": {
            "type": "integer",
            "minimum": 1
          },
          "draft_only": {
            "const": true
          },
          "automerge": {
            "const": false
          },
          "requires_openclaw_review": {
            "const": true
          },
          "rollback_required": {
            "const": true
          },
          "required_check_ids": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            }
          },
          "allowed_change_kinds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "blocked_change_kinds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "lane_steps": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "step_id",
          "owner_agent",
          "purpose",
          "planned_output",
          "runtime_execution_allowed",
          "repo_write_allowed",
          "approval_gate"
        ],
        "properties": {
          "step_id": {
            "type": "string"
          },
          "owner_agent": {
            "type": "string"
          },
          "purpose": {
            "type": "string"
          },
          "planned_output": {
            "type": "string"
          },
          "runtime_execution_allowed": {
            "const": false
          },
          "repo_write_allowed": {
            "const": false
          },
          "approval_gate": {
            "type": "string"
          }
        }
      }
    },
    "required_checks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "check_id",
          "display_name",
          "owner_agent",
          "blocking",
          "evidence_required",
          "run_now_allowed",
          "planned_command_or_evidence"
        ],
        "properties": {
          "check_id": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "owner_agent": {
            "type": "string"
          },
          "blocking": {
            "const": true
          },
          "evidence_required": {
            "const": true
          },
          "run_now_allowed": {
            "const": false
          },
          "planned_command_or_evidence": {
            "type": "string"
          }
        }
      }
    },
    "owner_response_requirements": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "requirement_id",
          "owner_agent",
          "required_fields",
          "required_before_pr_creation"
        ],
        "properties": {
          "requirement_id": {
            "type": "string"
          },
          "owner_agent": {
            "type": "string"
          },
          "required_fields": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            }
          },
          "required_before_pr_creation": {
            "const": true
          }
        }
      }
    },
    "rollback_requirements": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "requirement_id",
          "description",
          "required",
          "must_be_attached_before_pr_creation"
        ],
        "properties": {
          "requirement_id": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "required": {
            "const": true
          },
          "must_be_attached_before_pr_creation": {
            "const": true
          }
        }
      }
    },
    "draft_templates": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "template_id",
          "display_name",
          "applies_to_group_ids",
          "required_sections",
          "forbidden_fields",
          "automerge",
          "branch_push_allowed"
        ],
        "properties": {
          "template_id": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "applies_to_group_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "required_sections": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "forbidden_fields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "automerge": {
            "const": false
          },
          "branch_push_allowed": {
            "const": false
          }
        }
      }
    },
    "agent_roles": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "display_redaction_contract": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "conversation_transcript_display_allowed",
        "redaction_required",
        "allowed_frontend_fields",
        "forbidden_frontend_content"
      ],
      "properties": {
        "conversation_transcript_display_allowed": {
          "const": false
        },
        "redaction_required": {
          "const": true
        },
        "allowed_frontend_fields": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "forbidden_frontend_content": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "operation_boundaries": {
      "type": "object"
    },
    "approval_boundaries": {
      "type": "object"
    },
    "rollups": {
      "type": "object"
    }
  }
}
