{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/tale-dev/json-schema/tale-dev-task-status-snapshot-schema.json",
  "title": "TaskStatusSnapshot",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/tale-dev-tasks-api-openapi.yml#/components/schemas/TaskStatusSnapshot",
  "type": "object",
  "required": [
    "task",
    "revision",
    "statusChangedAt",
    "change",
    "externalStatus",
    "workflow",
    "request"
  ],
  "properties": {
    "task": {
      "type": "object",
      "required": [
        "id",
        "status"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "backlog",
            "todo",
            "in_progress",
            "in_review",
            "done",
            "cancelled"
          ]
        },
        "archivedAt": {
          "type": "integer",
          "minimum": 0,
          "description": "Epoch milliseconds"
        },
        "externalSystem": {
          "type": "string"
        },
        "externalId": {
          "type": "string"
        }
      }
    },
    "revision": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d{0,18})$",
      "description": "Opaque lifecycle activity sequence; compare it as a string"
    },
    "statusChangedAt": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0,
      "description": "Epoch milliseconds"
    },
    "change": {
      "type": [
        "object",
        "null"
      ],
      "description": "Latest status activity, including creation or accepted source projection; a later archival activity advances revision without replacing this actor",
      "required": [
        "id",
        "action",
        "createdAt",
        "origin",
        "actor"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "action": {
          "type": "string"
        },
        "createdAt": {
          "type": "integer",
          "minimum": 0,
          "description": "Epoch milliseconds"
        },
        "origin": {
          "type": "string",
          "enum": [
            "native",
            "external"
          ]
        },
        "actor": {
          "type": "object",
          "required": [
            "type",
            "userId",
            "emailVerified",
            "activeMember"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "user",
                "agent"
              ]
            },
            "userId": {
              "type": "string",
              "description": "Immutable activity actor id; a person only when type is user"
            },
            "email": {
              "type": "string",
              "format": "email",
              "description": "Present only for an active verified human member of this organization"
            },
            "emailVerified": {
              "type": "boolean"
            },
            "activeMember": {
              "type": "boolean"
            }
          }
        }
      }
    },
    "externalStatus": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "sourceRevision",
        "sourceStatusAt",
        "status",
        "archived"
      ],
      "properties": {
        "sourceRevision": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        },
        "sourceStatusAt": {
          "type": "integer",
          "minimum": 0,
          "description": "Epoch milliseconds"
        },
        "status": {
          "type": "string",
          "enum": [
            "backlog",
            "todo",
            "in_progress",
            "in_review",
            "done",
            "cancelled"
          ]
        },
        "archived": {
          "type": "boolean"
        }
      }
    },
    "workflow": {
      "allOf": [
        {
          "$ref": "#/$defs/ExternalStatusWorkflow"
        }
      ]
    },
    "request": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "id",
        "revision",
        "statusChangeId",
        "actionId",
        "status",
        "input",
        "sourceRevision",
        "sourceStatusAt",
        "createdAt",
        "actor",
        "decision"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "revision": {
          "type": "string"
        },
        "statusChangeId": {
          "type": "string",
          "description": "Actual status activity observed when submitting the form; a later archive does not replace it"
        },
        "actionId": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "backlog",
            "todo",
            "in_progress",
            "in_review",
            "done",
            "cancelled"
          ]
        },
        "input": {
          "type": "object",
          "additionalProperties": {
            "oneOf": [
              {
                "type": "string",
                "maxLength": 4000
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "description": "Validated declared values plus move: actionId"
        },
        "sourceRevision": {
          "type": "string"
        },
        "sourceStatusAt": {
          "type": "integer",
          "minimum": 0,
          "description": "Epoch milliseconds"
        },
        "createdAt": {
          "type": "integer",
          "minimum": 0,
          "description": "Epoch milliseconds"
        },
        "actor": {
          "type": "object",
          "required": [
            "type",
            "userId",
            "emailVerified",
            "activeMember"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "user"
              ]
            },
            "userId": {
              "type": "string"
            },
            "email": {
              "type": "string",
              "format": "email"
            },
            "emailVerified": {
              "type": "boolean"
            },
            "activeMember": {
              "type": "boolean"
            }
          }
        },
        "decision": {
          "allOf": [
            {
              "$ref": "#/$defs/ExternalStatusDecision"
            }
          ]
        }
      }
    }
  },
  "$defs": {
    "ExternalStatusDecision": {
      "type": "object",
      "properties": {
        "accepted": {
          "type": "boolean"
        },
        "reason": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        }
      },
      "required": [
        "accepted"
      ],
      "additionalProperties": false
    },
    "ExternalStatusWorkflow": {
      "type": "object",
      "properties": {
        "actions": {
          "maxItems": 16,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "description": {
                "type": "string",
                "maxLength": 2000
              },
              "i18n": {
                "type": "object",
                "additionalProperties": {
                  "type": "object",
                  "properties": {
                    "title": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "description": {
                      "type": "string",
                      "maxLength": 2000
                    }
                  },
                  "additionalProperties": false
                }
              },
              "id": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_]{0,63}$"
              },
              "status": {
                "type": "string",
                "enum": [
                  "backlog",
                  "todo",
                  "in_progress",
                  "in_review",
                  "done",
                  "cancelled"
                ]
              },
              "fields": {
                "default": [],
                "maxItems": 30,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string",
                      "maxLength": 64,
                      "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
                    },
                    "label": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "text",
                        "number",
                        "boolean",
                        "select"
                      ]
                    },
                    "required": {
                      "type": "boolean"
                    },
                    "pattern": {
                      "type": "string",
                      "maxLength": 500
                    },
                    "default": {
                      "type": "string",
                      "maxLength": 4000
                    },
                    "placeholder": {
                      "type": "string",
                      "maxLength": 200
                    },
                    "help": {
                      "type": "string",
                      "maxLength": 500
                    },
                    "options": {
                      "minItems": 1,
                      "maxItems": 1000,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "value": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "label": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "i18n": {
                            "type": "object",
                            "additionalProperties": {
                              "type": "object",
                              "properties": {
                                "label": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 200
                                }
                              },
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "value",
                          "label"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "i18n": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "object",
                        "properties": {
                          "label": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "placeholder": {
                            "type": "string",
                            "maxLength": 200
                          },
                          "help": {
                            "type": "string",
                            "maxLength": 500
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "multiline": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "key",
                    "label",
                    "type"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "title",
              "id",
              "status"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "actions"
      ],
      "additionalProperties": false
    }
  }
}