{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sana-os.org/llm-ambiguity-lab/data/execution-handoff-schema.json",
  "title": "LLM Ambiguity Lab v2 Premise-Aware Execution Handoff",
  "description": "Schema for the structured handoff displayed by the public v2 simulator. The simulator displays this object but does not execute the downstream task.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "resolved_task",
    "premise_map",
    "premise_alignment_state",
    "unresolved_premises",
    "preserved_divergences",
    "assumption_disclosures",
    "execution_instructions"
  ],
  "properties": {
    "resolved_task": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "context_resolution_score",
        "resolution_state",
        "target_task",
        "target_object",
        "context_grounding",
        "ambiguity_type"
      ],
      "properties": {
        "context_resolution_score": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Illustrative Layer 1 operational simulation score; not model confidence."
        },
        "resolution_state": {
          "enum": [
            "READY",
            "READY_WITH_DISCLOSED_ASSUMPTION",
            "CLARIFICATION_REQUIRED",
            "PENDING_SPECIFICATION"
          ]
        },
        "target_task": {
          "type": [
            "string",
            "null"
          ]
        },
        "target_object": {
          "type": [
            "string",
            "null"
          ]
        },
        "context_grounding": {
          "enum": [
            "grounded",
            "partial",
            "ungrounded"
          ]
        },
        "ambiguity_type": {
          "enum": [
            "none",
            "lexical",
            "referential",
            "intent_task",
            "mixed"
          ]
        }
      }
    },
    "premise_map": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/premise_unit"
      }
    },
    "premise_alignment_state": {
      "enum": [
        "MAPPED",
        "MAPPED_WITH_DIVERGENCE",
        "PREMISE_CLARIFICATION_REQUIRED",
        "PREMISE_CONTEXT_INSUFFICIENT"
      ]
    },
    "unresolved_premises": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "preserved_divergences": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/divergence"
      }
    },
    "assumption_disclosures": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "execution_instructions": {
      "type": "string"
    }
  },
  "$defs": {
    "premise_unit": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "premise_id",
        "text",
        "category",
        "source",
        "status",
        "materiality",
        "support_state",
        "execution_effect"
      ],
      "properties": {
        "premise_id": {
          "type": "string",
          "pattern": "^P[0-9]+$"
        },
        "text": {
          "type": "string"
        },
        "category": {
          "enum": [
            "FACT",
            "VIEW",
            "CARE"
          ]
        },
        "source": {
          "enum": [
            "user_explicit",
            "user_implied",
            "provided_source",
            "system_default",
            "agent_inference",
            "unknown"
          ]
        },
        "status": {
          "enum": [
            "explicit",
            "inferred",
            "unclear"
          ]
        },
        "materiality": {
          "enum": [
            "low",
            "medium",
            "high"
          ]
        },
        "support_state": {
          "enum": [
            "provided",
            "unsupported",
            "disputed",
            "unknown",
            "not_applicable"
          ]
        },
        "execution_effect": {
          "enum": [
            "none",
            "changes_scope",
            "changes_framing",
            "changes_output",
            "changes_recommendation",
            "requires_clarification"
          ]
        }
      }
    },
    "divergence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "a",
        "b",
        "behavior"
      ],
      "properties": {
        "a": {
          "type": "string"
        },
        "b": {
          "type": "string"
        },
        "behavior": {
          "type": "string"
        }
      }
    }
  }
}
