{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "PersonaDef": {
      "type": "object",
      "properties": {
        "role": {
          "type": "string"
        },
        "mandate": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "checklist": {
          "type": "object",
          "patternProperties": {
            "^.*$": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ]
            }
          }
        }
      },
      "required": [
        "role",
        "mandate",
        "checklist"
      ]
    },
    "ChecklistObject": {
      "type": "object",
      "description": "A map of boolean flags representing checklist items.",
      "patternProperties": {
        "^.*$": {
          "type": "boolean"
        }
      }
    },
    "EnvironmentDef": {
      "type": "object",
      "properties": {
        "vcs": {
          "type": "string",
          "enum": [
            "GIT",
            "JJ"
          ]
        },
        "harness": {
          "type": "string",
          "enum": [
            "JETSKI",
            "GENERIC_CLI"
          ]
        },
        "orchestration_pattern": {
          "type": "string",
          "enum": [
            "CENTRALIZED",
            "DECENTRALIZED"
          ],
          "description": "CENTRALIZED for Simulated MAS (JetSki), DECENTRALIZED for True MAS (Gemini CLI)."
        },
        "use_reclient": {
          "type": "boolean",
          "description": "True if reclient (remote execution) is configured for builds."
        },
        "is_debug_build": {
          "type": "boolean",
          "description": "True if the build configuration is for Debug, False for Release."
        },
        "repo_type": {
          "type": "string",
          "enum": [
            "CHROMIUM",
            "GOOGLE_INTERNAL"
          ]
        },
        "output_directory": {
          "type": "string"
        },
        "temp_directory": {
          "type": "string",
          "description": "The relative path (recommended for workspace isolation) or absolute path to a directory where interim files are stored."
        }
      },
      "required": [
        "vcs",
        "harness",
        "temp_directory"
      ]
    },
    "StateBlock": {
      "type": "object",
      "properties": {
        "checklist": {
          "$ref": "#/definitions/ChecklistObject"
        },
        "unlisted_issues_found": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "iteration": {
          "type": "integer"
        },
        "oscillation_detected": {
          "type": "boolean"
        },
        "conflict_report": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "active_constraints": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "resolved_constraints": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "next_stage": {
          "type": "string",
          "enum": [
            "CRITIQUE",
            "SCAFFOLDING",
            "PREPARATION",
            "IMPLEMENTATION",
            "SYNTHESIS",
            "TEST_FILLING",
            "TRAINING",
            "ESCALATION",
            "VALIDATION",
            "DEPLOYMENT"
          ]
        },
        "state_transport": {
          "type": "string",
          "enum": [
            "FILE_IO",
            "EPHEMERAL_WITH_LOGS"
          ]
        }
      },
      "required": [
        "checklist",
        "iteration",
        "oscillation_detected",
        "active_constraints",
        "resolved_constraints",
        "state_transport",
        "next_stage"
      ]
    },
    "RefactoringMeta": {
      "type": "object",
      "properties": {
        "original_commit": {
          "type": "string"
        },
        "file_mappings": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "original_file": {
                "type": "string"
              },
              "new_files": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "original_file",
              "new_files"
            ]
          }
        }
      },
      "required": [
        "original_commit",
        "file_mappings"
      ]
    },
    "ProjectSpec": {
      "type": "object",
      "properties": {
        "task_type": {
          "type": "string",
          "enum": [
            "IMPLEMENTATION",
            "REVIEW",
            "AUDIT",
            "REFACTORING"
          ]
        },
        "execution_path": {
          "type": "string",
          "enum": [
            "FAST_PATH",
            "RIGOR_PATH"
          ]
        },
        "complexity_level": {
          "type": "string",
          "enum": [
            "LOW",
            "MEDIUM",
            "HIGH"
          ]
        },
        "unlisted_issues_found": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "goal": {
          "type": "string"
        },
        "target_files": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "anti_goals": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "edge_cases": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "build_targets": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "context_resolved": {
          "type": "boolean",
          "description": "True only if all external bugs/links were successfully read and no hallucinations occurred."
        },
        "approach_confirmed": {
          "type": "boolean",
          "description": "True only if the human has explicitly approved the goal and target files."
        },
        "ambiguity_level": {
          "type": "string",
          "enum": [
            "LOW",
            "HIGH"
          ],
          "description": "Assessment of how prescriptive the human instructions were versus how much discovery/decision-making is required."
        },
        "environment": {
          "$ref": "#/definitions/EnvironmentDef"
        },
        "refactoring_meta": {
          "$ref": "#/definitions/RefactoringMeta"
        },
        "routing_overlay": {
          "type": "string",
          "description": "Optional path to an internal routing overlay file (e.g., in google3) to merge with ROUTING.md."
        },
        "active_protocol": {
          "type": "string",
          "enum": [
            "WORKFLOW",
            "TDD",
            "REVIEW"
          ],
          "description": "Identifies the active protocol for tagging and tracking."
        }
      },
      "required": [
        "task_type",
        "execution_path",
        "complexity_level",
        "goal",
        "target_files",
        "context_resolved",
        "approach_confirmed",
        "ambiguity_level",
        "environment",
        "active_protocol"
      ]
    },
    "ReviewFeedback": {
      "type": "object",
      "properties": {
        "checklist": {
          "$ref": "#/definitions/ChecklistObject"
        },
        "unlisted_issues_found": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "verdict": {
          "type": "string",
          "enum": [
            "ACCEPT",
            "REJECT"
          ]
        },
        "reasoning": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "comments": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "file": {
                "type": "string"
              },
              "line": {
                "type": "integer"
              },
              "comment": {
                "type": "string"
              }
            },
            "required": [
              "file",
              "comment"
            ]
          }
        }
      },
      "required": [
        "checklist",
        "verdict",
        "reasoning"
      ]
    },
    "Constraints": {
      "type": "object",
      "properties": {
        "checklist": {
          "$ref": "#/definitions/ChecklistObject"
        },
        "unlisted_issues_found": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "iteration": {
          "type": "integer"
        },
        "oscillation_detected": {
          "type": "boolean"
        },
        "conflict_report": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "constraints": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "next_stage": {
          "type": "string",
          "enum": [
            "SYNTHESIS",
            "VALIDATION",
            "ESCALATION"
          ]
        }
      },
      "required": [
        "checklist",
        "iteration",
        "oscillation_detected",
        "constraints",
        "next_stage"
      ]
    }
  }
}
