{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:woodcut:tutorial:1.0.0",
  "title": "Woodcut tutorial v1.0.0",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": "1.0.0"
    },
    "id": {
      "type": "string",
      "minLength": 1
    },
    "slug": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*$"
    },
    "locale": {
      "type": "string",
      "minLength": 1
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "summary": {
      "type": "string",
      "minLength": 1
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 1
    },
    "request": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "input": {
          "type": "string",
          "minLength": 1
        },
        "subject": {
          "type": "string",
          "minLength": 1
        },
        "constraints": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0
        },
        "assumptions": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        }
      },
      "required": [
        "input",
        "subject",
        "constraints",
        "assumptions"
      ]
    },
    "craft": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "technique": {
          "enum": [
            "low-relief",
            "incised",
            "in-the-round",
            "woodblock-print"
          ]
        },
        "difficulty": {
          "enum": [
            "beginner",
            "intermediate",
            "advanced"
          ]
        },
        "estimated_minutes": {
          "type": "integer",
          "minimum": 1
        },
        "wood": {
          "type": "string",
          "minLength": 1
        },
        "board_mm": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "width": {
              "type": "number",
              "minimum": 0
            },
            "height": {
              "type": "number",
              "minimum": 0
            },
            "thickness": {
              "type": "number",
              "minimum": 0
            }
          },
          "required": [
            "width",
            "height",
            "thickness"
          ]
        }
      },
      "required": [
        "technique",
        "difficulty",
        "estimated_minutes",
        "wood",
        "board_mm"
      ]
    },
    "design": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "pose": {
          "type": "string",
          "minLength": 1
        },
        "composition": {
          "type": "string",
          "minLength": 1
        },
        "grain_axis": {
          "enum": [
            "vertical",
            "horizontal"
          ]
        },
        "view_box": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "minItems": 4,
          "maxItems": 4
        },
        "silhouette_path": {
          "type": "string",
          "minLength": 1
        },
        "detail_paths": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0
        },
        "regions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/region"
          },
          "minItems": 1
        },
        "template_asset_id": {
          "type": "string",
          "minLength": 1
        },
        "print": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "paper": {
              "type": "string",
              "minLength": 1
            },
            "scale_percent": {
              "const": 100
            },
            "calibration_mm": {
              "const": 20
            }
          },
          "required": [
            "paper",
            "scale_percent",
            "calibration_mm"
          ]
        }
      },
      "required": [
        "pose",
        "composition",
        "grain_axis",
        "view_box",
        "silhouette_path",
        "detail_paths",
        "regions",
        "template_asset_id",
        "print"
      ]
    },
    "materials": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "minItems": 1
    },
    "tools": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      },
      "minItems": 1
    },
    "safety": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 1
    },
    "assets": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/asset"
      },
      "minItems": 1
    },
    "states": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/state"
      },
      "minItems": 2
    },
    "steps": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/step"
      },
      "minItems": 1
    },
    "quality": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "status": {
          "enum": [
            "ready",
            "partial"
          ]
        },
        "schema_validation": {
          "enum": [
            "pending",
            "passed",
            "failed"
          ]
        },
        "visual_review": {
          "enum": [
            "pending",
            "passed",
            "failed"
          ]
        },
        "physical_trial": {
          "enum": [
            "not_tested",
            "passed",
            "failed"
          ]
        },
        "physical_trial_record": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "limitations": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "missing_items": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0
        }
      },
      "required": [
        "status",
        "schema_validation",
        "visual_review",
        "physical_trial",
        "physical_trial_record",
        "limitations",
        "missing_items"
      ]
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "method": {
          "type": "string",
          "minLength": 1
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "sources": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "license": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "method",
        "created_at",
        "sources",
        "license"
      ]
    }
  },
  "required": [
    "schema_version",
    "id",
    "slug",
    "locale",
    "title",
    "summary",
    "tags",
    "request",
    "craft",
    "design",
    "materials",
    "tools",
    "safety",
    "assets",
    "states",
    "steps",
    "quality",
    "provenance"
  ],
  "$defs": {
    "item": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "specification": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "id",
        "name",
        "specification"
      ]
    },
    "asset": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "role": {
          "enum": [
            "cover",
            "step",
            "template",
            "preview"
          ]
        },
        "path": {
          "type": "string",
          "minLength": 1
        },
        "format": {
          "enum": [
            "svg",
            "png",
            "jpg",
            "webp"
          ]
        },
        "width": {
          "type": "integer",
          "minimum": 1
        },
        "height": {
          "type": "integer",
          "minimum": 1
        },
        "alt": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "enum": [
            "ready",
            "pending",
            "failed"
          ]
        }
      },
      "required": [
        "id",
        "role",
        "path",
        "format",
        "width",
        "height",
        "alt",
        "source",
        "status"
      ]
    },
    "region": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "action": {
          "enum": [
            "retain",
            "remove",
            "detail"
          ]
        },
        "path": {
          "type": "string",
          "minLength": 1
        },
        "target_depth_mm": {
          "type": "number",
          "minimum": 0
        }
      },
      "required": [
        "id",
        "name",
        "action",
        "path",
        "target_depth_mm"
      ]
    },
    "state": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "stage": {
          "type": "integer",
          "minimum": 0,
          "maximum": 8
        },
        "completed_region_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0
        },
        "background_depth_mm": {
          "type": "number",
          "minimum": 0
        }
      },
      "required": [
        "id",
        "description",
        "stage",
        "completed_region_ids",
        "background_depth_mm"
      ]
    },
    "step": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "order": {
          "type": "integer",
          "minimum": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "goal": {
          "type": "string",
          "minLength": 1
        },
        "instructions": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "tool_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0
        },
        "before_state_id": {
          "type": "string",
          "minLength": 1
        },
        "after_state_id": {
          "type": "string",
          "minLength": 1
        },
        "region_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0
        },
        "depth_mm": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0
            },
            {
              "type": "null"
            }
          ]
        },
        "grain_direction": {
          "type": "string",
          "minLength": 1
        },
        "image_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "checkpoints": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "common_mistakes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "safety_notes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "duration_minutes": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "id",
        "order",
        "title",
        "goal",
        "instructions",
        "tool_ids",
        "before_state_id",
        "after_state_id",
        "region_ids",
        "depth_mm",
        "grain_direction",
        "image_ids",
        "checkpoints",
        "common_mistakes",
        "safety_notes",
        "duration_minutes"
      ]
    }
  }
}
