{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openappdefinition.org/schema/0.2/definition.schema.json",
  "title": "OAD 0.2 app definition",
  "description": "An app definition (*.oad.json): a single JSON document that describes what an app does, the values it holds, the things it can do, when it does them, what it needs from the outside world, what it is permitted to touch, and how people and agents use it.",
  "type": "object",
  "required": ["oad", "id", "version", "meta"],
  "properties": {
    "$schema": {
      "description": "Optional URI of a JSON Schema for this document, for editors. Hosts ignore it.",
      "$ref": "common.schema.json#/$defs/uriReference"
    },
    "oad": {
      "title": "version marker",
      "description": "Spec version the document targets, MAJOR.MINOR. This schema validates version 0.2.",
      "$ref": "common.schema.json#/$defs/specVersion",
      "const": "0.2"
    },
    "id": {
      "description": "Globally unique identifier in reverse-DNS form, lowercase, segments of [a-z0-9-], at least two segments.",
      "$ref": "common.schema.json#/$defs/reverseDnsId"
    },
    "version": {
      "description": "Semantic version (semver 2.0.0) of this definition.",
      "$ref": "common.schema.json#/$defs/semver"
    },
    "meta": {
      "description": "Descriptive information about the app.",
      "$ref": "#/$defs/meta"
    },
    "uses": {
      "description": "Catalogs, other definitions and the design system this definition references.",
      "$ref": "#/$defs/uses"
    },
    "types": {
      "description": "Named types: an object of type name to JSON Schema object.",
      "$ref": "common.schema.json#/$defs/types"
    },
    "roles": {
      "description": "Named roles that principals may hold; expressions see a principal's roles as user.roles.",
      "type": "object",
      "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
      "additionalProperties": { "$ref": "#/$defs/role" }
    },
    "capabilities": {
      "description": "Typed access to the outside world, referenced by contract and bound by the host. Keyed by capability alias.",
      "type": "object",
      "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
      "additionalProperties": { "$ref": "#/$defs/capability" }
    },
    "grants": {
      "description": "The permissions the app asks for. Never contains issued permissions.",
      "type": "object",
      "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
      "additionalProperties": { "$ref": "#/$defs/grant" }
    },
    "state": {
      "description": "Named, typed values: stored, derived from other values, or sourced from a capability.",
      "type": "object",
      "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
      "additionalProperties": { "$ref": "#/$defs/stateEntry" }
    },
    "actions": {
      "description": "Named, typed, described operations. The only entry points into the app's behavior.",
      "type": "object",
      "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
      "additionalProperties": { "$ref": "#/$defs/action" }
    },
    "rules": {
      "description": "Rules of the form when X, do Y: a trigger plus steps.",
      "type": "object",
      "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
      "additionalProperties": { "$ref": "#/$defs/rule" }
    },
    "flows": {
      "description": "Explicit finite state machines for multi-step processes.",
      "type": "object",
      "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
      "additionalProperties": { "$ref": "#/$defs/flow" }
    },
    "code": {
      "description": "Sandboxed pure functions for logic nothing else can express.",
      "type": "object",
      "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
      "additionalProperties": { "$ref": "#/$defs/codeModule" }
    },
    "parts": {
      "description": "Other definitions included in this one, keyed by part name.",
      "type": "object",
      "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
      "additionalProperties": { "$ref": "#/$defs/part" }
    },
    "exports": {
      "description": "What this definition offers to a parent that includes it as a part.",
      "$ref": "#/$defs/exports"
    },
    "surfaces": {
      "description": "Projections of the kernel for kinds of user. A surface exists only if its key is present.",
      "$ref": "#/$defs/surfaces"
    },
    "assets": {
      "description": "Pictures that are part of the app, keyed by asset name. A prop that a contract marks remote refers to one as asset: followed by its name.",
      "type": "object",
      "propertyNames": { "$ref": "#/$defs/assetName" },
      "additionalProperties": { "$ref": "#/$defs/asset" }
    },
    "localization": {
      "description": "The app's own texts in several languages, and the language of its plain texts.",
      "$ref": "#/$defs/localization"
    },
    "extensions": {
      "description": "Vendor extensions keyed by reverse-DNS namespace. Hosts ignore namespaces they do not understand.",
      "$ref": "common.schema.json#/$defs/extensions"
    },
    "included": {
      "description": "Carried copies: whole definitions and design systems this file brings along so that it opens alone. A reference of uses.definitions or uses.design is looked up among them first. The digest of the definition never covers this member.",
      "type": "array",
      "items": { "$ref": "#/$defs/carriedCopy" }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "carriedCopy": {
      "title": "carried copy",
      "description": "A whole design system (it has oadDesign) or a whole definition. A carried definition has no included of its own. A catalog is never carried, and neither is a document of the format itself: its id never begins with org.openappdefinition.",
      "type": "object",
      "properties": {
        "id": {
          "description": "Never an id that begins with org.openappdefinition., which names a document of the format itself that every host provides.",
          "not": { "type": "string", "pattern": "^org\\.openappdefinition\\." }
        }
      },
      "if": { "type": "object", "required": ["oadDesign"], "properties": { "oadDesign": true } },
      "then": { "$ref": "design.schema.json" },
      "else": { "$ref": "#/$defs/carriedDefinition" }
    },
    "carriedDefinition": {
      "title": "carried definition",
      "description": "A definition carried in the included of another: a whole definition without included.",
      "type": "object",
      "$ref": "#",
      "properties": { "included": false }
    },
    "localization": {
      "title": "localization",
      "description": "The app's own texts in several languages. default is the language of every plain text of the document and the last table a text is looked for in; strings maps a language tag to its table of key to entry; notes says, for whoever translates, what a key's text is for. A language tag is written language[-Script][-REGION]; the semantic checks, not this schema, hold a tag to that spelling.",
      "type": "object",
      "required": ["default"],
      "properties": {
        "default": {
          "title": "language tag",
          "description": "The language of every plain text of the document, as a language tag. When strings is present it has a member for this tag.",
          "type": "string"
        },
        "strings": {
          "description": "Language tag to the table of that language: key to entry.",
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "propertyNames": { "$ref": "#/$defs/localizationKey" },
            "additionalProperties": { "$ref": "#/$defs/localizationEntry" }
          }
        },
        "notes": {
          "description": "Key to a note for whoever translates the key's text: what it is for and what each blank holds. Never shown to a person using the app.",
          "type": "object",
          "propertyNames": { "$ref": "#/$defs/localizationKey" },
          "additionalProperties": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          }
        }
      },
      "additionalProperties": false
    },
    "localizationKey": {
      "title": "text key",
      "description": "The key of a text: an ASCII letter, then ASCII letters, digits, _ or ., at most 80 characters in all. Case matters; dots only group names for a reader.",
      "type": "string",
      "pattern": "^[A-Za-z][A-Za-z0-9_.]{0,79}$"
    },
    "localizationEntry": {
      "title": "text entry",
      "description": "A text, which may hold blanks written {name}, or forms: the text chosen by the value of the blank named by.",
      "oneOf": [
        { "type": "string" },
        {
          "type": "object",
          "required": ["by", "forms"],
          "properties": {
            "by": {
              "description": "The name of the blank whose value chooses the form.",
              "type": "string"
            },
            "forms": {
              "description": "Form key to text: other, a plural category name, = and a number, or an exact text.",
              "type": "object",
              "additionalProperties": { "type": "string" }
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "assetName": {
      "title": "asset name",
      "description": "The name of an asset: a name, at most 64 characters.",
      "type": "string",
      "$ref": "common.schema.json#/$defs/name",
      "maxLength": 64
    },
    "asset": {
      "title": "asset",
      "description": "A picture that is part of the app. digest says which bytes it is; data, when present, carries those bytes. An entry without data is valid: a host that holds bytes with that digest shows the asset.",
      "type": "object",
      "required": ["type", "digest"],
      "properties": {
        "type": {
          "description": "The media type of the picture.",
          "enum": ["image/png", "image/jpeg", "image/webp", "image/gif"]
        },
        "digest": {
          "description": "The digest of the picture's bytes.",
          "$ref": "common.schema.json#/$defs/digest"
        },
        "data": {
          "title": "base64 text",
          "description": "The picture's bytes as base64 (RFC 4648 section 4): the standard alphabet, with padding, no line breaks and no other characters, and zero bits where padding leaves bits unused, so that the same bytes always give the same text.",
          "type": "string",
          "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/][AQgw]==|[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=)?$"
        },
        "width": {
          "description": "The picture's width in pixels as it shows: as its own header gives it, or its height when its EXIF orientation turns it a quarter.",
          "type": "integer",
          "minimum": 1,
          "maximum": 4096
        },
        "height": {
          "description": "The picture's height in pixels as it shows: as its own header gives it, or its width when its EXIF orientation turns it a quarter.",
          "type": "integer",
          "minimum": 1,
          "maximum": 4096
        },
        "source": {
          "title": "http or https address",
          "description": "The absolute http or https address the bytes came from, for people. A host never loads it.",
          "type": "string",
          "pattern": "^[Hh][Tt][Tt][Pp][Ss]?://[^\\s/?#]+(?:[/?#][^\\s]*)?$"
        },
        "credit": {
          "title": "one line of text",
          "description": "One line that credits the author and the license, for a host to show where it tells about the app.",
          "type": "string",
          "minLength": 1,
          "maxLength": 300,
          "pattern": "^[^\\n\\r\\u2028\\u2029]*$"
        }
      },
      "additionalProperties": false
    },
    "meta": {
      "title": "meta",
      "description": "Descriptive information about the app.",
      "type": "object",
      "required": ["name", "description"],
      "properties": {
        "name": {
          "description": "Human-readable name of the app.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "description": {
          "description": "Plain-language description of what the app does.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "authors": {
          "description": "Authors of the definition.",
          "type": "array",
          "items": { "$ref": "common.schema.json#/$defs/text" }
        },
        "license": {
          "description": "License of the definition, as an SPDX expression.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "tags": {
          "description": "Free-form tags that help people and agents find the app.",
          "type": "array",
          "items": { "$ref": "common.schema.json#/$defs/text" },
          "uniqueItems": true
        },
        "icon": {
          "description": "A name of the core catalog's icon vocabulary (its type IconName), as an icon control's name takes. A host that does not know the name shows no symbol.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "homepage": {
          "description": "Home page of the app, as an absolute URI.",
          "$ref": "common.schema.json#/$defs/uri"
        },
        "derivedFrom": {
          "description": "The definition this one was forked or remixed from.",
          "$ref": "#/$defs/derivedFrom"
        }
      },
      "additionalProperties": false
    },
    "derivedFrom": {
      "title": "derived from",
      "description": "Identity of the definition this one was forked or remixed from.",
      "type": "object",
      "required": ["id", "version"],
      "properties": {
        "id": {
          "description": "Id of the original definition.",
          "$ref": "common.schema.json#/$defs/reverseDnsId"
        },
        "version": {
          "description": "Version of the original definition.",
          "$ref": "common.schema.json#/$defs/semver"
        },
        "digest": {
          "description": "Optional digest pinning the exact content of the original definition.",
          "$ref": "common.schema.json#/$defs/digest"
        }
      },
      "additionalProperties": false
    },
    "uses": {
      "title": "uses",
      "description": "References to catalogs, other definitions and a design system.",
      "type": "object",
      "properties": {
        "catalogs": {
          "description": "Maps a local alias to a catalog id and semver range. Contracts are referenced as alias:contractName.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "common.schema.json#/$defs/versionedReference" }
        },
        "definitions": {
          "description": "Maps a local alias to another definition, by id and semver range.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "#/$defs/definitionUse" }
        },
        "design": {
          "description": "Optional reference to a design system, or null for none.",
          "oneOf": [
            { "$ref": "#/$defs/noValue" },
            { "$ref": "common.schema.json#/$defs/versionedReference" }
          ]
        }
      },
      "additionalProperties": false
    },
    "noValue": {
      "title": "null",
      "description": "The JSON null value.",
      "type": "null"
    },
    "definitionUse": {
      "title": "definition reference",
      "description": "A reference to another definition used as a part.",
      "type": "object",
      "required": ["id", "version"],
      "properties": {
        "id": {
          "description": "Id of the referenced definition.",
          "$ref": "common.schema.json#/$defs/reverseDnsId"
        },
        "version": {
          "description": "Semantic version range of the referenced definition.",
          "$ref": "common.schema.json#/$defs/semverRange"
        },
        "digest": {
          "description": "Optional digest that pins exact content.",
          "$ref": "common.schema.json#/$defs/digest"
        },
        "source": {
          "description": "Optional URI hint for where to fetch the definition.",
          "$ref": "common.schema.json#/$defs/uriReference"
        }
      },
      "additionalProperties": false
    },
    "role": {
      "title": "role",
      "description": "A role name the app's guards refer to. The host, never the definition, decides who holds it.",
      "type": "object",
      "properties": {
        "description": {
          "description": "Plain-language description of the role. Required.",
          "$ref": "common.schema.json#/$defs/text"
        }
      },
      "additionalProperties": false,
      "required": ["description"]
    },
    "capability": {
      "title": "capability",
      "description": "A capability request: typed access to something outside the app, named by contract.",
      "type": "object",
      "required": ["contract", "description"],
      "properties": {
        "contract": {
          "description": "alias:name of a capability contract. Required.",
          "$ref": "common.schema.json#/$defs/contractRef"
        },
        "description": {
          "description": "Why the app uses it, in plain language. Required.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "config": {
          "description": "Dynamic value matching the contract's config field map, with only env in scope. Evaluated once, when the capability is bound for the instance. A required field may be left out for the host to supply.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "required": {
          "description": "Default true. When false, the app loads without it and capabilities.<name>.available is false in expressions.",
          "type": "boolean"
        },
        "prefer": {
          "description": "Optional ordered list of provider ids. A preference, never a requirement.",
          "type": "array",
          "items": { "$ref": "common.schema.json#/$defs/reverseDnsId" },
          "uniqueItems": true
        }
      },
      "additionalProperties": false
    },
    "rate": {
      "title": "rate",
      "description": "A rate limit: at most count operations per ISO 8601 duration.",
      "type": "object",
      "required": ["count", "per"],
      "properties": {
        "count": {
          "description": "Maximum number of operations in each period.",
          "type": "integer",
          "minimum": 1
        },
        "per": {
          "description": "The period, as an ISO 8601 duration.",
          "$ref": "common.schema.json#/$defs/isoDuration"
        }
      },
      "additionalProperties": false
    },
    "grant": {
      "title": "grant request",
      "description": "A permission the app asks for. Exactly one of capability or code names what the request covers.",
      "oneOf": [
        { "$ref": "#/$defs/capabilityGrant" },
        { "$ref": "#/$defs/codeGrant" }
      ]
    },
    "capabilityGrant": {
      "title": "capability grant request",
      "description": "A request to use operations of a capability.",
      "type": "object",
      "required": ["capability", "scopes", "reason"],
      "properties": {
        "capability": {
          "description": "The capability alias the request covers.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "scopes": {
          "description": "Scope names defined by the contract. Required and non-empty.",
          "type": "array",
          "items": { "$ref": "common.schema.json#/$defs/scopeName" },
          "minItems": 1,
          "uniqueItems": true
        },
        "operations": {
          "description": "Optional non-empty list of names of operations and events of the capability. The issued grant then covers only those, within its scopes.",
          "$ref": "#/$defs/operationNameList"
        },
        "reason": {
          "description": "Plain-language justification shown to the approver. Required.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "where": {
          "description": "Expression over input (the operation input, after the contract's defaults are applied) and env. A call is permitted only if it evaluates to true.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "rate": {
          "description": "Optional rate limit.",
          "$ref": "#/$defs/rate"
        },
        "duration": {
          "description": "Longest lifetime requested for the issued grant. Hosts may shorten it.",
          "$ref": "common.schema.json#/$defs/isoDuration"
        },
        "required": {
          "description": "Default true. When false, the app loads if the request is declined, and operations it would have covered fail with grant.denied.",
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "operationNameList": {
      "title": "operation list",
      "description": "A non-empty list of distinct operation and event names of a capability.",
      "type": "array",
      "items": { "$ref": "common.schema.json#/$defs/name" },
      "minItems": 1,
      "uniqueItems": true
    },
    "codeGrant": {
      "title": "code grant request",
      "description": "A request to run a sandboxed code module.",
      "type": "object",
      "required": ["code", "reason"],
      "properties": {
        "code": {
          "description": "The code module name the request covers.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "reason": {
          "description": "Plain-language justification shown to the approver. Required.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "rate": {
          "description": "Optional rate limit.",
          "$ref": "#/$defs/rate"
        },
        "duration": {
          "description": "Longest lifetime requested for the issued grant. Hosts may shorten it.",
          "$ref": "common.schema.json#/$defs/isoDuration"
        },
        "required": {
          "description": "Default true. When false, the app loads if the request is declined.",
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "stateEntry": {
      "title": "state entry",
      "description": "A named, typed value. Exactly one of three kinds: stored (initial, or no kind key), derived (derive) or sourced (source).",
      "oneOf": [
        { "$ref": "#/$defs/storedState" },
        { "$ref": "#/$defs/derivedState" },
        { "$ref": "#/$defs/sourcedState" }
      ]
    },
    "storedState": {
      "title": "stored state",
      "description": "A stored value, written by steps and by two-way bindings; a shared entry only by actions. Starts as initial, or null when initial is absent.",
      "type": "object",
      "required": ["type"],
      "properties": {
        "type": {
          "description": "Type reference. Required.",
          "$ref": "common.schema.json#/$defs/typeRef"
        },
        "description": {
          "description": "Plain-language description. Recommended.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "initial": {
          "description": "Dynamic value with env in scope, evaluated once when the instance is created and stored, giving the starting value. Seed data; should be small.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "scope": {
          "description": "Where the value lives: session (one value per session), device (one value per person on each device), user (the default; one value per person, following them across devices) or shared (one value for the whole instance).",
          "enum": ["session", "device", "user", "shared"]
        },
        "sensitive": {
          "description": "Default false. When true, the value is kept out of view: redacted in audit records and not exposed on an agent surface unless resources.include names it.",
          "type": "boolean"
        },
        "internal": {
          "description": "Default false. When true, the entry is never an agent resource and never an export.",
          "type": "boolean"
        },
        "conflict": {
          "description": "For user and shared scope, how concurrent or offline writes resolve: lastWrite (the default), merge (top-level merge; list elements are matched by key) or reject (a stale write fails with state.conflict).",
          "enum": ["lastWrite", "merge", "reject"]
        },
        "key": {
          "description": "The field that identifies list elements when a list value is merged. Only with conflict merge.",
          "$ref": "common.schema.json#/$defs/name"
        }
      },
      "additionalProperties": false,
      "dependentSchemas": {
        "key": {
          "required": ["conflict"],
          "properties": {
            "conflict": {
              "description": "key is used only for list merges, so conflict must be merge.",
              "const": "merge"
            }
          }
        }
      },
      "if": {
        "type": "object",
        "required": ["scope"],
        "properties": {
          "scope": { "enum": ["session", "device"] }
        }
      },
      "then": {
        "properties": {
          "conflict": false,
          "key": false
        }
      }
    },
    "derivedState": {
      "title": "derived state",
      "description": "A read-only value recomputed when any value it reads changes.",
      "type": "object",
      "required": ["derive", "type"],
      "properties": {
        "derive": {
          "description": "Expression that computes the value.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "type": {
          "description": "Type reference. Required.",
          "$ref": "common.schema.json#/$defs/typeRef"
        },
        "description": {
          "description": "Plain-language description. Recommended.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "sensitive": {
          "description": "Whether the value is kept out of view. Without it, the entry is sensitive when it reads a sensitive entry; false states that the computed value may be shown.",
          "type": "boolean"
        },
        "internal": {
          "description": "Default false. When true, the entry is never an agent resource and never an export.",
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "sourcedState": {
      "title": "sourced state",
      "description": "A read-only value that is the output of a capability read operation, re-read per refresh.",
      "type": "object",
      "required": ["source", "type"],
      "properties": {
        "source": {
          "description": "The capability operation that supplies the value.",
          "$ref": "#/$defs/stateSource"
        },
        "type": {
          "description": "Type reference. Required.",
          "$ref": "common.schema.json#/$defs/typeRef"
        },
        "description": {
          "description": "Plain-language description. Recommended.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "sensitive": {
          "description": "Default false. When true, the value is kept out of view: redacted in audit records and not exposed on an agent surface unless resources.include names it.",
          "type": "boolean"
        },
        "internal": {
          "description": "Default false. When true, the entry is never an agent resource and never an export.",
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "operationRef": {
      "title": "operation reference",
      "description": "A capability operation, written alias.operation.",
      "type": "string",
      "pattern": "^(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*\\.(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*$"
    },
    "stateSource": {
      "title": "state source",
      "description": "A capability read operation whose output is the state value.",
      "type": "object",
      "required": ["call"],
      "properties": {
        "call": {
          "description": "The operation to call, as alias.operation. It must have effect read and not be interactive.",
          "$ref": "#/$defs/operationRef"
        },
        "with": {
          "description": "Dynamic value passed as the operation input.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "when": {
          "description": "Expression. The entry is read only while it is true; otherwise its status is idle and its value is kept.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "pages": {
          "description": "How many pages to read and join, from 1 to 50 (default 1). Above 1 the operation must declare paging.",
          "type": "integer",
          "minimum": 1,
          "maximum": 50
        },
        "refresh": {
          "description": "When the value is read again.",
          "$ref": "#/$defs/refresh"
        }
      },
      "additionalProperties": false
    },
    "refresh": {
      "title": "refresh",
      "description": "When a sourced value is read again. on defaults to open and change whenever it is absent, also when every is given.",
      "type": "object",
      "properties": {
        "every": {
          "description": "Interval between reads, as an ISO 8601 duration.",
          "$ref": "common.schema.json#/$defs/isoDuration"
        },
        "on": {
          "description": "Occasions that cause a read: open, change (when the value of with or when changes), or a capability event alias.event. Defaults to open and change.",
          "type": "array",
          "items": {
            "title": "refresh occasion",
            "type": "string",
            "pattern": "^(?:open|change|(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*\\.(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*)$"
          },
          "uniqueItems": true
        }
      },
      "additionalProperties": false
    },
    "action": {
      "title": "action",
      "description": "A named, typed, described operation.",
      "type": "object",
      "required": ["description", "steps"],
      "properties": {
        "description": {
          "description": "Required. Written for both people and agents.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "input": {
          "description": "Field map of the action's input. Default empty.",
          "$ref": "common.schema.json#/$defs/fieldMap"
        },
        "output": {
          "description": "Type reference of the value produced by return. An action that ends without return produces null.",
          "$ref": "common.schema.json#/$defs/typeRef"
        },
        "allow": {
          "description": "Expression guard: who may run the action. It sees input and the base roots. If present and not true, the invocation fails with action.forbidden.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "require": {
          "description": "What must hold for the action to be done now, checked in order after allow. The first entry whose that is not true fails the invocation with action.refused and that entry's message.",
          "type": "array",
          "items": { "$ref": "#/$defs/requirement" }
        },
        "confirm": {
          "description": "true, false (the default) or { message }. Whether a person must confirm before the action runs.",
          "$ref": "#/$defs/confirm"
        },
        "done": {
          "description": "{ message }: what to say to whoever invoked the action from outside, once it has been done. Optional.",
          "$ref": "#/$defs/done"
        },
        "internal": {
          "description": "Default false. When true, the action is callable only from steps inside this definition.",
          "type": "boolean"
        },
        "steps": {
          "description": "The steps the action runs, in order. Required.",
          "$ref": "#/$defs/steps"
        }
      },
      "additionalProperties": false
    },
    "requirement": {
      "title": "requirement",
      "description": "A condition the action needs, with the message given when it does not hold.",
      "type": "object",
      "required": ["that", "message"],
      "properties": {
        "that": {
          "description": "Expression that must be true. It sees what allow sees.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "message": {
          "description": "Dynamic value of the message carried by action.refused when that is not true, written to be shown to whoever asked. It sees what allow sees.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "confirm": {
      "title": "confirmation",
      "description": "true or false, or an object with a message shown to the person asked to confirm.",
      "oneOf": [
        { "$ref": "common.schema.json#/$defs/booleanFlag" },
        { "$ref": "#/$defs/confirmMessage" }
      ]
    },
    "confirmMessage": {
      "title": "confirmation with a message",
      "description": "Confirmation is asked, and the message is shown beside the action, its input and who is asking, marked as the app's own words.",
      "type": "object",
      "required": ["message"],
      "properties": {
        "message": {
          "description": "Dynamic value of the message, evaluated before asking with the roots allow sees.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "done": {
      "title": "done",
      "description": "What is said to whoever invoked the action from outside once it has been done: a person through a visual handler's run or a voice intent, or an agent through the agent surface.",
      "type": "object",
      "required": ["message"],
      "properties": {
        "message": {
          "description": "Dynamic value of the message, evaluated once after the steps succeeded, with the roots allow sees, the state as the steps left it, and output.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "actionRef": {
      "title": "action reference",
      "description": "An action in this definition, or partName.actionName for an exported action of a part.",
      "type": "string",
      "pattern": "^(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*(?:\\.(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*)?$"
    },
    "errorCode": {
      "title": "error code",
      "description": "A stable error code of the form area.problem: two or more names joined by dots, such as goal.invalid.",
      "type": "string",
      "pattern": "^(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*(?:\\.(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*)+$"
    },
    "steps": {
      "title": "steps",
      "description": "An array of steps, run in order.",
      "type": "array",
      "items": { "$ref": "#/$defs/step" }
    },
    "step": {
      "title": "step",
      "description": "One step of an action, rule or flow. The key that names the step kind (set, append, remove, patch, let, call, run, code, refresh, send, emit, if, each, return, fail) selects its shape.",
      "type": "object",
      "oneOf": [
        { "$ref": "#/$defs/setStep" },
        { "$ref": "#/$defs/appendStep" },
        { "$ref": "#/$defs/removeStep" },
        { "$ref": "#/$defs/patchStep" },
        { "$ref": "#/$defs/letStep" },
        { "$ref": "#/$defs/callStep" },
        { "$ref": "#/$defs/runStep" },
        { "$ref": "#/$defs/codeStep" },
        { "$ref": "#/$defs/refreshStep" },
        { "$ref": "#/$defs/sendStep" },
        { "$ref": "#/$defs/emitStep" },
        { "$ref": "#/$defs/ifStep" },
        { "$ref": "#/$defs/eachStep" },
        { "$ref": "#/$defs/returnStep" },
        { "$ref": "#/$defs/failStep" }
      ]
    },
    "setStep": {
      "title": "set step",
      "description": "Write a stored or view state value, or a field inside one.",
      "type": "object",
      "required": ["set", "to"],
      "properties": {
        "set": {
          "description": "Path of the location to write.",
          "$ref": "common.schema.json#/$defs/writeTarget"
        },
        "to": {
          "description": "Dynamic value to write.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "appendStep": {
      "title": "append step",
      "description": "Add an element to the end of a list.",
      "type": "object",
      "required": ["append", "value"],
      "properties": {
        "append": {
          "description": "Path of the list.",
          "$ref": "common.schema.json#/$defs/writeTarget"
        },
        "value": {
          "description": "Dynamic value of the element to add.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "removeStep": {
      "title": "remove step",
      "description": "Remove list elements for which the expression is true.",
      "type": "object",
      "required": ["remove", "where"],
      "properties": {
        "remove": {
          "description": "Path of the list.",
          "$ref": "common.schema.json#/$defs/writeTarget"
        },
        "where": {
          "description": "Expression with item and index (the element under test) in scope; matching elements are removed.",
          "$ref": "common.schema.json#/$defs/expression"
        }
      },
      "additionalProperties": false
    },
    "patchStep": {
      "title": "patch step",
      "description": "Shallow-merge an object into each matching list element, or, without where, into the object at the path.",
      "type": "object",
      "required": ["patch", "with"],
      "properties": {
        "patch": {
          "description": "Path of the list, or of the object when where is absent.",
          "$ref": "common.schema.json#/$defs/writeTarget"
        },
        "where": {
          "description": "Expression with item and index (the element under test) in scope selecting the elements to patch.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "with": {
          "description": "Dynamic value of the object to merge. With where, item and index are the element being patched.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "letStep": {
      "title": "let step",
      "description": "Bind a local name to a value for the steps that follow.",
      "type": "object",
      "required": ["let", "to"],
      "properties": {
        "let": {
          "description": "The local name to bind.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "to": {
          "description": "Dynamic value bound to the name.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "refreshStep": {
      "title": "refresh step",
      "description": "Ask for a sourced entry to be read again, without waiting for the result.",
      "type": "object",
      "required": ["refresh"],
      "properties": {
        "refresh": {
          "description": "state followed by the name of a sourced entry.",
          "$ref": "common.schema.json#/$defs/statePath"
        }
      },
      "additionalProperties": false
    },
    "callStep": {
      "title": "call step",
      "description": "Invoke a capability operation.",
      "type": "object",
      "required": ["call"],
      "properties": {
        "call": {
          "description": "The operation, as alias.operation.",
          "$ref": "#/$defs/operationRef"
        },
        "with": {
          "description": "Dynamic value passed as the operation input.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "once": {
          "description": "Dynamic value giving a string of 1 to 200 code points that names the effect, so the call takes effect at most once per key. Only on write and external operations.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "as": {
          "description": "Local name the output is bound to for later steps.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "onError": {
          "description": "Steps run if the call fails, with error ({ code, message }) in scope.",
          "$ref": "#/$defs/steps"
        },
        "orElse": {
          "description": "Dynamic value bound to as when the call fails, evaluated after any onError steps with error in scope. A step with orElse or onError handles its own failure and the steps after it run.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "runStep": {
      "title": "run step",
      "description": "Run another action in this definition, or an exported action of a part.",
      "type": "object",
      "required": ["run"],
      "properties": {
        "run": {
          "description": "actionName, or partName.actionName.",
          "$ref": "#/$defs/actionRef"
        },
        "with": {
          "description": "Dynamic value passed as the action input.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "as": {
          "description": "Local name the action output is bound to for later steps.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "onError": {
          "description": "Steps run if the action fails, with error ({ code, message }) in scope.",
          "$ref": "#/$defs/steps"
        },
        "orElse": {
          "description": "Dynamic value bound to as when the action fails, evaluated after any onError steps with error in scope. A step with orElse or onError handles its own failure and the steps after it run.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "codeStep": {
      "title": "code step",
      "description": "Run a sandboxed code module.",
      "type": "object",
      "required": ["code"],
      "properties": {
        "code": {
          "description": "The code module name.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "with": {
          "description": "Dynamic value passed as the module input.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "as": {
          "description": "Local name the module output is bound to for later steps.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "onError": {
          "description": "Steps run if the module fails, with error ({ code, message }) in scope.",
          "$ref": "#/$defs/steps"
        },
        "orElse": {
          "description": "Dynamic value bound to as when the module fails, evaluated after any onError steps with error in scope. A step with orElse or onError handles its own failure and the steps after it run.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "sendStep": {
      "title": "send step",
      "description": "Send an event to a flow instance.",
      "type": "object",
      "required": ["send", "to"],
      "properties": {
        "send": {
          "description": "The flow event name.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "to": {
          "description": "The flow name.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "key": {
          "description": "Dynamic value identifying the instance. Required for collection flows.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "with": {
          "description": "Dynamic value passed as the event payload.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "emitStep": {
      "title": "emit step",
      "description": "Raise an app event that rules can trigger on and parent definitions and agents can observe.",
      "type": "object",
      "required": ["emit"],
      "properties": {
        "emit": {
          "description": "The app event name.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "with": {
          "description": "Dynamic value of the event payload.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "ifStep": {
      "title": "if step",
      "description": "Branch on an expression.",
      "type": "object",
      "required": ["if", "then"],
      "properties": {
        "if": {
          "description": "The condition.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "then": {
          "description": "Steps run when the condition is true.",
          "$ref": "#/$defs/steps"
        },
        "else": {
          "description": "Optional steps run when the condition is not true.",
          "$ref": "#/$defs/steps"
        }
      },
      "additionalProperties": false
    },
    "eachStep": {
      "title": "each step",
      "description": "Run steps once per element of a finite list.",
      "type": "object",
      "required": ["each", "do"],
      "properties": {
        "each": {
          "description": "Expression giving the list to iterate.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "as": {
          "description": "Local name of the current element. Without it the element is item.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "indexAs": {
          "description": "Local name of the current position. Without it the position is index.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "do": {
          "description": "Steps run for each element.",
          "$ref": "#/$defs/steps"
        }
      },
      "additionalProperties": false
    },
    "returnStep": {
      "title": "return step",
      "description": "End the action with an output.",
      "type": "object",
      "required": ["return"],
      "properties": {
        "return": {
          "description": "Dynamic value of the output.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "failStep": {
      "title": "fail step",
      "description": "End the action with an error.",
      "type": "object",
      "required": ["fail", "message"],
      "properties": {
        "fail": {
          "description": "The error code.",
          "$ref": "#/$defs/errorCode"
        },
        "message": {
          "description": "Dynamic value of the human-readable error message.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "handler": {
      "title": "event handler",
      "description": "A visual event handler: a step or an array of steps. Handler steps may also navigate. A handler may hold only set, append, remove, patch, let, if, each, navigate, refresh and run steps; validation reports any other step kind (view.handlerStep).",
      "oneOf": [
        { "$ref": "#/$defs/handlerStep" },
        { "$ref": "#/$defs/handlerSteps" }
      ]
    },
    "handlerSteps": {
      "title": "handler steps",
      "description": "An array of steps inside a visual event handler, where navigate is also allowed.",
      "type": "array",
      "items": { "$ref": "#/$defs/handlerStep" }
    },
    "handlerStep": {
      "title": "handler step",
      "description": "One step inside a visual event handler: any step kind, plus navigate. Nested steps are handler steps too. Which kinds a handler may hold is checked by validation (view.handlerStep).",
      "type": "object",
      "oneOf": [
        { "$ref": "#/$defs/setStep" },
        { "$ref": "#/$defs/appendStep" },
        { "$ref": "#/$defs/removeStep" },
        { "$ref": "#/$defs/patchStep" },
        { "$ref": "#/$defs/letStep" },
        { "$ref": "#/$defs/handlerCallStep" },
        { "$ref": "#/$defs/handlerRunStep" },
        { "$ref": "#/$defs/handlerCodeStep" },
        { "$ref": "#/$defs/refreshStep" },
        { "$ref": "#/$defs/sendStep" },
        { "$ref": "#/$defs/emitStep" },
        { "$ref": "#/$defs/handlerIfStep" },
        { "$ref": "#/$defs/handlerEachStep" },
        { "$ref": "#/$defs/returnStep" },
        { "$ref": "#/$defs/failStep" },
        { "$ref": "#/$defs/navigateStep" }
      ]
    },
    "handlerCallStep": {
      "title": "call step",
      "description": "Invoke a capability operation, inside a visual event handler.",
      "type": "object",
      "required": ["call"],
      "properties": {
        "call": {
          "description": "The operation, as alias.operation.",
          "$ref": "#/$defs/operationRef"
        },
        "with": {
          "description": "Dynamic value passed as the operation input.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "once": {
          "description": "Dynamic value giving a string of 1 to 200 code points that names the effect, so the call takes effect at most once per key. Only on write and external operations.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "as": {
          "description": "Local name the output is bound to for later steps.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "onError": {
          "description": "Steps run if the call fails, with error ({ code, message }) in scope.",
          "$ref": "#/$defs/handlerSteps"
        },
        "orElse": {
          "description": "Dynamic value bound to as when the call fails, evaluated after any onError steps with error in scope. A step with orElse or onError handles its own failure and the steps after it run.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "handlerRunStep": {
      "title": "run step",
      "description": "Run an action, inside a visual event handler.",
      "type": "object",
      "required": ["run"],
      "properties": {
        "run": {
          "description": "actionName, or partName.actionName.",
          "$ref": "#/$defs/actionRef"
        },
        "with": {
          "description": "Dynamic value passed as the action input.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "as": {
          "description": "Local name the action output is bound to for later steps.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "onError": {
          "description": "Steps run if the action fails, with error ({ code, message }) in scope.",
          "$ref": "#/$defs/handlerSteps"
        },
        "orElse": {
          "description": "Dynamic value bound to as when the action fails, evaluated after any onError steps with error in scope. A step with orElse or onError handles its own failure and the steps after it run.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "handlerCodeStep": {
      "title": "code step",
      "description": "Run a sandboxed code module, inside a visual event handler.",
      "type": "object",
      "required": ["code"],
      "properties": {
        "code": {
          "description": "The code module name.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "with": {
          "description": "Dynamic value passed as the module input.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "as": {
          "description": "Local name the module output is bound to for later steps.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "onError": {
          "description": "Steps run if the module fails, with error ({ code, message }) in scope.",
          "$ref": "#/$defs/handlerSteps"
        },
        "orElse": {
          "description": "Dynamic value bound to as when the module fails, evaluated after any onError steps with error in scope. A step with orElse or onError handles its own failure and the steps after it run.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    },
    "handlerIfStep": {
      "title": "if step",
      "description": "Branch on an expression, inside a visual event handler.",
      "type": "object",
      "required": ["if", "then"],
      "properties": {
        "if": {
          "description": "The condition.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "then": {
          "description": "Steps run when the condition is true.",
          "$ref": "#/$defs/handlerSteps"
        },
        "else": {
          "description": "Optional steps run when the condition is not true.",
          "$ref": "#/$defs/handlerSteps"
        }
      },
      "additionalProperties": false
    },
    "handlerEachStep": {
      "title": "each step",
      "description": "Run steps once per element of a finite list, inside a visual event handler.",
      "type": "object",
      "required": ["each", "do"],
      "properties": {
        "each": {
          "description": "Expression giving the list to iterate.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "as": {
          "description": "Local name of the current element. Without it the element is item.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "indexAs": {
          "description": "Local name of the current position. Without it the position is index.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "do": {
          "description": "Steps run for each element.",
          "$ref": "#/$defs/handlerSteps"
        }
      },
      "additionalProperties": false
    },
    "navigateStep": {
      "title": "navigate step",
      "description": "Navigate to a view, or back. Available only in visual event handlers.",
      "type": "object",
      "required": ["navigate"],
      "properties": {
        "navigate": {
          "description": "The view name, or back to close the current view.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "with": {
          "description": "Dynamic value passed as the target view's input.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false,
      "if": {
        "type": "object",
        "required": ["navigate"],
        "properties": {
          "navigate": { "const": "back" }
        }
      },
      "then": {
        "properties": { "with": false }
      }
    },
    "rule": {
      "title": "rule",
      "description": "When a trigger fires and the optional guard holds, run steps.",
      "type": "object",
      "required": ["description", "when", "do"],
      "properties": {
        "description": {
          "description": "Plain-language description of the rule. Required.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "when": {
          "description": "Exactly one trigger.",
          "$ref": "#/$defs/trigger"
        },
        "if": {
          "description": "Optional expression guard.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "do": {
          "description": "Steps run as an anonymous internal action.",
          "$ref": "#/$defs/steps"
        }
      },
      "additionalProperties": false
    },
    "trigger": {
      "title": "trigger",
      "description": "Exactly one of becomes, changes, event, every or lifecycle.",
      "type": "object",
      "oneOf": [
        { "$ref": "#/$defs/becomesTrigger" },
        { "$ref": "#/$defs/changesTrigger" },
        { "$ref": "#/$defs/eventTrigger" },
        { "$ref": "#/$defs/everyTrigger" },
        { "$ref": "#/$defs/lifecycleTrigger" }
      ]
    },
    "becomesTrigger": {
      "title": "becomes trigger",
      "description": "Fires when the expression changes from not-true to true (edge-triggered).",
      "type": "object",
      "required": ["becomes"],
      "properties": {
        "becomes": {
          "description": "The expression watched for becoming true.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "initial": {
          "description": "When true, also fires when a session opens while the expression is true, in that session.",
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "changesTrigger": {
      "title": "changes trigger",
      "description": "Fires when the value at a state path changes. event is { previous, current }.",
      "type": "object",
      "required": ["changes"],
      "properties": {
        "changes": {
          "description": "The state path watched for changes.",
          "$ref": "common.schema.json#/$defs/statePath"
        }
      },
      "additionalProperties": false
    },
    "eventTrigger": {
      "title": "event trigger",
      "description": "Fires on an app event raised by emit, a capability event alias.event, an action completion action:name, a flow transition flow:name, or a part's exported event part.name. event is the payload.",
      "type": "object",
      "required": ["event"],
      "properties": {
        "event": {
          "description": "The event: name, alias.event, part.name, action:name or flow:name.",
          "title": "event reference",
          "type": "string",
          "pattern": "^(?:(?:action|flow):(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*|(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*(?:\\.(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*)?)$"
        }
      },
      "additionalProperties": false
    },
    "everyTrigger": {
      "title": "every trigger",
      "description": "Fires repeatedly at an interval while the app is active, first one interval after the trigger starts running.",
      "type": "object",
      "required": ["every"],
      "properties": {
        "every": {
          "description": "The interval, as an ISO 8601 duration.",
          "$ref": "common.schema.json#/$defs/isoDuration"
        },
        "foreground": {
          "description": "When true, the rule runs only while a person has a surface of the app open, also when the app holds a background grant, and no background grant is expected for it.",
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "lifecycleTrigger": {
      "title": "lifecycle trigger",
      "description": "Fires at a point in the app's life.",
      "type": "object",
      "required": ["lifecycle"],
      "properties": {
        "lifecycle": {
          "description": "install (the first load of an instance), open (a session's first surface opens) or close (its last surface closes).",
          "enum": ["install", "open", "close"]
        }
      },
      "additionalProperties": false
    },
    "flow": {
      "title": "flow",
      "description": "A finite state machine. Without over, a singleton; with over, one instance per element of a stored list.",
      "type": "object",
      "required": ["description", "initial", "states"],
      "properties": {
        "description": {
          "description": "Plain-language description of the flow. Required.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "over": {
          "description": "Makes this a collection flow over a stored list.",
          "$ref": "#/$defs/flowOver"
        },
        "initial": {
          "description": "The state a new instance starts in.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "states": {
          "description": "The flow's states, keyed by state name.",
          "type": "object",
          "minProperties": 1,
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "#/$defs/flowState" }
        }
      },
      "additionalProperties": false
    },
    "flowOver": {
      "title": "flow collection",
      "description": "The stored list a collection flow runs over.",
      "type": "object",
      "required": ["collection", "key", "field"],
      "properties": {
        "collection": {
          "description": "Path of the stored list.",
          "$ref": "common.schema.json#/$defs/statePath"
        },
        "key": {
          "description": "The element's identity field.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "field": {
          "description": "The element field that holds the current flow state.",
          "$ref": "common.schema.json#/$defs/name"
        }
      },
      "additionalProperties": false
    },
    "flowState": {
      "title": "flow state",
      "description": "One state of a flow.",
      "type": "object",
      "properties": {
        "description": {
          "description": "Plain-language description of the state.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "on": {
          "description": "Event name to a transition, or an ordered array of transitions; the first whose if is true (or absent) is taken.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "#/$defs/transitions" }
        },
        "after": {
          "description": "ISO 8601 duration to a transition taken if the instance stays in the state that long.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/isoDuration" },
          "additionalProperties": { "$ref": "#/$defs/transition" }
        },
        "enter": {
          "description": "Steps run when the state is entered.",
          "$ref": "#/$defs/steps"
        },
        "exit": {
          "description": "Steps run when the state is left.",
          "$ref": "#/$defs/steps"
        },
        "final": {
          "description": "When true, the state has no outgoing transitions.",
          "type": "boolean"
        }
      },
      "additionalProperties": false,
      "if": {
        "type": "object",
        "required": ["final"],
        "properties": {
          "final": { "const": true }
        }
      },
      "then": {
        "properties": {
          "on": false,
          "after": false
        }
      }
    },
    "transitions": {
      "title": "transitions",
      "description": "A transition, or an ordered non-empty array of transitions.",
      "oneOf": [
        { "$ref": "#/$defs/transition" },
        { "$ref": "#/$defs/transitionList" }
      ]
    },
    "transitionList": {
      "title": "transition list",
      "description": "An ordered array of candidate transitions; the first whose if is true (or absent) is taken.",
      "type": "array",
      "items": { "$ref": "#/$defs/transition" },
      "minItems": 1
    },
    "transition": {
      "title": "transition",
      "description": "A move to another state.",
      "type": "object",
      "required": ["to"],
      "properties": {
        "to": {
          "description": "The target state. Required.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "if": {
          "description": "Expression; when false, the next candidate transition is considered.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "allow": {
          "description": "Expression guard; failing it is flow.forbidden.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "do": {
          "description": "Steps run on the transition, after the source exit and before the target enter.",
          "$ref": "#/$defs/steps"
        }
      },
      "additionalProperties": false
    },
    "codeModule": {
      "title": "code module",
      "description": "A sandboxed pure function. Exactly one of source (inline text) or module (external reference).",
      "type": "object",
      "oneOf": [
        { "$ref": "#/$defs/inlineCodeModule" },
        { "$ref": "#/$defs/externalCodeModule" }
      ]
    },
    "inlineCodeModule": {
      "title": "inline code module",
      "description": "A code module whose text is held inline in source.",
      "type": "object",
      "required": ["source", "description", "runtime"],
      "properties": {
        "source": {
          "description": "The module text, inline.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "description": {
          "description": "Plain-language description of the module. Required.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "runtime": {
          "description": "js: an ECMAScript module whose default export is the function. wasm is reserved and not valid in 0.2.",
          "const": "js"
        },
        "input": {
          "description": "Field map of the function input.",
          "$ref": "common.schema.json#/$defs/fieldMap"
        },
        "output": {
          "description": "Type reference of the function output.",
          "$ref": "common.schema.json#/$defs/typeRef"
        },
        "limits": {
          "description": "Resource limits the host enforces.",
          "$ref": "#/$defs/codeLimits"
        }
      },
      "additionalProperties": false
    },
    "externalCodeModule": {
      "title": "external code module",
      "description": "A code module whose text is fetched from a URI and pinned by digest.",
      "type": "object",
      "required": ["module", "description", "runtime"],
      "properties": {
        "module": {
          "description": "Where to fetch the module and the digest of its content.",
          "$ref": "#/$defs/moduleRef"
        },
        "description": {
          "description": "Plain-language description of the module. Required.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "runtime": {
          "description": "js: an ECMAScript module whose default export is the function. wasm is reserved and not valid in 0.2.",
          "const": "js"
        },
        "input": {
          "description": "Field map of the function input.",
          "$ref": "common.schema.json#/$defs/fieldMap"
        },
        "output": {
          "description": "Type reference of the function output.",
          "$ref": "common.schema.json#/$defs/typeRef"
        },
        "limits": {
          "description": "Resource limits the host enforces.",
          "$ref": "#/$defs/codeLimits"
        }
      },
      "additionalProperties": false
    },
    "moduleRef": {
      "title": "module reference",
      "description": "An external module: its URI and content digest.",
      "type": "object",
      "required": ["uri", "digest"],
      "properties": {
        "uri": {
          "description": "Where the module text is fetched from.",
          "$ref": "common.schema.json#/$defs/uriReference"
        },
        "digest": {
          "description": "Digest of the module's bytes.",
          "$ref": "common.schema.json#/$defs/digest"
        }
      },
      "additionalProperties": false
    },
    "codeLimits": {
      "title": "code limits",
      "description": "Resource limits for a code module. Defaults: 100 ms, 32 MB.",
      "type": "object",
      "properties": {
        "timeMs": {
          "description": "Maximum run time in milliseconds.",
          "type": "integer",
          "minimum": 1
        },
        "memoryMb": {
          "description": "Maximum memory in megabytes.",
          "type": "integer",
          "minimum": 1
        }
      },
      "additionalProperties": false
    },
    "part": {
      "title": "part",
      "description": "Another definition included in this one.",
      "type": "object",
      "required": ["definition"],
      "properties": {
        "definition": {
          "description": "Alias of the included definition in uses.definitions.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "with": {
          "description": "Maps each of the part's exported input names to a dynamic value that drives it reactively.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "common.schema.json#/$defs/dynamicValue" }
        },
        "capabilities": {
          "description": "Maps each of the part's capability aliases to one of the parent's.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "common.schema.json#/$defs/name" }
        },
        "grants": {
          "description": "Attenuates the part's grant requests, keyed by the part's grant name, or declines one with false.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "#/$defs/partGrant" }
        }
      },
      "additionalProperties": false
    },
    "partGrant": {
      "title": "part grant adjustment",
      "description": "false to decline the part's grant request, or an attenuation of it.",
      "oneOf": [
        { "$ref": "#/$defs/declined" },
        { "$ref": "#/$defs/grantAttenuation" }
      ]
    },
    "declined": {
      "title": "declined",
      "description": "false: the request is declined.",
      "type": "boolean",
      "const": false
    },
    "grantAttenuation": {
      "title": "grant attenuation",
      "description": "A narrowing of a part's grant request: an additional where, a lower rate, a shorter duration, fewer scopes or a shorter operations list.",
      "type": "object",
      "properties": {
        "where": {
          "description": "An additional expression over input, combined with the part's own where by logical and.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "rate": {
          "description": "A lower rate limit.",
          "$ref": "#/$defs/rate"
        },
        "duration": {
          "description": "A shorter longest lifetime.",
          "$ref": "common.schema.json#/$defs/isoDuration"
        },
        "scopes": {
          "description": "A subset of the requested scopes.",
          "type": "array",
          "items": { "$ref": "common.schema.json#/$defs/scopeName" },
          "minItems": 1,
          "uniqueItems": true
        },
        "operations": {
          "description": "A subset of the operations and events the request covers.",
          "$ref": "#/$defs/operationNameList"
        }
      },
      "additionalProperties": false
    },
    "nameList": {
      "title": "name list",
      "description": "A list of distinct names.",
      "type": "array",
      "items": { "$ref": "common.schema.json#/$defs/name" },
      "uniqueItems": true
    },
    "exports": {
      "title": "exports",
      "description": "What a definition offers to a parent that includes it. Everything else is private.",
      "type": "object",
      "properties": {
        "inputs": {
          "description": "Maps an input name to a stored state path in this definition, which the parent's with drives.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "common.schema.json#/$defs/statePath" }
        },
        "state": {
          "description": "State entries readable by the parent as parts.<part>.state.<name>.",
          "$ref": "#/$defs/nameList"
        },
        "actions": {
          "description": "Actions the parent may run as <part>.<action>.",
          "$ref": "#/$defs/nameList"
        },
        "events": {
          "description": "App events the parent may trigger on as <part>.<event>.",
          "$ref": "#/$defs/nameList"
        },
        "views": {
          "description": "Views the parent may embed with a part node.",
          "$ref": "#/$defs/nameList"
        }
      },
      "additionalProperties": false
    },
    "surfaces": {
      "title": "surfaces",
      "description": "Projections of the kernel. Every surface is optional and none holds logic.",
      "type": "object",
      "properties": {
        "agent": {
          "description": "Projects actions into callable tools and state into readable resources.",
          "$ref": "#/$defs/agentSurface"
        },
        "visual": {
          "description": "Projects state into controls and events into actions.",
          "$ref": "#/$defs/visualSurface"
        },
        "voice": {
          "description": "Projects actions into intents. Less proven than the agent and visual surfaces; its shape may change.",
          "$ref": "#/$defs/voiceSurface"
        }
      },
      "additionalProperties": false
    },
    "exposedName": {
      "title": "name or part.name",
      "description": "A name in this definition, or part.name for an action, state entry or event that a part exports.",
      "type": "string",
      "pattern": "^(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*(?:\\.(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*)?$"
    },
    "exposedNameList": {
      "title": "include list",
      "description": "A list of distinct names, each a name in this definition or part.name for something a part exports.",
      "type": "array",
      "items": { "$ref": "#/$defs/exposedName" },
      "uniqueItems": true
    },
    "includeOrExclude": {
      "title": "include or exclude",
      "description": "Narrows a set by include or exclude, not both.",
      "type": "object",
      "properties": {
        "include": {
          "description": "Only these names are included. A name may be part.name for something a part exports.",
          "$ref": "#/$defs/exposedNameList"
        },
        "exclude": {
          "description": "These names are excluded.",
          "$ref": "#/$defs/nameList"
        }
      },
      "additionalProperties": false,
      "dependentSchemas": {
        "include": {
          "properties": { "exclude": false }
        }
      }
    },
    "agentSurface": {
      "title": "agent surface",
      "description": "An agent surface. An empty object is a complete agent surface.",
      "type": "object",
      "properties": {
        "instructions": {
          "description": "Guidance for agents using the app.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "tools": {
          "description": "Narrows which non-internal actions are tools, and overrides descriptions for agent readers.",
          "type": "object",
          "properties": {
            "include": {
              "description": "Only these actions are tools. A name may be part.action for an action a part exports.",
              "$ref": "#/$defs/exposedNameList"
            },
            "exclude": {
              "description": "These actions are not tools.",
              "$ref": "#/$defs/nameList"
            },
            "describe": {
              "description": "Action name to a description that overrides the action's description for agent readers.",
              "type": "object",
              "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
              "additionalProperties": { "$ref": "common.schema.json#/$defs/text" }
            }
          },
          "additionalProperties": false,
          "dependentSchemas": {
            "include": {
              "properties": { "exclude": false }
            }
          }
        },
        "resources": {
          "description": "Narrows which state entries are readable resources. include is the only way to expose a sensitive entry, and never names an internal entry.",
          "$ref": "#/$defs/includeOrExclude"
        },
        "events": {
          "description": "App events observable by agents.",
          "type": "object",
          "properties": {
            "include": {
              "description": "The app events agents may observe: names raised by emit, flow:<name>, or part.name for an event a part exports.",
              "type": "array",
              "items": {
                "title": "agent event name",
                "type": "string",
                "pattern": "^(?:flow:(?!(?:true|false|null|in)$)[a-z][a-zA-Z0-9]*|(?!(?:true|false|null|in)(?![a-zA-Z0-9]))[a-z][a-zA-Z0-9]*(?:\\.(?!(?:true|false|null|in)$)[a-z][a-zA-Z0-9]*)?)$"
              },
              "uniqueItems": true
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "visualSurface": {
      "title": "visual surface",
      "description": "A visual surface: named views and the first view to show.",
      "type": "object",
      "required": ["start", "views"],
      "properties": {
        "start": {
          "description": "The name of the first view.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "views": {
          "description": "Views keyed by view name. back is reserved for navigation.",
          "type": "object",
          "minProperties": 1,
          "propertyNames": {
            "$ref": "common.schema.json#/$defs/name",
            "not": { "const": "back" }
          },
          "additionalProperties": { "$ref": "#/$defs/view" }
        },
        "navigation": {
          "description": "The app's main sections, in order: 1 to 12 entries (sections, repeated sections and groups) a host draws as the app's own navigation.",
          "type": "array",
          "minItems": 1,
          "maxItems": 12,
          "items": { "$ref": "#/$defs/navigationEntry" }
        }
      },
      "additionalProperties": false
    },
    "navigationEntry": {
      "title": "navigation entry",
      "description": "One entry of the app's main navigation: a section, a repeated section (a section with each) or a group of them under a heading.",
      "type": "object",
      "oneOf": [
        { "$ref": "#/$defs/navigationSection" },
        { "$ref": "#/$defs/navigationGroup" }
      ]
    },
    "navigationSection": {
      "title": "navigation section",
      "description": "One main section of the app: a view, the input it opens with, and the name it is shown under. With each, one section for each element of a list.",
      "type": "object",
      "required": ["view", "label"],
      "properties": {
        "view": {
          "description": "The name of a declared view. Two sections that have neither each nor with name different views.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "label": {
          "description": "The section's name, a dynamic value.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "icon": {
          "description": "A name of the core catalog's icon vocabulary, as meta.icon takes. A host that does not know the name shows no symbol.",
          "$ref": "common.schema.json#/$defs/text"
        },
        "when": {
          "description": "Expression; the section is offered only while it is true.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "with": {
          "description": "Dynamic value: the input the section opens its view with, as the with of a navigate step. Without it the view is opened with no input.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "count": {
          "description": "Dynamic value giving a whole number not below zero, or null: how many things wait in the section.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "each": {
          "description": "Offers the section once for each element of a list, as a node's each repeats the node.",
          "$ref": "#/$defs/nodeEach"
        }
      },
      "additionalProperties": false
    },
    "navigationGroup": {
      "title": "navigation group",
      "description": "Sections under a heading. A group holds no group.",
      "type": "object",
      "required": ["group", "sections"],
      "properties": {
        "group": {
          "description": "The group's heading, a dynamic value.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "when": {
          "description": "Expression; the group and its sections are offered only while it is true.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "sections": {
          "description": "The group's sections and repeated sections, in order: 1 to 12.",
          "type": "array",
          "minItems": 1,
          "maxItems": 12,
          "items": { "$ref": "#/$defs/navigationSection" }
        }
      },
      "additionalProperties": false
    },
    "view": {
      "title": "view",
      "description": "One view of a visual surface.",
      "type": "object",
      "required": ["body"],
      "properties": {
        "title": {
          "description": "Optional title, a dynamic value.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "input": {
          "description": "Field map of values passed on navigation, read as view.<name>.",
          "$ref": "common.schema.json#/$defs/fieldMap"
        },
        "state": {
          "description": "View state: values that belong to one visit of the view, read and written as view.<name>. Names must differ from the view's input fields.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "#/$defs/viewStateEntry" }
        },
        "body": {
          "description": "The root node of the view.",
          "$ref": "#/$defs/node"
        }
      },
      "additionalProperties": false
    },
    "viewStateEntry": {
      "title": "view state entry",
      "description": "A value that belongs to one visit of a view. Evaluated when the view opens and gone when the view leaves the navigation stack. Never seen by actions and never a resource.",
      "type": "object",
      "required": ["type"],
      "properties": {
        "type": {
          "description": "Type reference. Required.",
          "$ref": "common.schema.json#/$defs/typeRef"
        },
        "initial": {
          "description": "Dynamic value evaluated when the view opens, with the view's inputs, state, user and env in scope. Without it the entry starts as null.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "description": {
          "description": "Plain-language description.",
          "$ref": "common.schema.json#/$defs/text"
        }
      },
      "additionalProperties": false
    },
    "node": {
      "title": "node",
      "description": "A control node ({ control: alias:name, ... }) or a part node ({ part, view }).",
      "type": "object",
      "oneOf": [
        { "$ref": "#/$defs/controlNode" },
        { "$ref": "#/$defs/partNode" }
      ]
    },
    "controlNode": {
      "title": "control node",
      "description": "A node that renders a control contract.",
      "type": "object",
      "required": ["control"],
      "properties": {
        "control": {
          "description": "alias:name of a control contract. Required.",
          "$ref": "common.schema.json#/$defs/contractRef"
        },
        "id": {
          "description": "Optional name, unique within the view, giving the node a stable address.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "props": {
          "description": "Prop name to dynamic value, matching the contract's props.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "common.schema.json#/$defs/dynamicValue" }
        },
        "bind": {
          "description": "Bindable prop name or output name to a path into a stored state entry that is not shared, or into a view state entry. The path may select a list element. Two-way for a bindable prop; write-only for an output.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "common.schema.json#/$defs/bindTarget" }
        },
        "on": {
          "description": "Control event name to a step or array of steps. event holds the payload.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "#/$defs/handler" }
        },
        "children": {
          "description": "Child nodes, for controls whose contract accepts children.",
          "type": "array",
          "items": { "$ref": "#/$defs/node" }
        },
        "slots": {
          "description": "Slot name to a node, for controls with named template regions.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "#/$defs/node" }
        },
        "when": {
          "description": "Expression; the node exists only while it is true.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "each": {
          "description": "Repeats the node per element of a list.",
          "$ref": "#/$defs/nodeEach"
        },
        "fallback": {
          "description": "A complete node drawn instead if the host cannot provide the control. It takes nothing from the node it replaces except its place; the outer when and each apply to whichever is drawn.",
          "$ref": "#/$defs/node"
        }
      },
      "additionalProperties": false
    },
    "nodeEach": {
      "title": "node repetition",
      "description": "Repeats the node itself once per element. as defaults to item and indexAs to index; key is optional.",
      "type": "object",
      "required": ["in"],
      "properties": {
        "in": {
          "description": "Expression giving the list.",
          "$ref": "common.schema.json#/$defs/expression"
        },
        "as": {
          "description": "Local name of the current element. Defaults to item.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "indexAs": {
          "description": "Local name of the current position. Defaults to index.",
          "$ref": "common.schema.json#/$defs/localName"
        },
        "key": {
          "description": "Optional expression giving each element a stable identity across updates.",
          "$ref": "common.schema.json#/$defs/expression"
        }
      },
      "additionalProperties": false
    },
    "partNode": {
      "title": "part node",
      "description": "Embeds an exported view of a part. May also carry id and when, and nothing else.",
      "type": "object",
      "required": ["part", "view"],
      "properties": {
        "part": {
          "description": "The part name.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "view": {
          "description": "The exported view name.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "id": {
          "description": "Optional name, unique within the view, giving the node a stable address.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "when": {
          "description": "Expression; the node exists only while it is true.",
          "$ref": "common.schema.json#/$defs/expression"
        }
      },
      "additionalProperties": false
    },
    "voiceSurface": {
      "title": "voice surface",
      "description": "A voice surface. Less proven than the agent and visual surfaces; its shape may change.",
      "type": "object",
      "properties": {
        "greeting": {
          "description": "Dynamic value spoken when a voice session starts.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        },
        "intents": {
          "description": "Intents keyed by intent name.",
          "type": "object",
          "propertyNames": { "$ref": "common.schema.json#/$defs/name" },
          "additionalProperties": { "$ref": "#/$defs/voiceIntent" }
        },
        "announce": {
          "description": "App event name (an emit name or flow:<name>) to a dynamic value spoken when that event is raised while a voice session is active, with event in scope.",
          "type": "object",
          "propertyNames": {
            "title": "app event name",
            "type": "string",
            "pattern": "^(?:flow:)?(?!(?:true|false|null|in)$)[a-z][a-zA-Z0-9]*$"
          },
          "additionalProperties": { "$ref": "common.schema.json#/$defs/dynamicValue" }
        }
      },
      "additionalProperties": false
    },
    "voiceIntent": {
      "title": "voice intent",
      "description": "Phrases a person might say, the action they invoke, and what is said back. Without action the intent only replies.",
      "type": "object",
      "required": ["examples"],
      "properties": {
        "examples": {
          "description": "Phrases a person might say, at least one; {slot} placeholders each name an input field of the action. An intent without action has no slots.",
          "type": "array",
          "items": { "$ref": "common.schema.json#/$defs/text" },
          "minItems": 1
        },
        "action": {
          "description": "Optional. The action the intent invokes.",
          "$ref": "common.schema.json#/$defs/name"
        },
        "reply": {
          "description": "Dynamic value spoken after the action succeeds, with state as it is after the action, input, output, env and user in scope. Without action, input is {} and output is null.",
          "$ref": "common.schema.json#/$defs/dynamicValue"
        }
      },
      "additionalProperties": false
    }
  }
}
