{
  "$defs": {
    "app": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "kind": {
          "enum": [
            "internal_tool"
          ]
        },
        "root_route": {
          "maxLength": 96,
          "pattern": "^/[A-Za-z0-9_.~\\-/]*$",
          "type": "string"
        },
        "title": {
          "$ref": "#/$defs/safe_string"
        }
      },
      "required": [
        "id",
        "title",
        "kind",
        "root_route"
      ],
      "type": "object"
    },
    "app_bundle_v1": {
      "additionalProperties": false,
      "properties": {
        "app": {
          "$ref": "#/$defs/app"
        },
        "resources": {
          "$ref": "#/$defs/resources"
        },
        "routes": {
          "$ref": "#/$defs/routes"
        },
        "schema_version": {
          "const": 1
        },
        "screens": {
          "items": {
            "$ref": "#/$defs/screen_v1"
          },
          "maxItems": 16,
          "minItems": 1,
          "type": "array"
        }
      },
      "required": [
        "schema_version",
        "app",
        "routes",
        "resources",
        "screens"
      ],
      "type": "object"
    },
    "app_bundle_v2": {
      "additionalProperties": false,
      "properties": {
        "app": {
          "$ref": "#/$defs/app"
        },
        "resource_binding": {
          "const": "fixture_readonly_v0"
        },
        "resources": {
          "$ref": "#/$defs/resources"
        },
        "routes": {
          "$ref": "#/$defs/routes"
        },
        "schema_version": {
          "const": 2
        },
        "screens": {
          "items": {
            "$ref": "#/$defs/screen_v2"
          },
          "maxItems": 16,
          "minItems": 1,
          "type": "array"
        }
      },
      "required": [
        "schema_version",
        "resource_binding",
        "app",
        "routes",
        "resources",
        "screens"
      ],
      "type": "object"
    },
    "app_bundle_v3": {
      "additionalProperties": false,
      "properties": {
        "app": {
          "$ref": "#/$defs/app"
        },
        "interactive_state": {
          "const": "interactive_state_v0"
        },
        "mutations": {
          "$ref": "#/$defs/state_mutations"
        },
        "resource_binding": {
          "const": "fixture_readonly_v0"
        },
        "resources": {
          "$ref": "#/$defs/resources"
        },
        "routes": {
          "$ref": "#/$defs/routes"
        },
        "schema_version": {
          "const": 3
        },
        "screens": {
          "items": {
            "$ref": "#/$defs/screen_v2"
          },
          "maxItems": 16,
          "minItems": 1,
          "type": "array"
        },
        "selectors": {
          "$ref": "#/$defs/state_selectors"
        },
        "state": {
          "$ref": "#/$defs/state_entries"
        },
        "state_replay_assertions": {
          "$ref": "#/$defs/state_replay_assertions"
        }
      },
      "required": [
        "schema_version",
        "resource_binding",
        "interactive_state",
        "app",
        "routes",
        "resources",
        "screens",
        "state",
        "mutations",
        "selectors"
      ],
      "type": "object"
    },
    "app_bundle_v4": {
      "additionalProperties": false,
      "properties": {
        "app": {
          "$ref": "#/$defs/app"
        },
        "interactive_state": {
          "const": "interactive_state_v0"
        },
        "mutations": {
          "$ref": "#/$defs/state_mutations"
        },
        "resource_binding": {
          "const": "fixture_readonly_v0"
        },
        "resources": {
          "$ref": "#/$defs/resources"
        },
        "routes": {
          "$ref": "#/$defs/routes"
        },
        "schema_version": {
          "const": 4
        },
        "screens": {
          "items": {
            "$ref": "#/$defs/screen_v2"
          },
          "maxItems": 16,
          "minItems": 1,
          "type": "array"
        },
        "selectors": {
          "$ref": "#/$defs/state_selectors"
        },
        "state": {
          "$ref": "#/$defs/state_entries"
        },
        "state_replay_assertions": {
          "$ref": "#/$defs/state_replay_assertions_v4"
        },
        "state_text": {
          "$ref": "#/$defs/state_text_rules"
        },
        "visibility": {
          "$ref": "#/$defs/visibility_rules"
        }
      },
      "required": [
        "schema_version",
        "resource_binding",
        "interactive_state",
        "app",
        "routes",
        "resources",
        "screens",
        "state",
        "mutations",
        "selectors"
      ],
      "type": "object"
    },
    "app_bundle_v5": {
      "additionalProperties": false,
      "properties": {
        "app": {
          "$ref": "#/$defs/app"
        },
        "interactive_state": {
          "const": "interactive_state_v0"
        },
        "mutations": {
          "$ref": "#/$defs/state_mutations"
        },
        "resource_binding": {
          "const": "fixture_readonly_v0"
        },
        "resources": {
          "$ref": "#/$defs/resources"
        },
        "routes": {
          "$ref": "#/$defs/routes"
        },
        "schema_version": {
          "const": 5
        },
        "screens": {
          "items": {
            "$ref": "#/$defs/screen_v2"
          },
          "maxItems": 16,
          "minItems": 1,
          "type": "array"
        },
        "selectors": {
          "$ref": "#/$defs/state_selectors"
        },
        "state": {
          "$ref": "#/$defs/state_entries"
        },
        "state_replay_assertions": {
          "$ref": "#/$defs/state_replay_assertions_v5"
        },
        "state_text": {
          "$ref": "#/$defs/state_text_rules_v5"
        },
        "visibility": {
          "$ref": "#/$defs/visibility_rules_v5"
        }
      },
      "required": [
        "schema_version",
        "resource_binding",
        "interactive_state",
        "app",
        "routes",
        "resources",
        "screens",
        "state",
        "mutations",
        "selectors"
      ],
      "type": "object"
    },
    "fixture_record": {
      "additionalProperties": {
        "anyOf": [
          {
            "maxLength": 2048,
            "type": "string"
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "type": "null"
          }
        ]
      },
      "maxProperties": 32,
      "propertyNames": {
        "maxLength": 96,
        "pattern": "^[A-Za-z0-9_.-]+$"
      },
      "type": "object"
    },
    "intent_bundle": {
      "description": "Embedded local V1 IntentBundle. viewspec check and viewspec prove enforce the full local V1 validator.",
      "type": "object"
    },
    "json_scalar": {
      "anyOf": [
        {
          "maxLength": 2048,
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ]
    },
    "json_value": {
      "anyOf": [
        {
          "maxLength": 2048,
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "items": {
            "$ref": "#/$defs/json_value"
          },
          "maxItems": 100,
          "type": "array"
        },
        {
          "additionalProperties": {
            "$ref": "#/$defs/json_value"
          },
          "maxProperties": 32,
          "propertyNames": {
            "maxLength": 96,
            "pattern": "^[A-Za-z0-9_.-]+$"
          },
          "type": "object"
        }
      ]
    },
    "payload_expr": {
      "anyOf": [
        {
          "$ref": "#/$defs/json_value"
        },
        {
          "additionalProperties": false,
          "properties": {
            "from_payload": {
              "$ref": "#/$defs/safe_id"
            }
          },
          "required": [
            "from_payload"
          ],
          "type": "object"
        }
      ]
    },
    "presentation": {
      "additionalProperties": false,
      "description": "Shared static/React layout contract. operations_workspace keeps sibling sidebar/main regions visible, stacks them at compact/medium, and uses a wide rail/content row.",
      "properties": {
        "anchors": {
          "items": {
            "$ref": "#/$defs/presentation_anchor"
          },
          "maxItems": 64,
          "type": "array"
        },
        "profile": {
          "enum": [
            "neutral",
            "operations_workspace",
            "editorial_dashboard"
          ]
        },
        "rules": {
          "items": {
            "$ref": "#/$defs/presentation_rule"
          },
          "maxItems": 96,
          "type": "array"
        }
      },
      "type": "object"
    },
    "presentation_anchor": {
      "additionalProperties": false,
      "description": "Responsive semantic geometry assertion. Scope viewports to widths where the relation is true; a rail/content same_row relation is normally wide-only when compact and medium stack.",
      "properties": {
        "anchor_ref": {
          "$ref": "#/$defs/presentation_target_ref"
        },
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "relation": {
          "enum": [
            "inside",
            "before",
            "after",
            "aligned_start",
            "aligned_center",
            "same_row"
          ]
        },
        "target_ref": {
          "$ref": "#/$defs/presentation_target_ref"
        },
        "viewports": {
          "items": {
            "enum": [
              "compact",
              "medium",
              "wide"
            ]
          },
          "maxItems": 3,
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        }
      },
      "required": [
        "id",
        "target_ref",
        "relation",
        "anchor_ref"
      ],
      "type": "object"
    },
    "presentation_item_layout": {
      "additionalProperties": false,
      "properties": {
        "base": {
          "$ref": "#/$defs/presentation_layout"
        },
        "variants": {
          "additionalProperties": false,
          "properties": {
            "compact": {
              "$ref": "#/$defs/presentation_layout"
            },
            "medium": {
              "$ref": "#/$defs/presentation_layout"
            },
            "wide": {
              "$ref": "#/$defs/presentation_layout"
            }
          },
          "type": "object"
        }
      },
      "type": "object"
    },
    "presentation_layout": {
      "additionalProperties": false,
      "properties": {
        "align": {
          "enum": [
            "start",
            "center",
            "end",
            "stretch"
          ]
        },
        "area": {
          "$ref": "#/$defs/safe_id"
        },
        "areas": {
          "items": {
            "items": {
              "$ref": "#/$defs/safe_id"
            },
            "maxItems": 4,
            "minItems": 1,
            "type": "array"
          },
          "maxItems": 4,
          "minItems": 1,
          "type": "array"
        },
        "background": {
          "enum": [
            "transparent",
            "canvas",
            "surface",
            "sidebar",
            "subtle",
            "accent",
            "danger_subtle"
          ]
        },
        "border": {
          "enum": [
            "none",
            "subtle",
            "strong"
          ]
        },
        "columns": {
          "oneOf": [
            {
              "maximum": 4,
              "minimum": 1,
              "type": "integer"
            },
            {
              "items": {
                "enum": [
                  "auto",
                  "fluid",
                  "fluid_wide",
                  "content_sm",
                  "content_md",
                  "identity_sm",
                  "identity_md",
                  "identity_lg",
                  "rail_sm",
                  "rail_md",
                  "rail_lg"
                ]
              },
              "maxItems": 4,
              "minItems": 1,
              "type": "array"
            }
          ]
        },
        "direction": {
          "enum": [
            "row",
            "column"
          ]
        },
        "display": {
          "enum": [
            "block",
            "flex",
            "grid",
            "none"
          ]
        },
        "font_family": {
          "enum": [
            "sans",
            "serif",
            "mono"
          ]
        },
        "font_size": {
          "enum": [
            "caption",
            "small",
            "body",
            "title",
            "display_sm",
            "display_lg"
          ]
        },
        "font_weight": {
          "enum": [
            "regular",
            "medium",
            "semibold",
            "bold",
            "black"
          ]
        },
        "foreground": {
          "enum": [
            "ink",
            "muted",
            "inverse",
            "accent",
            "danger"
          ]
        },
        "gap": {
          "enum": [
            "none",
            "xs",
            "sm",
            "md",
            "lg",
            "xl",
            "2xl",
            "3xl"
          ]
        },
        "justify": {
          "enum": [
            "start",
            "center",
            "end",
            "between",
            "stretch"
          ]
        },
        "letter_spacing": {
          "enum": [
            "tight",
            "normal",
            "wide"
          ]
        },
        "line_height": {
          "enum": [
            "tight",
            "snug",
            "normal",
            "relaxed"
          ]
        },
        "max_lines": {
          "maximum": 8,
          "minimum": 1,
          "type": "integer"
        },
        "max_width": {
          "enum": [
            "auto",
            "full",
            "intrinsic",
            "content_sm",
            "content_md",
            "content_lg",
            "rail_sm",
            "rail_md",
            "rail_lg"
          ]
        },
        "min_inline_size": {
          "enum": [
            "zero",
            "content"
          ]
        },
        "order": {
          "maximum": 16,
          "minimum": -16,
          "type": "integer"
        },
        "padding": {
          "enum": [
            "none",
            "xs",
            "sm",
            "md",
            "lg",
            "xl",
            "2xl",
            "3xl"
          ]
        },
        "radius": {
          "enum": [
            "none",
            "sm",
            "md",
            "pill"
          ]
        },
        "span": {
          "maximum": 4,
          "minimum": 1,
          "type": "integer"
        },
        "sticky": {
          "type": "boolean"
        },
        "text_transform": {
          "enum": [
            "none",
            "uppercase"
          ]
        },
        "text_wrap": {
          "enum": [
            "normal",
            "anywhere",
            "no_wrap"
          ]
        },
        "visibility": {
          "enum": [
            "visible",
            "hidden"
          ]
        },
        "width": {
          "enum": [
            "auto",
            "full",
            "intrinsic",
            "content_sm",
            "content_md",
            "content_lg",
            "rail_sm",
            "rail_md",
            "rail_lg"
          ]
        }
      },
      "type": "object"
    },
    "presentation_rule": {
      "additionalProperties": false,
      "properties": {
        "base": {
          "$ref": "#/$defs/presentation_layout"
        },
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "items": {
          "$ref": "#/$defs/presentation_item_layout"
        },
        "target_ref": {
          "$ref": "#/$defs/presentation_target_ref"
        },
        "variants": {
          "additionalProperties": false,
          "properties": {
            "compact": {
              "$ref": "#/$defs/presentation_layout"
            },
            "medium": {
              "$ref": "#/$defs/presentation_layout"
            },
            "wide": {
              "$ref": "#/$defs/presentation_layout"
            }
          },
          "type": "object"
        }
      },
      "required": [
        "id",
        "target_ref"
      ],
      "type": "object"
    },
    "presentation_target_ref": {
      "pattern": "^(region|motif|binding):[A-Za-z0-9_.-]+$",
      "type": "string"
    },
    "resource": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "kind": {
          "enum": [
            "fixture"
          ]
        },
        "records": {
          "items": {
            "$ref": "#/$defs/fixture_record"
          },
          "maxItems": 100,
          "type": "array"
        }
      },
      "required": [
        "id",
        "kind",
        "records"
      ],
      "type": "object"
    },
    "resource_repeat": {
      "additionalProperties": false,
      "description": "Generates every declared record-field binding inside the target motif. Do not also keep hand-authored prototype bindings for repeated record-fields in that motif.",
      "properties": {
        "field_presentations": {
          "items": {
            "$ref": "#/$defs/resource_repeat_field_presentation"
          },
          "maxItems": 16,
          "minItems": 1,
          "type": "array"
        },
        "group_id": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "field_presentations"
      ],
      "type": "object"
    },
    "resource_repeat_field_presentation": {
      "additionalProperties": false,
      "properties": {
        "field": {
          "$ref": "#/$defs/safe_id"
        },
        "present_as": {
          "enum": [
            "badge",
            "label",
            "text",
            "value"
          ]
        }
      },
      "required": [
        "field",
        "present_as"
      ],
      "type": "object"
    },
    "resource_view": {
      "additionalProperties": false,
      "properties": {
        "fields": {
          "items": {
            "$ref": "#/$defs/safe_id"
          },
          "maxItems": 16,
          "minItems": 1,
          "type": "array"
        },
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "mode": {
          "const": "list"
        },
        "record_ids": {
          "items": {
            "$ref": "#/$defs/safe_id"
          },
          "maxItems": 50,
          "minItems": 1,
          "type": "array"
        },
        "repeat": {
          "$ref": "#/$defs/resource_repeat"
        },
        "resource_id": {
          "$ref": "#/$defs/safe_id"
        },
        "target_motif_id": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "id",
        "resource_id",
        "mode",
        "record_ids",
        "fields",
        "target_motif_id"
      ],
      "type": "object"
    },
    "resource_view_ref": {
      "additionalProperties": false,
      "properties": {
        "screen_id": {
          "$ref": "#/$defs/safe_id"
        },
        "view_id": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "screen_id",
        "view_id"
      ],
      "type": "object"
    },
    "resources": {
      "items": {
        "$ref": "#/$defs/resource"
      },
      "maxItems": 8,
      "type": "array"
    },
    "route": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "label": {
          "$ref": "#/$defs/safe_string"
        },
        "path": {
          "maxLength": 96,
          "pattern": "^/[A-Za-z0-9_.~\\-/]*$",
          "type": "string"
        },
        "screen_id": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "id",
        "path",
        "label",
        "screen_id"
      ],
      "type": "object"
    },
    "routes": {
      "items": {
        "$ref": "#/$defs/route"
      },
      "maxItems": 32,
      "minItems": 1,
      "type": "array"
    },
    "safe_id": {
      "maxLength": 96,
      "pattern": "^[A-Za-z0-9_.-]+$",
      "type": "string"
    },
    "safe_string": {
      "maxLength": 2048,
      "type": "string"
    },
    "screen_v1": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "intent_bundle": {
          "$ref": "#/$defs/intent_bundle"
        },
        "presentation": {
          "$ref": "#/$defs/presentation"
        },
        "title": {
          "$ref": "#/$defs/safe_string"
        }
      },
      "required": [
        "id",
        "title",
        "intent_bundle"
      ],
      "type": "object"
    },
    "screen_v2": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "intent_bundle": {
          "$ref": "#/$defs/intent_bundle"
        },
        "presentation": {
          "$ref": "#/$defs/presentation"
        },
        "resource_views": {
          "items": {
            "$ref": "#/$defs/resource_view"
          },
          "maxItems": 8,
          "type": "array"
        },
        "title": {
          "$ref": "#/$defs/safe_string"
        }
      },
      "required": [
        "id",
        "title",
        "resource_views",
        "intent_bundle"
      ],
      "type": "object"
    },
    "selector_op_filter_eq": {
      "additionalProperties": false,
      "properties": {
        "field": {
          "$ref": "#/$defs/safe_id"
        },
        "op": {
          "const": "filter_eq"
        },
        "value": {
          "$ref": "#/$defs/json_value"
        }
      },
      "required": [
        "op",
        "field",
        "value"
      ],
      "type": "object"
    },
    "selector_op_slice": {
      "additionalProperties": false,
      "properties": {
        "end": {
          "minimum": 0,
          "type": "integer"
        },
        "op": {
          "const": "slice"
        },
        "start": {
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "op"
      ],
      "type": "object"
    },
    "selector_op_sort_by": {
      "additionalProperties": false,
      "properties": {
        "direction": {
          "enum": [
            "asc",
            "desc"
          ]
        },
        "field": {
          "$ref": "#/$defs/safe_id"
        },
        "op": {
          "const": "sort_by"
        }
      },
      "required": [
        "op",
        "field"
      ],
      "type": "object"
    },
    "state_entries": {
      "items": {
        "$ref": "#/$defs/state_entry"
      },
      "maxItems": 32,
      "type": "array"
    },
    "state_entry": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "initial": {
          "$ref": "#/$defs/state_initial"
        },
        "kind": {
          "enum": [
            "collection",
            "record",
            "scalar",
            "selection"
          ]
        },
        "scope": {
          "enum": [
            "app",
            "screen"
          ]
        },
        "screen_id": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "id",
        "kind",
        "scope",
        "initial"
      ],
      "type": "object"
    },
    "state_initial": {
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "value": {
              "$ref": "#/$defs/json_value"
            }
          },
          "required": [
            "value"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "from_resource_view": {
              "$ref": "#/$defs/resource_view_ref"
            }
          },
          "required": [
            "from_resource_view"
          ],
          "type": "object"
        }
      ]
    },
    "state_mutation": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "ops": {
          "items": {
            "$ref": "#/$defs/state_mutation_op"
          },
          "maxItems": 16,
          "type": "array"
        },
        "trigger": {
          "$ref": "#/$defs/state_mutation_trigger"
        }
      },
      "required": [
        "id",
        "trigger",
        "ops"
      ],
      "type": "object"
    },
    "state_mutation_op": {
      "oneOf": [
        {
          "$ref": "#/$defs/state_op_set"
        },
        {
          "$ref": "#/$defs/state_op_patch"
        },
        {
          "$ref": "#/$defs/state_op_toggle"
        },
        {
          "$ref": "#/$defs/state_op_append"
        },
        {
          "$ref": "#/$defs/state_op_remove"
        },
        {
          "$ref": "#/$defs/state_op_move"
        },
        {
          "$ref": "#/$defs/state_op_increment"
        }
      ]
    },
    "state_mutation_trigger": {
      "additionalProperties": false,
      "properties": {
        "action_id": {
          "$ref": "#/$defs/safe_id"
        },
        "screen_id": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "screen_id",
        "action_id"
      ],
      "type": "object"
    },
    "state_mutations": {
      "items": {
        "$ref": "#/$defs/state_mutation"
      },
      "maxItems": 128,
      "type": "array"
    },
    "state_op_append": {
      "additionalProperties": false,
      "properties": {
        "op": {
          "const": "append"
        },
        "state": {
          "$ref": "#/$defs/safe_id"
        },
        "value": {
          "$ref": "#/$defs/payload_expr"
        }
      },
      "required": [
        "op",
        "state",
        "value"
      ],
      "type": "object"
    },
    "state_op_increment": {
      "additionalProperties": false,
      "properties": {
        "amount": {
          "$ref": "#/$defs/payload_expr"
        },
        "field": {
          "$ref": "#/$defs/safe_id"
        },
        "item_id": {
          "$ref": "#/$defs/payload_expr"
        },
        "op": {
          "const": "increment"
        },
        "state": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "op",
        "state"
      ],
      "type": "object"
    },
    "state_op_move": {
      "additionalProperties": false,
      "properties": {
        "item_id": {
          "$ref": "#/$defs/payload_expr"
        },
        "op": {
          "const": "move"
        },
        "state": {
          "$ref": "#/$defs/safe_id"
        },
        "to_index": {
          "$ref": "#/$defs/payload_expr"
        }
      },
      "required": [
        "op",
        "state",
        "item_id",
        "to_index"
      ],
      "type": "object"
    },
    "state_op_patch": {
      "additionalProperties": false,
      "properties": {
        "item_id": {
          "$ref": "#/$defs/payload_expr"
        },
        "op": {
          "const": "patch"
        },
        "state": {
          "$ref": "#/$defs/safe_id"
        },
        "value": {
          "$ref": "#/$defs/payload_expr"
        }
      },
      "required": [
        "op",
        "state",
        "value"
      ],
      "type": "object"
    },
    "state_op_remove": {
      "additionalProperties": false,
      "properties": {
        "item_id": {
          "$ref": "#/$defs/payload_expr"
        },
        "op": {
          "const": "remove"
        },
        "state": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "op",
        "state",
        "item_id"
      ],
      "type": "object"
    },
    "state_op_set": {
      "additionalProperties": false,
      "properties": {
        "op": {
          "const": "set"
        },
        "state": {
          "$ref": "#/$defs/safe_id"
        },
        "value": {
          "$ref": "#/$defs/payload_expr"
        }
      },
      "required": [
        "op",
        "state",
        "value"
      ],
      "type": "object"
    },
    "state_op_toggle": {
      "additionalProperties": false,
      "properties": {
        "field": {
          "$ref": "#/$defs/safe_id"
        },
        "item_id": {
          "$ref": "#/$defs/payload_expr"
        },
        "op": {
          "const": "toggle"
        },
        "state": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "op",
        "state"
      ],
      "type": "object"
    },
    "state_replay_assertion": {
      "additionalProperties": false,
      "properties": {
        "events": {
          "items": {
            "$ref": "#/$defs/state_replay_event"
          },
          "maxItems": 32,
          "type": "array"
        },
        "expect_selectors": {
          "additionalProperties": {
            "$ref": "#/$defs/json_value"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "expect_state": {
          "additionalProperties": {
            "$ref": "#/$defs/json_value"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "id": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "id",
        "events",
        "expect_state",
        "expect_selectors"
      ],
      "type": "object"
    },
    "state_replay_assertion_v4": {
      "additionalProperties": false,
      "properties": {
        "events": {
          "items": {
            "$ref": "#/$defs/state_replay_event"
          },
          "maxItems": 32,
          "type": "array"
        },
        "expect_selectors": {
          "additionalProperties": {
            "$ref": "#/$defs/json_value"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "expect_state": {
          "additionalProperties": {
            "$ref": "#/$defs/json_value"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "expect_text": {
          "additionalProperties": {
            "maxLength": 2304,
            "type": "string"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "expect_visibility": {
          "additionalProperties": {
            "type": "boolean"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "id": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "id",
        "events",
        "expect_state",
        "expect_selectors"
      ],
      "type": "object"
    },
    "state_replay_assertion_v5": {
      "additionalProperties": false,
      "properties": {
        "events": {
          "items": {
            "$ref": "#/$defs/state_replay_event"
          },
          "maxItems": 32,
          "type": "array"
        },
        "expect_selectors": {
          "additionalProperties": {
            "$ref": "#/$defs/json_value"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "expect_state": {
          "additionalProperties": {
            "$ref": "#/$defs/json_value"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "expect_text": {
          "additionalProperties": {
            "maxLength": 16896,
            "type": "string"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "expect_visibility": {
          "additionalProperties": {
            "type": "boolean"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "id": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "id",
        "events",
        "expect_state",
        "expect_selectors"
      ],
      "type": "object"
    },
    "state_replay_assertions": {
      "items": {
        "$ref": "#/$defs/state_replay_assertion"
      },
      "maxItems": 32,
      "type": "array"
    },
    "state_replay_assertions_v4": {
      "items": {
        "$ref": "#/$defs/state_replay_assertion_v4"
      },
      "maxItems": 32,
      "type": "array"
    },
    "state_replay_assertions_v5": {
      "items": {
        "$ref": "#/$defs/state_replay_assertion_v5"
      },
      "maxItems": 32,
      "type": "array"
    },
    "state_replay_event": {
      "additionalProperties": false,
      "oneOf": [
        {
          "not": {
            "required": [
              "action_id"
            ]
          },
          "required": [
            "mutation_id"
          ]
        },
        {
          "not": {
            "required": [
              "mutation_id"
            ]
          },
          "required": [
            "action_id"
          ]
        }
      ],
      "properties": {
        "action_id": {
          "$ref": "#/$defs/safe_id"
        },
        "mutation_id": {
          "$ref": "#/$defs/safe_id"
        },
        "payload_values": {
          "additionalProperties": {
            "$ref": "#/$defs/json_value"
          },
          "propertyNames": {
            "$ref": "#/$defs/safe_id"
          },
          "type": "object"
        },
        "repeat": {
          "maximum": 32,
          "minimum": 1,
          "type": "integer"
        },
        "screen_id": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "type": "object"
    },
    "state_selector": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "ops": {
          "items": {
            "$ref": "#/$defs/state_selector_op"
          },
          "maxItems": 8,
          "type": "array"
        },
        "source_state": {
          "$ref": "#/$defs/safe_id"
        }
      },
      "required": [
        "id",
        "source_state",
        "ops"
      ],
      "type": "object"
    },
    "state_selector_op": {
      "oneOf": [
        {
          "$ref": "#/$defs/selector_op_filter_eq"
        },
        {
          "$ref": "#/$defs/selector_op_sort_by"
        },
        {
          "$ref": "#/$defs/selector_op_slice"
        }
      ]
    },
    "state_selectors": {
      "items": {
        "$ref": "#/$defs/state_selector"
      },
      "maxItems": 64,
      "type": "array"
    },
    "state_text_format": {
      "description": "The closed formatter set. Formatters use no locale or time zone.",
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "format": {
              "const": "integer"
            }
          },
          "required": [
            "format"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "digits": {
              "maximum": 6,
              "minimum": 0,
              "type": "integer"
            },
            "format": {
              "const": "decimal"
            }
          },
          "required": [
            "format",
            "digits"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "digits": {
              "maximum": 6,
              "minimum": 0,
              "type": "integer"
            },
            "format": {
              "const": "percent"
            }
          },
          "required": [
            "format",
            "digits"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "currency": {
              "enum": [
                "CHF",
                "EUR",
                "GBP",
                "INR",
                "JPY",
                "USD"
              ]
            },
            "format": {
              "const": "currency"
            }
          },
          "required": [
            "format",
            "currency"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "format": {
              "const": "date_iso"
            }
          },
          "required": [
            "format"
          ],
          "type": "object"
        }
      ]
    },
    "state_text_rule": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "screen_id": {
          "$ref": "#/$defs/safe_id"
        },
        "state": {
          "$ref": "#/$defs/safe_id"
        },
        "target_ref": {
          "maxLength": 104,
          "pattern": "^binding:[A-Za-z0-9_.-]+$",
          "type": "string"
        },
        "template": {
          "maxLength": 256,
          "pattern": "^[^{}]*\\{value\\}[^{}]*$",
          "type": "string"
        }
      },
      "required": [
        "id",
        "screen_id",
        "target_ref",
        "state",
        "template"
      ],
      "type": "object"
    },
    "state_text_rule_v5": {
      "oneOf": [
        {
          "$ref": "#/$defs/state_text_rule_v5_single"
        },
        {
          "$ref": "#/$defs/state_text_rule_v5_values"
        }
      ]
    },
    "state_text_rule_v5_single": {
      "additionalProperties": false,
      "properties": {
        "format": {
          "$ref": "#/$defs/state_text_format"
        },
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "screen_id": {
          "$ref": "#/$defs/safe_id"
        },
        "state": {
          "$ref": "#/$defs/safe_id"
        },
        "target_ref": {
          "maxLength": 104,
          "pattern": "^binding:[A-Za-z0-9_.-]+$",
          "type": "string"
        },
        "template": {
          "maxLength": 256,
          "pattern": "^[^{}]*\\{value\\}[^{}]*$",
          "type": "string"
        }
      },
      "required": [
        "id",
        "screen_id",
        "target_ref",
        "state",
        "template"
      ],
      "type": "object"
    },
    "state_text_rule_v5_values": {
      "additionalProperties": false,
      "description": "Each {name} placeholder appears once in template and has exactly one values entry.",
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "screen_id": {
          "$ref": "#/$defs/safe_id"
        },
        "target_ref": {
          "maxLength": 104,
          "pattern": "^binding:[A-Za-z0-9_.-]+$",
          "type": "string"
        },
        "template": {
          "maxLength": 512,
          "pattern": "^[^{}]*(\\{[a-z][a-z0-9_]{0,31}\\}[^{}]*)+$",
          "type": "string"
        },
        "values": {
          "additionalProperties": {
            "$ref": "#/$defs/state_text_value_source"
          },
          "maxProperties": 8,
          "minProperties": 1,
          "propertyNames": {
            "pattern": "^[a-z][a-z0-9_]{0,31}$"
          },
          "type": "object"
        }
      },
      "required": [
        "id",
        "screen_id",
        "target_ref",
        "template",
        "values"
      ],
      "type": "object"
    },
    "state_text_rules": {
      "items": {
        "$ref": "#/$defs/state_text_rule"
      },
      "maxItems": 64,
      "type": "array"
    },
    "state_text_rules_v5": {
      "items": {
        "$ref": "#/$defs/state_text_rule_v5"
      },
      "maxItems": 64,
      "type": "array"
    },
    "state_text_value_source": {
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "format": {
              "$ref": "#/$defs/state_text_format"
            },
            "state": {
              "$ref": "#/$defs/safe_id"
            }
          },
          "required": [
            "state"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "format": {
              "$ref": "#/$defs/state_text_format"
            },
            "measure": {
              "const": "count"
            },
            "selector": {
              "$ref": "#/$defs/safe_id"
            }
          },
          "required": [
            "selector",
            "measure"
          ],
          "type": "object"
        }
      ]
    },
    "visibility_condition": {
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "is": {
              "enum": [
                "truthy",
                "falsy"
              ]
            },
            "state": {
              "$ref": "#/$defs/safe_id"
            }
          },
          "required": [
            "state",
            "is"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "equals": {
              "$ref": "#/$defs/json_scalar"
            },
            "state": {
              "$ref": "#/$defs/safe_id"
            }
          },
          "required": [
            "state",
            "equals"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "is": {
              "enum": [
                "non_empty",
                "empty"
              ]
            },
            "selector": {
              "$ref": "#/$defs/safe_id"
            }
          },
          "required": [
            "selector",
            "is"
          ],
          "type": "object"
        }
      ]
    },
    "visibility_condition_v5": {
      "description": "A leaf condition, all or any of 2 to 8 conditions, or not of one condition. Nesting stops at depth 3, and a rule holds at most 8 leaves.",
      "oneOf": [
        {
          "$ref": "#/$defs/visibility_condition"
        },
        {
          "additionalProperties": false,
          "properties": {
            "all": {
              "items": {
                "$ref": "#/$defs/visibility_condition_v5_level_2"
              },
              "maxItems": 8,
              "minItems": 2,
              "type": "array"
            }
          },
          "required": [
            "all"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "any": {
              "items": {
                "$ref": "#/$defs/visibility_condition_v5_level_2"
              },
              "maxItems": 8,
              "minItems": 2,
              "type": "array"
            }
          },
          "required": [
            "any"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "not": {
              "$ref": "#/$defs/visibility_condition_v5_level_2"
            }
          },
          "required": [
            "not"
          ],
          "type": "object"
        }
      ]
    },
    "visibility_condition_v5_level_2": {
      "oneOf": [
        {
          "$ref": "#/$defs/visibility_condition"
        },
        {
          "additionalProperties": false,
          "properties": {
            "all": {
              "items": {
                "$ref": "#/$defs/visibility_condition"
              },
              "maxItems": 8,
              "minItems": 2,
              "type": "array"
            }
          },
          "required": [
            "all"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "any": {
              "items": {
                "$ref": "#/$defs/visibility_condition"
              },
              "maxItems": 8,
              "minItems": 2,
              "type": "array"
            }
          },
          "required": [
            "any"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "not": {
              "$ref": "#/$defs/visibility_condition"
            }
          },
          "required": [
            "not"
          ],
          "type": "object"
        }
      ]
    },
    "visibility_rule": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "screen_id": {
          "$ref": "#/$defs/safe_id"
        },
        "target_ref": {
          "maxLength": 104,
          "pattern": "^(region|binding|motif):[A-Za-z0-9_.-]+$",
          "type": "string"
        },
        "when": {
          "$ref": "#/$defs/visibility_condition"
        }
      },
      "required": [
        "id",
        "screen_id",
        "target_ref",
        "when"
      ],
      "type": "object"
    },
    "visibility_rule_v5": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/safe_id"
        },
        "screen_id": {
          "$ref": "#/$defs/safe_id"
        },
        "target_ref": {
          "maxLength": 104,
          "pattern": "^(region|binding|motif):[A-Za-z0-9_.-]+$",
          "type": "string"
        },
        "when": {
          "$ref": "#/$defs/visibility_condition_v5"
        }
      },
      "required": [
        "id",
        "screen_id",
        "target_ref",
        "when"
      ],
      "type": "object"
    },
    "visibility_rules": {
      "items": {
        "$ref": "#/$defs/visibility_rule"
      },
      "maxItems": 64,
      "type": "array"
    },
    "visibility_rules_v5": {
      "items": {
        "$ref": "#/$defs/visibility_rule_v5"
      },
      "maxItems": 64,
      "type": "array"
    }
  },
  "$id": "https://viewspec.dev/agent-app-bundle.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "Local-only multi-screen app contract with embedded IntentBundles, static routes, V1 unbound fixtures, V2 read-only fixture binding proof, V3 bounded interactive_state_v0 reducers, V4 bounded visibility_v0 conditional visibility rules, and V5 bounded expressions: composed visibility conditions, multi-value state text, and closed formatters.",
  "oneOf": [
    {
      "$ref": "#/$defs/app_bundle_v1"
    },
    {
      "$ref": "#/$defs/app_bundle_v2"
    },
    {
      "$ref": "#/$defs/app_bundle_v3"
    },
    {
      "$ref": "#/$defs/app_bundle_v4"
    },
    {
      "$ref": "#/$defs/app_bundle_v5"
    }
  ],
  "title": "ViewSpec Agent AppBundle V1/V2/V3/V4/V5",
  "x-viewspec-anti-goals": [
    "No runtime browser navigation proof.",
    "No dynamic routes, route params, query strings, hashes, redirects, guards, nested routers, or locale routing.",
    "No live data rebinding, framework state adapter, optimistic server reconciliation, persistence, CRDT, websocket sync, or gesture runtime.",
    "No transformed, localized, formatted, joined, sorted, filtered, paginated, grouped, or aggregated fixture proof.",
    "No whole-app data-flow consistency proof beyond explicitly declared resource_views.",
    "No accessibility, pixel-perfect, cross-browser, production deployment, or arbitrary host-app certification.",
    "Visibility V0 (schema_version 4) is bounded conditional show/hide only: no boolean condition composition, animation, or focus management.",
    "State Text V0 (schema_version 4) is one scalar-to-text projection only: no HTML, expressions, paths, localization, formatting functions, or multiple placeholders.",
    "Bounded expressions (schema_version 5) add no free expressions, arbitrary JSON paths, host functions, HTML, Intl, locale, or time zone behavior, and no animation or focus management."
  ],
  "x-viewspec-app-schema-versions": [
    1,
    2,
    3,
    4,
    5
  ],
  "x-viewspec-binding-scope": "declared_resource_views_only",
  "x-viewspec-embedded-intent-schema": "https://viewspec.dev/agent-intent-bundle.schema.json",
  "x-viewspec-interactive-state": "interactive_state_v0",
  "x-viewspec-invariants": [
    "AppBundles are local-only and no-network.",
    "schema_version 1 rejects resource_binding and resource_views, and reports unbound_v0.",
    "schema_version 2 requires resource_binding fixture_readonly_v0 and per-screen resource_views.",
    "schema_version 3 requires fixture_readonly_v0 plus interactive_state_v0 state, mutations, and selectors.",
    "schema_version 4 adds optional bounded visibility rules: per-screen show/hide conditions over declared state and selectors, at most one rule per (screen, target).",
    "schema_version 4 optionally projects one scalar state value into one exactly-once text binding through a literal {value} template.",
    "schema_version 5 accepts every schema_version 4 construct, composes visibility conditions with all, any, and not (lists of 2 to 8, depth at most 3, at most 8 leaves per rule), and fills up to 8 named state_text placeholders from scalar state or selector counts through closed formatters.",
    "A schema_version 1 to 4 bundle that uses a schema_version 5 construct fails with APP_V5_FEATURE_REQUIRES_SCHEMA_VERSION_5.",
    "Routes are static canonical paths only and must map to declared screens.",
    "The root route must resolve to exactly one route.",
    "Every screen must be reachable by at least one static route.",
    "V2 binding proof is exact byte-for-byte fixture scalar visibility in declared target motifs only.",
    "V3 state mutations are declarative reducer operations triggered by declared embedded screen actions only.",
    "V3 selectors are deterministic read-only derived views over declared state.",
    "Every embedded screen intent must validate against the local V1 IntentBundle contract.",
    "Unknown AppBundle-owned fields are rejected instead of ignored.",
    "Proof output paths are derived from validated safe ids only."
  ],
  "x-viewspec-resource-binding": "unbound_v0",
  "x-viewspec-resource-bindings": [
    "unbound_v0",
    "fixture_readonly_v0"
  ]
}
