{
	"$id": "https://archboard.local/schemas/model-import.schema.json",
	"title": "Portable canonical installation",
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"type": "object",
	"properties": {
		"bundle": {
			"type": "object",
			"properties": {
				"format": {
					"type": "string",
					"const": "archboard-model"
				},
				"schemaVersion": {
					"type": "number",
					"const": 1
				},
				"model": {
					"type": "string",
					"pattern": "^[A-Za-z0-9-]{1,8}$"
				},
				"revision": {
					"type": "object",
					"properties": {
						"digest": {
							"type": "string"
						},
						"files": {
							"type": "array",
							"items": {
								"type": "object",
								"properties": {
									"path": {
										"type": "string"
									},
									"sha256": {
										"type": "string"
									}
								},
								"required": [
									"path",
									"sha256"
								],
								"additionalProperties": false
							}
						}
					},
					"required": [
						"digest",
						"files"
					],
					"additionalProperties": false
				},
				"inputs": {
					"type": "array",
					"items": {
						"type": "object",
						"properties": {
							"path": {
								"type": "string"
							},
							"bytes": {
								"type": "string",
								"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
							}
						},
						"required": [
							"path",
							"bytes"
						],
						"additionalProperties": false
					}
				},
				"history": {
					"type": "object",
					"properties": {
						"tips": {
							"type": "array",
							"items": {
								"type": "string",
								"pattern": "^(?:[a-f0-9]{40}|[a-f0-9]{64})$"
							}
						},
						"bundle": {
							"anyOf": [
								{
									"type": "string",
									"pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
								},
								{
									"type": "null"
								}
							]
						}
					},
					"required": [
						"tips",
						"bundle"
					],
					"additionalProperties": false
				}
			},
			"required": [
				"format",
				"schemaVersion",
				"model",
				"revision",
				"inputs",
				"history"
			],
			"additionalProperties": false
		},
		"expectedRevision": {
			"type": "object",
			"properties": {
				"digest": {
					"type": "string"
				},
				"files": {
					"type": "array",
					"items": {
						"type": "object",
						"properties": {
							"path": {
								"type": "string"
							},
							"sha256": {
								"type": "string"
							}
						},
						"required": [
							"path",
							"sha256"
						],
						"additionalProperties": false
					}
				}
			},
			"required": [
				"digest",
				"files"
			],
			"additionalProperties": false
		},
		"operationId": {
			"type": "string",
			"minLength": 1,
			"allOf": [
				{
					"pattern": "\\S"
				},
				{
					"pattern": "^[^\\n]*$"
				}
			]
		},
		"writer": {
			"type": "string",
			"minLength": 1,
			"allOf": [
				{
					"pattern": "\\S"
				},
				{
					"pattern": "^[^\\n]*$"
				}
			]
		},
		"doing": {
			"type": "string",
			"minLength": 1,
			"maxLength": 140,
			"allOf": [
				{
					"pattern": "\\S"
				},
				{
					"pattern": "^[^\\n]*$"
				}
			]
		}
	},
	"required": [
		"bundle",
		"expectedRevision",
		"operationId",
		"writer",
		"doing"
	],
	"additionalProperties": false,
	"x-archboard": {
		"runtimeObligations": [
			"The complete canonical candidate must be coherent.",
			"Continuing identities remain stable.",
			"A write requires its complete revision, intent, and claim."
		]
	}
}
