{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oods-foundry.com/schemas/repl.input.json",
  "title": "schema_render input",
  "description": "Grouped action-parameter tool consolidating schema_render action=render and schema_render action=validate. Select the per-action body via the top-level `action` discriminator. Each branch reproduces the exact body of the corresponding per-action input schema, with `action` added to the allowed property set. Per-action handlers, schemas, and the external repl_render/repl_validate tools are unchanged; this is a zero-functionality-loss bolt-on.",
  "type": "object",
  "required": [
    "action"
  ],
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "render",
        "validate"
      ],
      "description": "Selects the per-action handler. 'render' -> schema_render action=render, 'validate' -> schema_render action=validate."
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "action": {
            "type": "string",
            "const": "render"
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "const": "render"
          },
          "mode": {
            "type": "string",
            "enum": [
              "full",
              "patch"
            ],
            "default": "full"
          },
          "schema": {
            "$ref": "./repl.ui.schema.json"
          },
          "schemaRef": {
            "type": "string",
            "description": "Reference to a cached UiSchema returned by design_compose."
          },
          "patch": {
            "$ref": "./repl.patch.json"
          },
          "baseTree": {
            "$ref": "./repl.ui.schema.json"
          },
          "brand": {
            "type": "string",
            "format": "oods-brand",
            "description": "Brand to render. Optional with NO default: omitting it preserves the previous behaviour byte-for-byte, including the document's data-brand=\"default\". Uppercase 'A' or 'B' exactly. Applies to output.format='document' only — the 'fragments' branch emits no <html> element to carry data-brand, so fragments diagnose an ignored brand with OODS-W001."
          },
          "options": {
            "type": "object",
            "properties": {
              "includeTree": {
                "type": "boolean",
                "default": true
              }
            },
            "additionalProperties": false,
            "default": {}
          },
          "output": {
            "type": "object",
            "description": "Optional render output controls. Omitting this object preserves full-document behavior.",
            "properties": {
              "format": {
                "type": "string",
                "enum": [
                  "document",
                  "fragments"
                ],
                "default": "document"
              },
              "strict": {
                "type": "boolean",
                "default": false
              },
              "includeCss": {
                "type": "boolean",
                "default": true
              },
              "compact": {
                "type": "boolean",
                "description": "Opt in to omitting token CSS; the default includes token CSS.",
                "default": false
              },
              "showConfidence": {
                "type": "boolean",
                "description": "When true, emit data-oods-confidence and data-confidence-level attributes on rendered components that carry composition confidence metadata. Low-confidence components (below confidenceThreshold) also receive an oods-low-confidence CSS class. Default false.",
                "default": false
              },
              "confidenceThreshold": {
                "type": "number",
                "description": "Confidence threshold for low-confidence affordance. Components with confidence below this value receive the oods-low-confidence CSS class. Only effective when showConfidence is true. Default 0.5.",
                "default": 0.5,
                "minimum": 0,
                "maximum": 1
              },
              "tokenOverlay": {
                "type": "object",
                "description": "Inline token-delta object resolved to a scoped :root{} override; applied only in document output (format=document), diagnosed as ignored for fragments with OODS-W001; distinct from the FS-resolved named brandOverlay on fidelity_preview.",
                "additionalProperties": true
              },
              "skinOverlay": {
                "type": "object",
                "description": "Inline measured-colour delta resolved against the OODS Foundry-owned style library to a scoped :root{} override on the --sys-/--ref- skin (distinct from tokenOverlay's --oods- token path); applied only in document output (format=document), gated by apply===true. An unmapped logical key fails loud with OODS-V140. Lands in the same components <style> block as tokenOverlay; default-absent is byte-identical.",
                "additionalProperties": true
              },
              "payloadMode": {
                "type": "string",
                "enum": [
                  "inline",
                  "file"
                ],
                "description": "Unset: inline, unless the output would exceed 100,000 characters, in which case it is written as with file and warning OODS-W004 says so. inline returns html (or fragments and css) in the response. file writes index.html (or fragments.json and css.json) beside the saved-schema store (<store>/../payloads/schema_render action=render-<digest>/) and returns a payload block of file references instead; html, fragments and css are then omitted."
              }
            },
            "additionalProperties": false
          },
          "apply": {
            "type": "boolean",
            "description": "When true and the schema validates, render it: the HTML document in html, or per-node fragments with output.format 'fragments'. Omitted or false is a dry run that validates and returns the tree with no HTML."
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "mode": {
                  "type": "string",
                  "const": "full"
                }
              },
              "required": [
                "mode"
              ]
            },
            "then": {
              "anyOf": [
                {
                  "required": [
                    "schema"
                  ]
                },
                {
                  "required": [
                    "schemaRef"
                  ]
                }
              ]
            }
          },
          {
            "if": {
              "not": {
                "required": [
                  "mode"
                ]
              }
            },
            "then": {
              "anyOf": [
                {
                  "required": [
                    "schema"
                  ]
                },
                {
                  "required": [
                    "schemaRef"
                  ]
                }
              ]
            }
          },
          {
            "if": {
              "properties": {
                "mode": {
                  "type": "string",
                  "const": "patch"
                }
              },
              "required": [
                "mode"
              ]
            },
            "then": {
              "required": [
                "patch",
                "baseTree"
              ]
            }
          }
        ],
        "additionalProperties": false
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "type": "string",
            "const": "validate"
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "const": "validate"
          },
          "mode": {
            "type": "string",
            "enum": [
              "full",
              "patch"
            ],
            "default": "full"
          },
          "schema": {
            "$ref": "./repl.ui.schema.json"
          },
          "schemaRef": {
            "type": "string",
            "description": "Reference to a cached UiSchema returned by design_compose."
          },
          "patch": {
            "$ref": "./repl.patch.json",
            "description": "Required when mode='patch'. Accepts JSON Patch array or node patch object(s)."
          },
          "baseTree": {
            "$ref": "./repl.ui.schema.json",
            "description": "Required when mode='patch' to provide the base UiSchema to patch."
          },
          "options": {
            "type": "object",
            "properties": {
              "includeNormalized": {
                "type": "boolean",
                "default": true
              },
              "checkComponents": {
                "type": "boolean",
                "default": true
              },
              "checkA11y": {
                "type": "boolean",
                "default": false,
                "description": "Checks declared foreground/background pairs derived from shared component CSS against current built tokens for every registered brand and theme, including team brands. With a UiSchema, renders through the shared HTML renderer and checks document language/title, one main landmark, unique IDs, ARIA reference targets, control names/labels, image alternatives, chart SVG name/description, and heading names/order. Reports unresolved inherited surfaces, dynamic CSS, alpha compositing and OS colours as unmeasured. Does not check browser-computed colour/layout, keyboard/focus interaction or screen-reader behavior; no complete WCAG conformance claim."
              }
            },
            "additionalProperties": false,
            "default": {}
          },
          "apply": {
            "type": "boolean",
            "description": "Accepted for bridge dry-run/apply mode parity (this tool is apply-capable); ignored by this action."
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "mode": {
                  "type": "string",
                  "const": "full"
                }
              },
              "required": [
                "mode"
              ]
            },
            "then": {
              "anyOf": [
                {
                  "required": [
                    "schema"
                  ]
                },
                {
                  "required": [
                    "schemaRef"
                  ]
                }
              ]
            }
          },
          {
            "if": {
              "not": {
                "required": [
                  "mode"
                ]
              }
            },
            "then": {
              "anyOf": [
                {
                  "required": [
                    "schema"
                  ]
                },
                {
                  "required": [
                    "schemaRef"
                  ]
                }
              ]
            }
          },
          {
            "if": {
              "properties": {
                "mode": {
                  "type": "string",
                  "const": "patch"
                }
              },
              "required": [
                "mode"
              ]
            },
            "then": {
              "required": [
                "patch"
              ]
            }
          }
        ],
        "additionalProperties": false
      }
    }
  ]
}
