{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "FormulaContract",
  "type": "object",
  "properties": {
    "schema_version": { "type": "string" },
    "formula_registry": {
      "type": "object",
      "properties": {
        "formulas": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "required": [
              "owner",
              "lifecycle_state",
              "input_fields",
              "output_fields",
              "missing_policy",
              "golden_cases"
            ],
            "properties": {
              "owner": { "type": "string" },
              "lifecycle_state": { "type": "string", "enum": ["idea", "contract", "shadow", "active", "retire"] },
              "input_fields": { "type": "array", "items": { "type": "string" } },
              "output_fields": { "type": "array", "items": { "type": "string" } },
              "missing_policy": { "type": "string" },
              "golden_cases": { "type": "array" },
              "activation_threshold": { "type": "object" },
              "retirement_condition": { "type": "string" }
            }
          }
        }
      },
      "required": ["formulas"]
    }
  }
}
