{
	"$id": "https://archboard.local/schemas/module.schema.json",
	"title": "Canonical module definition",
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"type": "object",
	"properties": {
		"order": {
			"type": "integer",
			"minimum": 0,
			"maximum": 9007199254740991
		},
		"name": {
			"type": "string",
			"minLength": 1,
			"maxLength": 120,
			"allOf": [
				{
					"pattern": "\\S"
				},
				{
					"pattern": "^[^\\n]*$"
				}
			]
		},
		"kind": {
			"type": "string",
			"minLength": 1,
			"pattern": "^[a-z0-9]+(?:[-_.][a-z0-9]+)*$"
		},
		"responsibility": {
			"type": "string",
			"minLength": 1,
			"maxLength": 200,
			"pattern": "\\S"
		},
		"description": {
			"type": "string",
			"minLength": 1,
			"maxLength": 2000,
			"pattern": "\\S"
		},
		"groups": {
			"type": "array",
			"items": {
				"type": "string",
				"minLength": 1,
				"pattern": "^[a-z0-9]+(?:[-_.][a-z0-9]+)*$"
			},
			"uniqueItems": true
		},
		"binding": {
			"type": "object",
			"properties": {
				"repo": {
					"type": "string",
					"minLength": 1
				},
				"path": {
					"type": "string"
				},
				"symbol": {
					"type": "string",
					"minLength": 1
				},
				"branch": {
					"type": "string",
					"minLength": 1
				},
				"commit": {
					"type": "string",
					"minLength": 1
				},
				"confirmedAt": {
					"type": "string",
					"minLength": 1
				}
			},
			"required": [
				"repo",
				"path"
			],
			"additionalProperties": false
		},
		"schemaVersion": {
			"type": "number",
			"const": 1
		},
		"id": {
			"type": "string",
			"pattern": "^[A-Za-z0-9-]{1,8}(?:\\/[A-Za-z0-9-]{1,8})?#[A-Za-z0-9-]{1,8}$"
		},
		"parent": {
			"type": "string",
			"pattern": "^[A-Za-z0-9-]{1,8}(?:\\/[A-Za-z0-9-]{1,8})?#[A-Za-z0-9-]{1,8}$"
		},
		"formerNames": {
			"type": "array",
			"items": {
				"type": "string",
				"minLength": 1,
				"maxLength": 120,
				"allOf": [
					{
						"pattern": "\\S"
					},
					{
						"pattern": "^[^\\n]*$"
					}
				]
			}
		},
		"documents": {
			"type": "array",
			"items": {
				"type": "object",
				"properties": {
					"repo": {
						"type": "string",
						"minLength": 1
					},
					"branch": {
						"type": "string",
						"minLength": 1
					},
					"commit": {
						"type": "string",
						"minLength": 1
					},
					"path": {
						"type": "string",
						"minLength": 1
					}
				},
				"required": [
					"repo",
					"path"
				],
				"additionalProperties": false
			}
		},
		"references": {
			"type": "array",
			"items": {
				"type": "object",
				"properties": {
					"repo": {
						"type": "string",
						"minLength": 1
					},
					"model": {
						"type": "string",
						"pattern": "^[A-Za-z0-9-]{1,8}$"
					},
					"subject": {
						"type": "string",
						"pattern": "^[A-Za-z0-9-]{1,8}(?:\\/[A-Za-z0-9-]{1,8})?#[A-Za-z0-9-]{1,8}$"
					},
					"state": {
						"anyOf": [
							{
								"type": "string",
								"pattern": "^[A-Za-z0-9-]{1,8}$"
							},
							{
								"type": "string",
								"pattern": "^[A-Za-z0-9-]{1,8}(?:\\/[A-Za-z0-9-]{1,8})?#[A-Za-z0-9-]{1,8}$"
							}
						]
					},
					"checkpoint": {
						"type": "string",
						"pattern": "^(?:[a-f0-9]{40}|[a-f0-9]{64})$"
					}
				},
				"required": [
					"repo",
					"model",
					"subject",
					"state"
				],
				"additionalProperties": false
			}
		},
		"outgoing": {
			"type": "array",
			"items": {
				"type": "object",
				"properties": {
					"order": {
						"type": "integer",
						"minimum": 0,
						"maximum": 9007199254740991
					},
					"kind": {
						"type": "string",
						"minLength": 1,
						"pattern": "^[a-z0-9]+(?:[-_.][a-z0-9]+)*$"
					},
					"label": {
						"type": "string",
						"minLength": 1,
						"maxLength": 60
					},
					"description": {
						"type": "string",
						"minLength": 1,
						"maxLength": 2000,
						"pattern": "\\S"
					},
					"emphasis": {
						"default": "normal",
						"type": "string",
						"enum": [
							"normal",
							"hero",
							"muted"
						]
					},
					"traffic": {
						"type": "object",
						"properties": {
							"speed": {
								"default": 80,
								"type": "number",
								"exclusiveMinimum": 0
							},
							"volume": {
								"default": 1,
								"type": "number",
								"exclusiveMinimum": 0
							}
						},
						"additionalProperties": false
					},
					"anchor": {
						"type": "object",
						"properties": {
							"repo": {
								"type": "string",
								"minLength": 1
							},
							"path": {
								"type": "string",
								"minLength": 1
							},
							"symbol": {
								"type": "string",
								"minLength": 1
							}
						},
						"required": [
							"repo",
							"path",
							"symbol"
						],
						"additionalProperties": false
					},
					"id": {
						"type": "string",
						"pattern": "^[A-Za-z0-9-]{1,8}(?:\\/[A-Za-z0-9-]{1,8})?#[A-Za-z0-9-]{1,8}$"
					},
					"to": {
						"type": "string",
						"pattern": "^[A-Za-z0-9-]{1,8}(?:\\/[A-Za-z0-9-]{1,8})?#[A-Za-z0-9-]{1,8}$"
					}
				},
				"required": [
					"order",
					"kind",
					"id",
					"to"
				],
				"additionalProperties": false
			}
		}
	},
	"required": [
		"order",
		"name",
		"kind",
		"schemaVersion",
		"id",
		"outgoing"
	],
	"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."
		]
	}
}
