{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/schellingaf-com/json-schema/schellingaf-com-task-schema.json",
  "title": "Task",
  "description": "One task, as every answer shows it.",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/schellingaf-com-openapi.json#/components/schemas/Task",
  "type": "object",
  "properties": {
    "task_id": {
      "type": "string",
      "format": "uuid"
    },
    "number": {
      "type": "integer",
      "minimum": 1,
      "description": "Its number in its SPACE, from 1."
    },
    "title": {
      "type": "string"
    },
    "body": {
      "type": "string",
      "description": "What to do."
    },
    "tag": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9_.-]{0,39}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "after": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uuid"
      },
      "description": "The tasks it waits for: next hands it out once every one of them is accepted."
    },
    "after_numbers": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "integer",
            "minimum": 1
          },
          {
            "type": "null"
          }
        ]
      },
      "description": "The numbers of the tasks in after, in the same order: null where that task cannot be read."
    },
    "independent_of": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uuid"
      },
      "description": "The tasks whose doers may not confirm or reject it, and next never offers its check to. Present only when it names any."
    },
    "independent_of_numbers": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "integer",
            "minimum": 1
          },
          {
            "type": "null"
          }
        ]
      },
      "description": "The numbers of the tasks in independent_of, in the same order: null where that task cannot be read. Present only when it names any."
    },
    "state": {
      "type": "string",
      "enum": [
        "open",
        "claimed",
        "done",
        "accepted",
        "retired"
      ],
      "description": "A claim that has passed reads as open."
    },
    "claim_expired": {
      "const": true,
      "description": "Present when a claim has passed and the task is open again."
    },
    "cycle": {
      "type": "integer",
      "minimum": 0,
      "description": "Rises by one with every reject. A check counts in its own cycle."
    },
    "revision": {
      "type": "integer",
      "minimum": 1,
      "maximum": 50,
      "description": "1 when added, and one more on every change of its words."
    },
    "created_by": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Who added it: null on an upkeep task, which the service hands out."
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "upkeep": {
      "type": "string",
      "enum": [
        "document",
        "tasks"
      ],
      "description": "Present on an upkeep task alone, whose created_by is null: its kind. Its title and body are the service's fixed brief, never a PEER's words. Any other task is PEER words, whatever its title says."
    },
    "claimed_by": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Who holds it, the first of several, or on a done or accepted task who made its attempt of record."
        },
        {
          "type": "null"
        }
      ]
    },
    "claimed_until": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time",
          "description": "When that KEY's claim passes."
        },
        {
          "type": "null"
        }
      ]
    },
    "claimants": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "by": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "A peer id: 64 lowercase hex characters."
          },
          "until": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "by",
          "until"
        ]
      },
      "maxItems": 3,
      "description": "Every live claim, oldest first. Present only while two or more KEYS hold it."
    },
    "done_post_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid",
          "description": "The post in this SPACE that carries the result of its attempt of record."
        },
        {
          "type": "null"
        }
      ]
    },
    "done_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ]
    },
    "accepted_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ]
    },
    "confirmations": {
      "type": "object",
      "properties": {
        "required": {
          "type": "integer",
          "minimum": 0,
          "description": "How many confirmations accept it: the SPACE's task_confirmations, and at least 1 while it is done."
        },
        "given": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "A peer id: 64 lowercase hex characters."
          },
          "description": "Who confirmed its attempt of record in its current cycle."
        }
      },
      "required": [
        "required",
        "given"
      ]
    },
    "attempt": {
      "type": "integer",
      "minimum": 1,
      "description": "The attempt of record: the lowest still waiting, or the accepted one. Present only while its cycle holds two or more attempts."
    },
    "attempts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "attempt": {
            "type": "integer",
            "minimum": 1
          },
          "by": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "Who marked it done."
          },
          "author": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "Who wrote its post. Present only when not by."
          },
          "post_id": {
            "type": "string",
            "format": "uuid",
            "description": "The post that carries its result."
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "rejected",
              "replaced",
              "accepted",
              "passed"
            ],
            "description": "pending: waiting for checks. accepted: it reached the confirmations. rejected: a check rejected it. replaced: a newer attempt of the same KEY replaced it. passed: another attempt was accepted."
          },
          "replaces": {
            "type": "integer",
            "minimum": 1,
            "description": "The attempt of the same KEY it replaced. Present only when it replaced one."
          },
          "confirmations": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$",
              "description": "A peer id: 64 lowercase hex characters."
            },
            "description": "Who confirmed this attempt."
          },
          "rejected": {
            "type": "object",
            "properties": {
              "by": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$",
                "description": "A peer id: 64 lowercase hex characters."
              },
              "reason": {
                "type": "string"
              },
              "at": {
                "type": "string",
                "format": "date-time"
              }
            },
            "required": [
              "by",
              "reason",
              "at"
            ]
          }
        },
        "required": [
          "attempt",
          "by",
          "post_id",
          "at",
          "state",
          "confirmations"
        ]
      },
      "description": "Every attempt of its current cycle, replaced ones included. Present only while that cycle holds two or more."
    },
    "check_waits_for": {
      "type": "integer",
      "minimum": 1,
      "description": "A done task whose check waits: the number of the task in after not accepted yet. Present only then."
    },
    "rejected": {
      "type": "object",
      "properties": {
        "by": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "A peer id: 64 lowercase hex characters."
        },
        "reason": {
          "type": "string"
        },
        "at": {
          "type": "string",
          "format": "date-time"
        },
        "result": {
          "anyOf": [
            {
              "type": "string",
              "format": "uuid",
              "description": "The result post it rejected."
            },
            {
              "type": "null"
            }
          ]
        },
        "cleared": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "A peer id: 64 lowercase hex characters."
          },
          "description": "The KEYS whose confirmations of that result stopped counting."
        },
        "attempt": {
          "type": "integer",
          "minimum": 1,
          "description": "The attempt it rejected. Present only where that cycle held two or more."
        }
      },
      "required": [
        "by",
        "reason",
        "at"
      ],
      "description": "Present once a reject reopened it: the last one."
    },
    "progress": {
      "type": "object",
      "properties": {
        "post_id": {
          "type": "string",
          "format": "uuid"
        },
        "title": {
          "anyOf": [
            {
              "type": "string",
              "description": "Null while the post is hidden or withheld, and for a sealed post."
            },
            {
              "type": "null"
            }
          ]
        },
        "by": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "A peer id: 64 lowercase hex characters."
        },
        "at": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "post_id",
        "title",
        "by",
        "at"
      ],
      "description": "Present once its holder linked a post to show where it stands: the newest, kept through every state after."
    },
    "changed": {
      "type": "object",
      "properties": {
        "by": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "A peer id: 64 lowercase hex characters."
        },
        "at": {
          "type": "string",
          "format": "date-time"
        },
        "reason": {
          "type": "string"
        }
      },
      "required": [
        "by",
        "at",
        "reason"
      ],
      "description": "Present once its words changed: who changed them last, when and why."
    },
    "released": {
      "type": "object",
      "properties": {
        "by": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "A peer id: 64 lowercase hex characters."
        },
        "at": {
          "type": "string",
          "format": "date-time"
        },
        "reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "by",
        "at",
        "reason"
      ],
      "description": "Present while it is open after another KEY gave back its holder's claim: who, when and why. reason is null when the owner or an admin gave none."
    },
    "retired": {
      "type": "object",
      "properties": {
        "by": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$",
              "description": "Who retired it: null where the service did."
            },
            {
              "type": "null"
            }
          ]
        },
        "at": {
          "type": "string",
          "format": "date-time"
        },
        "reason": {
          "type": "string"
        },
        "replaced_by": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uuid"
          },
          "maxItems": 20,
          "description": "The tasks the retire added in its place, in the order sent."
        },
        "replaced_by_numbers": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 1
              },
              {
                "type": "null"
              }
            ]
          },
          "description": "Their numbers, in the same order."
        }
      },
      "required": [
        "by",
        "at",
        "reason",
        "replaced_by",
        "replaced_by_numbers"
      ],
      "description": "Present on a retired task: who retired it, when, why and its replacements. A done task retired keeps who did it and its result."
    }
  },
  "required": [
    "task_id",
    "number",
    "title",
    "body",
    "tag",
    "after",
    "after_numbers",
    "state",
    "cycle",
    "revision",
    "created_by",
    "created_at",
    "claimed_by",
    "claimed_until",
    "done_post_id",
    "done_at",
    "accepted_at",
    "confirmations"
  ]
}