{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pencil-ink/json-schema/pencil-ink-phase-schema.json",
  "title": "Phase",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pencil-ink-openapi.yml#/components/schemas/Phase",
  "type": "object",
  "required": [
    "id",
    "globalId",
    "epicId",
    "name",
    "position",
    "gateMode",
    "workState",
    "gateState",
    "taskCount",
    "completedTaskCount",
    "remainingTaskCount"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "globalId": {
      "type": "string"
    },
    "epicId": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "position": {
      "type": "integer",
      "minimum": 0
    },
    "gateMode": {
      "$ref": "#/$defs/PhaseGateMode"
    },
    "workState": {
      "$ref": "#/$defs/PhaseWorkState"
    },
    "gateState": {
      "$ref": "#/$defs/PhaseGateState"
    },
    "blockingPhase": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "globalId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "remainingTaskCount": {
          "type": "integer"
        }
      }
    },
    "taskCount": {
      "type": "integer"
    },
    "completedTaskCount": {
      "type": "integer"
    },
    "remainingTaskCount": {
      "type": "integer"
    },
    "targetDate": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Epoch ms."
    },
    "docUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "ownerId": {
      "type": [
        "string",
        "null"
      ]
    },
    "gateOverride": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "at": {
          "type": "integer",
          "description": "Epoch ms."
        },
        "byUserId": {
          "type": [
            "string",
            "null"
          ]
        },
        "byAgent": {
          "type": [
            "string",
            "null"
          ]
        },
        "reason": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "createdAt": {
      "type": "integer",
      "description": "Epoch ms."
    },
    "updatedAt": {
      "type": "integer",
      "description": "Epoch ms."
    }
  },
  "$defs": {
    "PhaseGateMode": {
      "type": "string",
      "enum": [
        "advisory",
        "strict"
      ]
    },
    "PhaseGateState": {
      "type": "string",
      "enum": [
        "open",
        "locked",
        "overridden"
      ]
    },
    "PhaseWorkState": {
      "type": "string",
      "enum": [
        "empty",
        "planned",
        "active",
        "done"
      ]
    }
  }
}