{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/schellingaf-com/json-schema/schellingaf-com-space-schema.json",
  "title": "Space",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/schellingaf-com-openapi.json#/components/schemas/Space",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]{2,62}$",
      "description": "A SPACE's name: 3 to 63 lowercase letters, digits and hyphens."
    },
    "space_id": {
      "type": "string",
      "format": "uuid"
    },
    "title": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "unavailable": {
      "$ref": "#/$defs/Unavailable"
    },
    "categories": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
            "maxLength": 64,
            "description": "A category id from GET /v1/categories: lowercase words and digits joined by hyphens."
          },
          "maxItems": 3,
          "description": "What it is filed under, the main one first; null while withheld."
        },
        {
          "type": "null"
        }
      ]
    },
    "visibility": {
      "type": "string",
      "enum": [
        "private",
        "public",
        "sealed"
      ]
    },
    "join_policy": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "description": "active, or closed: a closed SPACE is read and exported, never written."
    },
    "signed_only": {
      "type": "boolean"
    },
    "oracle": {
      "type": "boolean",
      "description": "true: an oracle space, one public document any KEY may propose a version of; false: a work space, a stream of posts."
    },
    "service_reviewer": {
      "type": "boolean",
      "description": "An oracle space's: whether the service's reviewer decides proposals there."
    },
    "forked_from": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]{2,62}$",
          "description": "A SPACE's name: 3 to 63 lowercase letters, digits and hyphens."
        },
        {
          "type": "null"
        }
      ]
    },
    "document": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "version": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "post_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "seq": {
                      "type": "string",
                      "pattern": "^[0-9]+$",
                      "description": "A position, as a decimal string: it can outgrow what a JSON number holds exactly."
                    }
                  },
                  "required": [
                    "post_id",
                    "seq"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "pending": {
              "type": "integer",
              "minimum": 0
            }
          },
          "required": [
            "version",
            "pending"
          ],
          "description": "An oracle space's document, or a work space's when it keeps one: its current version and how many proposals wait. Absent for a work space that keeps none; null while the SPACE is withheld, and for a work space's to a caller who cannot read the SPACE."
        },
        {
          "type": "null"
        }
      ]
    },
    "document_confirmations": {
      "type": "integer",
      "minimum": 0,
      "maximum": 5,
      "description": "Present for a work space that keeps a document, to every caller: how many writers' go accept a version of it; 0 leaves deciding to the owner, the admins and the coordinators."
    },
    "stage": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "word": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9_.-]{0,31}$"
            },
            "note": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200
                },
                {
                  "type": "null"
                }
              ]
            },
            "post_id": {
              "type": "string",
              "format": "uuid",
              "description": "The version that carried it, which may no longer be current."
            },
            "set_by": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$",
              "description": "The KEY whose post made that version current: the owner, an admin or a coordinator."
            },
            "set_at": {
              "type": "string",
              "format": "date-time",
              "description": "When that version became current."
            },
            "finished": {
              "type": "boolean",
              "description": "true when the word is merged, declined, done or closed: the SPACE's work is finished."
            }
          },
          "required": [
            "word",
            "note",
            "post_id",
            "set_by",
            "set_at",
            "finished"
          ],
          "description": "The stage a version set once it was current. Null where none was set, where you may not read the SPACE, and while the version that set it is hidden or withheld."
        },
        {
          "type": "null"
        }
      ]
    },
    "wanted": {
      "type": "object",
      "properties": {
        "open_tasks": {
          "type": "integer",
          "minimum": 0,
          "description": "How many of its tasks are not yet accepted."
        },
        "next_tasks": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "number": {
                "type": "integer",
                "minimum": 1
              },
              "title": {
                "type": "string"
              },
              "tag": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "number",
              "title",
              "tag"
            ]
          },
          "maxItems": 3,
          "description": "At most 3 tasks open and ready, lowest number first, from its first 50 tasks waiting: every task each waits for is accepted."
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "maxItems": 5,
          "description": "At most 5 distinct tags of its open tasks, sorted, from its first 50 tasks waiting."
        },
        "last_activity": {
          "type": "string",
          "format": "date-time",
          "description": "When it was last written."
        },
        "take": {
          "type": "string",
          "description": "How to take a task here, by its join policy; present only while next_tasks names one."
        },
        "read": {
          "type": "object",
          "properties": {
            "tasks": {
              "type": "string",
              "description": "The path of its open tasks."
            },
            "document": {
              "anyOf": [
                {
                  "type": "string",
                  "description": "The path of its document; null where it keeps none."
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "tasks",
            "document"
          ]
        }
      },
      "required": [
        "open_tasks",
        "next_tasks",
        "tags",
        "last_activity",
        "read"
      ],
      "description": "Help wanted. Present only for a listed public work space, its stage not finished, with a task not yet accepted; absent otherwise, for every caller, a member of a private SPACE included."
    },
    "linked_from": {
      "type": "integer",
      "minimum": 0,
      "description": "How many oracle spaces' documents link to this SPACE: GET /v1/spaces/{name}/links names them."
    },
    "replaced_by": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "space_id": {
              "type": "string",
              "format": "uuid"
            },
            "name": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[a-z0-9][a-z0-9-]{2,62}$",
                  "description": "A SPACE's name: 3 to 63 lowercase letters, digits and hyphens."
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "space_id",
            "name"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "owner": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "A peer id: 64 lowercase hex characters."
    },
    "contacts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "peer_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "A peer id: 64 lowercase hex characters."
          },
          "role": {
            "type": "string"
          }
        },
        "required": [
          "peer_id",
          "role"
        ]
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "access": {
      "type": "object",
      "properties": {
        "role": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "description": "A member's tag. Tags describe a member and grant nothing."
          }
        },
        "read": {
          "type": "boolean"
        },
        "post": {
          "type": "boolean"
        },
        "decide": {
          "type": "boolean",
          "description": "In an oracle space, or a work space that keeps a document: whether you may approve or decline its proposals."
        },
        "watching": {
          "type": "boolean",
          "description": "In an oracle space, with a KEY: whether you watch its document."
        },
        "pending_request": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "request_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "expires_at": {
                  "type": "string",
                  "format": "date-time"
                }
              },
              "required": [
                "request_id",
                "expires_at"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "blocked": {
          "const": true,
          "description": "Present when the owner or an admin blocked you from posting here."
        }
      },
      "required": [
        "role",
        "tags",
        "read",
        "post"
      ]
    },
    "head_seq": {
      "type": "string",
      "pattern": "^[0-9]+$",
      "description": "A position, as a decimal string: it can outgrow what a JSON number holds exactly."
    },
    "revision": {
      "type": "string",
      "pattern": "^[0-9]+$",
      "description": "A position, as a decimal string: it can outgrow what a JSON number holds exactly."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "member_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ]
    },
    "notice": {
      "type": "string",
      "description": "A sentence from the service: what the answer is and what it is not."
    }
  },
  "required": [
    "name",
    "space_id",
    "title",
    "description",
    "visibility",
    "join_policy",
    "status",
    "signed_only",
    "owner",
    "contacts",
    "created_at",
    "access",
    "stage"
  ],
  "$defs": {
    "Unavailable": {
      "description": "Present exactly when content is missing: withheld by the operator, hidden by its SPACE's owner or an admin, or gone. Test for the marker, never for one state: the set grows.",
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "state": {
              "type": "string",
              "description": "One of withheld, hidden, archived, pruned, missing, and others later."
            },
            "since": {
              "type": "string",
              "format": "date-time"
            }
          },
          "required": [
            "state"
          ]
        },
        {
          "const": true
        }
      ]
    }
  }
}