REQUIRED = {"scenario": str, "source_ids": list, "workflow_owner": str,
            "baseline": str, "metric": dict, "resource_bound": dict,
            "validation_route": str, "integration_boundary": str, "gates": dict}
GATE_NAMES = {"structure", "input", "baseline", "metric", "resources", "integration"}
def evaluate(case):
    errors = [name for name, kind in REQUIRED.items()
              if name not in case or type(case[name]) is not kind]
    for name in ("metric", "resource_bound"):
        item = case.get(name, {})
        if type(item.get("value")) not in (int, float) or not item.get("unit"):
            errors.append(name + "_value_or_unit")
    if not case.get("source_ids") or set(case.get("gates", {})) != GATE_NAMES:
        errors.append("sources_or_gate_schema")
    if any(type(value) is not bool for value in case.get("gates", {}).values()):
        errors.append("gate_type")
    decision = "invalid" if errors else ("monitor" if all(case["gates"].values()) else "reject-now")
    return {"decision": decision, "errors": sorted(set(errors)),
            "failed_gates": sorted(k for k, value in case.get("gates", {}).items() if not value)}
case = {"scenario": "Fe-S screening case", "source_ids": ["feynman-1982", "benchmarking-2025"],
        "workflow_owner": "catalysis lead", "baseline": "selected-CI on identical active space",
        "metric": {"value": 1.6, "unit": "millihartree"},
        "resource_bound": {"value": 30, "unit": "logical-qubit-days"},
        "validation_route": "blind energy comparison", "integration_boundary": "candidate ranking only",
        "gates": {name: name != "resources" for name in GATE_NAMES}}
base_result = evaluate(case)
bad_case = {key: value for key, value in case.items() if key != "workflow_owner"}
bad_result = evaluate(bad_case)
repaired = {**case, "gates": {**case["gates"], "resources": True}}
repaired_result = evaluate(repaired)
assert base_result["decision"] == "reject-now" and base_result["failed_gates"] == ["resources"]
assert bad_result["decision"] == "invalid" and "workflow_owner" in bad_result["errors"]
assert repaired_result["decision"] == "monitor"
print(f"PASS: 64 suitability dossier base={base_result['decision']} missing={bad_result['errors']} repaired={repaired_result['decision']}")
