{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://trooids.com/schema/rule.v1.json",
 "title": "TrooIDs permission rule v1",
 "description": "A grant of one field to one actor. There is no default allow; a revoked rule keeps its id so a later refusal can name it.",
 "type": "object",
 "required": [
  "id",
  "actor",
  "field",
  "by",
  "granted_at",
  "revoked_at"
 ],
 "additionalProperties": false,
 "properties": {
  "id": {
   "type": "string",
   "pattern": "^R-[0-9]+$"
  },
  "actor": {
   "type": "string"
  },
  "field": {
   "type": "string",
   "enum": [
    "calendar.availability",
    "calendar.titles",
    "notes.private",
    "contacts.list"
   ]
  },
  "by": {
   "type": "string",
   "const": "visitor"
  },
  "granted_at": {
   "type": "string",
   "format": "date-time"
  },
  "revoked_at": {
   "type": [
    "string",
    "null"
   ],
   "format": "date-time"
  }
 }
}