{
  "schemaVersion": 1,
  "id": "rag-query-rewrite",
  "function": "build_query_plan",
  "starter": "def build_query_plan(payload):\n    raise NotImplementedError(\"Implement the documented contract yourself\")\n",
  "checks": [
    {
      "id": "ambiguous",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-b"
        ],
        "allowed_entities": [
          "order-a",
          "order-b"
        ],
        "selected_entity": null,
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": {
        "status": "clarify",
        "entities": [
          "order-a",
          "order-b"
        ],
        "text": "Can it be returned, excluding gifts, during October?",
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "error": null
    },
    {
      "id": "explicit-choice",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-b"
        ],
        "allowed_entities": [
          "order-a",
          "order-b"
        ],
        "selected_entity": "order-b",
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": {
        "status": "search",
        "entities": [
          "order-b"
        ],
        "text": "Can it be returned, excluding gifts, during October?",
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "error": null
    },
    {
      "id": "one-authorized",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-b"
        ],
        "allowed_entities": [
          "order-a"
        ],
        "selected_entity": null,
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": {
        "status": "search",
        "entities": [
          "order-a"
        ],
        "text": "Can it be returned, excluding gifts, during October?",
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "error": null
    },
    {
      "id": "unauthorized-choice",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-b"
        ],
        "allowed_entities": [
          "order-a"
        ],
        "selected_entity": "order-b",
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": {
        "status": "denied",
        "entities": [],
        "text": "Can it be returned, excluding gifts, during October?",
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "error": null
    },
    {
      "id": "none-authorized",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-b"
        ],
        "allowed_entities": [],
        "selected_entity": null,
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": {
        "status": "missing",
        "entities": [],
        "text": "Can it be returned, excluding gifts, during October?",
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "error": null
    },
    {
      "id": "preserve-negation",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-b"
        ],
        "allowed_entities": [
          "order-a",
          "order-b"
        ],
        "selected_entity": "order-a",
        "constraints": {
          "exclude": [
            "opened",
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": {
        "status": "search",
        "entities": [
          "order-a"
        ],
        "text": "Can it be returned, excluding gifts, during October?",
        "constraints": {
          "exclude": [
            "gift",
            "opened"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "error": null
    },
    {
      "id": "empty-candidates",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [],
        "allowed_entities": [
          "order-a",
          "order-b"
        ],
        "selected_entity": null,
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": {
        "status": "missing",
        "entities": [],
        "text": "Can it be returned, excluding gifts, during October?",
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "error": null
    },
    {
      "id": "one-day-range",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-b"
        ],
        "allowed_entities": [
          "order-a",
          "order-b"
        ],
        "selected_entity": null,
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-01"
        }
      },
      "expected": {
        "status": "clarify",
        "entities": [
          "order-a",
          "order-b"
        ],
        "text": "Can it be returned, excluding gifts, during October?",
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-01"
        }
      },
      "error": null
    },
    {
      "id": "date-order",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-b"
        ],
        "allowed_entities": [
          "order-a",
          "order-b"
        ],
        "selected_entity": null,
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-11-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": null,
      "error": "ValueError:input"
    },
    {
      "id": "unknown-choice",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-b"
        ],
        "allowed_entities": [
          "order-a",
          "order-b"
        ],
        "selected_entity": "order-c",
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": null,
      "error": "ValueError:input"
    },
    {
      "id": "duplicate-candidate",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-a"
        ],
        "allowed_entities": [
          "order-a",
          "order-b"
        ],
        "selected_entity": null,
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": null,
      "error": "ValueError:input"
    },
    {
      "id": "missing-selected-entity",
      "input": {
        "text": "Can it be returned, excluding gifts, during October?",
        "candidates": [
          "order-a",
          "order-b"
        ],
        "allowed_entities": [
          "order-a",
          "order-b"
        ],
        "constraints": {
          "exclude": [
            "gift"
          ],
          "from_date": "2026-10-01",
          "to_date": "2026-10-31"
        }
      },
      "expected": null,
      "error": "ValueError:input"
    }
  ]
}
