{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "anu_v3_1_micro_refinement_result.schema.json",
  "title": "ANU v3.1 Micro Refinement Result",
  "description": "Result emitted by ANU-Codex micro refinement loop after rounds converge. Source: ANU v3 master spec section 5.6.",
  "type": "object",
  "required": [
    "schema",
    "task_id",
    "rounds",
    "final_verdict",
    "codex_final_verdict",
    "critical_7",
    "permission_expansion",
    "github_write_required",
    "dev_bot_reactivation_required",
    "changed_files",
    "remaining_findings",
    "round_history",
    "evidence_paths"
  ],
  "properties": {
    "schema": {"type": "string", "const": "anu_v3.micro_refinement_result.v1"},
    "task_id": {"type": "string", "pattern": "^task-[0-9A-Za-z_+.-]+$"},
    "rounds": {"type": "integer", "minimum": 0},
    "final_verdict": {"type": "string", "enum": ["GO_READY", "HOLD_FOR_CHAIR"]},
    "codex_final_verdict": {
      "type": "string",
      "enum": ["PASS", "PASS_WITH_RECOMMENDATIONS", "FAIL", "UNKNOWN"]
    },
    "critical_7": {"type": "boolean"},
    "permission_expansion": {"type": "boolean"},
    "github_write_required": {"type": "boolean"},
    "dev_bot_reactivation_required": {"type": "boolean"},
    "real_write_required": {"type": "boolean"},
    "forbidden_write_target_touched": {"type": "boolean"},
    "scope_expansion_detected": {"type": "boolean"},
    "security_high_or_critical": {"type": "boolean"},
    "changed_files": {
      "type": "array",
      "items": {"type": "string"}
    },
    "remaining_findings": {
      "type": "array",
      "items": {"type": "object"}
    },
    "round_history": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["round", "codex_verdict", "actions", "safety_gates_triggered"],
        "properties": {
          "round": {"type": "integer", "minimum": 1},
          "codex_verdict": {"type": "string"},
          "actions": {"type": "array", "items": {"type": "string"}},
          "safety_gates_triggered": {"type": "array", "items": {"type": "string"}}
        }
      }
    },
    "evidence_paths": {
      "type": "array",
      "items": {"type": "string"}
    },
    "go_ready_packet_path": {"type": ["string", "null"]},
    "hold_packet_path": {"type": ["string", "null"]}
  },
  "additionalProperties": false
}
