{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://oods-foundry.com/schemas/map.input.json",
  "title": "component_map input",
  "description": "Stage or write component mappings.",
  "type": "object",
  "required": [
    "action"
  ],
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "apply",
        "create",
        "update",
        "delete",
        "draft"
      ],
      "description": "Choose apply, create, update, delete, draft."
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "action": {
            "type": "string",
            "const": "apply"
          }
        },
        "required": [
          "action"
        ],
        "not": {
          "required": [
            "draftId"
          ]
        }
      },
      "then": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "action": {
            "type": "string",
            "const": "apply"
          },
          "apply": {
            "type": "boolean",
            "default": false,
            "description": "When true, persist registry mutations. Defaults to dry-run."
          },
          "minConfidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0.75,
            "description": "Minimum confidence to apply; lower candidates are queued."
          },
          "reportPath": {
            "type": "string",
            "minLength": 1,
            "description": "Filesystem path to a reconciliation_report.json artifact."
          },
          "report": {
            "$ref": "#/$defs/ReconciliationReport"
          }
        },
        "oneOf": [
          {
            "required": [
              "report"
            ],
            "not": {
              "required": [
                "reportPath"
              ]
            }
          },
          {
            "required": [
              "reportPath"
            ],
            "not": {
              "required": [
                "report"
              ]
            }
          }
        ]
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "type": "string",
            "const": "create"
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "type": "object",
        "allOf": [
          {
            "if": {
              "anyOf": [
                {
                  "required": [
                    "mappings"
                  ]
                },
                {
                  "required": [
                    "mappingsPath"
                  ]
                }
              ]
            },
            "then": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "apply": {
                  "type": "boolean",
                  "default": false,
                  "description": "When true, write changes to disk."
                },
                "mappings": {
                  "type": "array",
                  "minItems": 1,
                  "items": {
                    "type": "object",
                    "description": "A single-create payload without action or apply; the handler checks every value against MappingEntry and returns OODS-V219 per-entry outcomes for invalid entries."
                  },
                  "description": "Create entries, each without apply. All entries are checked before one atomic write."
                },
                "mappingsPath": {
                  "type": "string",
                  "pattern": "^/[\\s\\S]*$",
                  "description": "Absolute path to a JSON document { mappings: [...] }, using the same entry shape."
                },
                "action": {
                  "type": "string",
                  "const": "create"
                }
              },
              "oneOf": [
                {
                  "required": [
                    "mappings"
                  ]
                },
                {
                  "required": [
                    "mappingsPath"
                  ]
                }
              ]
            },
            "else": {
              "allOf": [
                {
                  "$ref": "#/$defs/SingleCreate"
                }
              ],
              "properties": {
                "apply": {
                  "default": false
                }
              }
            }
          }
        ]
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "type": "string",
            "const": "update"
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "type": "object",
        "required": [
          "id",
          "updates"
        ],
        "additionalProperties": false,
        "properties": {
          "action": {
            "type": "string",
            "const": "update"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "Mapping ID."
          },
          "updates": {
            "$ref": "#/$defs/mappingUpdates",
            "description": "Fields to change: oodsTraits, confidence, propMappings, metadata, substitution. Omitted fields stay unchanged."
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "type": "string",
            "const": "delete"
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "type": "object",
        "required": [
          "id"
        ],
        "additionalProperties": false,
        "properties": {
          "action": {
            "type": "string",
            "const": "delete"
          },
          "id": {
            "type": "string",
            "minLength": 1,
            "description": "Mapping ID."
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "type": "string",
            "const": "draft"
          }
        },
        "required": [
          "action"
        ]
      },
      "then": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "action": {
            "type": "string",
            "const": "draft"
          },
          "source": {
            "type": "object",
            "properties": {
              "project": {
                "type": "string",
                "pattern": "^/[\\s\\S]*$"
              },
              "format": {
                "type": "string",
                "enum": [
                  "shadcn",
                  "storybook"
                ]
              },
              "storybook": {
                "type": "string"
              }
            },
            "required": [
              "project",
              "format"
            ],
            "additionalProperties": false
          },
          "externalSystem": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "source"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "action": {
            "type": "string",
            "const": "apply"
          }
        },
        "required": [
          "action",
          "draftId"
        ]
      },
      "then": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "action": {
            "type": "string",
            "const": "apply"
          },
          "draftId": {
            "type": "string",
            "pattern": "^components-[a-f0-9]{64}$"
          },
          "accept": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "uniqueItems": true
          }
        },
        "required": [
          "draftId",
          "accept"
        ]
      }
    }
  ],
  "$defs": {
    "EvidenceRef": {
      "type": "object",
      "additionalProperties": true
    },
    "AlternateInterpretation": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "required": [
            "role",
            "score",
            "reasoning"
          ],
          "additionalProperties": false,
          "properties": {
            "role": {
              "type": "string",
              "minLength": 1
            },
            "score": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "reasoning": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      ]
    },
    "AlternateVerb": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "required": [
            "verb_id",
            "score",
            "reasoning"
          ],
          "additionalProperties": false,
          "properties": {
            "verb_id": {
              "type": "string",
              "minLength": 1
            },
            "score": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "reasoning": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      ]
    },
    "CandidateDiffField": {
      "type": "object",
      "required": [
        "field"
      ],
      "additionalProperties": false,
      "properties": {
        "field": {
          "type": "string",
          "minLength": 1
        },
        "from": {},
        "to": {}
      }
    },
    "CandidateDiff": {
      "type": "object",
      "required": [
        "added_traits",
        "removed_traits",
        "changed_fields"
      ],
      "additionalProperties": false,
      "properties": {
        "added_traits": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "removed_traits": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "changed_fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CandidateDiffField"
          }
        }
      }
    },
    "CandidateObject": {
      "type": "object",
      "required": [
        "object_id",
        "name",
        "role",
        "confidence",
        "recommended_oods_traits",
        "action",
        "reasoning"
      ],
      "additionalProperties": false,
      "properties": {
        "object_id": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "role": {
          "type": "string",
          "minLength": 1
        },
        "inferred_role": {
          "type": "string",
          "minLength": 1
        },
        "inferred_role_score": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "recommended_oods_traits": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "recommended_domain": {
          "type": "string",
          "minLength": 1
        },
        "action": {
          "type": "string",
          "enum": [
            "create",
            "patch",
            "skip",
            "conflict"
          ]
        },
        "reasoning": {
          "type": "string",
          "minLength": 1
        },
        "verdict_reasoning": {
          "type": "string",
          "minLength": 1
        },
        "existing_map_id": {
          "type": "string",
          "minLength": 1
        },
        "external_component": {
          "type": "string",
          "minLength": 1
        },
        "diff": {
          "$ref": "#/$defs/CandidateDiff"
        },
        "alternate_interpretations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AlternateInterpretation"
          }
        },
        "evidence_chain": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EvidenceRef"
          }
        },
        "projection_variants": {
          "type": "array",
          "description": "Cross-surface mapping variants to append.",
          "items": {
            "$ref": "#/$defs/projection_variantsItem"
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "action": {
                "type": "string",
                "const": "patch"
              }
            }
          },
          "then": {
            "required": [
              "existing_map_id",
              "diff",
              "verdict_reasoning"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "action": {
                "type": "string",
                "const": "skip"
              }
            }
          },
          "then": {
            "required": [
              "existing_map_id",
              "verdict_reasoning"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "action": {
                "type": "string",
                "const": "conflict"
              }
            }
          },
          "then": {
            "required": [
              "existing_map_id",
              "verdict_reasoning"
            ]
          }
        }
      ]
    },
    "ActionPrecondition": {
      "type": "object",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "auth",
            "role",
            "state",
            "data"
          ]
        },
        "description": {
          "type": "string"
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "evidence_chain": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/EvidenceRef"
          }
        }
      }
    },
    "DisambiguationAlternative": {
      "type": "object",
      "required": [
        "value"
      ],
      "additionalProperties": false,
      "properties": {
        "value": {
          "type": "string",
          "minLength": 1
        },
        "score": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "reasoning": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "DisambiguationDecision": {
      "type": "object",
      "required": [
        "decision_id",
        "decision_type",
        "scope",
        "status",
        "target_kind",
        "target_id",
        "selected_value",
        "rationale",
        "decided_at"
      ],
      "additionalProperties": false,
      "description": "Draft v1.4.0-gated review-decision payload. OODS accepts the shape but current component_map action=apply handlers ignore it.",
      "properties": {
        "decision_id": {
          "type": "string",
          "minLength": 1
        },
        "decision_type": {
          "type": "string",
          "enum": [
            "preferred_name",
            "preferred_role",
            "mapping_rejection",
            "canonical_term"
          ]
        },
        "scope": {
          "type": "string",
          "enum": [
            "run",
            "target",
            "registry"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "proposed",
            "accepted",
            "rejected",
            "promoted"
          ]
        },
        "target_kind": {
          "type": "string",
          "enum": [
            "candidate_object",
            "candidate_action",
            "preferred_term"
          ]
        },
        "target_id": {
          "type": "string",
          "minLength": 1
        },
        "selected_value": {
          "type": "string",
          "minLength": 1
        },
        "rationale": {
          "type": "string",
          "minLength": 1
        },
        "alternatives": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DisambiguationAlternative"
          }
        },
        "preferred_term_id": {
          "type": "string",
          "minLength": 1
        },
        "decided_by": {
          "type": "string",
          "enum": [
            "human",
            "agent",
            "system"
          ]
        },
        "decided_at": {
          "type": "string",
          "format": "date-time"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": true
        }
      }
    },
    "CandidateAction": {
      "type": "object",
      "required": [
        "action_id",
        "name",
        "verb"
      ],
      "additionalProperties": false,
      "properties": {
        "action_id": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "verb": {
          "type": "string",
          "minLength": 1
        },
        "source_object_id": {
          "type": "string",
          "minLength": 1
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "suggested_oods_trait": {
          "type": "string",
          "minLength": 1
        },
        "suggested_action": {
          "type": "string",
          "minLength": 1
        },
        "reasoning": {
          "type": "string",
          "minLength": 1
        },
        "alternate_verbs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AlternateVerb"
          }
        },
        "preconditions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ActionPrecondition"
          }
        }
      }
    },
    "Conflict": {
      "type": "object",
      "required": [
        "type",
        "description",
        "severity"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "severity": {
          "type": "string",
          "enum": [
            "info",
            "warning",
            "error"
          ]
        },
        "action_id": {
          "type": "string",
          "minLength": 1
        },
        "object_id": {
          "type": "string",
          "minLength": 1
        },
        "existing_map_id": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "RegistryFetchTelemetry": {
      "type": "object",
      "required": [
        "source",
        "entries_count"
      ],
      "additionalProperties": false,
      "properties": {
        "source": {
          "type": "string",
          "enum": [
            "pre-supplied",
            "transport",
            "empty-fallback"
          ]
        },
        "entries_count": {
          "type": "integer",
          "minimum": 0
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "Manifest": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "inputs": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "oods_registry_fetch": {
              "$ref": "#/$defs/RegistryFetchTelemetry"
            }
          }
        }
      }
    },
    "ReconciliationSummary": {
      "type": "object",
      "required": [
        "mode",
        "existing_map_count",
        "verdict_counts"
      ],
      "additionalProperties": false,
      "properties": {
        "mode": {
          "type": "string",
          "minLength": 1
        },
        "existing_map_count": {
          "type": "integer",
          "minimum": 0
        },
        "verdict_counts": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "create": {
              "type": "integer",
              "minimum": 0
            },
            "patch": {
              "type": "integer",
              "minimum": 0
            },
            "skip": {
              "type": "integer",
              "minimum": 0
            },
            "conflict": {
              "type": "integer",
              "minimum": 0
            }
          }
        }
      }
    },
    "ReconciliationReport": {
      "type": "object",
      "required": [
        "kind",
        "schema_version",
        "generated_at",
        "target",
        "candidate_objects"
      ],
      "additionalProperties": false,
      "properties": {
        "kind": {
          "type": "string",
          "const": "reconciliation_report"
        },
        "schema_version": {
          "type": "string",
          "minLength": 1
        },
        "generated_at": {
          "type": "string",
          "format": "date-time"
        },
        "target": {
          "type": "object",
          "required": [
            "id"
          ],
          "additionalProperties": false,
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "description": "Mapping ID."
            },
            "url": {
              "type": "string",
              "format": "uri"
            }
          }
        },
        "candidate_objects": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CandidateObject"
          },
          "minItems": 1
        },
        "candidate_actions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CandidateAction"
          }
        },
        "candidate_traits": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "conflicts": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Conflict"
          }
        },
        "coverage_gaps": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "validation_failures": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "disambiguation_decisions": {
          "type": "array",
          "description": "Review decisions to append; does not gate creation.",
          "items": {
            "$ref": "#/$defs/disambiguation_decisionsItem"
          }
        },
        "manifest": {
          "$ref": "#/$defs/Manifest"
        },
        "reconciliation_summary": {
          "$ref": "#/$defs/ReconciliationSummary"
        }
      }
    },
    "SingleCreate": {
      "type": "object",
      "required": [
        "externalSystem",
        "externalComponent",
        "oodsTraits"
      ],
      "additionalProperties": false,
      "properties": {
        "substitution": {
          "type": "object",
          "required": [
            "component"
          ],
          "additionalProperties": false,
          "anyOf": [
            {
              "required": [
                "react"
              ]
            },
            {
              "required": [
                "vue"
              ]
            }
          ],
          "properties": {
            "component": {
              "type": "string",
              "minLength": 1,
              "description": "The shipped OODS Foundry component id being replaced."
            },
            "react": {
              "type": "object",
              "required": [
                "export"
              ],
              "additionalProperties": false,
              "properties": {
                "localPath": {
                  "type": "string",
                  "minLength": 1,
                  "description": "Absolute built package directory used by preview; omitted from consumer source imports."
                },
                "package": {
                  "type": "string",
                  "minLength": 1
                },
                "export": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][\\w$]*$"
                },
                "version": {
                  "type": "string",
                  "pattern": "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$",
                  "description": "Exact team package version; code generation needs this or an installed package manifest."
                },
                "passthrough": {
                  "type": "boolean",
                  "default": true,
                  "description": "Unlisted OODS Foundry props keep their names. False drops unlisted optional props; required props must be translated."
                },
                "props": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "required": [
                      "name"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string",
                        "pattern": "^[A-Za-z_$][\\w$]*$"
                      },
                      "values": {
                        "type": "object",
                        "additionalProperties": {
                          "type": [
                            "string",
                            "number",
                            "boolean",
                            "null"
                          ]
                        }
                      }
                    }
                  },
                  "description": "OODS Foundry prop to team prop, with optional scalar value map; values not in the map are preserved. Children, slots and event bindings keep their framework conventions."
                },
                "shadcn": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "project",
                    "module"
                  ],
                  "properties": {
                    "project": {
                      "type": "string",
                      "pattern": "^/[\\s\\S]*$",
                      "description": "Absolute shadcn project directory containing components.json and installed Tailwind 4 with Vite or PostCSS. React supports Radix and Base UI; Vue supports shadcn-vue on Reka. React Aria and unknown styles are refused."
                    },
                    "module": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Project import beginning with a components.json alias and resolved by TypeScript paths."
                    }
                  }
                }
              },
              "oneOf": [
                {
                  "required": [
                    "package"
                  ],
                  "not": {
                    "required": [
                      "shadcn"
                    ]
                  }
                },
                {
                  "required": [
                    "shadcn"
                  ],
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "package"
                        ]
                      },
                      {
                        "required": [
                          "version"
                        ]
                      },
                      {
                        "required": [
                          "localPath"
                        ]
                      }
                    ]
                  }
                }
              ]
            },
            "vue": {
              "type": "object",
              "required": [
                "export"
              ],
              "additionalProperties": false,
              "properties": {
                "localPath": {
                  "type": "string",
                  "minLength": 1,
                  "description": "Absolute built package directory used by preview; omitted from consumer source imports."
                },
                "package": {
                  "type": "string",
                  "minLength": 1
                },
                "export": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][\\w$]*$"
                },
                "version": {
                  "type": "string",
                  "pattern": "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$",
                  "description": "Exact team package version; code generation needs this or an installed package manifest."
                },
                "passthrough": {
                  "type": "boolean",
                  "default": true,
                  "description": "Unlisted OODS Foundry props keep their names. False drops unlisted optional props; required props must be translated."
                },
                "props": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "required": [
                      "name"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string",
                        "pattern": "^[A-Za-z_$][\\w$]*$"
                      },
                      "values": {
                        "type": "object",
                        "additionalProperties": {
                          "type": [
                            "string",
                            "number",
                            "boolean",
                            "null"
                          ]
                        }
                      }
                    }
                  },
                  "description": "OODS Foundry prop to team prop, with optional scalar value map; values not in the map are preserved. Children, slots and event bindings keep their framework conventions."
                },
                "shadcn": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "project",
                    "module"
                  ],
                  "properties": {
                    "project": {
                      "type": "string",
                      "pattern": "^/[\\s\\S]*$",
                      "description": "Absolute shadcn project directory containing components.json and installed Tailwind 4 with Vite or PostCSS. React supports Radix and Base UI; Vue supports shadcn-vue on Reka. React Aria and unknown styles are refused."
                    },
                    "module": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Project import beginning with a components.json alias and resolved by TypeScript paths."
                    }
                  }
                }
              },
              "oneOf": [
                {
                  "required": [
                    "package"
                  ],
                  "not": {
                    "required": [
                      "shadcn"
                    ]
                  }
                },
                {
                  "required": [
                    "shadcn"
                  ],
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "package"
                        ]
                      },
                      {
                        "required": [
                          "version"
                        ]
                      },
                      {
                        "required": [
                          "localPath"
                        ]
                      }
                    ]
                  }
                }
              ]
            }
          },
          "description": "Component substitution with React/Vue exports and prop translations."
        },
        "apply": {
          "type": "boolean",
          "description": "When true, write changes to disk."
        },
        "externalSystem": {
          "type": "string",
          "minLength": 1,
          "description": "External design system name (for example, 'team')."
        },
        "externalComponent": {
          "type": "string",
          "minLength": 1,
          "description": "External component name."
        },
        "oodsTraits": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0,
          "description": "OODS trait names this component maps to."
        },
        "propMappings": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "externalProp",
              "oodsProp"
            ],
            "additionalProperties": false,
            "properties": {
              "externalProp": {
                "type": "string",
                "minLength": 1
              },
              "oodsProp": {
                "type": "string",
                "minLength": 1
              },
              "coercion": {
                "description": "Legacy external-to-OODS Foundry annotation: a structured hint, raw captured label, or null. Stored and resolved as data; use substitution.props for executable OODS Foundry-to-team translation.",
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "object",
                    "required": [
                      "type",
                      "mapping"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "enum"
                      },
                      "mapping": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "type",
                      "trueValue",
                      "falseValue"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "boolean_to_string"
                      },
                      "trueValue": {
                        "type": "string"
                      },
                      "falseValue": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "type",
                      "pattern"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "template"
                      },
                      "pattern": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "type"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "identity"
                      }
                    }
                  }
                ],
                "default": null
              }
            }
          },
          "description": "Property translations from external to OODS prop names."
        },
        "confidence": {
          "type": "string",
          "enum": [
            "auto",
            "manual"
          ],
          "default": "manual",
          "description": "'auto' for machine-generated, 'manual' for human-curated."
        },
        "metadata": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "author": {
              "type": "string"
            },
            "notes": {
              "type": "string"
            }
          }
        },
        "disambiguation_decisions": {
          "type": "array",
          "description": "Review decisions to append; does not gate creation.",
          "items": {
            "$ref": "#/$defs/disambiguation_decisionsItem"
          }
        },
        "preferred_terms": {
          "type": "array",
          "description": "Canonical terms to append.",
          "items": {
            "$ref": "#/$defs/preferred_termsItem"
          }
        },
        "capabilities": {
          "type": "array",
          "description": "Capability definitions to append.",
          "items": {
            "$ref": "#/$defs/capabilitiesItem"
          }
        },
        "projection_variants": {
          "type": "array",
          "description": "Cross-surface mapping variants to append.",
          "items": {
            "$ref": "#/$defs/projection_variantsItem"
          }
        },
        "action": {
          "type": "string",
          "const": "create"
        }
      },
      "allOf": [
        {
          "if": {
            "not": {
              "required": [
                "substitution"
              ]
            }
          },
          "then": {
            "properties": {
              "oodsTraits": {
                "minItems": 1
              }
            }
          }
        }
      ]
    },
    "MappingEntry": {
      "allOf": [
        {
          "$ref": "#/$defs/SingleCreate"
        },
        {
          "not": {
            "anyOf": [
              {
                "required": [
                  "apply"
                ]
              },
              {
                "required": [
                  "action"
                ]
              }
            ]
          }
        }
      ]
    },
    "mappingUpdates": {
      "type": "object",
      "additionalProperties": false,
      "minProperties": 1,
      "description": "Fields to update. Only provided fields are changed.",
      "properties": {
        "oodsTraits": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0,
          "description": "Replace OODS trait list."
        },
        "confidence": {
          "type": "string",
          "enum": [
            "auto",
            "manual"
          ],
          "description": "Update confidence level."
        },
        "propMappings": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "externalProp",
              "oodsProp"
            ],
            "additionalProperties": false,
            "properties": {
              "externalProp": {
                "type": "string",
                "minLength": 1
              },
              "oodsProp": {
                "type": "string",
                "minLength": 1
              },
              "coercion": {
                "description": "Legacy external-to-OODS Foundry annotation: a structured hint, raw captured label, or null. Stored and resolved as data; use substitution.props for executable OODS Foundry-to-team translation.",
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "object",
                    "required": [
                      "type",
                      "mapping"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "enum"
                      },
                      "mapping": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "type",
                      "trueValue",
                      "falseValue"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "boolean_to_string"
                      },
                      "trueValue": {
                        "type": "string"
                      },
                      "falseValue": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "type",
                      "pattern"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "template"
                      },
                      "pattern": {
                        "type": "string"
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "type"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "type": {
                        "type": "string",
                        "const": "identity"
                      }
                    }
                  }
                ],
                "default": null
              }
            }
          },
          "description": "Replace property mappings."
        },
        "notes": {
          "type": "string",
          "description": "Update notes in metadata."
        },
        "projection_variants": {
          "type": "array",
          "description": "Cross-surface mapping variants to append.",
          "items": {
            "$ref": "#/$defs/projection_variantsItem"
          }
        },
        "substitution": {
          "type": "object",
          "required": [
            "component"
          ],
          "additionalProperties": false,
          "anyOf": [
            {
              "required": [
                "react"
              ]
            },
            {
              "required": [
                "vue"
              ]
            }
          ],
          "properties": {
            "component": {
              "type": "string",
              "minLength": 1,
              "description": "The shipped OODS Foundry component id being replaced."
            },
            "react": {
              "type": "object",
              "required": [
                "export"
              ],
              "additionalProperties": false,
              "properties": {
                "localPath": {
                  "type": "string",
                  "minLength": 1,
                  "description": "Absolute built package directory used by preview; omitted from consumer source imports."
                },
                "package": {
                  "type": "string",
                  "minLength": 1
                },
                "export": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][\\w$]*$"
                },
                "version": {
                  "type": "string",
                  "pattern": "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$",
                  "description": "Exact team package version; code generation needs this or an installed package manifest."
                },
                "passthrough": {
                  "type": "boolean",
                  "default": true,
                  "description": "Unlisted OODS Foundry props keep their names. False drops unlisted optional props; required props must be translated."
                },
                "props": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "required": [
                      "name"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string",
                        "pattern": "^[A-Za-z_$][\\w$]*$"
                      },
                      "values": {
                        "type": "object",
                        "additionalProperties": {
                          "type": [
                            "string",
                            "number",
                            "boolean",
                            "null"
                          ]
                        }
                      }
                    }
                  },
                  "description": "OODS Foundry prop to team prop, with optional scalar value map; values not in the map are preserved. Children, slots and event bindings keep their framework conventions."
                },
                "shadcn": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "project",
                    "module"
                  ],
                  "properties": {
                    "project": {
                      "type": "string",
                      "pattern": "^/[\\s\\S]*$",
                      "description": "Absolute shadcn project directory containing components.json and installed Tailwind 4 with Vite or PostCSS. React supports Radix and Base UI; Vue supports shadcn-vue on Reka. React Aria and unknown styles are refused."
                    },
                    "module": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Project import beginning with a components.json alias and resolved by TypeScript paths."
                    }
                  }
                }
              },
              "oneOf": [
                {
                  "required": [
                    "package"
                  ],
                  "not": {
                    "required": [
                      "shadcn"
                    ]
                  }
                },
                {
                  "required": [
                    "shadcn"
                  ],
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "package"
                        ]
                      },
                      {
                        "required": [
                          "version"
                        ]
                      },
                      {
                        "required": [
                          "localPath"
                        ]
                      }
                    ]
                  }
                }
              ]
            },
            "vue": {
              "type": "object",
              "required": [
                "export"
              ],
              "additionalProperties": false,
              "properties": {
                "localPath": {
                  "type": "string",
                  "minLength": 1,
                  "description": "Absolute built package directory used by preview; omitted from consumer source imports."
                },
                "package": {
                  "type": "string",
                  "minLength": 1
                },
                "export": {
                  "type": "string",
                  "pattern": "^[A-Za-z_$][\\w$]*$"
                },
                "version": {
                  "type": "string",
                  "pattern": "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$",
                  "description": "Exact team package version; code generation needs this or an installed package manifest."
                },
                "passthrough": {
                  "type": "boolean",
                  "default": true,
                  "description": "Unlisted OODS Foundry props keep their names. False drops unlisted optional props; required props must be translated."
                },
                "props": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "object",
                    "required": [
                      "name"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string",
                        "pattern": "^[A-Za-z_$][\\w$]*$"
                      },
                      "values": {
                        "type": "object",
                        "additionalProperties": {
                          "type": [
                            "string",
                            "number",
                            "boolean",
                            "null"
                          ]
                        }
                      }
                    }
                  },
                  "description": "OODS Foundry prop to team prop, with optional scalar value map; values not in the map are preserved. Children, slots and event bindings keep their framework conventions."
                },
                "shadcn": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "project",
                    "module"
                  ],
                  "properties": {
                    "project": {
                      "type": "string",
                      "pattern": "^/[\\s\\S]*$",
                      "description": "Absolute shadcn project directory containing components.json and installed Tailwind 4 with Vite or PostCSS. React supports Radix and Base UI; Vue supports shadcn-vue on Reka. React Aria and unknown styles are refused."
                    },
                    "module": {
                      "type": "string",
                      "minLength": 1,
                      "description": "Project import beginning with a components.json alias and resolved by TypeScript paths."
                    }
                  }
                }
              },
              "oneOf": [
                {
                  "required": [
                    "package"
                  ],
                  "not": {
                    "required": [
                      "shadcn"
                    ]
                  }
                },
                {
                  "required": [
                    "shadcn"
                  ],
                  "not": {
                    "anyOf": [
                      {
                        "required": [
                          "package"
                        ]
                      },
                      {
                        "required": [
                          "version"
                        ]
                      },
                      {
                        "required": [
                          "localPath"
                        ]
                      }
                    ]
                  }
                }
              ]
            }
          },
          "description": "Component substitution with React/Vue exports and prop translations."
        }
      },
      "allOf": [
        {
          "if": {
            "not": {
              "required": [
                "substitution"
              ]
            }
          },
          "then": {
            "properties": {
              "oodsTraits": {
                "minItems": 1
              }
            }
          }
        }
      ]
    },
    "projection_variantsItem": {
      "type": "object",
      "required": [
        "id",
        "surface"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "Mapping ID."
        },
        "surface": {
          "type": "string",
          "minLength": 1
        },
        "external_component": {
          "type": "string",
          "minLength": 1
        },
        "capability_id": {
          "type": "string",
          "minLength": 1
        },
        "selector": {
          "type": "string",
          "minLength": 1
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "evidence_chain": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "metadata": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "description": "Cross-surface variant record."
    },
    "disambiguation_decisionsItem": {
      "type": "object",
      "required": [
        "decision_id",
        "decision_type",
        "scope",
        "status",
        "target_kind",
        "target_id",
        "selected_value",
        "rationale",
        "decided_at"
      ],
      "additionalProperties": false,
      "properties": {
        "decision_id": {
          "type": "string",
          "minLength": 1
        },
        "decision_type": {
          "type": "string",
          "enum": [
            "preferred_name",
            "preferred_role",
            "mapping_rejection",
            "canonical_term"
          ]
        },
        "scope": {
          "type": "string",
          "enum": [
            "run",
            "target",
            "registry"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "proposed",
            "accepted",
            "rejected",
            "promoted"
          ]
        },
        "target_kind": {
          "type": "string",
          "enum": [
            "candidate_object",
            "candidate_action",
            "preferred_term"
          ]
        },
        "target_id": {
          "type": "string",
          "minLength": 1
        },
        "selected_value": {
          "type": "string",
          "minLength": 1
        },
        "rationale": {
          "type": "string",
          "minLength": 1
        },
        "alternatives": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "value"
            ],
            "additionalProperties": false,
            "properties": {
              "value": {
                "type": "string",
                "minLength": 1
              },
              "score": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              },
              "reasoning": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        },
        "preferred_term_id": {
          "type": "string",
          "minLength": 1
        },
        "decided_by": {
          "type": "string",
          "enum": [
            "human",
            "agent",
            "system"
          ]
        },
        "decided_at": {
          "type": "string",
          "format": "date-time"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "description": "Review decision record."
    },
    "preferred_termsItem": {
      "type": "object",
      "required": [
        "entity_type",
        "id",
        "slug",
        "label",
        "aliases",
        "scope"
      ],
      "additionalProperties": false,
      "properties": {
        "entity_type": {
          "type": "string",
          "const": "preferred_term"
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "Mapping ID."
        },
        "slug": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "aliases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "scope": {
          "type": "string",
          "enum": [
            "target",
            "registry"
          ]
        },
        "domain": {
          "type": "string",
          "minLength": 1
        },
        "source_decision_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "metadata": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "description": "Canonical term record."
    },
    "capabilitiesItem": {
      "type": "object",
      "required": [
        "entity_type",
        "id",
        "slug",
        "name",
        "canonical_verb"
      ],
      "additionalProperties": false,
      "properties": {
        "entity_type": {
          "type": "string",
          "const": "capability"
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "Mapping ID."
        },
        "slug": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "canonical_verb": {
          "type": "string",
          "minLength": 1
        },
        "aliases": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "oods_traits": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "projection_variant_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "preconditions": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "type"
            ],
            "additionalProperties": false,
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "auth",
                  "role",
                  "state",
                  "data"
                ]
              },
              "description": {
                "type": "string"
              },
              "confidence": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              },
              "evidence_chain": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "metadata": {
          "type": "object",
          "additionalProperties": true
        }
      },
      "description": "Capability record."
    }
  }
}
