{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"title": "Catalog Reconciliation Report",
	"type": "object",
	"additionalProperties": false,
	"required": ["$schema", "version", "domain", "generatedAt", "entries", "summary"],
	"properties": {
		"$schema": { "type": "string" },
		"version": { "const": 1 },
		"domain": { "enum": ["manifest", "webviews", "quickpicks", "formatter", "webviewHost"] },
		"generatedAt": { "type": "string", "format": "date-time" },
		"entries": {
			"type": "array",
			"items": { "$ref": "#/definitions/reconciliationEntry" }
		},
		"summary": {
			"type": "object",
			"additionalProperties": false,
			"required": ["added", "changed", "moved", "removed", "ambiguous"],
			"properties": {
				"added": { "type": "integer", "minimum": 0 },
				"changed": { "type": "integer", "minimum": 0 },
				"moved": { "type": "integer", "minimum": 0 },
				"removed": { "type": "integer", "minimum": 0 },
				"ambiguous": { "type": "integer", "minimum": 0 }
			}
		}
	},
	"definitions": {
		"position": {
			"type": "object",
			"additionalProperties": false,
			"required": ["line", "column"],
			"properties": {
				"line": { "type": "integer", "minimum": 1 },
				"column": { "type": "integer", "minimum": 1 }
			}
		},
		"sourceReference": {
			"anyOf": [
				{
					"type": "object",
					"additionalProperties": false,
					"required": ["kind", "file", "pointer", "segments"],
					"properties": {
						"kind": { "const": "json" },
						"file": { "type": "string" },
						"pointer": { "type": "string" },
						"segments": {
							"type": "array",
							"items": {
								"anyOf": [{ "type": "string" }, { "type": "integer" }]
							}
						}
					}
				},
				{
					"type": "object",
					"additionalProperties": false,
					"required": ["kind", "file", "syntax", "start", "end"],
					"properties": {
						"kind": { "const": "source" },
						"file": { "type": "string" },
						"syntax": { "type": "string" },
						"start": { "$ref": "#/definitions/position" },
						"end": { "$ref": "#/definitions/position" },
						"attribute": { "type": "string" }
					}
				}
			]
		},
		"outputReference": {
			"anyOf": [
				{
					"type": "object",
					"additionalProperties": false,
					"required": ["kind", "key"],
					"properties": {
						"kind": { "const": "manifest-key" },
						"key": { "type": "string" }
					}
				},
				{
					"type": "object",
					"additionalProperties": false,
					"required": ["kind", "bundle", "key"],
					"properties": {
						"kind": { "const": "runtime-key" },
						"bundle": { "type": "string" },
						"key": { "type": "string" }
					}
				}
			]
		},
		"reconciliationEntry": {
			"type": "object",
			"additionalProperties": false,
			"required": ["occurrenceId", "change"],
			"properties": {
				"occurrenceId": { "type": "string" },
				"change": { "enum": ["added", "changed", "moved", "removed", "ambiguous"] },
				"anchor": { "type": "string" },
				"previousReference": { "$ref": "#/definitions/sourceReference" },
				"currentReference": { "$ref": "#/definitions/sourceReference" },
				"previousSourceHash": { "type": "string" },
				"currentSourceHash": { "type": "string" },
				"output": { "$ref": "#/definitions/outputReference" },
				"reason": { "type": "string" }
			}
		}
	}
}
