{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://taku.ai/spec/system-surface/1",
  "title": "Taku system surface v1",
  "description": "Ephemeral display content. Actions are opaque callback identifiers, never executable instructions.",
  "type": "object",
  "additionalProperties": false,
  "required": ["version", "id", "revision", "kind", "placement", "title", "summary", "blocks", "actions", "ttlMs"],
  "properties": {
    "version": {"const": 1},
    "id": {"$ref": "#/$defs/id"},
    "revision": {"type": "integer", "minimum": 1, "maximum": 9007199254740991},
    "kind": {"enum": ["hint", "choice", "result"]},
    "placement": {"enum": ["top", "bottom"]},
    "title": {"type": "string", "minLength": 1, "maxLength": 160, "pattern": "\\S"},
    "summary": {"type": "string", "maxLength": 500},
    "ttlMs": {"type": "integer", "minimum": 1000, "maximum": 1800000},
    "blocks": {"type": "array", "maxItems": 8, "items": {"$ref": "#/$defs/block"}},
    "actions": {"type": "array", "maxItems": 3, "items": {"$ref": "#/$defs/action"}}
  },
  "$defs": {
    "id": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$"},
    "block": {
      "type": "object", "additionalProperties": false, "required": ["type", "label", "text"],
      "properties": {
        "type": {"enum": ["text", "field", "fact", "notice"]},
        "label": {"type": "string", "maxLength": 120},
        "text": {"type": "string", "minLength": 1, "maxLength": 2000, "pattern": "\\S"}
      },
      "if": {"properties": {"type": {"enum": ["field", "fact", "notice"]}}},
      "then": {"properties": {"label": {"minLength": 1, "pattern": "\\S"}}}
    },
    "action": {
      "type": "object", "additionalProperties": false, "required": ["id", "label", "primary"],
      "properties": {
        "id": {"$ref": "#/$defs/id"},
        "label": {"type": "string", "minLength": 1, "maxLength": 80, "pattern": "\\S"},
        "primary": {"type": "boolean"}
      }
    }
  }
}
