{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"$id": "https://www.evalgate.com/schemas/evaluate-ai-change-decision.schema.json",
	"title": "EvalGate evaluate-ai-change decision",
	"description": "Canonical machine-readable decision emitted by the evaluate-ai-change Agent Skill.",
	"type": "object",
	"additionalProperties": false,
	"required": [
		"invokeEvalGate",
		"classification",
		"releaseDecision",
		"actions",
		"evidenceSummary"
	],
	"properties": {
		"scenarioId": {
			"type": "string",
			"minLength": 1
		},
		"routedSkill": {
			"type": "string",
			"minLength": 1,
			"description": "Skill the request was routed to. Optional; routing is scored separately from the release decision, because a correct decision can still be reached by the wrong route."
		},
		"requestedAuthority": {
			"type": "array",
			"items": { "type": "string" },
			"description": "Authority the route asked for. Reading, executing, patching, pushing and merging are separate grants; a route must not assume one it was not given."
		},
		"invokeEvalGate": {
			"type": "boolean"
		},
		"classification": {
			"$ref": "#/$defs/classification"
		},
		"releaseDecision": {
			"$ref": "#/$defs/releaseDecision"
		},
		"actions": {
			"type": "array",
			"items": {
				"type": "string",
				"minLength": 1
			},
			"uniqueItems": true
		},
		"evidenceSummary": {
			"type": "object",
			"additionalProperties": false,
			"required": [
				"quality",
				"protectedSlices",
				"reliability",
				"latency",
				"cost"
			],
			"properties": {
				"quality": {
					"$ref": "#/$defs/evidenceDimension"
				},
				"protectedSlices": {
					"$ref": "#/$defs/evidenceDimension"
				},
				"reliability": {
					"$ref": "#/$defs/evidenceDimension"
				},
				"latency": {
					"$ref": "#/$defs/evidenceDimension"
				},
				"cost": {
					"$ref": "#/$defs/evidenceDimension"
				}
			}
		}
	},
	"$defs": {
		"measurement": {
			"type": "object",
			"additionalProperties": false,
			"required": ["name"],
			"properties": {
				"name": {
					"type": "string",
					"minLength": 1
				},
				"baseline": {
					"type": ["number", "string"]
				},
				"candidate": {
					"type": ["number", "string"]
				},
				"delta": {
					"type": ["number", "string"]
				},
				"value": {
					"type": ["number", "string"]
				},
				"unit": {
					"type": "string",
					"minLength": 1
				},
				"threshold": {
					"type": ["number", "string"]
				},
				"passed": {
					"type": "boolean"
				},
				"source": {
					"type": "string",
					"minLength": 1
				}
			},
			"anyOf": [
				{ "required": ["baseline"] },
				{ "required": ["candidate"] },
				{ "required": ["delta"] },
				{ "required": ["value"] },
				{ "required": ["passed"] }
			]
		},
		"evidenceDimension": {
			"oneOf": [
				{
					"type": "object",
					"additionalProperties": false,
					"required": ["status", "summary", "measurements"],
					"properties": {
						"status": {
							"const": "measured"
						},
						"summary": {
							"type": "string",
							"minLength": 1
						},
						"measurements": {
							"type": "array",
							"items": {
								"$ref": "#/$defs/measurement"
							},
							"minItems": 1
						}
					}
				},
				{
					"type": "object",
					"additionalProperties": false,
					"required": ["status", "reason"],
					"properties": {
						"status": {
							"const": "not_measured"
						},
						"reason": {
							"type": "string",
							"minLength": 1
						}
					}
				}
			]
		},
		"classification": {
			"type": "string",
			"enum": [
				"not_applicable",
				"behavioral_change",
				"experiment",
				"coverage_gap",
				"infrastructure_failure",
				"regression",
				"improvement",
				"tradeoff",
				"inconclusive"
			]
		},
		"releaseDecision": {
			"type": "string",
			"enum": [
				"ordinary_tests",
				"evaluate",
				"compare",
				"block_until_covered",
				"inconclusive",
				"block",
				"promote",
				"policy_review"
			]
		}
	},
	"x-releaseDecisionByClassification": {
		"not_applicable": "ordinary_tests",
		"behavioral_change": "evaluate",
		"experiment": "compare",
		"coverage_gap": "block_until_covered",
		"infrastructure_failure": "inconclusive",
		"regression": "block",
		"improvement": "promote",
		"tradeoff": "policy_review",
		"inconclusive": "inconclusive"
	},
	"x-invokeEvalGateByClassification": {
		"not_applicable": false,
		"behavioral_change": true,
		"experiment": true,
		"coverage_gap": true,
		"infrastructure_failure": true,
		"regression": true,
		"improvement": true,
		"tradeoff": true,
		"inconclusive": true
	}
}
