{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://resolutionprotocol.org/rp/0.2/locale.schema.json",
 "title": "Resolution Protocol locale grammar",
 "description": "Spoken phrases in one language → intents. SPEC §7.2. First matching rule wins.",
 "$defs": {
  "level": {
   "type": "integer",
   "minimum": 0,
   "maximum": 5
  },
  "duration": {
   "oneOf": [
    {
     "type": "string",
     "pattern": "^P(?:\\d+Y)?(?:\\d+M)?(?:\\d+W)?(?:\\d+D)?(?:T(?:\\d+H)?(?:\\d+M)?(?:\\d+(?:\\.\\d+)?S)?)?$"
    },
    {
     "type": "number",
     "minimum": 0
    }
   ]
  }
 },
 "type": "object",
 "required": [
  "rp",
  "locale",
  "rules"
 ],
 "properties": {
  "rp": {
   "type": "string"
  },
  "locale": {
   "type": "string"
  },
  "status": {
   "type": "string"
  },
  "normalize": {
   "type": "object",
   "properties": {
    "fold_accents": {
     "type": "boolean"
    },
    "replace": {
     "type": "array",
     "items": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "items": {
       "type": "string"
      }
     }
    }
   }
  },
  "numbers": {
   "type": "object",
   "additionalProperties": {
    "type": "number"
   }
  },
  "units": {
   "type": "object",
   "additionalProperties": {
    "type": "number",
    "description": "seconds"
   }
  },
  "rules": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "id",
     "match",
     "intent"
    ],
    "properties": {
     "id": {
      "type": "string"
     },
     "extension": {
      "type": "string"
     },
     "match": {
      "type": "string",
      "description": "Regex over space-normalised text; no \\b \\w \\W \\d, no capturing groups; placeholders {count} {unit} {invocation}"
     },
     "intent": {
      "type": "object",
      "required": [
       "kind"
      ],
      "properties": {
       "kind": {
        "type": "string",
        "description": "lower raise forget shorten resume object, or an extension kind"
       },
       "scope": {
        "enum": [
         "self",
         "room"
        ]
       },
       "level": {
        "$ref": "#/$defs/level"
       },
       "seconds": {
        "type": "number",
        "minimum": 0
       }
      }
     }
    }
   }
  }
 }
}