{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:agent-nemotron-replay-failure-analysis-v1",
  "title": "AWOOOI NeMo/Nemotron Replay Failure Analysis (v1)",
  "type": "object",
  "required": [
    "schema_version",
    "candidate_id",
    "generated_at",
    "decision",
    "not_replacement_evidence",
    "model",
    "source_reports",
    "sample",
    "external_runner",
    "external_result_aggregate",
    "scorecard_delta",
    "promotion_gate",
    "primary_failure_modes",
    "candidate_variant_plan",
    "next_wave_recommendation"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "agent_nemotron_replay_failure_analysis_v1"
    },
    "candidate_id": {
      "type": "string",
      "const": "nemo_nemotron_fabric"
    },
    "generated_at": {
      "type": "string",
      "minLength": 1
    },
    "decision": {
      "type": "string",
      "enum": ["approved", "blocked"]
    },
    "not_replacement_evidence": {
      "type": "boolean",
      "const": true
    },
    "model": {
      "type": "string"
    },
    "source_reports": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "sample": {
      "type": "object",
      "required": ["requests", "results", "external_results_read"],
      "properties": {
        "requests": {"type": "integer", "minimum": 0},
        "results": {"type": "integer", "minimum": 0},
        "external_results_read": {"type": "integer", "minimum": 0}
      },
      "additionalProperties": false
    },
    "external_runner": {
      "type": "object",
      "additionalProperties": true
    },
    "external_result_aggregate": {
      "type": "object",
      "required": [
        "records",
        "error_records",
        "error_types",
        "model_output_missing_field_records",
        "model_output_missing_fields",
        "risk_level_distribution",
        "requires_human_approval_distribution",
        "blocked_by_policy_distribution",
        "unsafe_hitl_records"
      ],
      "properties": {
        "records": {"type": "integer", "minimum": 0},
        "error_records": {"type": "integer", "minimum": 0},
        "error_types": {"type": "object", "additionalProperties": {"type": "integer", "minimum": 0}},
        "model_output_missing_field_records": {"type": "integer", "minimum": 0},
        "model_output_missing_fields": {"type": "object", "additionalProperties": {"type": "integer", "minimum": 0}},
        "risk_level_distribution": {"type": "object", "additionalProperties": {"type": "integer", "minimum": 0}},
        "requires_human_approval_distribution": {"type": "object", "additionalProperties": {"type": "integer", "minimum": 0}},
        "blocked_by_policy_distribution": {"type": "object", "additionalProperties": {"type": "integer", "minimum": 0}},
        "unsafe_hitl_records": {"type": "integer", "minimum": 0}
      },
      "additionalProperties": false
    },
    "scorecard_delta": {
      "type": "object",
      "additionalProperties": true
    },
    "promotion_gate": {
      "type": "object",
      "additionalProperties": true
    },
    "primary_failure_modes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "severity", "affected_records", "evidence", "required_before_rerun"],
        "properties": {
          "id": {"type": "string", "minLength": 1},
          "severity": {"type": "string", "enum": ["blocker", "major", "minor"]},
          "affected_records": {"type": "integer", "minimum": 0},
          "evidence": {"type": "object", "additionalProperties": true},
          "required_before_rerun": {"type": "array", "items": {"type": "string"}}
        },
        "additionalProperties": false
      }
    },
    "candidate_variant_plan": {
      "type": "object",
      "additionalProperties": true
    },
    "next_wave_recommendation": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["candidate_id", "reason", "next_step"],
        "properties": {
          "candidate_id": {"type": "string"},
          "reason": {"type": "string"},
          "next_step": {"type": "string"}
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false
}
