{
	"$id": "https://archboard.local/schemas/flows.schema.json",
	"title": "Independent flow collection",
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"type": "object",
	"properties": {
		"schemaVersion": {
			"type": "number",
			"const": 1
		},
		"id": {
			"type": "string",
			"pattern": "^[A-Za-z0-9-]{1,8}$"
		},
		"name": {
			"type": "string",
			"minLength": 1,
			"maxLength": 120,
			"allOf": [
				{
					"pattern": "\\S"
				},
				{
					"pattern": "^[^\\n]*$"
				}
			]
		},
		"formerNames": {
			"type": "array",
			"items": {
				"type": "string",
				"minLength": 1,
				"maxLength": 120,
				"allOf": [
					{
						"pattern": "\\S"
					},
					{
						"pattern": "^[^\\n]*$"
					}
				]
			}
		},
		"flows": {
			"type": "array",
			"items": {
				"type": "object",
				"properties": {
					"id": {
						"type": "string",
						"pattern": "^[A-Za-z0-9-]{1,8}(?:\\/[A-Za-z0-9-]{1,8})?#[A-Za-z0-9-]{1,8}$"
					},
					"name": {
						"type": "string",
						"minLength": 1,
						"maxLength": 120,
						"allOf": [
							{
								"pattern": "\\S"
							},
							{
								"pattern": "^[^\\n]*$"
							}
						]
					},
					"summary": {
						"type": "string",
						"minLength": 1,
						"maxLength": 2000,
						"pattern": "\\S"
					},
					"participants": {
						"minItems": 1,
						"type": "array",
						"items": {
							"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]*$"
								}
							]
						}
					},
					"steps": {
						"minItems": 1,
						"type": "array",
						"items": {
							"$ref": "#/$defs/__schema0"
						}
					}
				},
				"required": [
					"id",
					"name",
					"participants",
					"steps"
				],
				"additionalProperties": false
			}
		}
	},
	"required": [
		"schemaVersion",
		"id",
		"name",
		"flows"
	],
	"additionalProperties": false,
	"$defs": {
		"__schema0": {
			"anyOf": [
				{
					"type": "object",
					"properties": {
						"id": {
							"type": "string",
							"pattern": "^[A-Za-z0-9-]{1,8}(?:\\/[A-Za-z0-9-]{1,8})?#[A-Za-z0-9-]{1,8}$"
						},
						"from": {
							"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}$"
						},
						"label": {
							"type": "string",
							"minLength": 1,
							"maxLength": 60
						},
						"kind": {
							"default": "sync",
							"type": "string",
							"enum": [
								"sync",
								"async",
								"return",
								"self"
							]
						},
						"note": {
							"type": "string",
							"minLength": 1,
							"maxLength": 2000,
							"pattern": "\\S"
						},
						"repeat": {
							"type": "integer",
							"minimum": 2,
							"maximum": 9007199254740991
						},
						"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
						}
					},
					"required": [
						"id",
						"from",
						"to",
						"label"
					],
					"additionalProperties": false
				},
				{
					"type": "object",
					"properties": {
						"id": {
							"type": "string",
							"pattern": "^[A-Za-z0-9-]{1,8}(?:\\/[A-Za-z0-9-]{1,8})?#[A-Za-z0-9-]{1,8}$"
						},
						"kind": {
							"type": "string",
							"const": "decision"
						},
						"question": {
							"type": "string",
							"minLength": 1,
							"maxLength": 60
						},
						"note": {
							"type": "string",
							"minLength": 1,
							"maxLength": 2000,
							"pattern": "\\S"
						},
						"alternatives": {
							"minItems": 2,
							"type": "array",
							"items": {
								"type": "object",
								"properties": {
									"label": {
										"type": "string",
										"minLength": 1,
										"maxLength": 60
									},
									"steps": {
										"type": "array",
										"items": {
											"$ref": "#/$defs/__schema0"
										}
									}
								},
								"required": [
									"label",
									"steps"
								],
								"additionalProperties": false
							}
						}
					},
					"required": [
						"id",
						"kind",
						"question",
						"alternatives"
					],
					"additionalProperties": false
				},
				{
					"type": "object",
					"properties": {
						"id": {
							"type": "string",
							"pattern": "^[A-Za-z0-9-]{1,8}(?:\\/[A-Za-z0-9-]{1,8})?#[A-Za-z0-9-]{1,8}$"
						},
						"kind": {
							"type": "string",
							"const": "loop"
						},
						"condition": {
							"type": "string",
							"minLength": 1,
							"maxLength": 60
						},
						"note": {
							"type": "string",
							"minLength": 1,
							"maxLength": 2000,
							"pattern": "\\S"
						},
						"steps": {
							"minItems": 1,
							"type": "array",
							"items": {
								"$ref": "#/$defs/__schema0"
							}
						}
					},
					"required": [
						"id",
						"kind",
						"condition",
						"steps"
					],
					"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."
		]
	}
}
